📦 Moves setting to folder

This commit is contained in:
Rune Harlyk
2024-11-08 16:30:50 +01:00
parent 698b7fbba9
commit 9be13d1df5
14 changed files with 355 additions and 363 deletions
+1 -44
View File
@@ -9,6 +9,7 @@
#include <Timing.h>
#include <filesystem.h>
#include <Features.h>
#include <settings/peripherals_settings.h>
#include <list>
#include <SPI.h>
@@ -55,50 +56,6 @@
*/
#define MAX_DISTANCE 200
/*
* I2C software connection
*/
#ifndef SDA_PIN
#define SDA_PIN SDA
#endif
#ifndef SCL_PIN
#define SCL_PIN SCL
#endif
#ifndef I2C_FREQUENCY
#define I2C_FREQUENCY 100000UL
#endif
class PinConfig {
public:
int pin;
String mode;
String type;
String role;
PinConfig(int p, String m, String t, String r) : pin(p), mode(m), type(t), role(r) {}
};
class PeripheralsConfiguration {
public:
int sda = SDA_PIN;
int scl = SCL_PIN;
long frequency = I2C_FREQUENCY;
std::vector<PinConfig> pins;
static void read(PeripheralsConfiguration &settings, JsonObject &root) {
root["sda"] = settings.sda;
root["scl"] = settings.scl;
root["frequency"] = settings.frequency;
}
static StateUpdateResult update(JsonObject &root, PeripheralsConfiguration &settings) {
settings.sda = root["sda"] | SDA_PIN;
settings.scl = root["scl"] | SCL_PIN;
settings.frequency = root["frequency"] | I2C_FREQUENCY;
return StateUpdateResult::CHANGED;
};
};
class Peripherals : public StatefulService<PeripheralsConfiguration> {
public:
Peripherals(PsychicHttpServer *server, FS *fs)