Skip to content

Cleaning up/adding missing comments within examples. #58

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

Merged
merged 1 commit into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/Breaks_6/Breaks_6.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* This example is in fact expected to break, since we try
* to access a thread-private variable.
*/

#include <Arduino_Threads.h>

void setup()
Expand Down
6 changes: 6 additions & 0 deletions examples/Threading_Basics/Shared_Counter/Consumer.inot
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@ void setup()

void loop()
{
/* If a value is available for reading within the internal
* queue then the value is removed from the queue and made
* available to the calling function. Should no data be
* available, then this thread is suspended until new data
* is available for reading.
*/
Serial.println(counter);
}
4 changes: 4 additions & 0 deletions examples/Threading_Basics/Shared_Counter/Producer.inot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ void setup()
void loop()
{
static int i = 0;
/* Every 100 ms a new value is inserted into the shared variable
* 'counter'. Internally this is stored within a queue in a FIFO
* (First-In/First-Out) manner.
*/
counter = i;
i++;
delay(100);
Expand Down
1 change: 1 addition & 0 deletions examples/Threading_Basics/Shared_Counter/SharedVariables.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* Define a shared variable named 'counter' of type 'int'. */
SHARED(counter, int);
5 changes: 5 additions & 0 deletions examples/Threading_Basics/Shared_Counter/Shared_Counter.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* This example demonstrates data exchange between
* threads using a shared counter variable defined
* within 'SharedVariables.h'.
*/

void setup()
{
Producer.start();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* Define a data sink named 'counter' of type 'int' with a internal queue size of 10. */
SINK(counter, int, 10);

void setup()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* Define a data source named 'counter' of type 'int'. */
SOURCE(counter, int);

void setup()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* 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.
/* 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()
Expand Down
12 changes: 4 additions & 8 deletions examples/Threading_Basics/Source_Sink_LED/Sink_Thread.inot
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

/*
* 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.
*/
/* Define a data sink named 'led' of type 'bool' with a internal queue size of 1. */
SINK(led, bool);

void setup()
Expand All @@ -12,9 +8,9 @@ void setup()

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.
/* Read a 'bool' value from the SINK and discard it. Since there is no delay in the loop
* this call will block until new data is inserted from the connected SOURCE. This means
* that the pace is dictated by the SOURCE that sends data every 100 ms.
*/
digitalWrite(LED_BUILTIN, led);
}
7 changes: 3 additions & 4 deletions examples/Threading_Basics/Source_Sink_LED/Source_Sink_LED.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* 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.
/* 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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* The output SOURCE, it sends 'bool' values. */
/* Define a data source named 'led' of type 'bool'. */
SOURCE(led, bool);

void setup()
Expand Down
6 changes: 6 additions & 0 deletions examples/Threadsafe_IO/SPI/SPI.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* This example demonstrates how multiple threads can communicate
* with a single SPI client device using the BusDevice abstraction
* for SPI. In a similar way multiple threads can interface
* with different client devices on the same SPI bus.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
9 changes: 9 additions & 0 deletions examples/Threadsafe_IO/SPI_BusIO/SPI_BusIO.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/* This example demonstrates how multiple threads can communicate
* with a single SPI client device using the BusDevice abstraction
* for SPI. In a similar way multiple threads can interface
* with different client devices on the same SPI bus.
*
* This example uses Adafruit_BusIO style read(), write(),
* write_then_read() APIs.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/* This example demonstrates how every Serial message can be prefixed
* as well as suffixed by a user-configurable message. In this example
* this functionality is used for appending the current timestamp and
* prepending a line feed. Other uses might be to prepend the thread
* from which a given serial message is originating.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/* This example demonstrates how every Serial message can be prefixed
* as well as suffixed by a user-configurable message. In this example
* this functionality is used for prepending the right header for a
* pseudo NMEA-encoded (think GPS) message as well as for calculating
* and appending the checksum at the end.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
6 changes: 6 additions & 0 deletions examples/Threadsafe_IO/Serial_Reader/Serial_Reader.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* This example demonstrates how multiple threads can subscribe to
* reading from the same physical Serial interface. Incoming data
* is copied into per-thread receive buffers so that no thread
* can "steal" data from another thread by reading it first.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
5 changes: 5 additions & 0 deletions examples/Threadsafe_IO/Serial_Writer/Serial_Writer.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* This example demonstrates how multiple threads can write to
* the same physical Serial interface without interfering with
* one another.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
6 changes: 6 additions & 0 deletions examples/Threadsafe_IO/Wire/Wire.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* This example demonstrates how multiple threads can communicate
* with a single Wire client device using the BusDevice abstraction
* for Wire. In a similar way multiple threads can interface
* with different client devices on the same Wire bus.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
11 changes: 10 additions & 1 deletion examples/Threadsafe_IO/Wire_BusIO/Wire_BusIO.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/**************************************************************************************
/* This example demonstrates how multiple threads can communicate
* with a single Wire client device using the BusDevice abstraction
* for Wire. In a similar way multiple threads can interface
* with different client devices on the same Wire bus.
*
* This example uses Adafruit_BusIO style read(), write(),
* write_then_read() APIs.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/

Expand Down