diff --git a/esp32/include/spot.h b/esp32/include/spot.h index 21287cd..4dc3fee 100644 --- a/esp32/include/spot.h +++ b/esp32/include/spot.h @@ -68,7 +68,7 @@ class Spot { // communicate void emitTelemetry() { - if (updatedMotion) EXECUTE_EVERY_N_MS(100, { _motionService.syncAngles(); }); + if (updatedMotion) EXECUTE_EVERY_N_MS(100, { _motionService.emitAngles(); }); // _peripherals.loop(); EXECUTE_EVERY_N_MS(1000, { _peripherals.emitIMU(); }); // _peripherals.emitSonar(); diff --git a/esp32/lib/ESP32-sveltekit/MotionService.h b/esp32/lib/ESP32-sveltekit/MotionService.h index 20bdff8..3183360 100644 --- a/esp32/lib/ESP32-sveltekit/MotionService.h +++ b/esp32/lib/ESP32-sveltekit/MotionService.h @@ -90,12 +90,16 @@ class MotionService { socket.emit(MODE_EVENT, output, String(originId).c_str()); } - void syncAngles(const String &originId = "", bool sync = false) { + void emitAngles(const String &originId = "", bool sync = false) { char output[100]; snprintf(output, sizeof(output), "[%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f]", angles[0], angles[1], angles[2], angles[3], angles[4], angles[5], angles[6], angles[7], angles[8], angles[9], angles[10], angles[11]); socket.emit(ANGLES_EVENT, output, originId.c_str()); + } + + void syncAngles(const String &originId = "", bool sync = false) { + emitAngles(originId, sync); _servoController->setAngles(angles); }