MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / touch_loop

Function touch_loop

ESP32_AP-Flasher/src/ips_display.cpp:308–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306 ts.begin();
307}
308void touch_loop()
309{
310 if (millis() - last_touch_read >= 50) {
311 last_touch_read = millis();
312 ts.read();
313 if (ts.isTouched)
314 {
315 uint8_t count = ts.touches;
316 if (count > 5) count = 5; // the GT911 tracks at most 5 points
317 uint16_t xs[5], ys[5];
318 uint8_t ids[5], sizes[5];
319 for (uint8_t i = 0; i < count; i++) {
320 xs[i] = map(ts.points[i].x, 480, 0, 0, 480 - 1);
321 ys[i] = map(ts.points[i].y, 480, 0, 0, 480 - 1);
322 ids[i] = ts.points[i].id;
323 sizes[i] = ts.points[i].size;
324 }
325 touch_last_x = xs[0];
326 touch_last_y = ys[0];
327 // Stream the real touch positions (also while dragging) over websocket
328 wsSendTouch(count, xs, ys, ids, sizes);
329 Serial.printf("Touch position X: %i Y: %i\r\n", touch_last_x, touch_last_y);
330 if(is_new_touch_checked == false)
331 {
332 is_new_touch_checked = true;
333 if(touch_last_x <= 240)
334 sendAvail(WAKEUP_REASON_BUTTON1);
335 else
336 sendAvail(WAKEUP_REASON_BUTTON2);
337 }
338 }else{
339 if (is_new_touch_checked) // fingers just left the panel, send one release event
340 wsSendTouch(0, nullptr, nullptr, nullptr, nullptr);
341 is_new_touch_checked = false;
342 }
343 }
344}
345#else
346void touch_init()
347{

Callers 1

yellow_ap_touch_taskFunction · 0.85

Calls 4

wsSendTouchFunction · 0.85
sendAvailFunction · 0.85
printfMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected