From 0d6afa3f58c0f83c309af36eb2d2865d8a50fd75 Mon Sep 17 00:00:00 2001 From: fabianhugo Date: Mon, 27 Nov 2023 16:31:10 +0100 Subject: [PATCH] adds possibility to skip production test --- .github/workflows/build.yml | 30 +++++++++++++++++++++--------- source/main.cpp | 8 +++++--- source/samples/Menu.cpp | 10 ++++++---- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 53b94f1e..eef8216f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Natively +name: Build Natively on Ubuntu on: push: @@ -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 }} @@ -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 diff --git a/source/main.cpp b/source/main.cpp index 840bb431..ed549892 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -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{ diff --git a/source/samples/Menu.cpp b/source/samples/Menu.cpp index 51e2a6ce..5ed50de1 100644 --- a/source/samples/Menu.cpp +++ b/source/samples/Menu.cpp @@ -1,6 +1,7 @@ #include "Menu.h" #include "MicroBit.h" #include "Utils.h" +#include "RunTests.h" extern MicroBit uBit; @@ -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); }