This repository has been archived on 2025-01-09. You can view files and clone it, but cannot push or open issues or pull requests.
pig-feeder/src/Config.cpp

25 lines
607 B
C++

//
// Created by kirillius on 13.06.2022.
//
#include "Config.h"
#include "utils/EEPROM.h"
void Config::load() {
if (EEPROM::get(CONFIG_EEPROM_ADDR) == CONFIG_EEPROM_FLAG) {
//is valid EEPROM
EEPROM::get(CONFIG_EEPROM_ADDR + 1, (void *) this, sizeof(Config));
} else {
//load defaults
vbat = 4;
startTime.hours = 12;
startTime.minutes = 00;
feedTimer = 10;
calibration=1;
}
}
void Config::save() {
EEPROM::set(CONFIG_EEPROM_ADDR, CONFIG_EEPROM_FLAG);
EEPROM::set(CONFIG_EEPROM_ADDR + 1, (void *) this, sizeof(Config));
}