Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and refactor library #27

Merged
merged 37 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
27c8b4f
Removing Wire/Serial abstractions since Arduino_ThreadsafeIO will be …
aentinger Oct 6, 2021
a65ed03
Deleting super-fluous/confusing example code.
aentinger Oct 6, 2021
044bb8f
Providing simple example of shared variable usage.
aentinger Oct 6, 2021
900d8d7
Rename Shared to Demo_Shared
aentinger Oct 6, 2021
dd5ee85
Replace Blocks demo with Demo_Source_Sink
aentinger Oct 6, 2021
9cb1c58
Extract implementation of 'Sink' into a separate file.
aentinger Oct 7, 2021
a0d01a3
Extract implementation of 'Source' into a separate file.
aentinger Oct 7, 2021
30e2384
Extract implementation of 'Shared' into a separate file.
aentinger Oct 7, 2021
68d0a8a
Extract static member definition into dedicated cpp file.
aentinger Oct 7, 2021
619fa4b
Prefix member variables with '_'
aentinger Oct 7, 2021
c562750
Extract private member function 'execute' into cpp file.
aentinger Oct 7, 2021
dae21a6
Extract public Arduino_Threads member function implementation into cp…
aentinger Oct 7, 2021
3730130
Rearrange function definition for better overview.
aentinger Oct 7, 2021
c0583ed
Turn setup/loop into pure virtual functions, thereby turning ArduinoT…
aentinger Oct 7, 2021
6067040
A class with virtual functions needs a virtual destructor.
aentinger Oct 7, 2021
207b4fc
When terminating a thread, wait for the thread to join before dealloc…
aentinger Oct 7, 2021
ce77408
Rename 'execute' to 'threadFunc'
aentinger Oct 7, 2021
2d9ef0f
Providing a default ctor for initializing member variables.
aentinger Oct 7, 2021
661f97c
Renaming rtos::Thread pointer 't' to '_thread'
aentinger Oct 7, 2021
99bc3c6
Replace (leaky) manual memory handling with a smart pointer.
aentinger Oct 7, 2021
58f451c
Cast loop delay to expected type by rtos::ThisThread::sleep_for()
aentinger Oct 8, 2021
9e44f59
Rename _loop_delay to _loop_delay_ms for better clarity on the unit o…
aentinger Oct 8, 2021
e584553
Replace rtos::Queue/MemoryPool with rtos::Mail which contains both in…
aentinger Oct 11, 2021
83a748d
Separate implementation and definition.
aentinger Oct 11, 2021
048d823
Make actions during discarding of old data better visible in the code.
aentinger Oct 11, 2021
6b25c8c
Prefix private member variable 'val' with a '_'
aentinger Oct 11, 2021
fae2eb1
Reformat for better optical consistency.
aentinger Oct 11, 2021
3e4f2ad
Drop method 'latest' since its indistinguishable from 'peek'
aentinger Oct 11, 2021
3b83891
Changing return signature of 'peek' to prevent unauthorized manipulat…
aentinger Oct 11, 2021
7450577
Adding license file.
aentinger Oct 11, 2021
911f10c
Rename ArduinoThreads to Arduino_Threads to be consistent with librar…
aentinger Oct 11, 2021
904ee61
Adding missing mbed based platforms, eliminating no longer needed lib…
aentinger Oct 11, 2021
318d7ff
Using constant for defining queue size.
aentinger Oct 12, 2021
7bfd800
A big rework of the source/sink system.
aentinger Oct 12, 2021
63553a8
Provide a macro for instantiation of a Shared variable.
aentinger Oct 12, 2021
4863888
Implement non-blocking Sink.
aentinger Oct 12, 2021
de2a0d4
Extract implemention of SinkNonBlocking member functions.
aentinger Oct 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 17 additions & 18 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@ env:

jobs:
compile-test:
name: compile for ${{ matrix.fqbn }}
name: ${{ matrix.board.fqbn }}
runs-on: ubuntu-latest

env:
# libraries to install for all boards
UNIVERSAL_LIBRARIES: |
# Install the ArduinoThreads library from the repository
# Install the Arduino_Threads library from the repository
- source-path: ./
- name: Arduino_LSM9DS1
- name: Arduino_APDS9960
- name: ArduinoECCX08
- name: Arduino_HTS221
- name: OneWire
# sketch paths to compile (recursive) for all boards
UNIVERSAL_SKETCH_PATHS: |
- examples
Expand All @@ -49,10 +44,19 @@ jobs:
fail-fast: false

matrix:
fqbn:
- "arduino:mbed:nano33ble"
# - "arduino:mbed:envie_m4"
- "arduino:mbed:envie_m7"
board:
- fqbn: arduino:mbed_nano:nano33ble
platforms: |
- name: arduino:mbed_nano
- fqbn: arduino:mbed_nano:nanorp2040connect
platforms: |
- name: arduino:mbed_nano
- fqbn: arduino:mbed_portenta:envie_m4
platforms: |
- name: arduino:mbed_portenta
- fqbn: arduino:mbed_portenta:envie_m7
platforms: |
- name: arduino:mbed_portenta

