🖨️ Adds printing of feature flags
This commit is contained in:
+2
-2
@@ -4,12 +4,12 @@ build_flags =
|
|||||||
-D USE_UPLOAD_FIRMWARE=1
|
-D USE_UPLOAD_FIRMWARE=1
|
||||||
-D USE_DOWNLOAD_FIRMWARE=0
|
-D USE_DOWNLOAD_FIRMWARE=0
|
||||||
-D USE_MOTION=1
|
-D USE_MOTION=1
|
||||||
|
-D USE_MDNS=1
|
||||||
|
|
||||||
; Hardware specific
|
; Hardware specific
|
||||||
-D USE_IMU=0
|
|
||||||
-D USE_MAG=0
|
-D USE_MAG=0
|
||||||
-D USE_BMP=0
|
-D USE_BMP=0
|
||||||
-D USE_GPS=0
|
-D USE_MPU6050=0
|
||||||
-D USE_WS2812=1
|
-D USE_WS2812=1
|
||||||
-D USE_USS=0
|
-D USE_USS=0
|
||||||
-D USE_SERVO=1
|
-D USE_SERVO=1
|
||||||
@@ -2,15 +2,53 @@
|
|||||||
|
|
||||||
namespace feature_service {
|
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) {
|
void features(JsonObject &root) {
|
||||||
root["upload_firmware"] = USE_UPLOAD_FIRMWARE;
|
root["upload_firmware"] = USE_UPLOAD_FIRMWARE;
|
||||||
root["download_firmware"] = USE_DOWNLOAD_FIRMWARE;
|
root["download_firmware"] = USE_DOWNLOAD_FIRMWARE;
|
||||||
root["sleep"] = USE_SLEEP;
|
root["sleep"] = USE_SLEEP;
|
||||||
root["camera"] = USE_CAMERA;
|
root["camera"] = USE_CAMERA;
|
||||||
root["imu"] = USE_IMU;
|
root["imu"] = USE_MPU6050;
|
||||||
root["mag"] = USE_MAG;
|
root["mag"] = USE_MAG;
|
||||||
root["bmp"] = USE_BMP;
|
root["bmp"] = USE_BMP;
|
||||||
root["sonar"] = USE_USS;
|
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_version"] = APP_VERSION;
|
||||||
root["firmware_name"] = APP_NAME;
|
root["firmware_name"] = APP_NAME;
|
||||||
root["firmware_built_target"] = BUILD_TARGET;
|
root["firmware_built_target"] = BUILD_TARGET;
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ESP32 IMU on by default
|
// ESP32 IMU on by default
|
||||||
#ifndef USE_IMU
|
#ifndef USE_MPU6050
|
||||||
#define USE_IMU 1
|
#define USE_MPU6050 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ESP32 magnetometer on by default
|
// ESP32 magnetometer on by default
|
||||||
@@ -52,8 +52,15 @@
|
|||||||
#define USE_GPS 0
|
#define USE_GPS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ESP32 MDNS on by default
|
||||||
|
#ifndef USE_MDNS
|
||||||
|
#define USE_MDNS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace feature_service {
|
namespace feature_service {
|
||||||
|
|
||||||
|
void printFeatureConfiguration();
|
||||||
|
|
||||||
void features(JsonObject &root);
|
void features(JsonObject &root);
|
||||||
|
|
||||||
esp_err_t getFeatures(PsychicRequest *request);
|
esp_err_t getFeatures(PsychicRequest *request);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class IMU {
|
|||||||
public:
|
public:
|
||||||
IMU() {}
|
IMU() {}
|
||||||
bool initialize() {
|
bool initialize() {
|
||||||
|
#if FT_ENABLED(USE_MPU6050)
|
||||||
_imu.initialize();
|
_imu.initialize();
|
||||||
imu_success = _imu.testConnection();
|
imu_success = _imu.testConnection();
|
||||||
devStatus = _imu.dmpInitialize();
|
devStatus = _imu.dmpInitialize();
|
||||||
@@ -20,16 +21,19 @@ class IMU {
|
|||||||
_imu.setI2CMasterModeEnabled(false);
|
_imu.setI2CMasterModeEnabled(false);
|
||||||
_imu.setI2CBypassEnabled(true);
|
_imu.setI2CBypassEnabled(true);
|
||||||
_imu.setSleepEnabled(false);
|
_imu.setSleepEnabled(false);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readIMU() {
|
bool readIMU() {
|
||||||
if (!imu_success) return false;
|
if (!imu_success) return false;
|
||||||
|
#if FT_ENABLED(USE_MPU6050)
|
||||||
bool updated = _imu.dmpGetCurrentFIFOPacket(fifoBuffer);
|
bool updated = _imu.dmpGetCurrentFIFOPacket(fifoBuffer);
|
||||||
_imu.dmpGetQuaternion(&q, fifoBuffer);
|
_imu.dmpGetQuaternion(&q, fifoBuffer);
|
||||||
_imu.dmpGetGravity(&gravity, &q);
|
_imu.dmpGetGravity(&gravity, &q);
|
||||||
_imu.dmpGetYawPitchRoll(ypr, &q, &gravity);
|
_imu.dmpGetYawPitchRoll(ypr, &q, &gravity);
|
||||||
return updated;
|
return updated;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
float getTemperature() { return imu_success ? imu_temperature : -1; }
|
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; }
|
float getAngleZ() { return imu_success ? ypr[2] * 180 / M_PI : 0; }
|
||||||
|
|
||||||
Quaternion* getQuaternion() { return &q; }
|
|
||||||
|
|
||||||
void readIMU(JsonObject& root) {
|
void readIMU(JsonObject& root) {
|
||||||
if (!imu_success) return;
|
if (!imu_success) return;
|
||||||
root["x"] = round2(getAngleX());
|
root["x"] = round2(getAngleX());
|
||||||
@@ -52,12 +54,14 @@ class IMU {
|
|||||||
bool active() { return imu_success; }
|
bool active() { return imu_success; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if FT_ENABLED(USE_MPU6050)
|
||||||
MPU6050 _imu;
|
MPU6050 _imu;
|
||||||
bool imu_success {false};
|
|
||||||
uint8_t devStatus {false};
|
uint8_t devStatus {false};
|
||||||
Quaternion q;
|
Quaternion q;
|
||||||
uint8_t fifoBuffer[64];
|
uint8_t fifoBuffer[64];
|
||||||
VectorFloat gravity;
|
VectorFloat gravity;
|
||||||
|
#endif
|
||||||
|
bool imu_success {false};
|
||||||
float ypr[3];
|
float ypr[3];
|
||||||
float imu_temperature {-1};
|
float imu_temperature {-1};
|
||||||
};
|
};
|
||||||
@@ -67,7 +67,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
|
|||||||
|
|
||||||
updatePins();
|
updatePins();
|
||||||
|
|
||||||
#if FT_ENABLED(USE_IMU)
|
#if FT_ENABLED(USE_MPU6050)
|
||||||
if (!_imu.initialize()) ESP_LOGE("IMUService", "IMU initialize failed");
|
if (!_imu.initialize()) ESP_LOGE("IMUService", "IMU initialize failed");
|
||||||
#endif
|
#endif
|
||||||
#if FT_ENABLED(USE_MAG)
|
#if FT_ENABLED(USE_MAG)
|
||||||
@@ -137,7 +137,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
|
|||||||
/* IMU FUNCTIONS */
|
/* IMU FUNCTIONS */
|
||||||
bool readIMU() {
|
bool readIMU() {
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
#if FT_ENABLED(USE_IMU)
|
#if FT_ENABLED(USE_MPU6050)
|
||||||
beginTransaction();
|
beginTransaction();
|
||||||
updated = _imu.readIMU();
|
updated = _imu.readIMU();
|
||||||
endTransaction();
|
endTransaction();
|
||||||
@@ -181,7 +181,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
|
|||||||
void emitIMU() {
|
void emitIMU() {
|
||||||
doc.clear();
|
doc.clear();
|
||||||
JsonObject root = doc.to<JsonObject>();
|
JsonObject root = doc.to<JsonObject>();
|
||||||
#if FT_ENABLED(USE_IMU)
|
#if FT_ENABLED(USE_MPU6050)
|
||||||
_imu.readIMU(root);
|
_imu.readIMU(root);
|
||||||
#endif
|
#endif
|
||||||
#if FT_ENABLED(USE_MAG)
|
#if FT_ENABLED(USE_MAG)
|
||||||
@@ -214,7 +214,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
|
|||||||
|
|
||||||
JsonDocument doc;
|
JsonDocument doc;
|
||||||
char message[MAX_ESP_IMU_SIZE];
|
char message[MAX_ESP_IMU_SIZE];
|
||||||
#if FT_ENABLED(USE_IMU)
|
#if FT_ENABLED(USE_MPU6050)
|
||||||
IMU _imu;
|
IMU _imu;
|
||||||
#endif
|
#endif
|
||||||
#if FT_ENABLED(USE_MAG)
|
#if FT_ENABLED(USE_MAG)
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ Spot::Spot()
|
|||||||
|
|
||||||
void Spot::initialize() {
|
void Spot::initialize() {
|
||||||
ESP_LOGI(TAG, "Running Firmware Version: %s", APP_VERSION);
|
ESP_LOGI(TAG, "Running Firmware Version: %s", APP_VERSION);
|
||||||
|
|
||||||
|
feature_service::printFeatureConfiguration();
|
||||||
|
|
||||||
ESPFS.begin(true);
|
ESPFS.begin(true);
|
||||||
g_taskManager.begin();
|
g_taskManager.begin();
|
||||||
#if FT_ENABLED(USE_WS2812)
|
#if FT_ENABLED(USE_WS2812)
|
||||||
|
|||||||
Reference in New Issue
Block a user