Skip to content

Commit

Permalink
Provide support for custom devices (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
elral authored Oct 23, 2023
1 parent 2a4a43c commit 77ee809
Show file tree
Hide file tree
Showing 18 changed files with 254 additions and 45 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Checkout custom devices
uses: actions/checkout@v3
with:
repository: MobiFlight/MobiFlight-CustomDevices
path: CustomDevices

- name: Run PlatformIO
env:
VERSION: "0.0.${{ github.event.number }}"
Expand All @@ -43,5 +49,5 @@ jobs:
with:
name: firmware
path: |
.pio/build/**/mobiflight*.hex
.pio/build/**/mobiflight*.uf2
.pio/build/**/*.hex
.pio/build/**/*.uf2
14 changes: 10 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Checkout custom devices
uses: actions/checkout@v3
with:
repository: MobiFlight/MobiFlight-CustomDevices
path: CustomDevices

- name: Extract build version
id: get_version
uses: battila7/get-version-action@v2
Expand All @@ -46,14 +52,14 @@ jobs:
with:
name: firmware
path: |
.pio/build/**/mobiflight*.hex
.pio/build/**/mobiflight*.uf2
.pio/build/**/*.hex
.pio/build/**/*.uf2
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
.pio/build/**/mobiflight*.hex
.pio/build/**/mobiflight*.uf2
.pio/build/**/*.hex
.pio/build/**/*.uf2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.vscode/launch.json
.vscode/ipch
.vscode/arduino.json
.CustomDevices
6 changes: 6 additions & 0 deletions _Boards/Atmel/Board_Mega/MFBoards.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#define MF_MUX_SUPPORT 1
#define MF_DIGIN_MUX_SUPPORT 1
#endif
#ifndef MF_CUSTOMDEVICE_SUPPORT
#define MF_CUSTOMDEVICE_SUPPORT 1
#endif

#ifndef MAX_OUTPUTS
#define MAX_OUTPUTS 40
Expand Down Expand Up @@ -69,6 +72,9 @@
#ifndef MAX_DIGIN_MUX
#define MAX_DIGIN_MUX 4
#endif
#ifndef MAX_CUSTOM_DEVICES
#define MAX_CUSTOM_DEVICES 5
#endif

#ifndef MOBIFLIGHT_TYPE
#define MOBIFLIGHT_TYPE "MobiFlight Mega"
Expand Down
10 changes: 6 additions & 4 deletions _Boards/Atmel/Board_Nano/MFBoards.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#define MF_MUX_SUPPORT 1
#define MF_DIGIN_MUX_SUPPORT 1
#endif
#ifndef MF_CUSTOMDEVICE_SUPPORT
#define MF_CUSTOMDEVICE_SUPPORT 2
#endif

#ifndef MAX_OUTPUTS
#define MAX_OUTPUTS 18
Expand Down Expand Up @@ -69,10 +72,9 @@
#ifndef MAX_DIGIN_MUX
#define MAX_DIGIN_MUX 3
#endif

#define STEPS 64
#define STEPPER_SPEED 400 // 300 already worked, 467, too?
#define STEPPER_ACCEL 800
#ifndef MAX_CUSTOM_DEVICES
#define MAX_CUSTOM_DEVICES 2
#endif

#ifndef MOBIFLIGHT_TYPE
#define MOBIFLIGHT_TYPE "MobiFlight Nano"
Expand Down
6 changes: 6 additions & 0 deletions _Boards/Atmel/Board_ProMicro/MFBoards.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#define MF_MUX_SUPPORT 1
#define MF_DIGIN_MUX_SUPPORT 1
#endif
#ifndef MF_CUSTOMDEVICE_SUPPORT
#define MF_CUSTOMDEVICE_SUPPORT 2
#endif

#ifndef MAX_OUTPUTS
#define MAX_OUTPUTS 18
Expand Down Expand Up @@ -69,6 +72,9 @@
#ifndef MAX_DIGIN_MUX
#define MAX_DIGIN_MUX 3
#endif
#ifndef MAX_CUSTOM_DEVICES
#define MAX_CUSTOM_DEVICES 2
#endif

#ifndef MOBIFLIGHT_TYPE
#define MOBIFLIGHT_TYPE "MobiFlight Micro"
Expand Down
6 changes: 6 additions & 0 deletions _Boards/Atmel/Board_Uno/MFBoards.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#define MF_MUX_SUPPORT 1
#define MF_DIGIN_MUX_SUPPORT 1
#endif
#ifndef MF_CUSTOMDEVICE_SUPPORT
#define MF_CUSTOMDEVICE_SUPPORT 2
#endif

#ifndef MAX_OUTPUTS
#define MAX_OUTPUTS 18
Expand Down Expand Up @@ -69,6 +72,9 @@
#ifndef MAX_DIGIN_MUX
#define MAX_DIGIN_MUX 3
#endif
#ifndef MAX_CUSTOM_DEVICES
#define MAX_CUSTOM_DEVICES 2
#endif

#ifndef MOBIFLIGHT_TYPE
#define MOBIFLIGHT_TYPE "MobiFlight Uno"
Expand Down
7 changes: 3 additions & 4 deletions _Boards/RaspberryPi/Pico/MFBoards.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@
#ifndef MAX_DIGIN_MUX
#define MAX_DIGIN_MUX 4
#endif

#define STEPS 64
#define STEPPER_SPEED 400 // 300 already worked, 467, too?
#define STEPPER_ACCEL 800
#ifndef MAX_CUSTOM_DEVICES
#define MAX_CUSTOM_DEVICES 5
#endif

#ifndef MOBIFLIGHT_TYPE
#define MOBIFLIGHT_TYPE "MobiFlight RaspiPico"
Expand Down
12 changes: 12 additions & 0 deletions get_CustomDevices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os

Import("env")

CUSTOMDEVICES_DIR = env.subst("$PROJECT_DIR/CustomDevices")

if not os.path.exists(CUSTOMDEVICES_DIR):
print ("Cloning Mobiflight-CustomDevices repo ... ")
env.Execute("git clone --depth 100 https://github.com/MobiFlight/MobiFlight-CustomDevices $PROJECT_DIR/CustomDevices")
else:
print ("Checking for Mobiflight-CustomDevices repo updates ... ")
env.Execute("git --work-tree=$PROJECT_DIR/CustomDevices --git-dir=$PROJECT_DIR/CustomDevices/.git pull origin main --depth 100")
2 changes: 1 addition & 1 deletion get_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
])

