Skip to content

Commit

Permalink
adds possibility to skip production test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianhugo authored and Amerlander committed Jan 31, 2024
1 parent 796ff6b commit 3bc5f0a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Natively
name: Build Natively on Ubuntu

on:
push:
Expand All @@ -10,8 +10,8 @@ jobs:
build-py-script:
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
gcc: ['7-2017-q4', 'latest']
os: [ubuntu-20.04] #, macos-11, windows-2019]
gcc: ['latest'] # '7-2017-q4'
cmake: ['3.6.0', ''] # Empty string installs the latest CMake release
fail-fast: false
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -43,20 +43,32 @@ jobs:
- name: Upload hex file
uses: actions/upload-artifact@v1
with:
name: build-py-${{ matrix.os }}
name: build-py-NO_BLE-${{ matrix.os }}
path: MICROBIT.hex
- name: Prepare BLE example
- name: Prepare production example (BLE)
run: |
rm codal.json
mv codal.ble.json codal.json
python -c "import pathlib; \
f=pathlib.Path('source/main.cpp'); \
f.write_text(f.read_text().replace('out_of_box_experience()', 'ble_test()'))"
# python -c "import pathlib; \
# f=pathlib.Path('source/main.cpp'); \
# f.write_text(f.read_text().replace('out_of_box_experience()', 'ble_test()'))"
cat codal.json
- name: Build BLE project using build.py
run: python build.py --clean
- name: Upload BLE hex file
uses: actions/upload-artifact@v1
with:
name: build-py-BLE-${{ matrix.os }}
name: build-py-production-${{ matrix.os }}
path: MICROBIT.hex
- name: Prepare user example (BLE) (skip test)
run: |
python -c "import pathlib; \
f=pathlib.Path('source/main.cpp'); \
f.write_text(f.read_text().replace('int productiontest=1;', 'int productiontest=0;'))"
- name: Build BLE project using build.py
run: python build.py --clean
- name: Upload BLE hex file
uses: actions/upload-artifact@v1
with:
name: build-py-user-${{ matrix.os }}
path: MICROBIT.hex
8 changes: 5 additions & 3 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ int main()
uBit.serial.send("Calliope Demo v3.0\r\n");

int stored;
// stored = 1; uBit.storage.put("counter", (uint8_t *)&stored, sizeof(int)); // Skip Test Sequence
int productiontest=1;
KeyValuePair* firstTime = uBit.storage.get("counter");
// check if Test has already been done
if (firstTime == NULL)
{
tests_run(); // Perform test
if (productiontest==1){
tests_run();} // Perform test
stored = 1; // Set persistent counter so next boot will start in user program
uBit.storage.put("counter", (uint8_t *)&stored, sizeof(int));
uBit.sleep(2000);
if (productiontest==1){
uBit.sleep(2000);}
uBit.display.clear();
}
else{
Expand Down
10 changes: 6 additions & 4 deletions source/samples/Menu.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Menu.h"
#include "MicroBit.h"
#include "Utils.h"
#include "RunTests.h"

extern MicroBit uBit;

Expand Down Expand Up @@ -59,11 +60,12 @@ menustate_t menuWaitForChoice(menustate_t start)
}
return state;
}
// reset to test mode by touching all 4 edges
// reset to test mode by touching all 4 edges and turning the mini upside down
if ((uBit.accelerometer.getZ() > 900) && uBit.io.P0.isTouched() && uBit.io.P1.isTouched() && uBit.io.P2.isTouched() && uBit.io.P3.isTouched()){
uBit.storage.remove("counter");
uBit.display.print("TestMode");
uBit.reset();
uBit.storage.remove("counter");
uBit.display.scroll("tester");
tests_run();
uBit.reset();
}
uBit.sleep(10);
}
Expand Down

0 comments on commit 3bc5f0a

Please sign in to comment.