-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from bcmi-labs/pretty-the-horse-up
Cleanup and refactor library
- Loading branch information
Showing
55 changed files
with
636 additions
and
1,488 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
void setup() { | ||
|
||
} | ||
|
||
void loop() { | ||
Serial.println(counter); | ||
} |
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,13 @@ | ||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
while (!Serial) { } | ||
|
||
Producer.start(); | ||
Consumer.start(); | ||
} | ||
|
||
void loop() | ||
{ | ||
rtos::ThisThread::yield(); | ||
} |
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,10 @@ | ||
void setup() { | ||
|
||
} | ||
|
||
void loop() { | ||
static int i = 0; | ||
counter = i; | ||
i++; | ||
delay(100); | ||
} |
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 @@ | ||
SHARED(counter, int); |
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,11 @@ | ||
SINK(counter, int); | ||
|
||
void setup() | ||
{ | ||
|
||
} | ||
|
||
void loop() | ||
{ | ||
Serial.println(counter.read()); | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/Demo_Source_Sink_Counter/Demo_Source_Sink_Counter.ino
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,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(); | ||
} |
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,13 @@ | ||
SOURCE(counter, int); | ||
|
||
void setup() | ||
{ | ||
|
||
} | ||
|
||
void loop() | ||
{ | ||
static int i = 0; | ||
counter.write(i); | ||
i++; | ||
} |
File renamed without changes.
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,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.
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,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); | ||
} |
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,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); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.