# Set the output filename to the name of the board and the version
env.Replace(PROGNAME=f'mobiflight_{env["PIOENV"]}_{firmware_version.replace(".", "_")}')
env.Replace(PROGNAME=f'{env["PIOENV"]}_{firmware_version.replace(".", "_")}')
47 changes: 30 additions & 17 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
; development use VSCode to change the target to a non-default
; by clicking on the target name in the bottom status bar.
[platformio]
; include custom environments to be build
extra_configs =
./CustomDevices/KAV_Simulation/EFIS_FCU/EFIS_FCU_platformio.ini
./CustomDevices/Mobiflight/GNC255/GNC255_platformio.ini
./CustomDevices/Mobiflight/TM1637/TM1637_platformio.ini
./CustomDevices/Mobiflight/GenericI2C/GenericI2C_platformio.ini
./CustomDevices/_all_CustomDevices/all_devices_platformio.ini


; Common build settings across all devices
[env]
Expand Down Expand Up @@ -48,20 +56,23 @@ build_flags =
-I./src/MF_Modules
build_src_filter =
+<*>
-<./MF_CustomDevice>
extra_scripts =
pre:get_version.py
pre:get_CustomDevices.py

; Build settings for the Arduino Mega
[env:mega]
[env:mobiflight_mega]
platform = atmelavr
board = megaatmega2560
framework = arduino
build_flags =
${env.build_flags}
-DMF_CUSTOMDEVICE_SUPPORT=0
'-DMOBIFLIGHT_TYPE="MobiFlight Mega"'
-I./_Boards/Atmel/Board_Mega
build_src_filter =
${env.build_src_filter}
+<../_Boards/Atmel>
lib_deps =
${env.lib_deps}
${env.custom_lib_deps_Atmel}
Expand All @@ -70,16 +81,17 @@ extra_scripts =
${env.extra_scripts}

