diff --git a/.github/release.yml b/.github/release.yml index 5e6c5338..111d9d74 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -19,11 +19,13 @@ changelog: - documentation - title: Development 💻 labels: - - development + - Code cleanup + - development + - Build process - title: Bug Fixes (BETA) 🐛 labels: - bug_beta - beta-bug - title: Other Changes ⚡ labels: - - "*" \ No newline at end of file + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2353073a..b8764ac6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: run: pio run - name: Archive production artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ZIP files path: ./_dist/*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d21ed25f..a0d0f1ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,7 @@ jobs: run: pio run - name: Archive production artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ZIP files path: ./_dist/*.zip diff --git a/_Boards/Atmel/Board_Mega/arduino_mega.board.json b/_Boards/Atmel/Board_Mega/arduino_mega.board.json index 3efb0cd8..8af0c1b1 100644 --- a/_Boards/Atmel/Board_Mega/arduino_mega.board.json +++ b/_Boards/Atmel/Board_Mega/arduino_mega.board.json @@ -37,10 +37,30 @@ "DelayAfterFirmwareUpdate": 0, "FirmwareBaseName": "mobiflight_mega", "FirmwareExtension": "hex", - "LatestFirmwareVersion": "3.0.0", + "LatestFirmwareVersion": "0.0.1", "FriendlyName": "Arduino Mega 2560", "MobiFlightType": "MobiFlight Mega", - "ResetFirmwareFile": "reset.arduino_mega_1_0_2.hex" + "ResetFirmwareFile": "reset.arduino_mega_1_0_2.hex", + "Community": { + "Project": "MobiFlight Mega", + "Website": "https://mobiflight.com/links/connector/info/website/mega.html", + "Docs": "https://mobiflight.com/links/connector/info/docs/mega.html", + "Support": "https://mobiflight.com/discord" + }, + "DeviceConfigs": [ + { + "Name": "Prototyping Board (Latest version)", + "Description": "The device definitions for the Prototyping Board from the Community Shop", + "File": "prototyping-board-latest.mega.mfmc", + "DefaultUpload": false + }, + { + "Name": "Prototyping Board v2.0", + "Description": "The device definitions for the Prototyping Board from the Community Shop", + "File": "prototyping-board-latest.mega.mfmc", + "DefaultUpload": false + } + ] }, "ModuleLimits": { "MaxAnalogInputs": 16, diff --git a/_Boards/Atmel/Board_Mega/mobiflight_mega.png b/_Boards/Atmel/Board_Mega/mobiflight_mega.png new file mode 100644 index 00000000..30f10e1b Binary files /dev/null and b/_Boards/Atmel/Board_Mega/mobiflight_mega.png differ diff --git a/_Boards/Atmel/Board_Nano/arduino_nano.board.json b/_Boards/Atmel/Board_Nano/arduino_nano.board.json index 19add1aa..cb4593eb 100644 --- a/_Boards/Atmel/Board_Nano/arduino_nano.board.json +++ b/_Boards/Atmel/Board_Nano/arduino_nano.board.json @@ -33,9 +33,15 @@ "FirmwareBaseName": "mobiflight_nano", "FirmwareExtension": "hex", "FriendlyName": "Arduino Nano", - "LatestFirmwareVersion": "3.0.0", + "LatestFirmwareVersion": "0.0.1", "MobiFlightType": "MobiFlight Nano", - "ResetFirmwareFile": "reset.arduino_uno_1_0_2.hex" + "ResetFirmwareFile": "reset.arduino_uno_1_0_2.hex", + "Community": { + "Project": "MobiFlight Nano", + "Website": "https://mobiflight.com/links/connector/info/website/nano.html", + "Docs": "https://mobiflight.com/links/connector/info/docs/nano.html", + "Support": "https://mobiflight.com/discord" + } }, "ModuleLimits": { "MaxAnalogInputs": 8, diff --git a/_Boards/Atmel/Board_Nano/mobiflight_nano.png b/_Boards/Atmel/Board_Nano/mobiflight_nano.png new file mode 100644 index 00000000..580d107d Binary files /dev/null and b/_Boards/Atmel/Board_Nano/mobiflight_nano.png differ diff --git a/_Boards/Atmel/Board_ProMicro/arduino_micro.board.json b/_Boards/Atmel/Board_ProMicro/arduino_micro.board.json index b35fece8..3b4f2f29 100644 --- a/_Boards/Atmel/Board_ProMicro/arduino_micro.board.json +++ b/_Boards/Atmel/Board_ProMicro/arduino_micro.board.json @@ -27,9 +27,15 @@ "FirmwareBaseName": "mobiflight_micro", "FirmwareExtension": "hex", "FriendlyName": "Arduino Pro Micro", - "LatestFirmwareVersion": "3.0.0", + "LatestFirmwareVersion": "0.0.1", "MobiFlightType": "MobiFlight Micro", - "ResetFirmwareFile": "reset.arduino_promicro_1_0_2.hex" + "ResetFirmwareFile": "reset.arduino_promicro_1_0_2.hex", + "Community": { + "Project": "MobiFlight Pro Micro", + "Website": "https://mobiflight.com/links/connector/info/website/micro.html", + "Docs": "https://mobiflight.com/links/connector/info/docs/micro.html", + "Support": "https://mobiflight.com/discord" + } }, "ModuleLimits": { "MaxAnalogInputs": 9, diff --git a/_Boards/Atmel/Board_ProMicro/mobiflight_micro.png b/_Boards/Atmel/Board_ProMicro/mobiflight_micro.png new file mode 100644 index 00000000..b86964f0 Binary files /dev/null and b/_Boards/Atmel/Board_ProMicro/mobiflight_micro.png differ diff --git a/_Boards/Atmel/Board_Uno/arduino_uno.board.json b/_Boards/Atmel/Board_Uno/arduino_uno.board.json index bec60358..a03476f1 100644 --- a/_Boards/Atmel/Board_Uno/arduino_uno.board.json +++ b/_Boards/Atmel/Board_Uno/arduino_uno.board.json @@ -32,9 +32,15 @@ "FriendlyName": "Arduino Uno", "FirmwareBaseName": "mobiflight_uno", "FirmwareExtension": "hex", - "LatestFirmwareVersion": "3.0.0", + "LatestFirmwareVersion": "0.0.1", "MobiFlightType": "MobiFlight Uno", - "ResetFirmwareFile": "reset.arduino_uno_1_0_2.hex" + "ResetFirmwareFile": "reset.arduino_uno_1_0_2.hex", + "Community": { + "Project": "MobiFlight Uno", + "Website": "https://mobiflight.com/links/connector/info/website/uno.html", + "Docs": "https://mobiflight.com/links/connector/info/docs/uno.html", + "Support": "https://mobiflight.com/discord" + } }, "ModuleLimits": { "MaxAnalogInputs": 6, diff --git a/_Boards/Atmel/Board_Uno/mobiflight_uno.png b/_Boards/Atmel/Board_Uno/mobiflight_uno.png new file mode 100644 index 00000000..6ff8de5e Binary files /dev/null and b/_Boards/Atmel/Board_Uno/mobiflight_uno.png differ diff --git a/_Boards/RaspberryPi/Pico/raspberry_pico.png b/_Boards/RaspberryPi/Pico/raspberry_pico.png new file mode 100644 index 00000000..b9b5cfda Binary files /dev/null and b/_Boards/RaspberryPi/Pico/raspberry_pico.png differ diff --git a/_Boards/RaspberryPi/Pico/raspberrypi_pico.board.json b/_Boards/RaspberryPi/Pico/raspberrypi_pico.board.json index 6bbaeb08..20e3e6a0 100644 --- a/_Boards/RaspberryPi/Pico/raspberrypi_pico.board.json +++ b/_Boards/RaspberryPi/Pico/raspberrypi_pico.board.json @@ -20,7 +20,7 @@ "FirmwareBaseName": "mobiflight_raspberrypico", "FirmwareExtension": "uf2", "FriendlyName": "Raspberry Pico", - "LatestFirmwareVersion": "3.0.0", + "LatestFirmwareVersion": "0.0.1", "MobiFlightType": "MobiFlight RaspiPico", "ResetFirmwareFile": "reset.raspberry_pico_flash_nuke.uf2" }, diff --git a/_Boards/board-logo.png b/_Boards/board-logo.png new file mode 100644 index 00000000..c91cdd3d Binary files /dev/null and b/_Boards/board-logo.png differ diff --git a/copy_fw_files.py b/copy_fw_files.py index dd4eaa32..46b434f0 100644 --- a/copy_fw_files.py +++ b/copy_fw_files.py @@ -1,5 +1,6 @@ Import("env") import os, zipfile, shutil +import fileinput from pathlib import Path # Get the version number from the build environment. @@ -10,9 +11,9 @@ firmware_version = firmware_version.strip(".") zip_file_name = 'Mobiflight-Connector' -build_path = './_build' -build_path_fw = build_path + '/firmware' -build_path_json = build_path + '/Boards' +build_path = Path('./_build') +build_path_fw = build_path / 'firmware' +build_path_json = build_path / 'Boards' distrubution_path = './_dist' board_folder = ['./_Boards/Atmel', './_Boards/RaspberryPi'] @@ -38,6 +39,13 @@ def copy_fw_files (source, target, env): file_extension = '.json' copy_files_by_extension(board_folder, build_path_json, file_extension) + # set FW version within boad.json files + replacements = { + "0.0.1": firmware_version + } + for file_path in build_path_json.rglob("*.json"): + replace_in_file(file_path, replacements) + # Create ZIP file and add files from distrubution folder zip_file_path = distrubution_path + '/' + zip_file_name + '_' + firmware_version + '.zip' createZIP(build_path, zip_file_path, zip_file_name) @@ -65,5 +73,17 @@ def createZIP(original_folder_path, zip_file_path, new_folder_name): zipf.write(os.path.join(root, file), new_path) +def replace_in_file(file_path, replacements): + """Replace all keys in `replacements` with their values in the given file.""" + with open(file_path, "r", encoding="utf-8") as file: + content = file.read() + + for old, new in replacements.items(): + content = content.replace(old, new) + + with open(file_path, "w", encoding="utf-8") as file: + file.write(content) + + env.AddPostAction("$BUILD_DIR/${PROGNAME}.hex", copy_fw_files) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", copy_fw_files) diff --git a/src/Config.cpp b/src/Config.cpp index 03ba4f63..4b36c96b 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -514,10 +514,14 @@ void readConfigFromMemory(bool configFromFlash) #endif #if MF_ANALOG_SUPPORT == 1 + case kTypeAnalogInputDeprecated: case kTypeAnalogInput: params[0] = readUint(&addrMem, configFromFlash); // pin number params[1] = readUint(&addrMem, configFromFlash); // sensitivity - Analog::Add(params[0], &nameBuffer[pNameBuffer], params[1]); // MUST be before readName because readName returns the pointer for the NEXT Name + if (command == kTypeAnalogInputDeprecated) + Analog::Add(params[0], &nameBuffer[pNameBuffer], params[1], true); // MUST be before readName because readName returns the pointer for the NEXT Name + else + Analog::Add(params[0], &nameBuffer[pNameBuffer], params[1], false); // MUST be before readName because readName returns the pointer for the NEXT Name copy_success = readName(&addrMem, nameBuffer, &pNameBuffer, configFromFlash); // copy the NULL terminated name to to nameBuffer and set to next free memory location // copy_success = readEndCommand(&addrMem, ':'); // once the nameBuffer is not required anymore uncomment this line and delete the line before break; diff --git a/src/MF_Analog/Analog.cpp b/src/MF_Analog/Analog.cpp index e692f841..1829454d 100644 --- a/src/MF_Analog/Analog.cpp +++ b/src/MF_Analog/Analog.cpp @@ -34,13 +34,13 @@ namespace Analog return true; } - void Add(uint8_t pin, char const *name, uint8_t sensitivity) + void Add(uint8_t pin, char const *name, uint8_t sensitivity, bool deprecated) { if (analogRegistered == maxAnalogIn) return; analog[analogRegistered] = MFAnalog(); - analog[analogRegistered].attach(pin, name, sensitivity); + analog[analogRegistered].attach(pin, name, sensitivity, deprecated); MFAnalog::attachHandler(handlerOnAnalogChange); analogRegistered++; #ifdef DEBUG2CMDMESSENGER diff --git a/src/MF_Analog/Analog.h b/src/MF_Analog/Analog.h index 4c4b7099..32bd05ab 100644 --- a/src/MF_Analog/Analog.h +++ b/src/MF_Analog/Analog.h @@ -10,7 +10,7 @@ namespace Analog { bool setupArray(uint16_t count); - void Add(uint8_t pin, char const *name = "AnalogInput", uint8_t sensitivity = 3); + void Add(uint8_t pin, char const *name = "AnalogInput", uint8_t sensitivity = 3, bool deprecated = true); void Clear(); void read(); void readAverage(); diff --git a/src/MF_Analog/MFAnalog.cpp b/src/MF_Analog/MFAnalog.cpp index 72c34953..86f4af96 100644 --- a/src/MF_Analog/MFAnalog.cpp +++ b/src/MF_Analog/MFAnalog.cpp @@ -13,7 +13,7 @@ MFAnalog::MFAnalog() _initialized = false; } -void MFAnalog::attach(uint8_t pin, const char *name, uint8_t sensitivity) +void MFAnalog::attach(uint8_t pin, const char *name, uint8_t sensitivity, bool deprecated) { _sensitivity = sensitivity; _pin = pin; @@ -27,7 +27,10 @@ void MFAnalog::attach(uint8_t pin, const char *name, uint8_t sensitivity) else if (_pin == 6) _pin = A7; #endif - pinMode(_pin, INPUT_PULLUP); // set pin to input. Could use OUTPUT for analog, but shows the intention :-) + // enabling PullUp makes a nonlinear behaviour if pot is used + if (deprecated) + pinMode(_pin, INPUT_PULLUP); + // Fill averaging buffers with initial reading for (uint8_t i = 0; i < ADC_MAX_AVERAGE; i++) { readBuffer(); diff --git a/src/MF_Analog/MFAnalog.h b/src/MF_Analog/MFAnalog.h index 8945ca9e..00e01097 100644 --- a/src/MF_Analog/MFAnalog.h +++ b/src/MF_Analog/MFAnalog.h @@ -26,7 +26,7 @@ class MFAnalog public: MFAnalog(); static void attachHandler(analogEvent handler); - void attach(uint8_t pin, const char *name, uint8_t sensitivity); + void attach(uint8_t pin, const char *name, uint8_t sensitivity, bool deprecated); void update(); void retrigger(); void readBuffer(); diff --git a/src/config.h b/src/config.h index 269e9c10..7ef7dd71 100644 --- a/src/config.h +++ b/src/config.h @@ -18,13 +18,14 @@ enum { kTypeEncoder, // 8 kTypeStepperDeprecated2, // 9 (keep for backwards compatibility, stepper type with auto zero support if btnPin is > 0) kTypeOutputShifter, // 10 Shift register support (example: 74HC595, TLC592X) - kTypeAnalogInput, // 11 Analog Device with 1 pin + kTypeAnalogInputDeprecated,// 11 Analog Device with 1 pin kTypeInputShifter, // 12 Input shift register support (example: 74HC165) kTypeMuxDriver, // 13 Multiplexer selector support (generates select outputs) kTypeDigInMux, // 14 Digital input multiplexer support (example: 74HCT4067, 74HCT4051) kTypeStepper, // 15 new stepper type with settings for backlash and deactivate output kTypeLedSegmentMulti, // 16 new led segment with MAX7219 and TM1637 support kTypeCustomDevice, // 17 Custom Device + kTypeAnalogInput, // 18 Analog Device without PullUp enabled kTypeMax // if new device types are added, this MUST be before this one! };