Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions .github/scripts/get-pr-details.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@

#!/usr/bin/env bash

set -euo pipefail

echo "Retrieving PR information..."

if [ -z "${GITHUB_TOKEN:-}" ]; then
echo "GITHUB_TOKEN not set"
exit 1
fi

OWNER="${GITHUB_REPOSITORY%%/*}"
REPO="${GITHUB_REPOSITORY##*/}"
SHA="${GITHUB_SHA}"

PRS_JSON=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$OWNER/$REPO/commits/$SHA/pulls")

PR_COUNT=$(echo "$PRS_JSON" | jq length)

if [ "$PR_COUNT" -eq 0 ]; then
echo "No PR associated with this commit."
if [ -z "${PR_NUMBER:-}" ]; then
echo "No PR number provided, skipping release notes."
echo "title=" >> "$GITHUB_OUTPUT"
echo "body=" >> "$GITHUB_OUTPUT"
exit 0
fi

TITLE=$(echo "$PRS_JSON" | jq -r '.[0].title // ""')
BODY=$(echo "$PRS_JSON" | jq -r '.[0].body // ""')
PR_JSON=$(gh pr view "$PR_NUMBER" --json title,body)
TITLE=$(echo "$PR_JSON" | jq -r '.title // ""')
BODY=$(echo "$PR_JSON" | jq -r '.body // ""')

{
echo "title<<EOF"
Expand All @@ -43,6 +24,4 @@ BODY=$(echo "$PRS_JSON" | jq -r '.[0].body // ""')
echo "EOF"
} >> "$GITHUB_OUTPUT"

echo "PR details captured."
echo "- Title = $TITLE."
echo "- Description = $BODY."
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: pip install --upgrade platformio

- name: Build LumenLab
run: pio run
run: pio run -e release

- name: Run tests
run: pio test --environment native
run: pio test -e native
113 changes: 95 additions & 18 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

permissions:
contents: write
pull-requests: write

concurrency:
group: release-main
Expand All @@ -22,13 +23,51 @@ jobs:
with:
fetch-depth: 0

- name: Cache pip and PlatformIO
- name: Determine PR number
id: pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=$(gh pr list \
--state merged \
--base main \
--json number,mergeCommit \
--jq '.[] | select(.mergeCommit.oid=="'"$GITHUB_SHA"'") | .number')
if [[ -z "$PR_NUMBER" ]]; then
echo "No PR associated with this commit; skipping release."
echo "run_release=false" >> $GITHUB_OUTPUT
else
echo "Found PR #$PR_NUMBER"
echo "run_release=true" >> $GITHUB_OUTPUT
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
fi

- name: Determine next version id from PR labels
id: semver
run: |
PR_NUMBER=${{ steps.pr.outputs.pr_number }}
export PR_NUMBER
bash .github/scripts/compute-semver.sh
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get release description notes from PR
id: pr_details
run: bash .github/scripts/get-pr-details.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.semver.outputs.pr_number }}

- name: Cache PlatformIO & Arduino CLI
uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio-${{ hashFiles('**/platformio.ini') }}
~/.arduino15
key: ${{ runner.os }}-build-tools-${{ hashFiles('**/platformio.ini') }}

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -38,35 +77,73 @@ jobs:
- name: Install PlatformIO
run: pip install --upgrade platformio

- name: Determine next SemVer from PR labels
id: semver
run: bash .github/scripts/compute-semver.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get release description notes from PR
id: pr_details
run: bash .github/scripts/get-pr-details.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: pio test --environment native

- name: Build release
- name: Build PS3 Firmware (PlatformIO)
run: pio run -e release
env:
LUMENLAB_VERSION: ${{ steps.semver.outputs.tag }}

- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v1

- name: Setup Arduino CLI config
run: |
cat > arduino-cli.yaml <<EOF
board_manager:
additional_urls:
- https://raw.githubusercontent.com/ricardoquesada/esp32-arduino-lib-builder/master/bluepad32_files/package_esp32_bluepad32_index.json
EOF

