diff --git a/src/Config.cpp b/src/Config.cpp index 7b0b34b1..4d27dbff 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -55,12 +55,12 @@ const uint8_t MEM_OFFSET_SERIAL = MEM_OFFSET_NAME + MEM_LEN_NAME; const uint8_t MEM_LEN_SERIAL = 11; const uint8_t MEM_OFFSET_CONFIG = MEM_OFFSET_NAME + MEM_LEN_NAME + MEM_LEN_SERIAL; -const char type[sizeof(MOBIFLIGHT_TYPE)] = MOBIFLIGHT_TYPE; -char serial[MEM_LEN_SERIAL] = MOBIFLIGHT_SERIAL; -char name[MEM_LEN_NAME] = MOBIFLIGHT_NAME; -const int MEM_LEN_CONFIG = MEMLEN_CONFIG; -uint16_t configLength = 0; -boolean configActivated = false; +char serial[MEM_LEN_SERIAL] = MOBIFLIGHT_SERIAL; +char name[MEM_LEN_NAME] = MOBIFLIGHT_NAME; +const int MEM_LEN_CONFIG = MEMLEN_CONFIG; +char nameBuffer[MEM_LEN_CONFIG] = ""; +uint16_t configLength = 0; +boolean configActivated = false; void resetConfig(); void readConfig(); @@ -219,8 +219,9 @@ void readConfig() return; uint16_t addreeprom = MEM_OFFSET_CONFIG; // define first memory location where config is saved in EEPROM char params[6] = ""; - char command = readUintFromEEPROM(&addreeprom); // read the first value from EEPROM, it's a device definition - bool copy_success = true; // will be set to false if reading from eeprom exceeds size + uint8_t command = readUintFromEEPROM(&addreeprom); // read the first value from EEPROM, it's a device definition + bool copy_success = true; // will be set to false if copying input names to nameBuffer exceeds array dimensions + // not required anymore when pins instead of names are transferred to the UI if (command == 0) // just to be sure, configLength should also be 0 return; @@ -397,7 +398,7 @@ void OnGetInfo() { setLastCommandMillis(); cmdMessenger.sendCmdStart(kInfo); - cmdMessenger.sendCmdArg(type); + cmdMessenger.sendCmdArg(F(MOBIFLIGHT_TYPE)); cmdMessenger.sendCmdArg(name); cmdMessenger.sendCmdArg(serial); cmdMessenger.sendCmdArg(VERSION); @@ -437,16 +438,13 @@ void OnGenNewSerial() // ************************************************************ void storeName() { - char prefix[] = "#"; - MFeeprom.write_block(MEM_OFFSET_NAME, prefix, 1); + MFeeprom.write_byte(MEM_OFFSET_NAME, '#'); MFeeprom.write_block(MEM_OFFSET_NAME + 1, name, MEM_LEN_NAME - 1); } void restoreName() { - char testHasName[1] = ""; - MFeeprom.read_block(MEM_OFFSET_NAME, testHasName, 1); - if (testHasName[0] != '#') + if (MFeeprom.read_char(MEM_OFFSET_NAME) != '#') return; MFeeprom.read_block(MEM_OFFSET_NAME + 1, name, MEM_LEN_NAME - 1); diff --git a/src/MF_Analog/MFAnalog.h b/src/MF_Analog/MFAnalog.h index 78e02954..2a5d7b2a 100644 --- a/src/MF_Analog/MFAnalog.h +++ b/src/MF_Analog/MFAnalog.h @@ -8,8 +8,11 @@ #include -#define ADC_MAX_AVERAGE 8 // must be 2^n -#define ADC_MAX_AVERAGE_LOG2 3 // please calculate LOG2(ADC_MAX_AVERAGE) +// Following value defines the buffer size for samples; the larger the buffer, +// the smoother the response (and the larger the delay). +// Buffer size is 2^ADC_MAX_AVERAGE_LOG2: 3 -> 8 samples, 4 -> 16 samples etc. +#define ADC_MAX_AVERAGE_LOG2 3 +#define ADC_MAX_AVERAGE (1 << ADC_MAX_AVERAGE_LOG2) extern "C" { // callback functions