🪄 Formats Peripherals

This commit is contained in:
Rune Harlyk
2024-07-09 20:09:08 +02:00
committed by Rune Harlyk
parent 1aba163b60
commit b75c3bc251
+10 -19
View File
@@ -28,7 +28,6 @@
#define MAX_ESP_IMU_SIZE 500 #define MAX_ESP_IMU_SIZE 500
#define EVENT_IMU "imu" #define EVENT_IMU "imu"
/* /*
* Servo Settings * Servo Settings
*/ */
@@ -93,28 +92,23 @@ class PeripheralsConfiguration {
class Peripherals : public StatefulService<PeripheralsConfiguration> { class Peripherals : public StatefulService<PeripheralsConfiguration> {
public: public:
Peripherals(PsychicHttpServer *server, FS *fs, Peripherals(PsychicHttpServer *server, FS *fs, SecurityManager *securityManager, EventSocket *socket)
SecurityManager *securityManager,
EventSocket *socket)
: _server(server), : _server(server),
_socket(socket), _socket(socket),
_securityManager(securityManager), _securityManager(securityManager),
_httpEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, _httpEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, server,
this, server, CONFIGURATION_SETTINGS_PATH, CONFIGURATION_SETTINGS_PATH, securityManager, AuthenticationPredicates::IS_ADMIN),
securityManager, AuthenticationPredicates::IS_ADMIN), _eventEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, socket,
_eventEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, EVENT_CONFIGURATION_SETTINGS),
this, socket, EVENT_CONFIGURATION_SETTINGS),
#if FT_ENABLED(FT_MAG) #if FT_ENABLED(FT_MAG)
_mag(12345), _mag(12345),
#endif #endif
#if FT_ENABLED(FT_BMP) #if FT_ENABLED(FT_BMP)
_bmp(10085), _bmp(10085),
#endif #endif
_fsPersistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, _fsPersistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, fs,
this, fs, DEVICE_CONFIG_FILE) DEVICE_CONFIG_FILE) {
{ addUpdateHandler([&](const String &originId) { updatePins(); }, false);
addUpdateHandler([&](const String &originId) { updatePins(); },
false);
}; };
void begin() { void begin() {
@@ -176,8 +170,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
void loop() { void loop() {
unsigned long currentMillis = millis(); unsigned long currentMillis = millis();
if (currentMillis - _lastUpdate >= _updateInterval) if (currentMillis - _lastUpdate >= _updateInterval) {
{
_lastUpdate = currentMillis; _lastUpdate = currentMillis;
readIMU(); readIMU();
} }
@@ -340,9 +333,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
return temperature; return temperature;
} }
double round2(double value) { double round2(double value) { return (int)(value * 100 + 0.5) / 100.0; }
return (int)(value * 100 + 0.5) / 100.0;
}
protected: protected:
void updateImu() { void updateImu() {