Skip to content

Commit

Permalink
Merge branch 'MobiFlight:main' into Fast_IO
Browse files Browse the repository at this point in the history
  • Loading branch information
elral authored Feb 12, 2025
2 parents e8c7889 + e8eceb5 commit cec751a
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 24 deletions.
6 changes: 4 additions & 2 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- "*"
- "*"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions _Boards/Atmel/Board_Mega/arduino_mega.board.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Binary file added _Boards/Atmel/Board_Mega/mobiflight_mega.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions _Boards/Atmel/Board_Nano/arduino_nano.board.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Binary file added _Boards/Atmel/Board_Nano/mobiflight_nano.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions _Boards/Atmel/Board_ProMicro/arduino_micro.board.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Binary file added _Boards/Atmel/Board_ProMicro/mobiflight_micro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions _Boards/Atmel/Board_Uno/arduino_uno.board.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Binary file added _Boards/Atmel/Board_Uno/mobiflight_uno.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _Boards/RaspberryPi/Pico/raspberry_pico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion _Boards/RaspberryPi/Pico/raspberrypi_pico.board.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Binary file added _Boards/board-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 23 additions & 3 deletions copy_fw_files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Import("env")
import os, zipfile, shutil
import fileinput
from pathlib import Path

# Get the version number from the build environment.
Expand All @@ -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']

Expand All @@ -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)
Expand Down Expand Up @@ -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)
6 changes: 5 additions & 1 deletion src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/MF_Analog/Analog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/MF_Analog/Analog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 5 additions & 2 deletions src/MF_Analog/MFAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/MF_Analog/MFAnalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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!
};

Expand Down

0 comments on commit cec751a

Please sign in to comment.