rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
injector.h
Go to the documentation of this file.
1
55
56#pragma once
57
58#include <stdbool.h>
59#include <stddef.h>
60#include <stdint.h>
61
62#include "gt911_emu.h"
63#include "inj_line_id.h"
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
70#define INJ_PROTOCOL 1
72#define INJ_RES_X 1024u
74#define INJ_RES_Y 600u
75#define INJ_LINE_MAX 63u
76#define INJ_REPORT_MS 10u
77#define INJ_ACK_TIMEOUT_MS 100u
78#define INJ_TAP_MS 100u
79#define INJ_MS_MAX 30000u
80#define INJ_SWIPE_STEP_PX 100u
81#define INJ_LIVE_MS 100u
83#define INJ_CONTACTS GT911_EMU_POINTS
85#define INJ_ID_MAX 15u
87#define INJ_REPLY_LEN 128u
89#define INJ_REPLIES 8u
90
92typedef enum {
96
105
115
117typedef struct {
119 char tag[8];
120 uint16_t x0;
121 uint16_t y0;
122 uint16_t x1;
123 uint16_t y1;
124 uint32_t ms;
126 bool lifting;
127 bool in_frame;
129 uint32_t t_first;
130 uint32_t frames;
131 uint16_t px;
132 uint16_t py;
133 bool slowed;
137
169
174void injector_init(injector_t *in);
175
183void injector_input(injector_t *in, const char *bytes, size_t n,
184 uint32_t now_ms);
185
191void injector_poll(injector_t *in, uint32_t now_ms);
192
199
206
213
222
230bool injector_take_reply(injector_t *in, char *out, size_t n);
231
238inj_led_t injector_led(const injector_t *in, uint32_t now_ms);
239
245const char *inj_gesture_name(inj_gesture_t g);
246
247#ifdef __cplusplus
248}
249#endif
The register file of a GT911 touch controller as an I2C (Inter-Integrated Circuit) target sees it: th...
Which of two wires carries SCL, read from I2C (Inter-Integrated Circuit) traffic the injector only li...
inj_led_t
What the status LED shows.
Definition injector.h:107
@ INJ_LED_DOWN
Definition injector.h:112
@ INJ_LED_LISTEN
Definition injector.h:108
@ INJ_LED_WIRING_BAD
Definition injector.h:109
@ INJ_LED_OFF
Definition injector.h:110
@ INJ_LED_POLLED
Definition injector.h:111
@ INJ_LED_FAILED
Definition injector.h:113
void injector_host_closed(injector_t *in)
The host closed the port (DTR, data terminal ready, fell).
Definition injector.c:549
#define INJ_REPLIES
The replies queued: 8.
Definition injector.h:89
inj_state_t
The injector's state: LISTEN after a reset, ACTIVE once confirmed.
Definition injector.h:92
@ INJ_ACTIVE
Definition injector.h:94
@ INJ_LISTEN
Definition injector.h:93
#define INJ_REPLY_LEN
A reply line's buffer: 128 characters.
Definition injector.h:87
const char * inj_gesture_name(inj_gesture_t g)
The gesture's word.
Definition injector.c:57
bool injector_take_wiring(injector_t *in)
True once after wiring: the glue starts listening to the lines.
Definition injector.c:502
void injector_poll(injector_t *in, uint32_t now_ms)
Move the gestures on: frames, acknowledges, timeouts. Call often.
Definition injector.c:750
void injector_init(injector_t *in)
Reset: LISTEN, no contacts, no replies.
Definition injector.c:70
inj_gesture_t
What a contact is doing.
Definition injector.h:98
@ INJ_G_RELEASE
Definition injector.h:103
@ INJ_G_NONE
Definition injector.h:99
@ INJ_G_SWIPE
Definition injector.h:102
@ INJ_G_HOLD
Definition injector.h:101
@ INJ_G_TAP
Definition injector.h:100
#define INJ_LINE_MAX
Definition injector.h:75
#define INJ_ID_MAX
The highest contact id: ids are 0 to 15.
Definition injector.h:85
void injector_input(injector_t *in, const char *bytes, size_t n, uint32_t now_ms)
Bytes from the host. A full line runs at once.
Definition injector.c:476
bool injector_take_attach(injector_t *in)
True once after confirm: the glue attaches the I2C target.
Definition injector.c:542
inj_led_t injector_led(const injector_t *in, uint32_t now_ms)
What the status LED shows at now_ms.
Definition injector.c:802
void injector_wiring_done(injector_t *in, const inj_line_result_t *r)
The glue's 500ms of listening, classified.
Definition injector.c:509
bool injector_take_reply(injector_t *in, char *out, size_t n)
The oldest reply.
Definition injector.c:46
The register file and the transfer under way.
Definition gt911_emu.h:92
One contact id's gesture.
Definition injector.h:117
bool first_acked
Definition injector.h:128
uint16_t y0
Definition injector.h:121
bool in_frame
Definition injector.h:127
uint16_t y1
Definition injector.h:123
bool end_published
Definition injector.h:134
uint32_t frames
Definition injector.h:130
uint16_t px
Definition injector.h:131
bool slowed
Definition injector.h:133
uint32_t ms
Definition injector.h:124
uint32_t t_first
Definition injector.h:129
uint16_t x0
Definition injector.h:120
inj_gesture_t kind
Definition injector.h:118
uint16_t x1
Definition injector.h:122
char tag[8]
Definition injector.h:119
bool lifting
Definition injector.h:126
bool end_acked
Definition injector.h:135
bool down_published
Definition injector.h:125
uint16_t py
Definition injector.h:132
Definition inj_line_id.h:61
The whole injector: protocol, contacts, frames and replies.
Definition injector.h:139
bool any_read
Definition injector.h:162
uint32_t t_pub
Definition injector.h:155
char replies[INJ_REPLIES][INJ_REPLY_LEN]
Definition injector.h:165
uint8_t r_head
Definition injector.h:166
bool published
Definition injector.h:154
bool withdraw_due
Definition injector.h:156
bool overflow
Definition injector.h:145
uint32_t seen_reads
Definition injector.h:159
bool wiring_running
Definition injector.h:148
char line[INJ_LINE_MAX+1u]
Definition injector.h:143
uint8_t r_count
Definition injector.h:167
bool wiring_wanted
Definition injector.h:149
uint8_t len
Definition injector.h:144
inj_state_t state
Definition injector.h:140
bool pending
Definition injector.h:153
gt911_emu_t emu
Definition injector.h:141
inj_contact_t c[INJ_ID_MAX+1u]
Definition injector.h:152
bool attach_wanted
Definition injector.h:150
bool failed
Definition injector.h:157
uint32_t t_last_read
Definition injector.h:163
inj_line_result_t wiring
Definition injector.h:147
uint32_t seen_acks
Definition injector.h:160
uint32_t seen_product
Definition injector.h:161