Merge remote-tracking branch 'origin/master' into ICM20948_fix
# Conflicts: # esp32/src/main.cpp # esp32/src/peripherals/peripherals.cpp
This commit is contained in:
+9
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -144,7 +150,9 @@ void IRAM_ATTR serviceLoopEntry(void *) {
|
||||
MDNS.setInstanceName(APP_NAME);
|
||||
apService.begin();
|
||||
|
||||
#if FT_ENABLED(USE_CAMERA)
|
||||
cameraService.begin();
|
||||
#endif
|
||||
|
||||
setupServer();
|
||||
|
||||
@@ -155,7 +163,7 @@ void IRAM_ATTR serviceLoopEntry(void *) {
|
||||
for (;;) {
|
||||
wifiService.loop();
|
||||
apService.loop();
|
||||
EXECUTE_EVERY_N_MS(2000, system_service::emitMetrics());
|
||||
EXECUTE_EVERY_N_MS(2000, system_service::emitMetrics(socket));
|
||||
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
@@ -166,13 +166,16 @@ float Peripherals::rightDistance() { return _right_distance; }
|
||||
|
||||
void Peripherals::getIMUResult(JsonVariant &root) {
|
||||
#if FT_ENABLED(USE_MPU6050 || USE_BNO055 || USE_ICM20948)
|
||||
_imu.getResults(root);
|
||||
JsonVariant imu = root["imu"].to<JsonVariant>();
|
||||
_imu.getResults(imu);
|
||||
#endif
|
||||
#if FT_ENABLED(USE_HMC5883 || USE_ICM20948)
|
||||
_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
|
||||
}
|
||||
|
||||
|
||||
@@ -121,13 +121,14 @@ void metrics(JsonObject &root) {
|
||||
root["core_temp"] = temperatureRead();
|
||||
}
|
||||
|
||||
void emitMetrics() {
|
||||
// if (!socket.hasSubscribers(EVENT_ANALYTICS)) return;
|
||||
// analyticsDoc.clear();
|
||||
// JsonObject root = analyticsDoc.to<JsonObject>();
|
||||
// system_service::metrics(root);
|
||||
// JsonVariant data = analyticsDoc.as<JsonVariant>();
|
||||
// socket.emit(EVENT_ANALYTICS, data);
|
||||
void emitMetrics(Websocket &socket) {
|
||||
if (!socket.hasSubscribers(EVENT_ANALYTICS)) return;
|
||||
|
||||
JsonDocument doc;
|
||||
JsonObject root = doc.to<JsonObject>();
|
||||
system_service::metrics(root);
|
||||
JsonVariant data = doc.as<JsonVariant>();
|
||||
socket.emit(EVENT_ANALYTICS, data);
|
||||
}
|
||||
|
||||
const char *resetReason(esp_reset_reason_t reason) {
|
||||
|
||||
Reference in New Issue
Block a user