-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Get logging working Arduino, incorporate testing
- Loading branch information
Showing
13 changed files
with
277 additions
and
71 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,62 @@ | ||
name: Test | ||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cache/pip | ||
~/.platformio/.cache | ||
key: ${{ runner.os }}-pio | ||
- name: Install dependencies | ||
run: sudo apt-get update && sudo apt-get install -y libsdl2-2.0-0 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
- name: Install PlatformIO Core | ||
run: pip install --upgrade platformio | ||
- name: Set up QEMU | ||
id: setup-qemu | ||
run: | | ||
if [[ "$(uname -m)" == "x86_64" ]]; then | ||
QEMU_URL="/~https://github.com/espressif/qemu/releases/download/esp-develop-8.2.0-20240122/qemu-xtensa-softmmu-esp_develop_8.2.0_20240122-x86_64-linux-gnu.tar.xz" | ||
elif [[ "$(uname -m)" == "aarch64" ]]; then | ||
QEMU_URL="/~https://github.com/espressif/qemu/releases/download/esp-develop-8.2.0-20240122/qemu-xtensa-softmmu-esp_develop_8.2.0_20240122-aarch64-linux-gnu.tar.xz" | ||
else | ||
echo "Unsupported architecture: $(uname -m)" | ||
exit 1 | ||
fi | ||
wget $QEMU_URL -O qemu.tar.xz | ||
mkdir -p qemu | ||
tar -xf qemu.tar.xz -C qemu --strip-components=1 | ||
sudo mv qemu /usr/local/qemu | ||
- name: Add QEMU to PATH | ||
run: echo "/usr/local/qemu/bin" >> $GITHUB_PATH | ||
|
||
- name: Run unit tests | ||
run: pio test --without-uploading --project-conf=platformio-test.ini | ||
|
||
static-analysis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cache/pip | ||
~/.platformio/.cache | ||
key: ${{ runner.os }}-pio | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Install PlatformIO Core | ||
run: pip install --upgrade platformio | ||
|
||
- name: Run static analysis | ||
run: pio check |
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,66 @@ | ||
/** | ||
* This example shows how to use the text utilities that are packaged with TcMenu logging | ||
* framework. It should work on Arduino, mbed and PicoSDK with little to no adjustment. | ||
* | ||
* As this example logs output, either define flag `IO_LOGGING_DEBUG` or open IoLogging.h | ||
* and uncomment `#define IO_LOGGING_DEBUG` to enable. | ||
* | ||
* This logging is only complied in when the above define is set, if it is not set then | ||
* the logging is completely removed. | ||
* | ||
*/ | ||
|
||
#include <IoLogging.h> | ||
#include <TextUtilities.h> | ||
|
||
char sz[32] = {0}; | ||
|
||
void setup() { | ||
// This example logs using IoLogging, see the following guide to enable | ||
// https://www.thecoderscorner.com/products/arduino-libraries/io-abstraction/arduino-logging-with-io-logging/ | ||
IOLOG_START_SERIAL | ||
|
||
// convert 102934 to 8 decimal places not padded. | ||
// the clrBuff version also clears the sz buffer first | ||
// IE does not concatenate. | ||
ltoaClrBuff(sz, 102934, 8, NOT_PADDED, sizeof sz); | ||
serlogF2(SER_DEBUG, "Str is: ", sz); | ||
|
||
// concatenate 00102934 (to 8 decimal places zero padded). | ||
// this variant concatenates to a zero terminated string | ||
fastltoa(sz, 102934, 8, '0', sizeof sz); | ||
serlogF2(SER_DEBUG, "Str is: ", sz); | ||
|
||
// clear the string | ||
sz[0] = 0; | ||
|
||
// convert a float into sz string to 4 places. | ||
fastftoa(sz, 1024.512F, 4, sizeof sz); | ||
serlogF2(SER_DEBUG, "Float: ", sz); | ||
|
||
// find a power of ten for decimal place calculation | ||
serlogF2(SER_DEBUG, "Dp To Div: ", dpToDivisor(5)); | ||
|
||
// find the significant places needed to represent a value | ||
serlogF2(SER_DEBUG, "Dp To Div: ", valueToSignificantPlaces(50123, false)); | ||
|
||
// get the single hex character of a digit between 0..15 and vice versa | ||
serlogF2(SER_DEBUG, "Hexchar: ", hexChar(12)); | ||
serlogF2(SER_DEBUG, "HexVal: ", hexValueOf('D')); | ||
|
||
// convert a number into a hex string | ||
sz[0]=0; | ||
|
||
// convert a int into hex string | ||
intToHexString(sz, sizeof sz, 0xFACE, 4, true); | ||
serlogF2(SER_DEBUG, "Hex str: ", sz); | ||
} | ||
|
||
void loop() { | ||
delay(1000); | ||
// convert the time into seconds and then print via logging to 3dp. | ||
float now = millis() / 1000.0F; | ||
sz[0]=0; | ||
fastftoa(sz, now, 3, sizeof sz); | ||
serlogF2(SER_DEBUG, "Time = ", sz); | ||
} |
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,14 @@ | ||
[env:esp32dev] | ||
platform = espressif32 | ||
framework = arduino | ||
board = esp32dev | ||
extra_scripts = post:merge-bin.py | ||
test_build_src = true | ||
|
||
test_testing_command = | ||
qemu-system-xtensa | ||
-nographic | ||
-machine | ||
esp32 | ||
-drive | ||
file=${platformio.build_dir}/${this.__env__}/firmware-merged.bin,if=mtd,format=raw |
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
Oops, something went wrong.