🏕️ Renames the feature flag

This commit is contained in:
Rune Harlyk
2024-08-19 18:23:37 +02:00
committed by Rune Harlyk
parent cf55bf509e
commit 586dbc7a9a
14 changed files with 140 additions and 140 deletions
+16 -16
View File
@@ -1,20 +1,20 @@
[features] [features]
build_flags = build_flags =
-D FT_BATTERY=1 -D USE_BATTERY=1
-D FT_NTP=1 -D USE_NTP=1
-D FT_SECURITY=0 -D USE_SECURITY=0
-D FT_SLEEP=0 -D USE_SLEEP=0
-D FT_UPLOAD_FIRMWARE=0 -D USE_UPLOAD_FIRMWARE=0
-D FT_DOWNLOAD_FIRMWARE=0 -D USE_DOWNLOAD_FIRMWARE=0
-D FT_ANALYTICS=1 -D USE_ANALYTICS=1
-D FT_MOTION=1 -D USE_MOTION=1
; Hardware specific ; Hardware specific
-D FT_IMU=1 -D USE_IMU=1
-D FT_MAG=1 -D USE_MAG=1
-D FT_BMP=1 -D USE_BMP=1
-D FT_GPS=0 -D USE_GPS=0
-D FT_WS2812=1 -D USE_WS2812=1
-D FT_USS=0 -D USE_USS=0
-D FT_SERVO=1 -D USE_SERVO=1
-D FT_ADS1115=1 -D USE_ADS1115=1
@@ -14,7 +14,7 @@
#include <AuthenticationService.h> #include <AuthenticationService.h>
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(USE_SECURITY)
AuthenticationService::AuthenticationService(PsychicHttpServer *server, SecurityManager *securityManager) AuthenticationService::AuthenticationService(PsychicHttpServer *server, SecurityManager *securityManager)
: _server(server), _securityManager(securityManager) {} : _server(server), _securityManager(securityManager) {}
@@ -48,4 +48,4 @@ void AuthenticationService::begin() {
ESP_LOGV("AuthenticationService", "Registered GET endpoint: %s", VERIFY_AUTHORIZATION_PATH); ESP_LOGV("AuthenticationService", "Registered GET endpoint: %s", VERIFY_AUTHORIZATION_PATH);
} }
#endif // end FT_ENABLED(FT_SECURITY) #endif // end FT_ENABLED(USE_SECURITY)
@@ -22,7 +22,7 @@
#define VERIFY_AUTHORIZATION_PATH "/api/verifyAuthorization" #define VERIFY_AUTHORIZATION_PATH "/api/verifyAuthorization"
#define SIGN_IN_PATH "/api/signIn" #define SIGN_IN_PATH "/api/signIn"
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(USE_SECURITY)
class AuthenticationService { class AuthenticationService {
public: public:
@@ -35,5 +35,5 @@ class AuthenticationService {
PsychicHttpServer *_server; PsychicHttpServer *_server;
}; };
#endif // end FT_ENABLED(FT_SECURITY) #endif // end FT_ENABLED(USE_SECURITY)
#endif // end SecurityManager_h #endif // end SecurityManager_h
+1 -1
View File
@@ -44,7 +44,7 @@ esp_err_t CameraService::InitializeCamera() {
camera_config_t camera_config; camera_config_t camera_config;
camera_config.ledc_channel = LEDC_CHANNEL_0; camera_config.ledc_channel = LEDC_CHANNEL_0;
camera_config.ledc_timer = LEDC_TIMER_0; camera_config.ledc_timer = LEDC_TIMER_0;
#if FT_ENABLED(FT_CAMERA) #if FT_ENABLED(USE_CAMERA)
camera_config.pin_d0 = Y2_GPIO_NUM; camera_config.pin_d0 = Y2_GPIO_NUM;
camera_config.pin_d1 = Y3_GPIO_NUM; camera_config.pin_d1 = Y3_GPIO_NUM;
camera_config.pin_d2 = Y4_GPIO_NUM; camera_config.pin_d2 = Y4_GPIO_NUM;
+1 -1
View File
@@ -10,7 +10,7 @@
#include <async_worker.h> #include <async_worker.h>
#include <Features.h> #include <Features.h>
#if FT_ENABLED(FT_CAMERA) #if USE_CAMERA
#include <CameraPins.h> #include <CameraPins.h>
#endif #endif
+23 -23
View File
@@ -27,29 +27,29 @@ ESP32SvelteKit::ESP32SvelteKit(PsychicHttpServer *server, unsigned int numberEnd
_apSettingsService(server, &ESPFS, &_securitySettingsService), _apSettingsService(server, &ESPFS, &_securitySettingsService),
_apStatus(server, &_securitySettingsService, &_apSettingsService), _apStatus(server, &_securitySettingsService, &_apSettingsService),
_socket(server, &_securitySettingsService, AuthenticationPredicates::IS_AUTHENTICATED), _socket(server, &_securitySettingsService, AuthenticationPredicates::IS_AUTHENTICATED),
#if FT_ENABLED(FT_NTP) #if FT_ENABLED(USE_NTP)
_ntpSettingsService(server, &ESPFS, &_securitySettingsService), _ntpSettingsService(server, &ESPFS, &_securitySettingsService),
_ntpStatus(server, &_securitySettingsService), _ntpStatus(server, &_securitySettingsService),
#endif #endif
#if FT_ENABLED(FT_UPLOAD_FIRMWARE) #if FT_ENABLED(USE_UPLOAD_FIRMWARE)
_uploadFirmwareService(server, &_securitySettingsService), _uploadFirmwareService(server, &_securitySettingsService),
#endif #endif
#if FT_ENABLED(FT_DOWNLOAD_FIRMWARE) #if FT_ENABLED(USE_DOWNLOAD_FIRMWARE)
_downloadFirmwareService(server, &_securitySettingsService, &_socket, &_taskManager), _downloadFirmwareService(server, &_securitySettingsService, &_socket, &_taskManager),
#endif #endif
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(USE_SECURITY)
_authenticationService(server, &_securitySettingsService), _authenticationService(server, &_securitySettingsService),
#endif #endif
#if FT_ENABLED(FT_SLEEP) #if FT_ENABLED(USE_SLEEP)
_sleepService(server, &_securitySettingsService), _sleepService(server, &_securitySettingsService),
#endif #endif
#if FT_ENABLED(FT_BATTERY) #if FT_ENABLED(USE_BATTERY)
_batteryService(&_peripherals, &_socket), _batteryService(&_peripherals, &_socket),
#endif #endif
#if FT_ENABLED(FT_ANALYTICS) #if FT_ENABLED(USE_ANALYTICS)
_analyticsService(&_socket, &_taskManager), _analyticsService(&_socket, &_taskManager),
#endif #endif
#if FT_ENABLED(FT_CAMERA) #if FT_ENABLED(USE_CAMERA)
_cameraService(server, &_taskManager, &_securitySettingsService), _cameraService(server, &_taskManager, &_securitySettingsService),
_cameraSettingsService(server, &ESPFS, &_securitySettingsService, &_socket), _cameraSettingsService(server, &ESPFS, &_securitySettingsService, &_socket),
#endif #endif
@@ -58,10 +58,10 @@ ESP32SvelteKit::ESP32SvelteKit(PsychicHttpServer *server, unsigned int numberEnd
_systemStatus(server, &_securitySettingsService), _systemStatus(server, &_securitySettingsService),
_fileExplorer(server, &_securitySettingsService), _fileExplorer(server, &_securitySettingsService),
_servoController(server, &ESPFS, &_securitySettingsService, &_peripherals, &_socket), _servoController(server, &ESPFS, &_securitySettingsService, &_peripherals, &_socket),
#if FT_ENABLED(FT_MOTION) #if FT_ENABLED(USE_MOTION)
_motionService(_server, &_socket, &_securitySettingsService, &_servoController, &_taskManager), _motionService(_server, &_socket, &_securitySettingsService, &_servoController, &_taskManager),
#endif #endif
#if FT_ENABLED(FT_WS2812) #if FT_ENABLED(USE_WS2812)
_ledService(&_taskManager), _ledService(&_taskManager),
#endif #endif
_peripherals(server, &ESPFS, &_securitySettingsService, &_socket) { _peripherals(server, &ESPFS, &_securitySettingsService, &_socket) {
@@ -159,56 +159,56 @@ void ESP32SvelteKit::startServices() {
_wifiScanner.begin(); _wifiScanner.begin();
_wifiStatus.begin(); _wifiStatus.begin();
#if FT_ENABLED(FT_UPLOAD_FIRMWARE) #if FT_ENABLED(USE_UPLOAD_FIRMWARE)
_uploadFirmwareService.begin(); _uploadFirmwareService.begin();
#endif #endif
#if FT_ENABLED(FT_DOWNLOAD_FIRMWARE) #if FT_ENABLED(USE_DOWNLOAD_FIRMWARE)
_downloadFirmwareService.begin(); _downloadFirmwareService.begin();
#endif #endif
#if FT_ENABLED(FT_NTP) #if FT_ENABLED(USE_NTP)
_ntpSettingsService.begin(); _ntpSettingsService.begin();
_ntpStatus.begin(); _ntpStatus.begin();
#endif #endif
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(USE_SECURITY)
_authenticationService.begin(); _authenticationService.begin();
_securitySettingsService.begin(); _securitySettingsService.begin();
#endif #endif
#if FT_ENABLED(FT_ANALYTICS) #if FT_ENABLED(USE_ANALYTICS)
_analyticsService.begin(); _analyticsService.begin();
#endif #endif
#if FT_ENABLED(FT_SLEEP) #if FT_ENABLED(USE_SLEEP)
_sleepService.begin(); _sleepService.begin();
#endif #endif
#if FT_ENABLED(FT_BATTERY) #if FT_ENABLED(USE_BATTERY)
_batteryService.begin(); _batteryService.begin();
#endif #endif
_taskManager.begin(); _taskManager.begin();
_fileExplorer.begin(); _fileExplorer.begin();
_peripherals.begin(); _peripherals.begin();
_servoController.begin(); _servoController.begin();
#if FT_ENABLED(FT_MOTION) #if FT_ENABLED(USE_MOTION)
_motionService.begin(); _motionService.begin();
#endif #endif
#if FT_ENABLED(FT_CAMERA) #if FT_ENABLED(USE_CAMERA)
_cameraService.begin(); _cameraService.begin();
_cameraSettingsService.begin(); _cameraSettingsService.begin();
#endif #endif
#if FT_ENABLED(FT_WS2812) #if FT_ENABLED(USE_WS2812)
_ledService.begin(); _ledService.begin();
#endif #endif
} }
void IRAM_ATTR ESP32SvelteKit::loop() { void IRAM_ATTR ESP32SvelteKit::loop() {
while (1) { while (1) {
#if FT_ENABLED(FT_WS2812) #if FT_ENABLED(USE_WS2812)
_ledService.loop(); _ledService.loop();
#endif #endif
_wifiSettingsService.loop(); _wifiSettingsService.loop();
_apSettingsService.loop(); _apSettingsService.loop();
#if FT_ENABLED(FT_ANALYTICS) #if FT_ENABLED(USE_ANALYTICS)
_analyticsService.loop(); _analyticsService.loop();
#endif #endif
#if FT_ENABLED(FT_BATTERY) #if FT_ENABLED(USE_BATTERY)
_batteryService.loop(); _batteryService.loop();
#endif #endif
_peripherals.loop(); _peripherals.loop();
+16 -16
View File
@@ -89,15 +89,15 @@ class ESP32SvelteKit {
StatefulService<APSettings> *getAPSettingsService() { return &_apSettingsService; } StatefulService<APSettings> *getAPSettingsService() { return &_apSettingsService; }
#if FT_ENABLED(FT_NTP) #if FT_ENABLED(USE_NTP)
StatefulService<NTPSettings> *getNTPSettingsService() { return &_ntpSettingsService; } StatefulService<NTPSettings> *getNTPSettingsService() { return &_ntpSettingsService; }
#endif #endif
#if FT_ENABLED(FT_SLEEP) #if FT_ENABLED(USE_SLEEP)
SleepService *getSleepService() { return &_sleepService; } SleepService *getSleepService() { return &_sleepService; }
#endif #endif
#if FT_ENABLED(FT_BATTERY) #if FT_ENABLED(USE_BATTERY)
BatteryService *getBatteryService() { return &_batteryService; } BatteryService *getBatteryService() { return &_batteryService; }
#endif #endif
@@ -107,18 +107,18 @@ class ESP32SvelteKit {
FileExplorer *getFileExplorer() { return &_fileExplorer; } FileExplorer *getFileExplorer() { return &_fileExplorer; }
#if FT_ENABLED(FT_MOTION) #if FT_ENABLED(USE_MOTION)
MotionService *getMotionService() { return &_motionService; } MotionService *getMotionService() { return &_motionService; }
#endif #endif
#if FT_ENABLED(FT_CAMERA)
CameraService *getCameraService() { return &_cameraService; } CameraService *getCameraService() { return &_cameraService; }
CameraSettingsService *getCameraSettingsService() { return &_cameraSettingsService; } CameraSettingsService *getCameraSettingsService() { return &_cameraSettingsService; }
#if FT_ENABLED(USE_CAMERA)
#endif #endif
Peripherals *getPeripherals() { return &_peripherals; } Peripherals *getPeripherals() { return &_peripherals; }
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
ServoController *getServoController() { return &_servoController; } ServoController *getServoController() { return &_servoController; }
#endif #endif
@@ -141,26 +141,26 @@ class ESP32SvelteKit {
APSettingsService _apSettingsService; APSettingsService _apSettingsService;
APStatus _apStatus; APStatus _apStatus;
EventSocket _socket; EventSocket _socket;
#if FT_ENABLED(FT_NTP) #if FT_ENABLED(USE_NTP)
NTPSettingsService _ntpSettingsService; NTPSettingsService _ntpSettingsService;
NTPStatus _ntpStatus; NTPStatus _ntpStatus;
#endif #endif
#if FT_ENABLED(FT_UPLOAD_FIRMWARE) #if FT_ENABLED(USE_UPLOAD_FIRMWARE)
UploadFirmwareService _uploadFirmwareService; UploadFirmwareService _uploadFirmwareService;
#endif #endif
#if FT_ENABLED(FT_DOWNLOAD_FIRMWARE) #if FT_ENABLED(USE_DOWNLOAD_FIRMWARE)
DownloadFirmwareService _downloadFirmwareService; DownloadFirmwareService _downloadFirmwareService;
#endif #endif
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(USE_SECURITY)
AuthenticationService _authenticationService; AuthenticationService _authenticationService;
#endif #endif
#if FT_ENABLED(FT_SLEEP) #if FT_ENABLED(USE_SLEEP)
SleepService _sleepService; SleepService _sleepService;
#endif #endif
#if FT_ENABLED(FT_BATTERY) #if FT_ENABLED(USE_BATTERY)
BatteryService _batteryService; BatteryService _batteryService;
#endif #endif
#if FT_ENABLED(FT_ANALYTICS) #if FT_ENABLED(USE_ANALYTICS)
AnalyticsService _analyticsService; AnalyticsService _analyticsService;
#endif #endif
RestartService _restartService; RestartService _restartService;
@@ -168,16 +168,16 @@ class ESP32SvelteKit {
SystemStatus _systemStatus; SystemStatus _systemStatus;
TaskManager _taskManager; TaskManager _taskManager;
FileExplorer _fileExplorer; FileExplorer _fileExplorer;
#if FT_ENABLED(FT_MOTION) #if FT_ENABLED(USE_MOTION)
MotionService _motionService; MotionService _motionService;
#endif #endif
#if FT_ENABLED(FT_CAMERA)
CameraService _cameraService; CameraService _cameraService;
CameraSettingsService _cameraSettingsService; CameraSettingsService _cameraSettingsService;
#if FT_ENABLED(USE_CAMERA)
#endif #endif
Peripherals _peripherals; Peripherals _peripherals;
ServoController _servoController; ServoController _servoController;
#if FT_ENABLED(FT_WS2812) #if FT_ENABLED(USE_WS2812)
LEDService _ledService; LEDService _ledService;
#endif #endif
+26 -26
View File
@@ -18,68 +18,68 @@
#define FT_ENABLED(feature) feature #define FT_ENABLED(feature) feature
// security feature on by default // security feature on by default
#ifndef FT_SECURITY #ifndef USE_SECURITY
#define FT_SECURITY 1 #define USE_SECURITY 1
#endif #endif
// ntp feature on by default // ntp feature on by default
#ifndef FT_NTP #ifndef USE_NTP
#define FT_NTP 1 #define USE_NTP 1
#endif #endif
// upload firmware feature off by default // upload firmware feature off by default
#ifndef FT_UPLOAD_FIRMWARE #ifndef USE_UPLOAD_FIRMWARE
#define FT_UPLOAD_FIRMWARE 0 #define USE_UPLOAD_FIRMWARE 0
#endif #endif
// download firmware feature off by default // download firmware feature off by default
#ifndef FT_DOWNLOAD_FIRMWARE #ifndef USE_DOWNLOAD_FIRMWARE
#define FT_DOWNLOAD_FIRMWARE 0 #define USE_DOWNLOAD_FIRMWARE 0
#endif #endif
// ESP32 sleep states off by default // ESP32 sleep states off by default
#ifndef FT_SLEEP #ifndef USE_SLEEP
#define FT_SLEEP 0 #define USE_SLEEP 0
#endif #endif
// ESP32 battery state off by default // ESP32 battery state off by default
#ifndef FT_BATTERY #ifndef USE_BATTERY
#define FT_BATTERY 0 #define USE_BATTERY 0
#endif #endif
// ESP32 analytics on by default // ESP32 analytics on by default
#ifndef FT_ANALYTICS #ifndef USE_ANALYTICS
#define FT_ANALYTICS 1 #define USE_ANALYTICS 1
#endif #endif
// ESP32 camera off by default // ESP32 camera off by default
#ifndef FT_CAMERA #ifndef USE_CAMERA
#define FT_CAMERA 0 #define USE_CAMERA 0
#endif #endif
// ESP32 IMU on by default // ESP32 IMU on by default
#ifndef FT_IMU #ifndef USE_IMU
#define FT_IMU 1 #define USE_IMU 1
#endif #endif
// ESP32 magnetometer on by default // ESP32 magnetometer on by default
#ifndef FT_MAG #ifndef USE_MAG
#define FT_MAG 0 #define USE_MAG 0
#endif #endif
// ESP32 barometer off by default // ESP32 barometer off by default
#ifndef FT_BMP #ifndef USE_BMP
#define FT_BMP 0 #define USE_BMP 0
#endif #endif
// ESP32 SONAR off by default // ESP32 SONAR off by default
#ifndef FT_USS #ifndef USE_USS
#define FT_USS 0 #define USE_USS 0
#endif #endif
// ESP32 GPS off by default // ESP32 GPS off by default
#ifndef FT_GPS #ifndef USE_GPS
#define FT_GPS 0 #define USE_GPS 0
#endif #endif
#endif #endif
+12 -12
View File
@@ -22,18 +22,18 @@ void FeaturesService::begin() {
PsychicJsonResponse response = PsychicJsonResponse(request, false); PsychicJsonResponse response = PsychicJsonResponse(request, false);
JsonObject root = response.getRoot(); JsonObject root = response.getRoot();
root["security"] = FT_SECURITY; root["security"] = USE_SECURITY;
root["ntp"] = FT_NTP; root["ntp"] = USE_NTP;
root["upload_firmware"] = FT_UPLOAD_FIRMWARE; root["upload_firmware"] = USE_UPLOAD_FIRMWARE;
root["download_firmware"] = FT_DOWNLOAD_FIRMWARE; root["download_firmware"] = USE_DOWNLOAD_FIRMWARE;
root["sleep"] = FT_SLEEP; root["sleep"] = USE_SLEEP;
root["battery"] = FT_BATTERY; root["battery"] = USE_BATTERY;
root["analytics"] = FT_ANALYTICS; root["analytics"] = USE_ANALYTICS;
root["camera"] = FT_CAMERA; root["camera"] = USE_CAMERA;
root["imu"] = FT_IMU; root["imu"] = USE_IMU;
root["mag"] = FT_MAG; root["mag"] = USE_MAG;
root["bmp"] = FT_BMP; root["bmp"] = USE_BMP;
root["sonar"] = FT_USS; root["sonar"] = USE_USS;
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;
+35 -35
View File
@@ -109,10 +109,10 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
CONFIGURATION_SETTINGS_PATH, securityManager, AuthenticationPredicates::IS_ADMIN), CONFIGURATION_SETTINGS_PATH, securityManager, AuthenticationPredicates::IS_ADMIN),
_eventEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, socket, _eventEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, socket,
EVENT_CONFIGURATION_SETTINGS), EVENT_CONFIGURATION_SETTINGS),
#if FT_ENABLED(FT_MAG) #if FT_ENABLED(USE_MAG)
_mag(12345), _mag(12345),
#endif #endif
#if FT_ENABLED(FT_BMP) #if FT_ENABLED(USE_BMP)
_bmp(10085), _bmp(10085),
#endif #endif
_fsPersistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, fs, _fsPersistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, fs,
@@ -138,7 +138,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
updatePins(); updatePins();
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
_pca.begin(); _pca.begin();
_pca.setPWMFreq(FACTORY_SERVO_PWM_FREQUENCY); _pca.setPWMFreq(FACTORY_SERVO_PWM_FREQUENCY);
_pca.setOscillatorFrequency(FACTORY_SERVO_OSCILLATOR_FREQUENCY); _pca.setOscillatorFrequency(FACTORY_SERVO_OSCILLATOR_FREQUENCY);
@@ -149,7 +149,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
}); });
#endif #endif
#if FT_ENABLED(FT_IMU) #if FT_ENABLED(USE_IMU)
_imu.initialize(); _imu.initialize();
imu_success = _imu.testConnection(); imu_success = _imu.testConnection();
devStatus = _imu.dmpInitialize(); devStatus = _imu.dmpInitialize();
@@ -161,27 +161,27 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
_imu.setI2CBypassEnabled(true); _imu.setI2CBypassEnabled(true);
_imu.setSleepEnabled(false); _imu.setSleepEnabled(false);
#endif #endif
#if FT_ENABLED(FT_MAG) #if FT_ENABLED(USE_MAG)
mag_success = _mag.begin(); mag_success = _mag.begin();
if (!mag_success) { if (!mag_success) {
ESP_LOGE("IMUService", "MAG initialize failed"); ESP_LOGE("IMUService", "MAG initialize failed");
} }
#endif #endif
#if FT_ENABLED(FT_BMP) #if FT_ENABLED(USE_BMP)
bmp_success = _bmp.begin(); bmp_success = _bmp.begin();
if (!bmp_success) { if (!bmp_success) {
ESP_LOGE("IMUService", "BMP initialize failed"); ESP_LOGE("IMUService", "BMP initialize failed");
} }
#endif #endif
#if FT_ENABLED(FT_ADS1015) || FT_ENABLED(FT_ADS1115) #if FT_ENABLED(FT_ADS1015) || FT_ENABLED(USE_ADS1115)
if (!_ads.begin()) { if (!_ads.begin()) {
ESP_LOGE("Peripherals", "ADS1015/ADS1115 not found"); ESP_LOGE("Peripherals", "ADS1015/ADS1115 not found");
} }
_ads.startADCReading(ADS1X15_REG_CONFIG_MUX_DIFF_0_1, /*continuous=*/false); _ads.startADCReading(ADS1X15_REG_CONFIG_MUX_DIFF_0_1, /*continuous=*/false);
#endif #endif
#if FT_ENABLED(FT_USS) #if FT_ENABLED(USE_USS)
_left_sonar = new NewPing(USS_LEFT_PIN, USS_LEFT_PIN, MAX_DISTANCE); _left_sonar = new NewPing(USS_LEFT_PIN, USS_LEFT_PIN, MAX_DISTANCE);
_right_sonar = new NewPing(USS_RIGHT_PIN, USS_RIGHT_PIN, MAX_DISTANCE); _right_sonar = new NewPing(USS_RIGHT_PIN, USS_RIGHT_PIN, MAX_DISTANCE);
#endif #endif
@@ -241,13 +241,13 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
/* SERVO FUNCTIONS*/ /* SERVO FUNCTIONS*/
void pcaLerpTo(int index, int value, float t) { void pcaLerpTo(int index, int value, float t) {
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
target_pwm[index] = lerp(pwm[index], value, t); target_pwm[index] = lerp(pwm[index], value, t);
#endif #endif
} }
void pcaWrite(int index, int value) { void pcaWrite(int index, int value) {
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
if (value < 0 || value > 4096) { if (value < 0 || value > 4096) {
ESP_LOGE("Peripherals", "Invalid PWM value %d for %d :: Valid range 0-4096", value, index); ESP_LOGE("Peripherals", "Invalid PWM value %d for %d :: Valid range 0-4096", value, index);
return; return;
@@ -261,13 +261,13 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
} }
void pcaWriteAngle(int index, int angle) { void pcaWriteAngle(int index, int angle) {
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
_pca.setPWM(index, 0, 125 + angle * 2); _pca.setPWM(index, 0, 125 + angle * 2);
#endif #endif
} }
void pcaWriteAngles(float *angles, int numServos, int offset = 0) { void pcaWriteAngles(float *angles, int numServos, int offset = 0) {
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
for (int i = 0; i < numServos; i++) { for (int i = 0; i < numServos; i++) {
pcaWriteAngle(i + offset, angles[i]); pcaWriteAngle(i + offset, angles[i]);
} }
@@ -275,7 +275,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
} }
void pcaActivate() { void pcaActivate() {
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
if (_pca_active) return; if (_pca_active) return;
_pca_active = true; _pca_active = true;
_pca.wakeup(); _pca.wakeup();
@@ -283,7 +283,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
} }
void pcaDeactivate() { void pcaDeactivate() {
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
if (!_pca_active) return; if (!_pca_active) return;
_pca_active = false; _pca_active = false;
_pca.sleep(); _pca.sleep();
@@ -293,7 +293,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
/* ADC FUNCTIONS*/ /* ADC FUNCTIONS*/
int16_t readADCVoltage(uint8_t channel) { int16_t readADCVoltage(uint8_t channel) {
int16_t voltage = -1; int16_t voltage = -1;
#if FT_ENABLED(FT_ADS1015) || FT_ENABLED(FT_ADS1115) #if FT_ENABLED(FT_ADS1015) || FT_ENABLED(USE_ADS1115)
float adc0 = _ads.readADC_SingleEnded(channel); float adc0 = _ads.readADC_SingleEnded(channel);
voltage = _ads.computeVolts(adc0); voltage = _ads.computeVolts(adc0);
#endif #endif
@@ -303,7 +303,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
/* IMU FUNCTIONS */ /* IMU FUNCTIONS */
bool readIMU() { bool readIMU() {
bool updated = false; bool updated = false;
#if FT_ENABLED(FT_IMU) #if FT_ENABLED(USE_IMU)
updated = imu_success && _imu.dmpGetCurrentFIFOPacket(fifoBuffer); updated = imu_success && _imu.dmpGetCurrentFIFOPacket(fifoBuffer);
_imu.dmpGetQuaternion(&q, fifoBuffer); _imu.dmpGetQuaternion(&q, fifoBuffer);
_imu.dmpGetGravity(&gravity, &q); _imu.dmpGetGravity(&gravity, &q);
@@ -314,7 +314,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
float getTemp() { float getTemp() {
float temp = -1; float temp = -1;
#if FT_ENABLED(FT_IMU) #if FT_ENABLED(USE_IMU)
temp = imu_success ? imu_temperature : -1; temp = imu_success ? imu_temperature : -1;
#endif #endif
return temp; return temp;
@@ -322,7 +322,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
float getAngleX() { float getAngleX() {
float angle = 0; float angle = 0;
#if FT_ENABLED(FT_IMU) #if FT_ENABLED(USE_IMU)
angle = imu_success ? ypr[0] * 180 / M_PI : 0; angle = imu_success ? ypr[0] * 180 / M_PI : 0;
#endif #endif
return angle; return angle;
@@ -330,7 +330,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
float getAngleY() { float getAngleY() {
float angle = 0; float angle = 0;
#if FT_ENABLED(FT_IMU) #if FT_ENABLED(USE_IMU)
angle = imu_success ? ypr[1] * 180 / M_PI : 0; angle = imu_success ? ypr[1] * 180 / M_PI : 0;
#endif #endif
return angle; return angle;
@@ -338,7 +338,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
float getAngleZ() { float getAngleZ() {
float angle = 0; float angle = 0;
#if FT_ENABLED(FT_IMU) #if FT_ENABLED(USE_IMU)
angle = imu_success ? ypr[2] * 180 / M_PI : 0; angle = imu_success ? ypr[2] * 180 / M_PI : 0;
#endif #endif
return angle; return angle;
@@ -347,7 +347,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
/* MAG FUNCTIONS */ /* MAG FUNCTIONS */
float getHeading() { float getHeading() {
float heading = 0; float heading = 0;
#if FT_ENABLED(FT_MAG) #if FT_ENABLED(USE_MAG)
sensors_event_t event; sensors_event_t event;
_mag.getEvent(&event); _mag.getEvent(&event);
heading = atan2(event.magnetic.y, event.magnetic.x); heading = atan2(event.magnetic.y, event.magnetic.x);
@@ -363,7 +363,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
/* BMP FUNCTIONS */ /* BMP FUNCTIONS */
float getAltitude() { float getAltitude() {
float altitude = -1; float altitude = -1;
#if FT_ENABLED(FT_MAG) #if FT_ENABLED(USE_MAG)
sensors_event_t event; sensors_event_t event;
_bmp.getEvent(&event); _bmp.getEvent(&event);
float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA;
@@ -374,7 +374,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
float getPressure() { float getPressure() {
float pressure = -1; float pressure = -1;
#if FT_ENABLED(FT_BMP) #if FT_ENABLED(USE_BMP)
sensors_event_t event; sensors_event_t event;
_bmp.getEvent(&event); _bmp.getEvent(&event);
pressure = bmp_success && event.pressure ? event.pressure : -1; pressure = bmp_success && event.pressure ? event.pressure : -1;
@@ -384,7 +384,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
float getTemperature() { float getTemperature() {
float temperature = 0; float temperature = 0;
#if FT_ENABLED(FT_BMP) #if FT_ENABLED(USE_BMP)
_bmp.getTemperature(&temperature); _bmp.getTemperature(&temperature);
temperature = bmp_success ? temperature : -1; temperature = bmp_success ? temperature : -1;
#endif #endif
@@ -395,7 +395,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
void updateImu() { void updateImu() {
doc.clear(); doc.clear();
bool newData = false; bool newData = false;
#if FT_ENABLED(FT_IMU) #if FT_ENABLED(USE_IMU)
newData = imu_success && readIMU(); newData = imu_success && readIMU();
if (imu_success) { if (imu_success) {
doc["x"] = round2(getAngleX()); doc["x"] = round2(getAngleX());
@@ -403,13 +403,13 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
doc["z"] = round2(getAngleZ()); doc["z"] = round2(getAngleZ());
} }
#endif #endif
#if FT_ENABLED(FT_MAG) #if FT_ENABLED(USE_MAG)
newData = newData || mag_success; newData = newData || mag_success;
if (mag_success) { if (mag_success) {
doc["heading"] = round2(getHeading()); doc["heading"] = round2(getHeading());
} }
#endif #endif
#if FT_ENABLED(FT_BMP) #if FT_ENABLED(USE_BMP)
newData = newData || bmp_success; newData = newData || bmp_success;
if (bmp_success) { if (bmp_success) {
doc["pressure"] = round2(getPressure()); doc["pressure"] = round2(getPressure());
@@ -424,7 +424,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
} }
void readSonar() { void readSonar() {
#if FT_ENABLED(FT_USS) #if FT_ENABLED(USE_USS)
_left_distance = _left_sonar->ping_cm(); _left_distance = _left_sonar->ping_cm();
delay(50); delay(50);
_right_distance = _right_sonar->ping_cm(); _right_distance = _right_sonar->ping_cm();
@@ -432,7 +432,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
} }
void emitSonar() { void emitSonar() {
#if FT_ENABLED(FT_USS) #if FT_ENABLED(USE_USS)
char output[16]; char output[16];
snprintf(output, sizeof(output), "[%.1f,%.1f]", _left_distance, _right_distance); snprintf(output, sizeof(output), "[%.1f,%.1f]", _left_distance, _right_distance);
@@ -459,13 +459,13 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
JsonDocument doc; JsonDocument doc;
char message[MAX_ESP_IMU_SIZE]; char message[MAX_ESP_IMU_SIZE];
#if FT_ENABLED(FT_SERVO) #if FT_ENABLED(USE_SERVO)
Adafruit_PWMServoDriver _pca; Adafruit_PWMServoDriver _pca;
bool _pca_active {false}; bool _pca_active {false};
uint16_t pwm[16] = {0}; uint16_t pwm[16] = {0};
uint16_t target_pwm[16] = {0}; uint16_t target_pwm[16] = {0};
#endif #endif
#if FT_ENABLED(FT_IMU) #if FT_ENABLED(USE_IMU)
MPU6050 _imu; MPU6050 _imu;
bool imu_success {false}; bool imu_success {false};
uint8_t devStatus {false}; uint8_t devStatus {false};
@@ -475,21 +475,21 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
float ypr[3]; float ypr[3];
float imu_temperature {-1}; float imu_temperature {-1};
#endif #endif
#if FT_ENABLED(FT_MAG) #if FT_ENABLED(USE_MAG)
Adafruit_HMC5883_Unified _mag; Adafruit_HMC5883_Unified _mag;
bool mag_success {false}; bool mag_success {false};
#endif #endif
#if FT_ENABLED(FT_BMP) #if FT_ENABLED(USE_BMP)
Adafruit_BMP085_Unified _bmp; Adafruit_BMP085_Unified _bmp;
bool bmp_success {false}; bool bmp_success {false};
#endif #endif
#if FT_ENABLED(FT_ADS1015) #if FT_ENABLED(FT_ADS1015)
Adafruit_ADS1015 _ads; Adafruit_ADS1015 _ads;
#endif #endif
#if FT_ENABLED(FT_ADS1115) #if FT_ENABLED(USE_ADS1115)
Adafruit_ADS1115 _ads; Adafruit_ADS1115 _ads;
#endif #endif
#if FT_ENABLED(FT_USS) #if FT_ENABLED(USE_USS)
NewPing *_left_sonar; NewPing *_left_sonar;
NewPing *_right_sonar; NewPing *_right_sonar;
#endif #endif
+1 -1
View File
@@ -62,7 +62,7 @@ class AuthenticationPredicates {
class SecurityManager { class SecurityManager {
public: public:
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(USE_SECURITY)
/* /*
* Authenticate, returning the user if found * Authenticate, returning the user if found
*/ */
@@ -14,7 +14,7 @@
#include <SecuritySettingsService.h> #include <SecuritySettingsService.h>
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(USE_SECURITY)
SecuritySettingsService::SecuritySettingsService(PsychicHttpServer *server, FS *fs) SecuritySettingsService::SecuritySettingsService(PsychicHttpServer *server, FS *fs)
: _server(server), : _server(server),
@@ -46,7 +46,7 @@
#define GENERATE_TOKEN_PATH "/api/generateToken" #define GENERATE_TOKEN_PATH "/api/generateToken"
#if FT_ENABLED(FT_SECURITY) #if FT_ENABLED(USE_SECURITY)
class SecuritySettings { class SecuritySettings {
public: public:
@@ -136,5 +136,5 @@ class SecuritySettingsService : public SecurityManager {
PsychicJsonRequestCallback wrapCallback(PsychicJsonRequestCallback onRequest, AuthenticationPredicate predicate); PsychicJsonRequestCallback wrapCallback(PsychicJsonRequestCallback onRequest, AuthenticationPredicate predicate);
}; };
#endif // end FT_ENABLED(FT_SECURITY) #endif // end FT_ENABLED(USE_SECURITY)
#endif // end SecuritySettingsService_h #endif // end SecuritySettingsService_h
+2 -2
View File
@@ -28,7 +28,7 @@ monitor_rts = 0
monitor_dtr = 0 monitor_dtr = 0
build_flags= build_flags=
${env.build_flags} ${env.build_flags}
-D FT_CAMERA=1 -D USE_CAMERA=1
-D CAMERA_MODEL_AI_THINKER=1 -D CAMERA_MODEL_AI_THINKER=1
-D SDA_PIN=14 -D SDA_PIN=14
-D SCL_PIN=15 -D SCL_PIN=15
@@ -43,7 +43,7 @@ build_flags =
${env.build_flags} ${env.build_flags}
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-issue
-D FT_CAMERA=1 -D USE_CAMERA=1
-D CAMERA_MODEL_ESP32S3_EYE=1 -D CAMERA_MODEL_ESP32S3_EYE=1
-D WS2812_PIN=48 -D WS2812_PIN=48
-D USS_LEFT_PIN=1 -D USS_LEFT_PIN=1