Added settings

This commit is contained in:
Gašper Dobrovoljc committed 2023-02-19 14:16:00 +01:00
1 parent af449d1a2b
commit 59252e81b0
7 files changed
+171 -24

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
#include "settings.h"
#include <EEPROM.h>
Settings::Settings() {
refreshInterval = 1000;
sensorPin = 26;
}
void Settings::load() {
EEPROM.begin(sizeof(Settings));
EEPROM.get(0, *this);
}
void Settings::save() {
EEPROM.put(0, *this);
EEPROM.commit();
}
void Settings::setRefreshInterval(unsigned long refreshInterval) {
this->refreshInterval = refreshInterval;
save();
}
long Settings::getRefreshInterval() { return refreshInterval; }
void Settings::setSensorPin(unsigned int sensorPin) {
this->sensorPin = sensorPin;
save();
}
unsigned int Settings::getSensorPin() { return sensorPin; }
+19
View File
@@ -0,0 +1,19 @@
class Settings {
public:
Settings();
void load();
void setRefreshInterval(unsigned long);
long getRefreshInterval();
void setSensorPin(unsigned int);
unsigned int getSensorPin();
private:
unsigned long refreshInterval;
unsigned int sensorPin;
void save();
};