Handle bool defaults on emulated eeprom platform platforms (fixes #5)

This commit is contained in:
Filip Ayazi 2023-03-08 23:51:22 +00:00
parent 13e9a2c598
commit 51b5b670e6
6 changed files with 24 additions and 5 deletions

View file

@ -2,6 +2,11 @@
#include "config.h"
#include <Arduino.h>
#include <ComPort.h>
#ifdef SUPPORT_EEPROM
#include <EEPROM.h>
#else
#include "dummyEEPROM.h"
#endif
#ifdef DEBUG_ON
#define D(x) comPort->println(x)
#else
@ -22,6 +27,16 @@ struct Command
inline bool check_end_command(Command c) { return strlen(c.command) > 0; }
inline bool check_end_command(Command * c) {return strlen(c->command) > 0; }
inline bool read_eeprom_bool(uint16_t address, bool default_value)
{
int8_t temp_value;
EEPROM.get(address, temp_value);
if (temp_value < 0)
return default_value;
return temp_value != 0;
}
const Command end_command = END_COMMAND;
uint8_t parse_arguments(char ** arguments, String, uint8_t);