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

Function wsSendTouch

ESP32_AP-Flasher/src/web.cpp:78–94  ·  view source on GitHub ↗

Sends the real touch positions to all connected websocket clients. Protocol: {"touch":{"count":N,"points":[{"id":..,"x":..,"y":..,"size":..}, ...]}} count == 0 (points empty) signals "all fingers released".

Source from the content-addressed store, hash-verified

76// Protocol: {"touch":{"count":N,"points":[{"id":..,"x":..,"y":..,"size":..}, ...]}}
77// count == 0 (points empty) signals "all fingers released".
78void wsSendTouch(uint8_t count, const uint16_t *xs, const uint16_t *ys, const uint8_t *ids, const uint8_t *sizes) {
79 if (wsClientCount() == 0) return; // nobody is listening, skip the work
80 JsonDocument doc;
81 JsonObject touch = doc["touch"].to<JsonObject>();
82 touch["count"] = count;
83 JsonArray points = touch["points"].to<JsonArray>();
84 for (uint8_t i = 0; i < count; i++) {
85 JsonObject p = points.add<JsonObject>();
86 p["id"] = ids[i];
87 p["x"] = xs[i];
88 p["y"] = ys[i];
89 p["size"] = sizes[i];
90 }
91 if (wsMutex) xSemaphoreTake(wsMutex, portMAX_DELAY);
92 ws.textAll(doc.as<String>());
93 if (wsMutex) xSemaphoreGive(wsMutex);
94}
95
96size_t dbSize() {
97 size_t size = tagDB.size() * sizeof(tagRecord);

Callers 1

touch_loopFunction · 0.85

Calls 1

wsClientCountFunction · 0.85

Tested by

no test coverage detected