Skip to content

Commit d3bc6bc

Browse files
Merge pull request #93 from JonnyHaystack/configurator
Configurator support, RGB support, OLED display support, and more
2 parents 382088a + d41200d commit d3bc6bc

File tree

152 files changed

+7432
-2317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+7432
-2317
lines changed

.clang-format

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
DisableFormat: false
23
AlignAfterOpenBracket: BlockIndent
34
AlignArrayOfStructures: Left
@@ -36,7 +37,7 @@ PackConstructorInitializers: CurrentLine
3637
PenaltyReturnTypeOnItsOwnLine: 2000
3738
PointerAlignment: Right
3839
QualifierAlignment: Custom
39-
QualifierOrder: ['inline', 'static', 'const', 'constexpr', 'restrict', 'volatile', 'type']
40+
QualifierOrder: ['inline', 'static', 'constexpr', 'const', 'restrict', 'volatile', 'type']
4041
ReferenceAlignment: Right
4142
ReflowComments: true
4243
SeparateDefinitionBlocks: Always
@@ -57,3 +58,6 @@ SpaceBeforeCtorInitializerColon: true
5758
SpacesInContainerLiterals: false
5859
TabWidth: 4
5960
UseTab: Never
61+
---
62+
Language: Proto
63+
ColumnLimit: 100

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "HayBox",
3-
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.11",
44
"features": {
55
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
66
"packages": "python3-pip,python3-venv,clang-format-14"
77
}
88
},
9-
"onCreateCommand": "python3 -m pip install -U platformio && pio pkg install && pio pkg update -g -p https://github.com/maxgerhardt/platform-raspberrypi",
9+
"onCreateCommand": "python3 -m pip install -U platformio && pio pkg install && pio pkg update -g -p https://github.com/maxgerhardt/platform-raspberrypi.git#5e87ae34ca025274df25b3303e9e9cb6c120123c",
1010
"customizations": {
1111
"vscode": {
1212
"settings": {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build device config
2+
3+
on: [workflow_call]
4+
5+
jobs:
6+
metadata:
7+
runs-on: ubuntu-latest
8+
name: Parse config metadata
9+
outputs:
10+
meta_json: ${{ steps.parse_yaml.outputs.metadata }}
11+
build_matrix: ${{ steps.parse_yaml.outputs.metadata.build }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Install yaml2json
17+
run: python3 -m pip install remarshal
18+
19+
- name: Read metadata from yaml file
20+
id: parse_yaml
21+
run: |
22+
echo "metadata=$(yaml2json 'meta.yaml')" >> "$GITHUB_OUTPUT"
23+
24+
build:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
needs: metadata
29+
env:
30+
HAYBOX_REPO: ${{ fromJson(needs.metadata.outputs.meta_json).repo }}
31+
HAYBOX_REVISION: ${{ fromJson(needs.metadata.outputs.meta_json).revision }}
32+
DEVICE_CONFIG_REVISION: ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
33+
PIO_ENV: ${{ matrix.env }}
34+
BIN_EXT: ${{ matrix.bin_ext }}
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
include: ${{ fromJson(needs.metadata.outputs.meta_json).build }}
39+
40+
steps:
41+
- name: Check out specific HayBox revision
42+
run: |
43+
git clone "https://github.com/$HAYBOX_REPO" .
44+
git checkout "$HAYBOX_REVISION"
45+
46+
- name: Check out config repo
47+
uses: actions/checkout@v4
48+
with:
49+
path: config/device
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@v5
53+
with:
54+
python-version: '3.10'
55+
56+
- name: Install PlatformIO
57+
run: |
58+
python -m pip install --upgrade pip
59+
pip install --upgrade platformio
60+
61+
- name: Set artifact filename environment variable
62+
run: |
63+
echo "ARTIFACT_NAME=HayBox-${HAYBOX_REVISION}-${PIO_ENV}-${DEVICE_CONFIG_REVISION}.${BIN_EXT}" >> "$GITHUB_ENV"
64+
65+
- name: Set artifact path environment variable
66+
run: |
67+
echo "ARTIFACT_PATH=${PIO_ENV}/${ARTIFACT_NAME}" >> "$GITHUB_ENV"
68+
69+
- name: Build ${{ matrix.env }} env
70+
run: |
71+
pio run -e "$PIO_ENV"
72+
mkdir -p "$PIO_ENV"
73+
74+
cp ".pio/build/${PIO_ENV}/firmware.${BIN_EXT}" "$ARTIFACT_PATH"
75+
76+
- name: Publish ${{ matrix.env }} artifacts
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: ${{ env.ARTIFACT_NAME }}
80+
path: ${{ env.ARTIFACT_PATH }}
81+
82+
- name: Upload binaries to release
83+
uses: softprops/action-gh-release@v1
84+
if: github.ref_type == 'tag'
85+
with:
86+
files: ${{ env.ARTIFACT_PATH }}

.github/workflows/build.yml

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,53 @@ jobs:
99
contents: write
1010
env:
1111
VERSION_REF: ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
12+
PIO_ENV: ${{ matrix.env }}
13+
BIN_EXT: ${{ matrix.bin_ext }}
1214
strategy:
13-
matrix:
14-
include:
15-
- env: c53
16-
bin_ext: uf2
17-
- env: pico
18-
bin_ext: uf2
19-
- env: arduino_uno
20-
bin_ext: hex
21-
- env: arduino_nano
22-
bin_ext: hex
23-
- env: arduino_mega
24-
bin_ext: hex
25-
- env: arduino_leonardo
26-
bin_ext: hex
27-
- env: arduino_micro
28-
bin_ext: hex
29-
- env: b0xx_r1
30-
bin_ext: hex
31-
- env: b0xx_r2
32-
bin_ext: hex
33-
- env: gccmx
34-
bin_ext: hex
35-
- env: gccpcb1
36-
bin_ext: hex
37-
- env: gccpcb2
38-
bin_ext: hex
39-
- env: lbx
40-
bin_ext: hex
41-
- env: smashbox
42-
bin_ext: hex
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- env: c53
19+
bin_ext: uf2
20+
- env: b0xx_r4
21+
bin_ext: uf2
22+
- env: pico
23+
bin_ext: uf2
24+
- env: schism
25+
bin_ext: uf2
26+
- env: arduino_uno
27+
bin_ext: hex
28+
- env: arduino_nano
29+
bin_ext: hex
30+
- env: arduino_mega
31+
bin_ext: hex
32+
- env: arduino_leonardo
33+
bin_ext: hex
34+
- env: arduino_micro
35+
bin_ext: hex
36+
- env: b0xx_r1
37+
bin_ext: hex
38+
- env: b0xx_r2
39+
bin_ext: hex
40+
- env: gccmx
41+
bin_ext: hex
42+
- env: gccpcb1
43+
bin_ext: hex
44+
- env: gccpcb2
45+
bin_ext: hex
46+
- env: htangl_v1
47+
bin_ext: hex
48+
- env: lbx
49+
bin_ext: hex
50+
- env: smashbox
51+
bin_ext: hex
4352

4453
steps:
4554
- name: Check out source code
46-
uses: actions/checkout@v3
55+
uses: actions/checkout@v4
4756

4857
- name: Set up Python
49-
uses: actions/setup-python@v4
58+
uses: actions/setup-python@v5
5059
with:
5160
python-version: '3.10'
5261

@@ -55,20 +64,28 @@ jobs:
5564
python -m pip install --upgrade pip
5665
pip install --upgrade platformio
5766
67+
- name: Set artifact filename environment variable
68+
run: |
69+
echo "ARTIFACT_NAME=HayBox-${VERSION_REF}-${PIO_ENV}.${BIN_EXT}" >> "$GITHUB_ENV"
70+
71+
- name: Set artifact path environment variable
72+
run: |
73+
echo "ARTIFACT_PATH=${PIO_ENV}/${ARTIFACT_NAME}" >> "$GITHUB_ENV"
74+
5875
- name: Build ${{ matrix.env }} env
5976
run: |
60-
pio run -e ${{ matrix.env }}
61-
mkdir -p ${{ matrix.env }}
62-
cp .pio/build/${{ matrix.env }}/firmware.${{ matrix.bin_ext }} ${{ matrix.env }}/HayBox-${{ env.VERSION_REF }}-${{ matrix.env }}.${{ matrix.bin_ext }}
77+
pio run -e "$PIO_ENV"
78+
mkdir -p "$PIO_ENV"
79+
cp ".pio/build/${PIO_ENV}/firmware.${BIN_EXT}" "$ARTIFACT_PATH"
6380
6481
- name: Publish ${{ matrix.env }} artifacts
65-
uses: actions/upload-artifact@v3
82+
uses: actions/upload-artifact@v4
6683
with:
67-
name: HayBox-${{ env.VERSION_REF }}-${{ matrix.env }}.${{ matrix.bin_ext }}
68-
path: ${{ matrix.env }}/HayBox-${{ env.VERSION_REF }}-${{ matrix.env }}.${{ matrix.bin_ext }}
84+
name: ${{ env.ARTIFACT_NAME }}
85+
path: ${{ env.ARTIFACT_PATH }}
6986

7087
- name: Upload binaries to release
7188
uses: softprops/action-gh-release@v1
7289
if: github.ref_type == 'tag'
7390
with:
74-
files: ${{ matrix.env }}/HayBox-${{ env.VERSION_REF }}-${{ matrix.env }}.${{ matrix.bin_ext }}
91+
files: ${{ env.ARTIFACT_PATH }}

.vscode/extensions.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{
2-
// See http://go.microsoft.com/fwlink/?LinkId=827846
3-
// for the documentation about the extensions.json format
4-
"recommendations": [
5-
"platformio.platformio-ide"
6-
]
7-
}
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
]
7+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef _COMMS_BACKEND_INIT_HPP
2+
#define _COMMS_BACKEND_INIT_HPP
3+
4+
#include "core/CommunicationBackend.hpp"
5+
#include "core/InputSource.hpp"
6+
#include "core/pinout.hpp"
7+
#include "core/state.hpp"
8+
9+
#include <config.pb.h>
10+
11+
/**
12+
* @brief Initialize the backends array and return the number of elements in the array
13+
*
14+
* @param backends The reference to assign to the created backends array
15+
* @param inputs Reference to the InputState struct to pass into each backend's constructor
16+
* @param input_sources Input sources array to pass into each backend's constructor
17+
* @param input_source_count Number of elements in the input_sources array
18+
* @param config Reference to global config struct
19+
* @param pinout Pinout struct used for GameCube/N64 communication backends
20+
* @return size_t The number of backends in the array
21+
*/
22+
size_t initialize_backends(
23+
CommunicationBackend **&backends,
24+
InputState &inputs,
25+
InputSource **input_sources,
26+
size_t input_source_count,
27+
const Config &config,
28+
const Pinout &pinout
29+
);
30+
31+
bool initialize_backends_custom(
32+
CommunicationBackend **&backends,
33+
InputSource **input_sources,
34+
size_t input_source_count
35+
) __attribute__((weak));
36+
37+
void select_backend_custom(CommunicationBackendConfig &backend_config) __attribute__((weak));
38+
39+
#endif

0 commit comments

Comments
 (0)