diff --git a/esp32/features.ini b/esp32/features.ini index fe9611e..b30ad57 100644 --- a/esp32/features.ini +++ b/esp32/features.ini @@ -4,12 +4,12 @@ build_flags = -D USE_UPLOAD_FIRMWARE=1 -D USE_DOWNLOAD_FIRMWARE=0 -D USE_MOTION=1 + -D USE_MDNS=1 ; Hardware specific - -D USE_IMU=0 -D USE_MAG=0 -D USE_BMP=0 - -D USE_GPS=0 + -D USE_MPU6050=0 -D USE_WS2812=1 -D USE_USS=0 -D USE_SERVO=1 \ No newline at end of file diff --git a/esp32/lib/ESP32-sveltekit/features.cpp b/esp32/lib/ESP32-sveltekit/features.cpp index 83ceb6c..b10982b 100644 --- a/esp32/lib/ESP32-sveltekit/features.cpp +++ b/esp32/lib/ESP32-sveltekit/features.cpp @@ -2,15 +2,53 @@ namespace feature_service { +// New function to print all feature flags to log +void printFeatureConfiguration() { + ESP_LOGI("Features", "====================== FEATURE FLAGS ======================"); + ESP_LOGI("Features", "Firmware version: %s, name: %s, target: %s", APP_VERSION, APP_NAME, BUILD_TARGET); + + // Core features + ESP_LOGI("Features", "USE_UPLOAD_FIRMWARE: %s", USE_UPLOAD_FIRMWARE ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_DOWNLOAD_FIRMWARE: %s", USE_DOWNLOAD_FIRMWARE ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_SLEEP: %s", USE_SLEEP ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_CAMERA: %s", USE_CAMERA ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_MOTION: %s", USE_MOTION ? "enabled" : "disabled"); + + // Sensors + ESP_LOGI("Features", "USE_MPU6050: %s", USE_MPU6050 ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_MAG: %s", USE_MAG ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_BMP: %s", USE_BMP ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_USS: %s", USE_USS ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_GPS: %s", USE_GPS ? "enabled" : "disabled"); + + // Peripherals + ESP_LOGI("Features", "USE_SERVO: %s", USE_SERVO ? "enabled" : "disabled"); + ESP_LOGI("Features", "USE_WS2812: %s", USE_WS2812 ? "enabled" : "disabled"); + + // Web services + ESP_LOGI("Features", "USE_MDNS: %s", USE_MDNS ? "enabled" : "disabled"); + ESP_LOGI("Features", "EMBED_WWW: %s", EMBED_WWW ? "enabled" : "disabled"); + ESP_LOGI("Features", "ENABLE_CORS: %s", ENABLE_CORS ? "enabled" : "disabled"); + ESP_LOGI("Features", "SERVE_CONFIG_FILES: %s", SERVE_CONFIG_FILES ? "enabled" : "disabled"); + ESP_LOGI("Features", "=========================================================="); +} + void features(JsonObject &root) { root["upload_firmware"] = USE_UPLOAD_FIRMWARE; root["download_firmware"] = USE_DOWNLOAD_FIRMWARE; root["sleep"] = USE_SLEEP; root["camera"] = USE_CAMERA; - root["imu"] = USE_IMU; + root["imu"] = USE_MPU6050; root["mag"] = USE_MAG; root["bmp"] = USE_BMP; root["sonar"] = USE_USS; + root["motion"] = USE_MOTION; + root["servo"] = USE_SERVO; + root["ws2812"] = USE_WS2812; + root["mdns"] = USE_MDNS; + root["embed_www"] = EMBED_WWW; + root["enable_cors"] = ENABLE_CORS; + root["serve_config_files"] = SERVE_CONFIG_FILES; root["firmware_version"] = APP_VERSION; root["firmware_name"] = APP_NAME; root["firmware_built_target"] = BUILD_TARGET; diff --git a/esp32/lib/ESP32-sveltekit/features.h b/esp32/lib/ESP32-sveltekit/features.h index 3558f12..dd8d908 100644 --- a/esp32/lib/ESP32-sveltekit/features.h +++ b/esp32/lib/ESP32-sveltekit/features.h @@ -28,8 +28,8 @@ #endif // ESP32 IMU on by default -#ifndef USE_IMU -#define USE_IMU 1 +#ifndef USE_MPU6050 +#define USE_MPU6050 1 #endif // ESP32 magnetometer on by default @@ -52,8 +52,15 @@ #define USE_GPS 0 #endif +// ESP32 MDNS on by default +#ifndef USE_MDNS +#define USE_MDNS 1 +#endif + namespace feature_service { +void printFeatureConfiguration(); + void features(JsonObject &root); esp_err_t getFeatures(PsychicRequest *request); diff --git a/esp32/lib/ESP32-sveltekit/peripherals/imu.h b/esp32/lib/ESP32-sveltekit/peripherals/imu.h index 892da65..5d39be9 100644 --- a/esp32/lib/ESP32-sveltekit/peripherals/imu.h +++ b/esp32/lib/ESP32-sveltekit/peripherals/imu.h @@ -12,6 +12,7 @@ class IMU { public: IMU() {} bool initialize() { +#if FT_ENABLED(USE_MPU6050) _imu.initialize(); imu_success = _imu.testConnection(); devStatus = _imu.dmpInitialize(); @@ -20,16 +21,19 @@ class IMU { _imu.setI2CMasterModeEnabled(false); _imu.setI2CBypassEnabled(true); _imu.setSleepEnabled(false); +#endif return true; } bool readIMU() { if (!imu_success) return false; +#if FT_ENABLED(USE_MPU6050) bool updated = _imu.dmpGetCurrentFIFOPacket(fifoBuffer); _imu.dmpGetQuaternion(&q, fifoBuffer); _imu.dmpGetGravity(&gravity, &q); _imu.dmpGetYawPitchRoll(ypr, &q, &gravity); return updated; +#endif } float getTemperature() { return imu_success ? imu_temperature : -1; } @@ -40,8 +44,6 @@ class IMU { float getAngleZ() { return imu_success ? ypr[2] * 180 / M_PI : 0; } - Quaternion* getQuaternion() { return &q; } - void readIMU(JsonObject& root) { if (!imu_success) return; root["x"] = round2(getAngleX()); @@ -52,12 +54,14 @@ class IMU { bool active() { return imu_success; } private: +#if FT_ENABLED(USE_MPU6050) MPU6050 _imu; - bool imu_success {false}; uint8_t devStatus {false}; Quaternion q; uint8_t fifoBuffer[64]; VectorFloat gravity; +#endif + bool imu_success {false}; float ypr[3]; float imu_temperature {-1}; }; \ No newline at end of file diff --git a/esp32/lib/ESP32-sveltekit/peripherals/peripherals.h b/esp32/lib/ESP32-sveltekit/peripherals/peripherals.h index 672cfa7..4790241 100644 --- a/esp32/lib/ESP32-sveltekit/peripherals/peripherals.h +++ b/esp32/lib/ESP32-sveltekit/peripherals/peripherals.h @@ -67,7 +67,7 @@ class Peripherals : public StatefulService { updatePins(); -#if FT_ENABLED(USE_IMU) +#if FT_ENABLED(USE_MPU6050) if (!_imu.initialize()) ESP_LOGE("IMUService", "IMU initialize failed"); #endif #if FT_ENABLED(USE_MAG) @@ -137,7 +137,7 @@ class Peripherals : public StatefulService { /* IMU FUNCTIONS */ bool readIMU() { bool updated = false; -#if FT_ENABLED(USE_IMU) +#if FT_ENABLED(USE_MPU6050) beginTransaction(); updated = _imu.readIMU(); endTransaction(); @@ -181,7 +181,7 @@ class Peripherals : public StatefulService { void emitIMU() { doc.clear(); JsonObject root = doc.to(); -#if FT_ENABLED(USE_IMU) +#if FT_ENABLED(USE_MPU6050) _imu.readIMU(root); #endif #if FT_ENABLED(USE_MAG) @@ -214,7 +214,7 @@ class Peripherals : public StatefulService { JsonDocument doc; char message[MAX_ESP_IMU_SIZE]; -#if FT_ENABLED(USE_IMU) +#if FT_ENABLED(USE_MPU6050) IMU _imu; #endif #if FT_ENABLED(USE_MAG) diff --git a/esp32/src/spot.cpp b/esp32/src/spot.cpp index e1a1a4d..95dd63a 100644 --- a/esp32/src/spot.cpp +++ b/esp32/src/spot.cpp @@ -12,6 +12,9 @@ Spot::Spot() void Spot::initialize() { ESP_LOGI(TAG, "Running Firmware Version: %s", APP_VERSION); + + feature_service::printFeatureConfiguration(); + ESPFS.begin(true); g_taskManager.begin(); #if FT_ENABLED(USE_WS2812)