🖨️ Adds printing of feature flags

This commit is contained in:
Rune Harlyk
2025-03-23 16:27:56 +01:00
parent ad2d28c9ba
commit f864616303
6 changed files with 64 additions and 12 deletions
+2 -2
View File
@@ -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
+39 -1
View File
@@ -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;
+9 -2
View File
@@ -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);
+7 -3
View File
@@ -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};
};
@@ -67,7 +67,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
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<PeripheralsConfiguration> {
/* 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<PeripheralsConfiguration> {
void emitIMU() {
doc.clear();
JsonObject root = doc.to<JsonObject>();
#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<PeripheralsConfiguration> {
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)
+3
View File
@@ -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)