Emit imu, mag and bmp data

This commit is contained in:
Rune Harlyk
2025-11-27 17:38:37 +01:00
parent 7d2f384898
commit 6c61227623
5 changed files with 38 additions and 10 deletions
+6
View File
@@ -132,6 +132,12 @@ void IRAM_ATTR SpotControlLoopEntry(void *) {
#if FT_ENABLED(USE_WS2812)
ledService.loop();
#endif
EXECUTE_EVERY_N_MS(250, [&]() {
JsonDocument doc;
JsonVariant results = doc.to<JsonVariant>();
peripherals.getIMUResult(results);
socket.emit(EVENT_IMU, results);
});
vTaskDelayUntil(&xLastWakeTime, xFrequency);
}
}
+6 -3
View File
@@ -166,13 +166,16 @@ float Peripherals::rightDistance() { return _right_distance; }
void Peripherals::getIMUResult(JsonVariant &root) {
#if FT_ENABLED(USE_MPU6050 || USE_BNO055)
_imu.getResults(root);
JsonVariant imu = root["imu"].to<JsonVariant>();
_imu.getResults(imu);
#endif
#if FT_ENABLED(USE_HMC5883)
_mag.getResults(root);
JsonVariant mag = root["mag"].to<JsonVariant>();
_mag.getResults(mag);
#endif
#if FT_ENABLED(USE_BMP180)
_bmp.getResults(root);
JsonVariant bmp = root["bmp"].to<JsonVariant>();
_bmp.getResults(bmp);
#endif
}