MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / update

Method update

Drivers/TCA8418/Source/Tca8418.cpp:121–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121bool Tca8418::update() {
122 last_update_micros = this_update_micros;
123 uint8_t key_down, key_event, key_row, key_col;
124
125 key_event = get_key_event();
126 // TODO: read gpio R7/R6 status? 0x14 bits 7&6
127 // read(0x14, &new_keycode)
128
129 // TODO: use tick function to get an update delta time
130 this_update_micros = 0;
131 delta_micros = this_update_micros - last_update_micros;
132
133 if (key_event > 0) {
134 key_down = (key_event & 0x80);
135 uint16_t buffer = key_event;
136 buffer &= 0x7F;
137 buffer--;
138 key_row = buffer / 10;
139 key_col = buffer % 10;
140
141 // always clear the released list
142 clear_released_list();
143
144 if (key_down) {
145 add_pressed_key(key_row, key_col);
146 // TODO reject ghosts (assume multiple key presses with the same hold time are ghosts.)
147
148 } else {
149 add_released_key(key_row, key_col);
150 remove_pressed_key(key_row, key_col);
151 }
152
153 return true;
154 }
155
156 // Increment hold times for pressed keys
157 for (int i = 0; i < pressed_key_count; i++) {
158 pressed_list[i].hold_time += delta_micros;
159 }
160
161 return false;
162}
163
164
165void Tca8418::add_pressed_key(uint8_t row, uint8_t col) {

Callers 2

processKeyboardMethod · 0.45
processKeyboardMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected