From 6a9dcff847570ed3e4068bb726c0ca92d33a88cc Mon Sep 17 00:00:00 2001 From: GioCC <25667790+GioCC@users.noreply.github.com> Date: Wed, 5 Oct 2022 23:44:50 +0200 Subject: [PATCH] Changes for #205 - Device names kept in EEPROM instead of RAM buffer --- MF_firmware.code-workspace | 8 ++ _Boards/Atmel/Board_Mega/MFBoards.h | 14 +-- _Boards/Atmel/Board_ProMicro/MFBoards.h | 16 +-- _Boards/Atmel/Board_Uno/MFBoards.h | 24 ++--- src/Config.cpp | 134 ++++++++++++------------ src/MF_Analog/Analog.cpp | 7 +- src/MF_Analog/Analog.h | 2 +- src/MF_Analog/MFAnalog.cpp | 6 +- src/MF_Analog/MFAnalog.h | 6 +- src/MF_Button/Button.cpp | 7 +- src/MF_Button/Button.h | 2 +- src/MF_Button/MFButton.cpp | 14 +-- src/MF_Button/MFButton.h | 6 +- src/MF_DigInMux/DigInMux.cpp | 9 +- src/MF_DigInMux/DigInMux.h | 2 +- src/MF_DigInMux/MFDigInMux.cpp | 22 ++-- src/MF_DigInMux/MFDigInMux.h | 32 +++--- src/MF_Encoder/Encoder.cpp | 7 +- src/MF_Encoder/Encoder.h | 2 +- src/MF_Encoder/MFEncoder.cpp | 16 +-- src/MF_Encoder/MFEncoder.h | 14 +-- src/MF_InputShifter/InputShifter.cpp | 7 +- src/MF_InputShifter/InputShifter.h | 2 +- src/MF_InputShifter/MFInputShifter.cpp | 10 +- src/MF_InputShifter/MFInputShifter.h | 20 ++-- src/MF_LCDDisplay/MFLCDDisplay.h | 2 +- src/MF_Modules/MFMuxDriver.h | 6 +- src/config.h | 29 ++--- 28 files changed, 222 insertions(+), 204 deletions(-) create mode 100644 MF_firmware.code-workspace diff --git a/MF_firmware.code-workspace b/MF_firmware.code-workspace new file mode 100644 index 00000000..517e0b2a --- /dev/null +++ b/MF_firmware.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/_Boards/Atmel/Board_Mega/MFBoards.h b/_Boards/Atmel/Board_Mega/MFBoards.h index c1da424c..8b9ed1ad 100644 --- a/_Boards/Atmel/Board_Mega/MFBoards.h +++ b/_Boards/Atmel/Board_Mega/MFBoards.h @@ -52,13 +52,13 @@ #define STEPPER_SPEED 400 // 300 already worked, 467, too? #define STEPPER_ACCEL 800 -#define MOBIFLIGHT_TYPE "MobiFlight Mega" -#define MOBIFLIGHT_SERIAL "1234567890" -#define MOBIFLIGHT_NAME "MobiFlight Mega" -#define EEPROM_SIZE 4096 // EEPROMSizeMega -#define MEMLEN_CONFIG 1496 // max. size for config which wil be stored in EEPROM -#define MEMLEN_NAMES_BUFFER 1000 // max. size for configBuffer, contains only names from inputs -#define MF_MAX_DEVICEMEM 1500 // max. memory size for devices +#define MOBIFLIGHT_TYPE "MobiFlight Mega" +#define MOBIFLIGHT_SERIAL "1234567890" +#define MOBIFLIGHT_NAME "MobiFlight Mega" +#define EEPROM_SIZE 4096 // EEPROMSizeMega +#define MEMLEN_CONFIG 1496 // max. size for config which wil be stored in EEPROM +// #define MEMLEN_NAMES_BUFFER 1000 // max. size for configBuffer, contains only names from inputs +#define MF_MAX_DEVICEMEM 1500 // max. memory size for devices #define RANDOM_SEED_INPUT A0 diff --git a/_Boards/Atmel/Board_ProMicro/MFBoards.h b/_Boards/Atmel/Board_ProMicro/MFBoards.h index 30c565d4..a61d7b8c 100644 --- a/_Boards/Atmel/Board_ProMicro/MFBoards.h +++ b/_Boards/Atmel/Board_ProMicro/MFBoards.h @@ -17,7 +17,7 @@ #define MF_STEPPER_SUPPORT 1 #endif #ifndef MF_SERVO_SUPPORT -#define MF_SERVO_SUPPORT 0 +#define MF_SERVO_SUPPORT 0 #endif #ifndef MF_ANALOG_SUPPORT #define MF_ANALOG_SUPPORT 1 @@ -53,13 +53,13 @@ #define STEPPER_SPEED 400 // 300 already worked, 467, too? #define STEPPER_ACCEL 800 -#define MOBIFLIGHT_TYPE "MobiFlight Micro" -#define MOBIFLIGHT_SERIAL "0987654321" -#define MOBIFLIGHT_NAME "MobiFlight Micro" -#define EEPROM_SIZE 1024 // EEPROMSizeMicro -#define MEMLEN_CONFIG 440 // max. size for config which wil be stored in EEPROM -#define MEMLEN_NAMES_BUFFER 350 // max. size for configBuffer, contains only names from inputs -#define MF_MAX_DEVICEMEM 400 // max. memory size for devices +#define MOBIFLIGHT_TYPE "MobiFlight Micro" +#define MOBIFLIGHT_SERIAL "0987654321" +#define MOBIFLIGHT_NAME "MobiFlight Micro" +#define EEPROM_SIZE 1024 // EEPROMSizeMicro +#define MEMLEN_CONFIG 440 // max. size for config which wil be stored in EEPROM +// #define MEMLEN_NAMES_BUFFER 350 // max. size for configBuffer, contains only names from inputs +#define MF_MAX_DEVICEMEM 400 // max. memory size for devices #define RANDOM_SEED_INPUT A0 diff --git a/_Boards/Atmel/Board_Uno/MFBoards.h b/_Boards/Atmel/Board_Uno/MFBoards.h index ca3ab58b..6cc65b61 100644 --- a/_Boards/Atmel/Board_Uno/MFBoards.h +++ b/_Boards/Atmel/Board_Uno/MFBoards.h @@ -8,19 +8,19 @@ #define MFBoardUno_h #ifndef MF_SEGMENT_SUPPORT -#define MF_SEGMENT_SUPPORT 1 +#define MF_SEGMENT_SUPPORT 1 #endif #ifndef MF_LCD_SUPPORT -#define MF_LCD_SUPPORT 1 +#define MF_LCD_SUPPORT 1 #endif #ifndef MF_STEPPER_SUPPORT -#define MF_STEPPER_SUPPORT 1 +#define MF_STEPPER_SUPPORT 1 #endif #ifndef MF_SERVO_SUPPORT -#define MF_SERVO_SUPPORT 1 +#define MF_SERVO_SUPPORT 1 #endif #ifndef MF_ANALOG_SUPPORT -#define MF_ANALOG_SUPPORT 1 +#define MF_ANALOG_SUPPORT 1 #endif #ifndef MF_OUTPUT_SHIFTER_SUPPORT #define MF_OUTPUT_SHIFTER_SUPPORT 1 @@ -52,13 +52,13 @@ #define STEPPER_SPEED 400 // 300 already worked, 467, too? #define STEPPER_ACCEL 800 -#define MOBIFLIGHT_TYPE "MobiFlight Uno" -#define MOBIFLIGHT_SERIAL "0987654321" -#define MOBIFLIGHT_NAME "MobiFlight Uno" -#define EEPROM_SIZE 1024 // EEPROMSizeUno -#define MEMLEN_CONFIG 286 // max. size for config which wil be stored in EEPROM -#define MEMLEN_NAMES_BUFFER 220 // max. size for configBuffer, contains only names from inputs -#define MF_MAX_DEVICEMEM 300 // max. memory size for devices +#define MOBIFLIGHT_TYPE "MobiFlight Uno" +#define MOBIFLIGHT_SERIAL "0987654321" +#define MOBIFLIGHT_NAME "MobiFlight Uno" +#define EEPROM_SIZE 1024 // EEPROMSizeUno +#define MEMLEN_CONFIG 286 // max. size for config which wil be stored in EEPROM +// #define MEMLEN_NAMES_BUFFER 220 // max. size for configBuffer, contains only names from inputs +#define MF_MAX_DEVICEMEM 300 // max. memory size for devices #define RANDOM_SEED_INPUT A0 diff --git a/src/Config.cpp b/src/Config.cpp index 0d5c6853..328b1fb5 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -12,25 +12,25 @@ #include "Output.h" #if MF_ANALOG_SUPPORT == 1 - #include "Analog.h" +#include "Analog.h" #endif #if MF_INPUT_SHIFTER_SUPPORT == 1 - #include "InputShifter.h" +#include "InputShifter.h" #endif #if MF_SEGMENT_SUPPORT == 1 - #include "LedSegment.h" +#include "LedSegment.h" #endif #if MF_STEPPER_SUPPORT == 1 - #include "Stepper.h" +#include "Stepper.h" #endif #if MF_SERVO_SUPPORT == 1 - #include "Servos.h" +#include "Servos.h" #endif #if MF_LCD_SUPPORT == 1 - #include "LCDDisplay.h" +#include "LCDDisplay.h" #endif #if MF_OUTPUT_SHIFTER_SUPPORT == 1 - #include "OutputShifter.h" +#include "OutputShifter.h" #endif #if MF_MUX_SUPPORT == 1 #include "MFMuxDriver.h" @@ -49,6 +49,7 @@ #define STRINGIZER(arg) #arg #define STR_VALUE(arg) STRINGIZER(arg) #define VERSION STR_VALUE(BUILD_VERSION) + MFEEPROM MFeeprom; #if MF_MUX_SUPPORT == 1 @@ -65,9 +66,11 @@ 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; -char nameBuffer[MEM_LEN_CONFIG] = ""; -uint16_t configLength = 0; -boolean configActivated = false; +// There was an error here, nameBuffer[] had size MEM_LEN_CONFIG instead of MEMLEN_NAMES_BUFFER! + +char devNameBuffer[MAX_DEVNAME_LEN + 1] = ""; +uint16_t configLength = 0; +boolean configActivated = false; void resetConfig(); void readConfig(); @@ -117,7 +120,7 @@ void OnSetConfig() uint8_t cfgLen = strlen(cfg); if (configLength + cfgLen + 1 < MEM_LEN_CONFIG) { - MFeeprom.write_block(MEM_OFFSET_CONFIG + configLength, cfg, cfgLen + 1); // save the received config string including the terminatung NULL (+1) to EEPROM + MFeeprom.write_block(MEM_OFFSET_CONFIG + configLength, cfg, cfgLen + 1); // save the received config string including the terminating NULL (+1) to EEPROM configLength += cfgLen; cmdMessenger.sendCmd(kStatus, configLength); } else @@ -170,17 +173,17 @@ void OnResetConfig() void OnSaveConfig() { cmdMessenger.sendCmd(kConfigSaved, F("OK")); -// Uncomment the if{} part to reset and load the config via serial terminal for testing w/o the GUI -// 1: Type "13" to reset the config -// 2: Type "14" to get the config length -// 3: Type "16" to load the config -/* - if (readConfigLength()) - { - readConfig(); - _activateConfig(); - } -*/ + // Uncomment the if{} part to reset and load the config via serial terminal for testing w/o the GUI + // 1: Type "13" to reset the config + // 2: Type "14" to get the config length + // 3: Type "16" to load the config + /* + if (readConfigLength()) + { + readConfig(); + _activateConfig(); + } + */ } void OnActivateConfig() @@ -207,20 +210,17 @@ uint8_t readUintFromEEPROM(volatile uint16_t *addreeprom) return atoi(params); } -// reads a string from EEPROM at given address which is ':' terminated and saves it in the nameBuffer -// once the nameBuffer is not needed anymore, just read until the ":" termination -> see function below -bool readNameFromEEPROM(uint16_t *addreeprom, char *buffer, uint16_t *addrbuffer) +// reads a string from EEPROM at given address which is ':' terminated and saves it in the device name buffer +char *readNameFromEEPROM(uint16_t addreeprom) { - char temp = 0; + char ch = 0; + uint8_t pos = 0; do { - temp = MFeeprom.read_char((*addreeprom)++); // read the first character - buffer[(*addrbuffer)++] = temp; // save character and locate next buffer position - if (*addrbuffer >= MEMLEN_NAMES_BUFFER) { // nameBuffer will be exceeded - return false; // abort copying from EEPROM to nameBuffer - } - } while (temp != ':'); // reads until limiter ':' and locates the next free buffer position - buffer[(*addrbuffer) - 1] = 0x00; // replace ':' by NULL, terminates the string - return true; + ch = MFeeprom.read_char(addreeprom++); + devNameBuffer[pos++] = ch; + } while (ch != ':' && pos < MAX_DEVNAME_LEN); + devNameBuffer[pos++] = 0x00; // replace ':' by NULL, terminates the string + return devNameBuffer; } // reads the EEPRROM until end of command which ':' terminated @@ -240,12 +240,12 @@ void readConfig() { if (configLength == 0) // do nothing if no config is available return; - uint16_t addreeprom = MEM_OFFSET_CONFIG; // define first memory location where config is saved in EEPROM - uint16_t addrbuffer = 0; // and start with first memory location from nameBuffer - 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 copying input names to nameBuffer exceeds array dimensions - // not required anymore when pins instead of names are transferred to the UI + uint16_t addreeprom = MEM_OFFSET_CONFIG; // define first memory location where config is saved in EEPROM + // uint16_t addrbuffer = 0; // and start with first memory location from nameBuffer + 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 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; @@ -254,9 +254,10 @@ void readConfig() { switch (command) { case kTypeButton: - params[0] = readUintFromEEPROM(&addreeprom); // Pin number - Button::Add(params[0], &nameBuffer[addrbuffer]); // MUST be before readNameFromEEPROM because readNameFromEEPROM returns the pointer for the NEXT Name - copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to nameBuffer and set to next free memory location + params[0] = readUintFromEEPROM(&addreeprom); // Pin number + Button::Add(params[0], addreeprom); + // copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to nameBuffer and set to next free memory location + copy_success = readEndCommandFromEEPROM(&addreeprom); // check EEPROM until end of name break; case kTypeOutput: @@ -311,20 +312,20 @@ void readConfig() #endif case kTypeEncoderSingleDetent: - params[0] = readUintFromEEPROM(&addreeprom); // Pin1 number - params[1] = readUintFromEEPROM(&addreeprom); // Pin2 number - Encoder::Add(params[0], params[1], 0, &nameBuffer[addrbuffer]); // MUST be before readNameFromEEPROM because readNameFromEEPROM returns the pointer for the NEXT Name - copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to nameBuffer and set to next free memory location - // copy_success = readEndCommandFromEEPROM(&addreeprom); // once the nameBuffer is not required anymore uncomment this line and delete the line before + params[0] = readUintFromEEPROM(&addreeprom); // Pin1 number + params[1] = readUintFromEEPROM(&addreeprom); // Pin2 number + Encoder::Add(params[0], params[1], 0, addreeprom); // MUST be before readNameFromEEPROM because readNameFromEEPROM returns the pointer for the NEXT Name + // copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to nameBuffer and set to next free memory location + copy_success = readEndCommandFromEEPROM(&addreeprom); break; case kTypeEncoder: - params[0] = readUintFromEEPROM(&addreeprom); // Pin1 number - params[1] = readUintFromEEPROM(&addreeprom); // Pin2 number - params[2] = readUintFromEEPROM(&addreeprom); // type - Encoder::Add(params[0], params[1], params[2], &nameBuffer[addrbuffer]); // MUST be before readNameFromEEPROM because readNameFromEEPROM returns the pointer for the NEXT Name - copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to to nameBuffer and set to next free memory location - // copy_success = readEndCommandFromEEPROM(&addreeprom); // once the nameBuffer is not required anymore uncomment this line and delete the line before + params[0] = readUintFromEEPROM(&addreeprom); // Pin1 number + params[1] = readUintFromEEPROM(&addreeprom); // Pin2 number + params[2] = readUintFromEEPROM(&addreeprom); // type + Encoder::Add(params[0], params[1], params[2], addreeprom); // MUST be before readNameFromEEPROM because readNameFromEEPROM returns the pointer for the NEXT Name + // copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to to nameBuffer and set to next free memory location + copy_success = readEndCommandFromEEPROM(&addreeprom); break; #if MF_LCD_SUPPORT == 1 @@ -339,11 +340,11 @@ void readConfig() #if MF_ANALOG_SUPPORT == 1 case kTypeAnalogInput: - params[0] = readUintFromEEPROM(&addreeprom); // pin number - params[1] = readUintFromEEPROM(&addreeprom); // sensitivity - Analog::Add(params[0], &nameBuffer[addrbuffer], params[1]); // MUST be before readNameFromEEPROM because readNameFromEEPROM returns the pointer for the NEXT Name - copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to to nameBuffer and set to next free memory location - // copy_success = readEndCommandFromEEPROM(&addreeprom); // once the nameBuffer is not required anymore uncomment this line and delete the line before + params[0] = readUintFromEEPROM(&addreeprom); // pin number + params[1] = readUintFromEEPROM(&addreeprom); // sensitivity + Analog::Add(params[0], addreeprom, params[1]); // MUST be before readNameFromEEPROM because readNameFromEEPROM returns the pointer for the NEXT Name + // copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to to nameBuffer and set to next free memory location + copy_success = readEndCommandFromEEPROM(&addreeprom); break; #endif @@ -364,9 +365,9 @@ void readConfig() params[1] = readUintFromEEPROM(&addreeprom); // clock Pin params[2] = readUintFromEEPROM(&addreeprom); // data Pin params[3] = readUintFromEEPROM(&addreeprom); // number of daisy chained modules - InputShifter::Add(params[0], params[1], params[2], params[3], &nameBuffer[addrbuffer]); - copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to to nameBuffer and set to next free memory location - // copy_success = readEndCommandFromEEPROM(&addreeprom); // once the nameBuffer is not required anymore uncomment this line and delete the line before + InputShifter::Add(params[0], params[1], params[2], params[3], addreeprom); + // copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); // copy the NULL terminated name to to nameBuffer and set to next free memory location + copy_success = readEndCommandFromEEPROM(&addreeprom); break; #endif @@ -393,8 +394,9 @@ void readConfig() params[4] = readUintFromEEPROM(&addreeprom); // Sel3 pin MUX.attach(params[1], params[2], params[3], params[4]); params[5] = readUintFromEEPROM(&addreeprom); // 8-bit registers (1-2) - DigInMux::Add(params[0], params[5], &nameBuffer[addrbuffer]); - copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); + DigInMux::Add(params[0], params[5], addreeprom); + // copy_success = readNameFromEEPROM(&addreeprom, nameBuffer, &addrbuffer); + copy_success = readEndCommandFromEEPROM(&addreeprom); // cmdMessenger.sendCmd(kDebug, F("Mux loaded")); break; @@ -405,8 +407,8 @@ void readConfig() } command = readUintFromEEPROM(&addreeprom); } while (command && copy_success); - if (!copy_success) { // too much/long names for input devices - nameBuffer[MEMLEN_NAMES_BUFFER - 1] = 0x00; // terminate the last copied (part of) string with 0x00 + if (!copy_success) { // too much/long names for input devices + // nameBuffer[MEMLEN_NAMES_BUFFER - 1] = 0x00; // terminate the last copied (part of) string with 0x00 cmdMessenger.sendCmd(kStatus, F("Failure on reading config")); } } diff --git a/src/MF_Analog/Analog.cpp b/src/MF_Analog/Analog.cpp index 70a186cb..6e0f679e 100644 --- a/src/MF_Analog/Analog.cpp +++ b/src/MF_Analog/Analog.cpp @@ -14,15 +14,16 @@ namespace Analog MFAnalog *analog[MAX_ANALOG_INPUTS]; uint8_t analogRegistered = 0; - void handlerOnAnalogChange(int value, uint8_t pin, const char *name) + void handlerOnAnalogChange(int value, uint8_t pin, uint16_t nameAddr) { + const char *name = (nameAddr == 0xFFFF ? "AnalogInput" : readNameFromEEPROM(nameAddr)); cmdMessenger.sendCmdStart(kAnalogChange); cmdMessenger.sendCmdArg(name); cmdMessenger.sendCmdArg(value); cmdMessenger.sendCmdEnd(); }; - void Add(uint8_t pin, char const *name, uint8_t sensitivity) + void Add(uint8_t pin, uint16_t nameAddr, uint8_t sensitivity) { if (analogRegistered == MAX_ANALOG_INPUTS) return; @@ -32,7 +33,7 @@ namespace Analog cmdMessenger.sendCmd(kStatus, F("AnalogIn does not fit in Memory")); return; } - analog[analogRegistered] = new (allocateMemory(sizeof(MFAnalog))) MFAnalog(pin, name, sensitivity); + analog[analogRegistered] = new (allocateMemory(sizeof(MFAnalog))) MFAnalog(pin, nameAddr, sensitivity); MFAnalog::attachHandler(handlerOnAnalogChange); analogRegistered++; #ifdef DEBUG2CMDMESSENGER diff --git a/src/MF_Analog/Analog.h b/src/MF_Analog/Analog.h index 61fb0f5f..5c5c0947 100644 --- a/src/MF_Analog/Analog.h +++ b/src/MF_Analog/Analog.h @@ -9,7 +9,7 @@ #include namespace Analog { - void Add(uint8_t pin, char const *name = "AnalogInput", uint8_t sensitivity = 3); + void Add(uint8_t pin, uint16_t nameAddr = 0xFFFF, uint8_t sensitivity = 3); // "AnalogInput" void Clear(); void read(); void readAverage(); diff --git a/src/MF_Analog/MFAnalog.cpp b/src/MF_Analog/MFAnalog.cpp index 69566581..03aa572c 100644 --- a/src/MF_Analog/MFAnalog.cpp +++ b/src/MF_Analog/MFAnalog.cpp @@ -8,11 +8,11 @@ analogEvent MFAnalog::_handler = NULL; -MFAnalog::MFAnalog(uint8_t pin, const char *name, uint8_t sensitivity) +MFAnalog::MFAnalog(uint8_t pin, uint16_t nameAddr, uint8_t sensitivity) { _sensitivity = sensitivity; _pin = pin; - _name = name; + _nameAddr = nameAddr; _lastValue = 0; pinMode(_pin, INPUT_PULLUP); // set pin to input. Could use OUTPUT for analog, but shows the intention :-) for (uint8_t i = 0; i < ADC_MAX_AVERAGE; i++) { @@ -31,7 +31,7 @@ void MFAnalog::readChannel(uint8_t alwaysTrigger) if (alwaysTrigger || valueHasChanged(newValue)) { _lastValue = newValue; if (_handler != NULL) { - (*_handler)(_lastValue, _pin, _name); + (*_handler)(_lastValue, _pin, _nameAddr); } } } diff --git a/src/MF_Analog/MFAnalog.h b/src/MF_Analog/MFAnalog.h index b6256e5c..76e41cd4 100644 --- a/src/MF_Analog/MFAnalog.h +++ b/src/MF_Analog/MFAnalog.h @@ -13,7 +13,7 @@ extern "C" { // callback functions -typedef void (*analogEvent)(int, uint8_t, const char *); +typedef void (*analogEvent)(int, uint8_t, uint16_t); }; ///////////////////////////////////////////////////////////////////// @@ -21,12 +21,12 @@ typedef void (*analogEvent)(int, uint8_t, const char *); class MFAnalog { public: - MFAnalog(uint8_t pin = 1, const char *name = "Analog Input", uint8_t sensitivity = 2); + MFAnalog(uint8_t pin = 1, uint16_t nameAddr = 0xFFFF, uint8_t sensitivity = 2); //"Analog Input" static void attachHandler(analogEvent handler); void update(); void retrigger(); void readBuffer(); - const char *_name; + uint16_t _nameAddr; uint8_t _pin; private: diff --git a/src/MF_Button/Button.cpp b/src/MF_Button/Button.cpp index 8c767882..95cc9b8a 100644 --- a/src/MF_Button/Button.cpp +++ b/src/MF_Button/Button.cpp @@ -13,15 +13,16 @@ namespace Button MFButton *buttons[MAX_BUTTONS]; uint8_t buttonsRegistered = 0; - void handlerOnButton(uint8_t eventId, uint8_t pin, const char *name) + void handlerOnButton(uint8_t eventId, uint8_t pin, uint16_t nameAddr) { + const char *name = (nameAddr == 0xFFFF ? "Button" : readNameFromEEPROM(nameAddr)); cmdMessenger.sendCmdStart(kButtonChange); cmdMessenger.sendCmdArg(name); cmdMessenger.sendCmdArg(eventId); cmdMessenger.sendCmdEnd(); }; - void Add(uint8_t pin, char const *name) + void Add(uint8_t pin, uint16_t nameAddr) { if (buttonsRegistered == MAX_BUTTONS) return; @@ -31,7 +32,7 @@ namespace Button cmdMessenger.sendCmd(kStatus, F("Button does not fit in Memory")); return; } - buttons[buttonsRegistered] = new (allocateMemory(sizeof(MFButton))) MFButton(pin, name); + buttons[buttonsRegistered] = new (allocateMemory(sizeof(MFButton))) MFButton(pin, nameAddr); MFButton::attachHandler(handlerOnButton); buttonsRegistered++; #ifdef DEBUG2CMDMESSENGER diff --git a/src/MF_Button/Button.h b/src/MF_Button/Button.h index 1d52fb6a..c3286187 100644 --- a/src/MF_Button/Button.h +++ b/src/MF_Button/Button.h @@ -10,7 +10,7 @@ namespace Button { - void Add(uint8_t pin, char const *name = "Button"); + void Add(uint8_t pin, uint16_t _nameAddr = 0xFFFF); void Clear(); void read(); void OnTrigger(); diff --git a/src/MF_Button/MFButton.cpp b/src/MF_Button/MFButton.cpp index 1a80e17e..f057fffd 100644 --- a/src/MF_Button/MFButton.cpp +++ b/src/MF_Button/MFButton.cpp @@ -8,12 +8,12 @@ buttonEvent MFButton::_handler = NULL; -MFButton::MFButton(uint8_t pin, const char *name) +MFButton::MFButton(uint8_t pin, uint16_t nameAddr) { - _pin = pin; - _name = name; - pinMode(_pin, INPUT_PULLUP); // set pin to input - _state = digitalRead(_pin); // initialize on actual status + _pin = pin; + _nameAddr = nameAddr; + pinMode(_pin, INPUT_PULLUP); // set pin to input + _state = digitalRead(_pin); // initialize on actual status } void MFButton::update() @@ -33,14 +33,14 @@ void MFButton::trigger(uint8_t state) void MFButton::triggerOnPress() { if (_handler && _state == LOW) { - (*_handler)(btnOnPress, _pin, _name); + (*_handler)(btnOnPress, _pin, _nameAddr); } } void MFButton::triggerOnRelease() { if (_handler && _state == HIGH) { - (*_handler)(btnOnRelease, _pin, _name); + (*_handler)(btnOnRelease, _pin, _nameAddr); } } diff --git a/src/MF_Button/MFButton.h b/src/MF_Button/MFButton.h index 87386e20..f5690ed7 100644 --- a/src/MF_Button/MFButton.h +++ b/src/MF_Button/MFButton.h @@ -10,7 +10,7 @@ extern "C" { // callback functions always follow the signature: void cmd(void); -typedef void (*buttonEvent)(byte, uint8_t, const char *); +typedef void (*buttonEvent)(byte, uint8_t, uint16_t); }; enum { @@ -23,13 +23,13 @@ enum { class MFButton { public: - MFButton(uint8_t pin = 1, const char *name = "Button"); + MFButton(uint8_t pin = 1, uint16_t nameAddr = 0xFFFF); // "Button" static void attachHandler(buttonEvent newHandler); void update(); void trigger(uint8_t state); void triggerOnPress(); void triggerOnRelease(); - const char *_name; + uint16_t _nameAddr; uint8_t _pin; private: diff --git a/src/MF_DigInMux/DigInMux.cpp b/src/MF_DigInMux/DigInMux.cpp index dbee78a4..8e24f7b4 100644 --- a/src/MF_DigInMux/DigInMux.cpp +++ b/src/MF_DigInMux/DigInMux.cpp @@ -15,8 +15,9 @@ namespace DigInMux MFDigInMux *digInMux[MAX_DIGIN_MUX]; uint8_t digInMuxRegistered = 0; - void handlerOnDigInMux(uint8_t eventId, uint8_t channel, const char *name) + void handlerOnDigInMux(uint8_t eventId, uint8_t channel, uint16_t nameAddr) { + const char *name = (nameAddr == 0xFFFF ? "DigInMux" : readNameFromEEPROM(nameAddr)); cmdMessenger.sendCmdStart(kDigInMuxChange); cmdMessenger.sendCmdArg(name); cmdMessenger.sendCmdArg(channel); @@ -24,14 +25,14 @@ namespace DigInMux cmdMessenger.sendCmdEnd(); }; - void Add(uint8_t dataPin, uint8_t nRegs, char const *name, bool mode) + void Add(uint8_t dataPin, uint8_t nRegs, uint16_t nameAddr, bool mode) { if (digInMuxRegistered == MAX_DIGIN_MUX) return; MFDigInMux *dip; - dip = new (allocateMemory(sizeof(MFDigInMux))) MFDigInMux(&MUX, name); + dip = new (allocateMemory(sizeof(MFDigInMux))) MFDigInMux(&MUX, nameAddr); digInMux[digInMuxRegistered] = dip; - dip->attach(dataPin, (nRegs == 1), name); + dip->attach(dataPin, (nRegs == 1), nameAddr); dip->clear(); dip->setLazyMode(mode == MFDigInMux::MUX_MODE_LAZY); // MFDigInMux::setMux(&MUX); diff --git a/src/MF_DigInMux/DigInMux.h b/src/MF_DigInMux/DigInMux.h index 8727f875..4059d1e4 100644 --- a/src/MF_DigInMux/DigInMux.h +++ b/src/MF_DigInMux/DigInMux.h @@ -10,7 +10,7 @@ namespace DigInMux { - void Add(uint8_t dataPin, uint8_t nRegs, char const *name = "DigInMux", bool mode = MFDigInMux::MUX_MODE_FAST); + void Add(uint8_t dataPin, uint8_t nRegs, uint16_t nameAddr = 0xFFFF, bool mode = MFDigInMux::MUX_MODE_FAST); // "DigInMux" void Clear(); void read(); void OnTrigger(); diff --git a/src/MF_DigInMux/MFDigInMux.cpp b/src/MF_DigInMux/MFDigInMux.cpp index 2c6643dd..899d3c01 100644 --- a/src/MF_DigInMux/MFDigInMux.cpp +++ b/src/MF_DigInMux/MFDigInMux.cpp @@ -8,21 +8,21 @@ #include "MFDigInMux.h" #include "MFMuxDriver.h" -MFMuxDriver *MFDigInMux::_MUX; +MFMuxDriver *MFDigInMux::_MUX; MuxDigInEvent MFDigInMux::_inputHandler = NULL; MFDigInMux::MFDigInMux(void) { - _MUX = NULL; - _name = "MUXDigIn"; - _flags = 0x00; + _MUX = NULL; + _nameAddr = 0xFFFF; //"MUXDigIn"; + _flags = 0x00; setLazyMode(MUX_MODE_FAST); clear(); } -MFDigInMux::MFDigInMux(MFMuxDriver *MUX, const char *name) - : _name(name) +MFDigInMux::MFDigInMux(MFMuxDriver *MUX, uint16_t nameAddr) + : _nameAddr(nameAddr) { if (MUX) _MUX = MUX; _flags = 0x00; @@ -36,12 +36,12 @@ void MFDigInMux::setMux(MFMuxDriver *MUX) } // Registers a new MUX input block and configures the driver pins -void MFDigInMux::attach(uint8_t dataPin, bool halfSize, char const *name) +void MFDigInMux::attach(uint8_t dataPin, bool halfSize, uint16_t nameAddr) { // if(!_MUX) return; // no need to check, the object can be set up in advance before the MUX is configured - _dataPin = dataPin; - _name = name; - _flags = 0x00; + _dataPin = dataPin; + _nameAddr = nameAddr; + _flags = 0x00; if (halfSize) bitSet(_flags, MUX_HALFSIZE); pinMode(_dataPin, INPUT_PULLUP); bitSet(_flags, MUX_INITED); @@ -188,7 +188,7 @@ void MFDigInMux::trigger(uint8_t channel, bool state) { if (!_MUX) return; if (!_inputHandler) return; - (*_inputHandler)((state ? MuxDigInOnRelease : MuxDigInOnPress), channel, _name); + (*_inputHandler)((state ? MuxDigInOnRelease : MuxDigInOnPress), channel, _nameAddr); } // Attaches a new event handler for the specified event. diff --git a/src/MF_DigInMux/MFDigInMux.h b/src/MF_DigInMux/MFDigInMux.h index ea625762..f6225306 100644 --- a/src/MF_DigInMux/MFDigInMux.h +++ b/src/MF_DigInMux/MFDigInMux.h @@ -10,7 +10,7 @@ #include "MFMuxDriver.h" extern "C" { -typedef void (*MuxDigInEvent)(byte, uint8_t, const char *); +typedef void (*MuxDigInEvent)(byte, uint8_t, uint16_t); }; enum { @@ -26,17 +26,17 @@ class MFDigInMux }; MFDigInMux(void); - MFDigInMux(MFMuxDriver *MUX, const char *name); + MFDigInMux(MFMuxDriver *MUX, uint16_t nameAddr); static void setMux(MFMuxDriver *MUX); static void attachHandler(MuxDigInEvent newHandler); - void attach(uint8_t dataPin, bool halfSize, char const *name); - void detach(); - void clear(); - void retrigger(); - void update(); - void setLazyMode(bool mode); - uint16_t getValues(void) { return _lastState; } + void attach(uint8_t dataPin, bool halfSize, uint16_t nameAddr); + void detach(); + void clear(); + void retrigger(); + void update(); + void setLazyMode(bool mode); + uint16_t getValues(void) { return _lastState; } private: enum { MUX_INITED = 0, @@ -50,14 +50,14 @@ class MFDigInMux static MFMuxDriver *_MUX; static MuxDigInEvent _inputHandler; - const char *_name; - uint8_t _dataPin; // Data pin - MUX common, input to AVR - uint8_t _flags; - uint16_t _lastState; + uint16_t _nameAddr; + uint8_t _dataPin; // Data pin - MUX common, input to AVR + uint8_t _flags; + uint16_t _lastState; - void poll(bool detect, bool lazy); - void detectChanges(uint16_t lastState, uint16_t currentState); - void trigger(uint8_t channel, bool state); + void poll(bool detect, bool lazy); + void detectChanges(uint16_t lastState, uint16_t currentState); + void trigger(uint8_t channel, bool state); }; // MFDigInMux.h \ No newline at end of file diff --git a/src/MF_Encoder/Encoder.cpp b/src/MF_Encoder/Encoder.cpp index 46edd649..43b79f0d 100644 --- a/src/MF_Encoder/Encoder.cpp +++ b/src/MF_Encoder/Encoder.cpp @@ -13,15 +13,16 @@ namespace Encoder MFEncoder *encoders[MAX_ENCODERS]; uint8_t encodersRegistered = 0; - void handlerOnEncoder(uint8_t eventId, uint8_t pin, const char *name) + void handlerOnEncoder(uint8_t eventId, uint8_t pin, uint16_t nameAddr) { + const char *name = (nameAddr == 0xFFFF ? "Encoder" : readNameFromEEPROM(nameAddr)); cmdMessenger.sendCmdStart(kEncoderChange); cmdMessenger.sendCmdArg(name); cmdMessenger.sendCmdArg(eventId); cmdMessenger.sendCmdEnd(); }; - void Add(uint8_t pin1, uint8_t pin2, uint8_t encoder_type, char const *name) + void Add(uint8_t pin1, uint8_t pin2, uint8_t encoder_type, uint16_t nameAddr) { if (encodersRegistered == MAX_ENCODERS) return; @@ -32,7 +33,7 @@ namespace Encoder return; } encoders[encodersRegistered] = new (allocateMemory(sizeof(MFEncoder))) MFEncoder; - encoders[encodersRegistered]->attach(pin1, pin2, encoder_type, name); + encoders[encodersRegistered]->attach(pin1, pin2, encoder_type, nameAddr); MFEncoder::attachHandler(handlerOnEncoder); encodersRegistered++; #ifdef DEBUG2CMDMESSENGER diff --git a/src/MF_Encoder/Encoder.h b/src/MF_Encoder/Encoder.h index 20290802..71131ed0 100644 --- a/src/MF_Encoder/Encoder.h +++ b/src/MF_Encoder/Encoder.h @@ -9,7 +9,7 @@ namespace Encoder { - void Add(uint8_t pin1 = 1, uint8_t pin2 = 2, uint8_t encoder_type = 0, char const *name = "Encoder"); + void Add(uint8_t pin1 = 1, uint8_t pin2 = 2, uint8_t encoder_type = 0, uint16_t nameAddr = 0xFFFF); // "Encoder" void Clear(); void read(); } diff --git a/src/MF_Encoder/MFEncoder.cpp b/src/MF_Encoder/MFEncoder.cpp index 590d220f..4db5b2f0 100644 --- a/src/MF_Encoder/MFEncoder.cpp +++ b/src/MF_Encoder/MFEncoder.cpp @@ -4,7 +4,7 @@ // (C) MobiFlight Project 2022 // -// Dased on the RotaryEncoder library from Matthias Hertel, see below +// Based on the RotaryEncoder library from Matthias Hertel, see below // Copyright (C) 2013-2014 // ----- // RotaryEncoder.cpp - Library for using rotary encoders. @@ -60,10 +60,10 @@ MFEncoder::MFEncoder() _initialized = false; } -void MFEncoder::attach(uint8_t pin1, uint8_t pin2, uint8_t TypeEncoder, const char *name) +void MFEncoder::attach(uint8_t pin1, uint8_t pin2, uint8_t TypeEncoder, uint16_t nameAddr) { _pos = 0; - _name = name; + _nameAddr = nameAddr; _pin1 = pin1; _pin2 = pin2; _encoderType = encoderTypes[TypeEncoder]; @@ -103,16 +103,16 @@ void MFEncoder::update() if (abs(delta) < (MF_ENC_FAST_LIMIT)) { // slow turn detected if (dir) { - (*_handler)(encLeft, _pin1, _name); + (*_handler)(encLeft, _pin1, _nameAddr); } else { - (*_handler)(encRight, _pin2, _name); + (*_handler)(encRight, _pin2, _nameAddr); } } else { // fast turn detected if (dir) { - (*_handler)(encLeftFast, _pin1, _name); + (*_handler)(encLeftFast, _pin1, _nameAddr); } else { - (*_handler)(encRightFast, _pin2, _name); + (*_handler)(encRightFast, _pin2, _nameAddr); } } } @@ -132,7 +132,7 @@ void MFEncoder::tick(void) int _speed = 0; uint32_t currentMs = millis(); - int8_t thisState = sig1 | (sig2 << 1); + int8_t thisState = sig1 | (sig2 << 1); if (currentMs - _lastFastDec > 100 && _detentCounter > 1) { _lastFastDec = currentMs; diff --git a/src/MF_Encoder/MFEncoder.h b/src/MF_Encoder/MFEncoder.h index 0cb0db39..a407222f 100644 --- a/src/MF_Encoder/MFEncoder.h +++ b/src/MF_Encoder/MFEncoder.h @@ -20,7 +20,7 @@ #include extern "C" { -typedef void (*encoderEvent)(uint8_t, uint8_t, const char *); +typedef void (*encoderEvent)(uint8_t, uint8_t, uint16_t); }; // this prevents the internal position overflow. @@ -38,7 +38,7 @@ enum { typedef struct { // Detent positions in the quadrature (by value, not position) - bool detents[4]; + bool detents[4]; // Bit shift to apply given the detent resolution of this encoder. // @@ -53,21 +53,21 @@ class MFEncoder public: MFEncoder(); static void attachHandler(encoderEvent newHandler); - void attach(uint8_t pin1, uint8_t pin2, uint8_t TypeEncoder, const char *name = "Encoder"); + void attach(uint8_t pin1, uint8_t pin2, uint8_t TypeEncoder, uint16_t nameAddr = 0xFFFF); //"Encoder" void update(); // call this function every some milliseconds or by using an interrupt for handling state changes of the rotary encoder. - void tick(void); + void tick(void); // retrieve the current position - int16_t getPosition(); + int16_t getPosition(); // adjust the current position - void setPosition(int16_t newPosition); + void setPosition(int16_t newPosition); private: static encoderEvent _handler; uint8_t _pin1; uint8_t _pin2; bool _initialized; - const char *_name; + uint16_t _nameAddr; int16_t _pos; uint8_t _TypeEncoder; uint8_t _detentCounter; diff --git a/src/MF_InputShifter/InputShifter.cpp b/src/MF_InputShifter/InputShifter.cpp index cedf9429..7af0faa2 100644 --- a/src/MF_InputShifter/InputShifter.cpp +++ b/src/MF_InputShifter/InputShifter.cpp @@ -13,8 +13,9 @@ namespace InputShifter MFInputShifter *inputShifters[MAX_INPUT_SHIFTERS]; uint8_t inputShiftersRegistered = 0; - void handlerInputShifterOnChange(uint8_t eventId, uint8_t pin, const char *name) + void handlerInputShifterOnChange(uint8_t eventId, uint8_t pin, uint16_t nameAddr) { + const char *name = (nameAddr == 0xFFFF ? "InputShifter" : readNameFromEEPROM(nameAddr)); cmdMessenger.sendCmdStart(kInputShifterChange); cmdMessenger.sendCmdArg(name); cmdMessenger.sendCmdArg(pin); @@ -22,7 +23,7 @@ namespace InputShifter cmdMessenger.sendCmdEnd(); }; - void Add(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t modules, char const *name) + void Add(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t modules, uint16_t nameAddr) { if (inputShiftersRegistered == MAX_INPUT_SHIFTERS) return; @@ -32,7 +33,7 @@ namespace InputShifter return; } inputShifters[inputShiftersRegistered] = new (allocateMemory(sizeof(MFInputShifter))) MFInputShifter; - inputShifters[inputShiftersRegistered]->attach(latchPin, clockPin, dataPin, modules, name); + inputShifters[inputShiftersRegistered]->attach(latchPin, clockPin, dataPin, modules, nameAddr); MFInputShifter::attachHandler(handlerInputShifterOnChange); inputShiftersRegistered++; #ifdef DEBUG2CMDMESSENGER diff --git a/src/MF_InputShifter/InputShifter.h b/src/MF_InputShifter/InputShifter.h index b28a4e9c..af2395fe 100644 --- a/src/MF_InputShifter/InputShifter.h +++ b/src/MF_InputShifter/InputShifter.h @@ -9,7 +9,7 @@ namespace InputShifter { - void Add(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t modules, char const *name = "InputShifter"); + void Add(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t modules, uint16_t nameAddr = 0xFFFF); // "InputShifter" void Clear(); // void OnInit(); // this is defined but not used!? void read(); diff --git a/src/MF_InputShifter/MFInputShifter.cpp b/src/MF_InputShifter/MFInputShifter.cpp index 0cdb994c..900ccd65 100644 --- a/src/MF_InputShifter/MFInputShifter.cpp +++ b/src/MF_InputShifter/MFInputShifter.cpp @@ -8,20 +8,20 @@ inputShifterEvent MFInputShifter::_inputHandler = NULL; -MFInputShifter::MFInputShifter(const char *name) +MFInputShifter::MFInputShifter(uint16_t nameAddr) { _initialized = false; - _name = name; + _nameAddr = nameAddr; } // Registers a new input shifter and configures the clock, data and latch pins as well // as the number of modules to read from. -void MFInputShifter::attach(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t moduleCount, const char *name) +void MFInputShifter::attach(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t moduleCount, uint16_t nameAddr) { _latchPin = latchPin; _clockPin = clockPin; _dataPin = dataPin; - _name = name; + _nameAddr = nameAddr; _moduleCount = moduleCount; pinMode(_latchPin, OUTPUT); @@ -123,7 +123,7 @@ void MFInputShifter::retrigger() void MFInputShifter::trigger(uint8_t pin, bool state) { if (!_inputHandler) return; - (*_inputHandler)((state == LOW ? inputShifterOnPress : inputShifterOnRelease), pin, _name); + (*_inputHandler)((state == LOW ? inputShifterOnPress : inputShifterOnRelease), pin, _nameAddr); } // Attaches a new event handler for the specified event. diff --git a/src/MF_InputShifter/MFInputShifter.h b/src/MF_InputShifter/MFInputShifter.h index c2b5cbcc..8a00f614 100644 --- a/src/MF_InputShifter/MFInputShifter.h +++ b/src/MF_InputShifter/MFInputShifter.h @@ -14,7 +14,7 @@ #define MAX_CHAINED_INPUT_SHIFTERS 4 extern "C" { -typedef void (*inputShifterEvent)(byte, uint8_t, const char *); +typedef void (*inputShifterEvent)(byte, uint8_t, uint16_t); }; enum { @@ -25,8 +25,8 @@ enum { class MFInputShifter { public: - MFInputShifter(const char *name = "InputShifter"); - void attach(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t moduleCount, const char *name); + MFInputShifter(uint16_t nameAddr = 0xFFFF); //"InputShifter" + void attach(uint8_t latchPin, uint8_t clockPin, uint8_t dataPin, uint8_t moduleCount, uint16_t nameAddr); static void attachHandler(inputShifterEvent newHandler); void clear(); void detach(); @@ -37,13 +37,13 @@ class MFInputShifter enum { DONT_TRIGGER = 0, DO_TRIGGER = 1 }; - const char *_name; - uint8_t _latchPin; // SH/~LD (latch) pin - uint8_t _clockPin; // CLK (clock) pin - uint8_t _dataPin; // SDO (data) pin - uint8_t _moduleCount; // Number of 8 bit modules in series. - bool _initialized = false; - uint8_t _lastState[MAX_CHAINED_INPUT_SHIFTERS] = {0}; + uint16_t _nameAddr; + uint8_t _latchPin; // SH/~LD (latch) pin + uint8_t _clockPin; // CLK (clock) pin + uint8_t _dataPin; // SDO (data) pin + uint8_t _moduleCount; // Number of 8 bit modules in series. + bool _initialized = false; + uint8_t _lastState[MAX_CHAINED_INPUT_SHIFTERS] = {0}; void poll(uint8_t doTrigger); void detectChanges(uint8_t lastState, uint8_t currentState, uint8_t module); diff --git a/src/MF_LCDDisplay/MFLCDDisplay.h b/src/MF_LCDDisplay/MFLCDDisplay.h index 2084fa94..eb7ae819 100644 --- a/src/MF_LCDDisplay/MFLCDDisplay.h +++ b/src/MF_LCDDisplay/MFLCDDisplay.h @@ -26,7 +26,7 @@ class MFLCDDisplay byte _cols; byte _lines; - void _printCentered(const char *str, uint8_t line); + void _printCentered(const char *str, uint8_t line); }; // MFLCDDisplay.h \ No newline at end of file diff --git a/src/MF_Modules/MFMuxDriver.h b/src/MF_Modules/MFMuxDriver.h index 4cd39971..4e58ded1 100644 --- a/src/MF_Modules/MFMuxDriver.h +++ b/src/MF_Modules/MFMuxDriver.h @@ -9,15 +9,15 @@ #include extern "C" { -typedef void (*MuxDigInEvent)(byte, uint8_t, const char *); +typedef void (*MuxDigInEvent)(byte, uint8_t, uint16_t); }; class MFMuxDriver { public: MFMuxDriver(void); - void attach(uint8_t Sel0Pin, uint8_t Sel1Pin, uint8_t Sel2Pin, uint8_t Sel3Pin); - void detach(); + void attach(uint8_t Sel0Pin, uint8_t Sel1Pin, uint8_t Sel2Pin, uint8_t Sel3Pin); + void detach(); // void setChannelOpt(uint8_t mode); void setChannel(uint8_t value); diff --git a/src/config.h b/src/config.h index ba6d43e3..605cafc5 100644 --- a/src/config.h +++ b/src/config.h @@ -6,6 +6,9 @@ #pragma once +#define MAX_DEVNAME_LEN 16 +extern char devNameBuffer[]; + enum { kTypeNotSet, // 0 kTypeButton, // 1 @@ -24,17 +27,17 @@ enum { kTypeDigInMux, // 14 Digital input multiplexer support (example: 74HCT4067, 74HCT4051) }; -void loadConfig(void); -bool getStatusConfig(void); -void generateSerial(bool); -void OnSetConfig(void); -void OnResetConfig(void); -void OnSaveConfig(void); -void OnActivateConfig(void); -void OnGetConfig(void); -void OnGetInfo(void); -void OnGenNewSerial(void); -void OnSetName(void); -void restoreName(void); - +void loadConfig(void); +bool getStatusConfig(void); +void generateSerial(bool); +void OnSetConfig(void); +void OnResetConfig(void); +void OnSaveConfig(void); +void OnActivateConfig(void); +void OnGetConfig(void); +void OnGetInfo(void); +void OnGenNewSerial(void); +void OnSetName(void); +void restoreName(void); +char *readNameFromEEPROM(uint16_t addreeprom); // config.h \ No newline at end of file