iot-heater/lib/settings/settings.cpp
Gašper Dobrovoljc 59252e81b0
Added settings
2023-02-19 14:16:00 +01:00

31 lines
613 B
C++

#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; }