From 8543b0f9df2e527cb242d0629d5b5574c0d76d30 Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Thu, 1 Dec 2022 10:38:12 -0800 Subject: Move arduino program to rpmcount folder and rename cc files to cpp as the IDE expects. --- arduino/config.cc | 61 ------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100755 arduino/config.cc (limited to 'arduino/config.cc') diff --git a/arduino/config.cc b/arduino/config.cc deleted file mode 100755 index a46c663..0000000 --- a/arduino/config.cc +++ /dev/null @@ -1,61 +0,0 @@ -#include "config.h" - -#include -#include - -#define ROM_INITIALISED 17 - -#define DEFAULT_SIGNALS_PER_RPM 133 -#define DEFAULT_START_DELAY_MILLIS 1000 -#define DEFAULT_RPM_COUNT 5000 - -static Config config; - -int writeLong (int address, unsigned long val) -{ - const char* p = (char*) &val; - int i = 0; - for (; i < sizeof(val); ++i, ++p) - { - EEPROM.write(address + i, *p); - } - return address + i; -} - -int readLong (int address, unsigned long& val) -{ - char* p = (char*) &val; - int i = 0; - for (; i < sizeof(val); ++i, ++p) - { - *p = EEPROM.read(address + i); - } - return address + i; -} - -const Config& readConfig () -{ - byte initialised = EEPROM.read(0); - if (initialised != ROM_INITIALISED) - { - int addr = 1; - addr = writeLong(addr, DEFAULT_START_DELAY_MILLIS); - addr = writeLong(addr, DEFAULT_RPM_COUNT); - addr = writeLong(addr, DEFAULT_SIGNALS_PER_RPM); - EEPROM.write(0, ROM_INITIALISED); - } - int addr = 1; - addr = readLong(addr, config.startDelay); - addr = readLong(addr, config.rpmCount); - addr = readLong(addr, config.signalsPerRPM); - return config; -} - -void writeConfig (const Config& config) -{ - int addr = 1; - addr = writeLong(addr, config.startDelay); - addr = writeLong(addr, config.rpmCount); - addr = writeLong(addr, config.signalsPerRPM); - EEPROM.write(0, ROM_INITIALISED); -} -- cgit v1.2.3