-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CI config for - [x] Basic Navigation - [x] Callbacks - [x] IntFloatValues - [x] Sub Menu - [x] Item Back - [x] List - [x] CharsetInput - [x] Menu Timeout - [x] ~~_SimpleInput (ignored, largely covered by CharsetInput)_~~ ### Additionally: - BugFix for ItemSubMenu (ENTER action is ignored) - Added more logs
- Loading branch information
Showing
17 changed files
with
516 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Wokwi CI | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
provide-examples: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: set-matrix | ||
run: | | ||
TMP="[" | ||
for FILE in examples/*/*.ino; do | ||
EXAMPLE_NAME=$(basename $FILE .ino) | ||
TEST_FILE="test/$EXAMPLE_NAME.test.yml" | ||
if [ -f "$TEST_FILE" ]; then | ||
TMP="$TMP\"$FILE\"," | ||
fi | ||
done | ||
TMP="${TMP::-1}]" | ||
echo "::set-output name=matrix::$TMP" | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
|
||
run-ci: | ||
needs: provide-examples | ||
strategy: | ||
matrix: | ||
example: ${{ fromJson(needs.provide-examples.outputs.matrix) }} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cache/pip | ||
~/.platformio/.cache | ||
key: ${{ runner.os }}-pio | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Prepare Example File | ||
run: | | ||
EXAMPLE_FILE=$(python .scripts/prepare_example.py ${{ matrix.example }}) | ||
EXAMPLE_NAME=$(basename $EXAMPLE_FILE .cpp) | ||
cp $EXAMPLE_FILE src/main.cpp | ||
if [ -f "test/$EXAMPLE_NAME.test.yml" ]; then | ||
echo "TEST_FILE=test/$EXAMPLE_NAME.test.yml" >> $GITHUB_ENV | ||
fi | ||
- name: Prepare Test Script | ||
run: | | ||
RUN_DURATION=$(python .scripts/prepare_workflow.py ${{ env.TEST_FILE }} ${{ vars.WOKWI_CI_TIMINGS }}) | ||
echo "RUN_DURATION=$((RUN_DURATION + ${{ vars.WOKWI_TIMEOUT_BUFFER }}))" >> $GITHUB_ENV | ||
- name: Install PlatformIO | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --upgrade platformio | ||
- name: Install library dependencies | ||
run: pio lib install | ||
|
||
- name: Build PlatformIO | ||
run: pio run | ||
env: | ||
LOCAL_BUILD: 1 | ||
|
||
- name: Running ${{ env.TEST_FILE }} on Wokwi | ||
uses: wokwi/wokwi-ci-action@v1 | ||
with: | ||
token: ${{ secrets.WOKWI_CLI_TOKEN }} | ||
scenario: ${{ env.TEST_FILE }} | ||
timeout: ${{ env.RUN_DURATION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.env | ||
.vars | ||
.secrets | ||
.pio | ||
.vscode/ | ||
src/main.cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import os | ||
import re | ||
import sys | ||
|
||
|
||
def replace_lines(file_path, replacements): | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
|
||
with open(file_path, 'w') as file: | ||
for line in lines: | ||
for pattern, replacement in replacements.items(): | ||
if re.search(pattern, line): | ||
line = replacement + '\n' | ||
file.write(line) | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("Usage: python prepare_example.py <file_path>") | ||
sys.exit(1) | ||
|
||
file_path = sys.argv[1] | ||
|
||
# Change the file extension to .cpp | ||
base = os.path.splitext(file_path)[0] | ||
new_file_path = base + '.cpp' | ||
os.rename(file_path, new_file_path) | ||
|
||
replacement1 = """ | ||
#include <Button.h> | ||
#include <input/ButtonAdapter.h>""" | ||
|
||
replacement2 = """ | ||
Button upBtn(5); | ||
ButtonAdapter upBtnA(&menu, &upBtn, UP); | ||
Button downBtn(6); | ||
ButtonAdapter downBtnA(&menu, &downBtn, DOWN); | ||
Button enterBtn(7); | ||
ButtonAdapter enterBtnA(&menu, &enterBtn, ENTER); | ||
Button backBtn(8); | ||
ButtonAdapter backBtnA(&menu, &backBtn, BACK); | ||
Button leftBtn(9); | ||
ButtonAdapter leftBtnA(&menu, &leftBtn, LEFT); | ||
Button rightBtn(10); | ||
ButtonAdapter rightBtnA(&menu, &rightBtn, RIGHT); | ||
Button backspaceBtn(11); | ||
ButtonAdapter backspaceBtnA(&menu, &backspaceBtn, BACKSPACE);""" | ||
|
||
replacement3 = """ | ||
upBtnA.observe(); | ||
downBtnA.observe(); | ||
enterBtnA.observe(); | ||
backBtnA.observe(); | ||
leftBtnA.observe(); | ||
rightBtnA.observe(); | ||
backspaceBtnA.observe();""" | ||
|
||
replacement4 = """ | ||
upBtn.begin(); | ||
downBtn.begin(); | ||
enterBtn.begin(); | ||
backBtn.begin(); | ||
leftBtn.begin(); | ||
rightBtn.begin(); | ||
backspaceBtn.begin(); | ||
Serial.begin(9600);""" | ||
|
||
replacement5 = """ | ||
#define DISPLAY_TIMEOUT 2000 | ||
#include <LcdMenu.h>""" | ||
|
||
replacements = { | ||
r"#include <input/.*Adapter.h>": replacement1, | ||
r".*Adapter .*\(&menu, .*\);": replacement2, | ||
r".*\.observe\(\);": replacement3, | ||
r".*Serial.begin\(.*\);": replacement4, | ||
r"#include <LcdMenu.h>": replacement5 | ||
} | ||
|
||
replace_lines(new_file_path, replacements) | ||
|
||
# Print the new path | ||
print(new_file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import os | ||
import re | ||
import sys | ||
|
||
|
||
def button_press_template(button_name): | ||
return f""" | ||
- set-control: | ||
part-id: {button_name} | ||
control: pressed | ||
value: 1 | ||
- delay: {press_holding_time}ms | ||
- set-control: | ||
part-id: {button_name} | ||
control: pressed | ||
value: 0 | ||
- delay: {wait_time_after_release}ms | ||
""" | ||
|
||
def replace_lines(file_path, replacements): | ||
total_wait_time = 0 | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
|
||
with open(file_path, 'w') as file: | ||
for line in lines: | ||
for pattern, replacement in replacements.items(): | ||
if re.search(pattern, line): | ||
line = replacement + '\n' | ||
total_wait_time += press_holding_time + wait_time_after_release + serial_wait_time | ||
file.write(line) | ||
|
||
return total_wait_time | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 5: | ||
print("Usage: python prepare_workflow.py <file_path> <serial_wait_time> <wait_time_after_release> <press_holding_time>") | ||
sys.exit(1) | ||
|
||
file_path = sys.argv[1] | ||
serial_wait_time = int(sys.argv[2]) | ||
press_holding_time = int(sys.argv[3]) | ||
wait_time_after_release = int(sys.argv[4]) | ||
|
||
replacements = { | ||
r".*- simulate: upButton-press": button_press_template("btn1"), | ||
r".*- simulate: downButton-press": button_press_template("btn2"), | ||
r".*- simulate: enterButton-press": button_press_template("btn3"), | ||
r".*- simulate: backButton-press": button_press_template("btn4"), | ||
r".*- simulate: leftButton-press": button_press_template("btn5"), | ||
r".*- simulate: rightButton-press": button_press_template("btn6"), | ||
r".*- simulate: backspaceButton-press": button_press_template("btn7"), | ||
} | ||
|
||
total_wait_time = replace_lines(file_path, replacements) | ||
|
||
print(total_wait_time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ lib_deps = | |
feilipu/FreeRTOS@^11.0.1-5 | ||
mprograms/SimpleRotary@^1.1.3 | ||
madleech/Button@^1.0.0 | ||
Wire |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Basic Navigation Test | ||
version: 1 | ||
author: Thomas Forntoh | ||
steps: | ||
- wait-serial: "#LOG# LcdMenu::setScreen" | ||
- simulate: downButton-press | ||
- wait-serial: "#LOG# MenuScreen:down=1" | ||
- simulate: downButton-press | ||
- wait-serial: "#LOG# MenuScreen:down=2" | ||
- simulate: downButton-press | ||
- wait-serial: "#LOG# MenuScreen:down=3" | ||
- simulate: downButton-press | ||
- wait-serial: "#LOG# MenuScreen:down=4" | ||
- simulate: downButton-press | ||
- wait-serial: "#LOG# MenuScreen:down=4" | ||
- simulate: upButton-press | ||
- wait-serial: "#LOG# MenuScreen:up=3" | ||
- simulate: upButton-press | ||
- wait-serial: "#LOG# MenuScreen:up=2" | ||
- simulate: upButton-press | ||
- wait-serial: "#LOG# MenuScreen:up=1" | ||
- simulate: upButton-press | ||
- wait-serial: "#LOG# MenuScreen:up=0" | ||
- simulate: upButton-press | ||
- wait-serial: "#LOG# MenuScreen:up=0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Callbacks Test | ||
version: 1 | ||
author: Thomas Forntoh | ||
steps: | ||
- wait-serial: "#LOG# LcdMenu::setScreen" | ||
- simulate: downButton-press | ||
- wait-serial: "#LOG# MenuScreen:down=1" | ||
- simulate: downButton-press | ||
- wait-serial: "#LOG# MenuScreen:down=2" | ||
- simulate: enterButton-press | ||
- wait-serial: "#LOG# ItemToggle::toggle=ON" | ||
- simulate: enterButton-press | ||
- wait-serial: "#LOG# ItemToggle::toggle=OFF" | ||
- simulate: downButton-press | ||
- wait-serial: "#LOG# MenuScreen:down=3" |
Oops, something went wrong.