🪄 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 EVENT_IMU "imu"
/*
* Servo Settings
*/
@@ -93,28 +92,23 @@ class PeripheralsConfiguration {
class Peripherals : public StatefulService<PeripheralsConfiguration> {
public:
Peripherals(PsychicHttpServer *server, FS *fs,
SecurityManager *securityManager,
EventSocket *socket)
Peripherals(PsychicHttpServer *server, FS *fs, SecurityManager *securityManager, EventSocket *socket)
: _server(server),
_socket(socket),
_securityManager(securityManager),
_httpEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update,
this, server, CONFIGURATION_SETTINGS_PATH,
securityManager, AuthenticationPredicates::IS_ADMIN),
_eventEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update,
this, socket, EVENT_CONFIGURATION_SETTINGS),
_httpEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, server,
CONFIGURATION_SETTINGS_PATH, securityManager, AuthenticationPredicates::IS_ADMIN),
_eventEndpoint(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, socket,
EVENT_CONFIGURATION_SETTINGS),
#if FT_ENABLED(FT_MAG)
_mag(12345),
#endif
#if FT_ENABLED(FT_BMP)
_bmp(10085),
#endif
_fsPersistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update,
this, fs, DEVICE_CONFIG_FILE)
{
addUpdateHandler([&](const String &originId) { updatePins(); },
false);
_fsPersistence(PeripheralsConfiguration::read, PeripheralsConfiguration::update, this, fs,
DEVICE_CONFIG_FILE) {
addUpdateHandler([&](const String &originId) { updatePins(); }, false);
};
void begin() {
@@ -176,8 +170,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - _lastUpdate >= _updateInterval)
{
if (currentMillis - _lastUpdate >= _updateInterval) {
_lastUpdate = currentMillis;
readIMU();
}
@@ -340,9 +333,7 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
return temperature;
}
double round2(double value) {
return (int)(value * 100 + 0.5) / 100.0;
}
double round2(double value) { return (int)(value * 100 + 0.5) / 100.0; }
protected:
void updateImu() {