- name: Update Arduino CLI index
run: arduino-cli --config-file arduino-cli.yaml core update-index

- name: Install Bluepad32 core
run: arduino-cli --config-file arduino-cli.yaml core install esp32-bluepad32:esp32

- name: Install project dependencies
run: arduino-cli lib install FastLED@3.10.2 "Adafruit SSD1306@2.5.15"

- name: Build release for PS4
run: |
echo "" > lumenlab.ino
arduino-cli compile --fqbn esp32-bluepad32:esp32:uPesy_wroom \
--build-property compiler.cpp.extra_flags="-Iinclude -Isrc -Os -DRELEASE -std=gnu++2a -DLUMENLAB_VERSION=\"${LUMENLAB_VERSION}\"" \
--clean --output-dir build
env:
LUMENLAB_VERSION: ${{ steps.semver.outputs.tag }}

- name: Package PS3 Firmware ZIP
run: |
cp .pio/build/release/firmware.bin ./build/ps3-firmware.bin
cp .pio/build/release/bootloader.bin ./build/ps3-bootloader.bin
cp .pio/build/release/partitions.bin ./build/ps3-partitions.bin
zip -j ./build/ps3-firmware.zip \
./build/ps3-firmware.bin \
./build/ps3-bootloader.bin \
./build/ps3-partitions.bin


- name: Package PS4 Firmware ZIP
working-directory: build
run: |
mv ./lumenlab.ino.bin ./ps4-firmware.bin
mv ./lumenlab.ino.bootloader.bin ./ps4-bootloader.bin
mv ./lumenlab.ino.partitions.bin ./ps4-partitions.bin
zip -j ./ps4-firmware.zip \
./ps4-firmware.bin \
./ps4-bootloader.bin \
./ps4-partitions.bin

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.semver.outputs.tag }}
name: ${{ steps.semver.outputs.tag }} - ${{ steps.pr_details.outputs.title }}
body: ${{ steps.pr_details.outputs.body }}
files: |
.pio/build/release/firmware.bin
.pio/build/release/bootloader.bin
.pio/build/release/partitions.bin
./build/ps3-firmware.zip
./build/ps4-firmware.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
tools/.venv
activate-virtual-env.*
__pycache__
lumenlab.ino
build

