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".
| 76 | // Protocol: {"touch":{"count":N,"points":[{"id":..,"x":..,"y":..,"size":..}, ...]}} |
| 77 | // count == 0 (points empty) signals "all fingers released". |
| 78 | void 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 | |
| 96 | size_t dbSize() { |
| 97 | size_t size = tagDB.size() * sizeof(tagRecord); |
no test coverage detected