steps:
- name: Checkout
Expand Down Expand Up @@ -83,15 +87,10 @@ jobs:
uses: arduino/compile-sketches@v1
with:
cli-version: 'arduino_threads'
fqbn: ${{ matrix.fqbn }}
fqbn: ${{ matrix.board.fqbn }}
libraries: |
${{ env.UNIVERSAL_LIBRARIES }}
platforms: |
# Use Board Manager to install the latest release of Arduino mbed Boards to get the toolchain
- name: "arduino:mbed"
# Overwrite the Board Manager installation with the local platform
- source-path: "extras/ArduinoCore-mbed"
name: "arduino:mbed"
platforms: ${{ matrix.board.platforms }}
sketch-paths: |
${{ env.UNIVERSAL_SKETCH_PATHS }}
enable-deltas-report: 'true'
Expand Down
22 changes: 0 additions & 22 deletions examples/Blocks/Blocks.ino

This file was deleted.

12 changes: 0 additions & 12 deletions examples/Blocks/data_reader.inot

This file was deleted.

21 changes: 0 additions & 21 deletions examples/Blocks/data_writer.inot

This file was deleted.

7 changes: 7 additions & 0 deletions examples/Demo_Shared_Counter/Consumer.inot
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void setup() {

}

void loop() {
Serial.println(counter);
}
13 changes: 13 additions & 0 deletions examples/Demo_Shared_Counter/Demo_Shared_Counter.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
void setup()
{
Serial.begin(115200);
while (!Serial) { }

Producer.start();
Consumer.start();
}

void loop()
{
rtos::ThisThread::yield();
}
10 changes: 10 additions & 0 deletions examples/Demo_Shared_Counter/Producer.inot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
void setup() {

}

void loop() {
static int i = 0;
counter = i;
i++;
delay(100);
}
1 change: 1 addition & 0 deletions examples/Demo_Shared_Counter/SharedVariables.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SHARED(counter, int);
11 changes: 11 additions & 0 deletions examples/Demo_Source_Sink_Counter/Consumer.inot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SINK(counter, int);

void setup()
{

}

void loop()
{
Serial.println(counter.read());
}
16 changes: 16 additions & 0 deletions examples/Demo_Source_Sink_Counter/Demo_Source_Sink_Counter.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* This examples demonstrates the SOURCE/SINK abstraction.
* Each thread may have any number of SOURCES and SINKS that can be connected
* together using the "connectTo" method.
*/

void setup()
{
Producer.counter.connectTo(Consumer.counter);
Producer.start();
Consumer.start();
}

void loop() {
rtos::ThisThread::yield();
}
13 changes: 13 additions & 0 deletions examples/Demo_Source_Sink_Counter/Producer.inot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SOURCE(counter, int);

void setup()
{

}

void loop()
{
static int i = 0;
counter.write(i);
i++;
}
15 changes: 15 additions & 0 deletions examples/Demo_Source_Sink_LED/Demo_Source_Sink_LED.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This examples demonstrates the SOURCE/SINK abstraction.
* Each thread may have any number of SOURCES and SINKS that can be connected
* together using the "connectTo" method.
*/

void setup() {
Source_Thread.led.connectTo(Sink_Thread.led);
Sink_Thread.start();
Source_Thread.start();
}

void loop() {
rtos::ThisThread::yield();
}
Empty file.
21 changes: 21 additions & 0 deletions examples/Demo_Source_Sink_LED/Sink_Thread.inot
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

/*
* An 'bool' SINK with a size of '0'. This kind of SINK has no buffer so the reading thread
* will block until the writing thread has written something, or vice versa.
*/
SINK(led, bool);

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
/* Read a 'bool' from the SINK and discard it. Since there is basically no delay in the loop
* this call will surely block until something comes from the connected SOURCE. In this case
* the pace is dictated by the SOURCE that sends data every 100 ms.
*/
bool led_on = led.read();
digitalWrite(LED_BUILTIN, led_on);
}
15 changes: 15 additions & 0 deletions examples/Demo_Source_Sink_LED/Source_Thread.inot
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* The output SOURCE, it sends 'bool' values. */
SOURCE(led, bool);

void setup()
{

}

void loop()
{
led.write(true);
delay(100);
led.write(false);
delay(100);
}
13 changes: 0 additions & 13 deletions examples/Enqueue_test/Enqueue.inot

This file was deleted.

15 changes: 0 additions & 15 deletions examples/Enqueue_test/Enqueue_test.ino

This file was deleted.

1 change: 0 additions & 1 deletion examples/Enqueue_test/SharedVariables.h

This file was deleted.

13 changes: 0 additions & 13 deletions examples/Leds/Leds.ino

This file was deleted.

1 change: 0 additions & 1 deletion examples/Leds/SharedVariables.h

This file was deleted.

10 changes: 0 additions & 10 deletions examples/Leds/ledblue.inot

This file was deleted.

50 changes: 0 additions & 50 deletions examples/Nano33BLEMegaSketch/Accelerometer.inot

This file was deleted.