*.drl
*.gko
Expand Down
58 changes: 56 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
},
{
"label": "LumenLab - Upload (Virtualization)",
"label": "LumenLab - Upload (PS3 Virtualization)",
"type": "shell",
"command": "platformio",
"args": [
Expand All @@ -63,6 +63,24 @@
"panel": "shared"
}
},
{
"label": "LumenLab - Upload (PS4 Virtualization)",
"type": "shell",
"command": "echo \"\" > lumenlab.ino && export LUMENLAB_VERSION='v0.0.0' && echo $LUMENLAB_VERSION && arduino-cli compile --fqbn esp32-bluepad32:esp32:uPesy_wroom --build-property compiler.cpp.extra_flags=\"-Iinclude -Isrc -Os -DVIRTUALIZATION -std=gnu++2a -DLUMENLAB_VERSION=\\\"${LUMENLAB_VERSION}\\\"\" --output-dir build && ../lumenlab-installer/Firmware/esptool.exe --chip esp32 --baud 921600 write_flash -z 0x1000 build/lumenlab.ino.bootloader.bin 0x8000 build/lumenlab.ino.partitions.bin 0x10000 build/lumenlab.ino.bin",
"problemMatcher": [
"$platformio"
],
"options": {
"statusbar": {
"hide": true
}
},
"presentation": {
"reveal": "always",
"focus": true,
"panel": "shared"
}
},
{
"label": "PlatformIO: Upload",
"type": "shell",
Expand Down Expand Up @@ -179,6 +197,42 @@
"focus": true,
"panel": "shared"
}
}
},
{
"label": "Upload and Start Virtualization (PS3)",
"dependsOrder": "sequence",
"dependsOn": [
"LumenLab - Upload (PS3 Virtualization)",
"Start Virtualization"
],
"options": {
"statusbar": {
"hide": true
}
},
"presentation": {
"reveal": "always",
"focus": true,
"panel": "shared"
}
},
{
"label": "Upload and Start Virtualization (PS4)",
"dependsOrder": "sequence",
"dependsOn": [
"LumenLab - Upload (PS4 Virtualization)",
"Start Virtualization"
],
"options": {
"statusbar": {
"hide": true
}
},
"presentation": {
"reveal": "always",
"focus": true,
"panel": "shared"
}
},
]
}
3 changes: 3 additions & 0 deletions include/core/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ namespace SystemCore
{
public:
static const String &version() { return _version; }
static const String &psControllerType() { return _psControllerType; }
static const String &macAddress() { return _macAddress; }
static uint16_t numLeds() { return _numLeds; }
static uint32_t serialBaud() { return _serialBaud; }
static const std::array<uint16_t, 3> &recallBoundaries() { return _recallBoundaries; }

static constexpr uint8_t ledDimmerGpio = 34; // set from PCB design, should not be configurable

static void load(::Preferences &memory);

private:
static String _version;
static String _psControllerType;
static String _macAddress;
static uint16_t _numLeds;
static uint32_t _serialBaud;
Expand Down
10 changes: 8 additions & 2 deletions include/core/context-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#include "engine/layer.h"
#include "engine/state-manager.h"
#include "player/controller.h"
#include "player/ps3-controller.h"
#include "player/ps4-controller.h"
#include "lights/led-strip.h"
#include "display/display.h"
#include "display/menu-navigation.h"
Expand All @@ -21,12 +22,17 @@ namespace SystemCore

Engine::Layer *application = nullptr;
Engine::StateManager stateManager;
Player::Controller controller;
#ifdef USE_PS3
Player::Ps3Controller controller;
#else
Player::Ps4Controller controller;
#endif
Lights::LedStrip leds;
Display::OledDisplay display;
Preferences memory;
Display::MenuTileNavigation menuNav;

void initializeSystemMemory();
void navigateMainMenu();
void navigateGameMenu();
void navigateSceneMenu();
Expand Down
3 changes: 2 additions & 1 deletion include/engine/state-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ namespace Engine
recallGameState{ctx},
systemState{SystemState::Initialize},
userMainMenuChoice{MainMenuSelection::Games},
userGameChoice{GameSelection::Recall}
userGameChoice{GameSelection::Recall},
userSceneChoice{SceneSelection::Canvas}
{
}

Expand Down
2 changes: 1 addition & 1 deletion include/games/phase-evasion/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Games::PhaseEvasion
void loadHighScore();
uint16_t calculateTotalScore() const;
void checkHighScore();
void updateHighScore();
void updateHighScore(uint16_t newHighScore);

private:
SystemCore::ContextManager *contextManager;
Expand Down
6 changes: 4 additions & 2 deletions include/lights/led-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
#include <cstdint>

#include "core/configuration.h"
#include "lights/color.h"

namespace Lights
{
class LedBuffer
{
public:
LedBuffer() : leds{new Color[SystemCore::Configuration::numLeds()]} {}
~LedBuffer() { delete leds; }
LedBuffer() : leds{new Color[maxLEDs]} {}
~LedBuffer() { delete[] leds; }
LedBuffer(LedBuffer &&other) = delete;
LedBuffer &operator=(LedBuffer &&other) = delete;
LedBuffer(const LedBuffer &other) = delete;
Expand All @@ -26,5 +27,6 @@ namespace Lights

private:
Color *leds;
static constexpr uint16_t maxLEDs = 600;
};
}
Loading