; Build settings for the Arduino Pro Micro
[env:micro]
[env:mobiflight_micro]
platform = atmelavr
board = sparkfun_promicro16
framework = arduino
build_flags =
${env.build_flags}
-DMF_CUSTOMDEVICE_SUPPORT=0
'-DMOBIFLIGHT_TYPE="MobiFlight Micro"'
-I./_Boards/Atmel/Board_ProMicro
build_src_filter =
${env.build_src_filter}
+<../_Boards/Atmel>
lib_deps =
${env.lib_deps}
${env.custom_lib_deps_Atmel}
Expand All @@ -89,16 +101,17 @@ extra_scripts =


; Build settings for the Arduino Uno
[env:uno]
[env:mobiflight_uno]
platform = atmelavr
board = uno
framework = arduino
build_flags =
${env.build_flags}
-DMF_CUSTOMDEVICE_SUPPORT=0
'-DMOBIFLIGHT_TYPE="MobiFlight Uno"'
-I./_Boards/Atmel/Board_Uno
build_src_filter =
${env.build_src_filter}
+<../_Boards/Atmel>
lib_deps =
${env.lib_deps}
${env.custom_lib_deps_Atmel}
Expand All @@ -107,16 +120,17 @@ extra_scripts =
${env.extra_scripts}

; Build settings for the Arduino Nano
[env:nano]
[env:mobiflight_nano]
platform = atmelavr
board = nanoatmega328
framework = arduino
build_flags =
${env.build_flags}
-DMF_CUSTOMDEVICE_SUPPORT=0
'-DMOBIFLIGHT_TYPE="MobiFlight Nano"'
-I./_Boards/Atmel/Board_Nano
build_src_filter =
${env.build_src_filter}
+<../_Boards/Atmel>
lib_deps =
${env.lib_deps}
${env.custom_lib_deps_Atmel}
Expand All @@ -125,25 +139,24 @@ extra_scripts =
${env.extra_scripts}

; Build settings for the Raspberry Pico original
[env:raspberrypico]
[env:mobiflight_raspberrypico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower ; select new core
board_build.filesystem_size = 0M ; configure filesystem size. Default 0 Mbyte.
board_build.core = earlephilhower ; select new core
board_build.filesystem_size = 0M ; configure filesystem size. Default 0 Mbyte.
lib_ldf_mode = chain+
upload_protocol = mbed ; for debugging upoading can be changed to picoprobe
;debug_tool = picoprobe ; and uncomment this for debugging w/ picoprobe
upload_protocol = mbed ; for debugging upoading can be changed to picoprobe
;debug_tool = picoprobe ; and uncomment this for debugging w/ picoprobe
build_flags =
${env.build_flags}
-DUSE_INTERRUPT
-DMF_CUSTOMDEVICE_SUPPORT=0
'-DMOBIFLIGHT_TYPE="MobiFlight RaspiPico"'
-I./_Boards/RaspberryPi/Pico
-fpermissive
build_src_filter =
${env.build_src_filter}
+<../_Boards/RaspberryPi>
lib_deps =
${env.lib_deps}
monitor_speed = 115200
extra_scripts =
${env.extra_scripts}
${env.extra_scripts}
7 changes: 7 additions & 0 deletions src/CommandMessenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#if MF_DIGIN_MUX_SUPPORT == 1
#include "DigInMux.h"
#endif
#if MF_CUSTOMDEVICE_SUPPORT == 1
#include "CustomDevice.h"
#endif

CmdMessenger cmdMessenger = CmdMessenger(Serial);
unsigned long lastCommand;
Expand Down Expand Up @@ -83,6 +86,10 @@ void attachCommandCallbacks()
cmdMessenger.attach(kSetShiftRegisterPins, OutputShifter::OnSet);
#endif

#if MF_CUSTOMDEVICE_SUPPORT == 1
cmdMessenger.attach(kSetCustomDevice, CustomDevice::OnSet);
#endif

#ifdef DEBUG2CMDMESSENGER
cmdMessenger.sendCmd(kDebug, F("Attached callbacks"));
#endif
Expand Down
Loading

0 comments on commit 77ee809

Please sign in to comment.