You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 example demonstrates the merits of the source/sink paradigm in a application where there are multiple consumers (sinks) for a single producer (source). In this example a thermostat room control is simulated, which controls a heating device and an AC in two separate threads, based on the readings of one central temperature sensor (a bit contrived, but illustrative example).
examples/Threadsafe_IO/Serial_ProtocolWrapping RAM for global variables
%
examples/Threadsafe_IO/Serial_Reader flash
%
examples/Threadsafe_IO/Serial_Reader RAM for global variables
%
examples/Threadsafe_IO/Serial_Writer flash
%
examples/Threadsafe_IO/Serial_Writer RAM for global variables
%
examples/Threadsafe_IO/Wire flash
%
examples/Threadsafe_IO/Wire RAM for global variables
%
examples/Threadsafe_IO/Wire_BusIO flash
%
examples/Threadsafe_IO/Wire_BusIO RAM for global variables
%
arduino:mbed_nano:nano33ble
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
N/A
N/A
N/A
N/A
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
arduino:mbed_nano:nanorp2040connect
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
N/A
N/A
N/A
N/A
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
arduino:mbed_portenta:envie_m4
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
N/A
N/A
N/A
N/A
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
arduino:mbed_portenta:envie_m7
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
N/A
N/A
N/A
N/A
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
Click for full report CSV
Board,examples/Threading_Basics/Shared_Counter<br>flash,%,examples/Threading_Basics/Shared_Counter<br>RAM for global variables,%,examples/Threading_Basics/Source_Sink_Counter<br>flash,%,examples/Threading_Basics/Source_Sink_Counter<br>RAM for global variables,%,examples/Threading_Basics/Source_Sink_LED<br>flash,%,examples/Threading_Basics/Source_Sink_LED<br>RAM for global variables,%,examples/Threading_Basics/Thermostat<br>flash,%,examples/Threading_Basics/Thermostat<br>RAM for global variables,%,examples/Threadsafe_IO/SPI<br>flash,%,examples/Threadsafe_IO/SPI<br>RAM for global variables,%,examples/Threadsafe_IO/SPI_BusIO<br>flash,%,examples/Threadsafe_IO/SPI_BusIO<br>RAM for global variables,%,examples/Threadsafe_IO/Serial_GlobalPrefixSuffix<br>flash,%,examples/Threadsafe_IO/Serial_GlobalPrefixSuffix<br>RAM for global variables,%,examples/Threadsafe_IO/Serial_ProtocolWrapping<br>flash,%,examples/Threadsafe_IO/Serial_ProtocolWrapping<br>RAM for global variables,%,examples/Threadsafe_IO/Serial_Reader<br>flash,%,examples/Threadsafe_IO/Serial_Reader<br>RAM for global variables,%,examples/Threadsafe_IO/Serial_Writer<br>flash,%,examples/Threadsafe_IO/Serial_Writer<br>RAM for global variables,%,examples/Threadsafe_IO/Wire<br>flash,%,examples/Threadsafe_IO/Wire<br>RAM for global variables,%,examples/Threadsafe_IO/Wire_BusIO<br>flash,%,examples/Threadsafe_IO/Wire_BusIO<br>RAM for global variables,%
arduino:mbed_nano:nano33ble,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,N/A,N/A,N/A,N/A,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nano:nanorp2040connect,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,N/A,N/A,N/A,N/A,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_portenta:envie_m4,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,N/A,N/A,N/A,N/A,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_portenta:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,N/A,N/A,N/A,N/A,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
nice example but i don't see why you have a single inot for temperature control and instantiate it twice, eventually passing it different strings to print out a different report. in order to allow setting the string we may add a public function to set name so that you can set it up from the instance object
I agree that the example is a bit contrived. But you've misread it, the two temperature controls are for different things. One controls the heating the other controls an air-conditioner. Maybe I should adapt inot-naming and redesign the example a bit to be more easily "graspable".
examples/Threadsafe_IO/Serial_ProtocolWrapping RAM for global variables
%
examples/Threadsafe_IO/Serial_Reader flash
%
examples/Threadsafe_IO/Serial_Reader RAM for global variables
%
examples/Threadsafe_IO/Serial_Writer flash
%
examples/Threadsafe_IO/Serial_Writer RAM for global variables
%
examples/Threadsafe_IO/Wire flash
%
examples/Threadsafe_IO/Wire RAM for global variables
%
examples/Threadsafe_IO/Wire_BusIO flash
%
examples/Threadsafe_IO/Wire_BusIO RAM for global variables
%
arduino:mbed_nano:nano33ble
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
N/A
N/A
N/A
N/A
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
arduino:mbed_nano:nanorp2040connect
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
N/A
N/A
N/A
N/A
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
arduino:mbed_portenta:envie_m4
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
N/A
N/A
N/A
N/A
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
arduino:mbed_portenta:envie_m7
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
N/A
N/A
N/A
N/A
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
0
0.0
Click for full report CSV
Board,examples/Threading_Basics/Shared_Counter<br>flash,%,examples/Threading_Basics/Shared_Counter<br>RAM for global variables,%,examples/Threading_Basics/Source_Sink_Counter<br>flash,%,examples/Threading_Basics/Source_Sink_Counter<br>RAM for global variables,%,examples/Threading_Basics/Source_Sink_LED<br>flash,%,examples/Threading_Basics/Source_Sink_LED<br>RAM for global variables,%,examples/Threading_Basics/Thermostat<br>flash,%,examples/Threading_Basics/Thermostat<br>RAM for global variables,%,examples/Threadsafe_IO/SPI<br>flash,%,examples/Threadsafe_IO/SPI<br>RAM for global variables,%,examples/Threadsafe_IO/SPI_BusIO<br>flash,%,examples/Threadsafe_IO/SPI_BusIO<br>RAM for global variables,%,examples/Threadsafe_IO/Serial_GlobalPrefixSuffix<br>flash,%,examples/Threadsafe_IO/Serial_GlobalPrefixSuffix<br>RAM for global variables,%,examples/Threadsafe_IO/Serial_ProtocolWrapping<br>flash,%,examples/Threadsafe_IO/Serial_ProtocolWrapping<br>RAM for global variables,%,examples/Threadsafe_IO/Serial_Reader<br>flash,%,examples/Threadsafe_IO/Serial_Reader<br>RAM for global variables,%,examples/Threadsafe_IO/Serial_Writer<br>flash,%,examples/Threadsafe_IO/Serial_Writer<br>RAM for global variables,%,examples/Threadsafe_IO/Wire<br>flash,%,examples/Threadsafe_IO/Wire<br>RAM for global variables,%,examples/Threadsafe_IO/Wire_BusIO<br>flash,%,examples/Threadsafe_IO/Wire_BusIO<br>RAM for global variables,%
arduino:mbed_nano:nano33ble,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,N/A,N/A,N/A,N/A,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nano:nanorp2040connect,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,N/A,N/A,N/A,N/A,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_portenta:envie_m4,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,N/A,N/A,N/A,N/A,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_portenta:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,N/A,N/A,N/A,N/A,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
i still think it would be useful to show how the same block of code can be reused, which this example fails to show.
regarding the AC/heating differences, these are minimal and can be easily parametrized, which would make code reusability much more evident.
my proposal is to refactor code to have a single inot that handles temperature regulation by adding a parameter for the threshold, one for the hysteresis and one for the polarity of the control and then use two times the same code with different parameters to handle the two devices.
as i was mentioning we should be able to add public methods to set parameters and allow the main sketch to customize algorithm functionality before the start method is called.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #81.
This example demonstrates the merits of the source/sink paradigm in a application where there are multiple consumers (sinks) for a single producer (source). In this example a thermostat room control is simulated, which controls a heating device and an AC in two separate threads, based on the readings of one central temperature sensor (a bit contrived, but illustrative example).