-
Notifications
You must be signed in to change notification settings - Fork 8
Examples Observables
Luis Llamas edited this page Apr 25, 2019
·
13 revisions
★ = important
#include "ReactiveArduinoLib.h"
auto observableInt = Reactive::FromProperty<int>();
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
observableInt
>> Reactive::ToSerial<int>();
}
void loop()
{
delay(1000);
observableInt = 1;
delay(1000);
observableInt = 2;
delay(1000);
observableInt = 2;
delay(1000);
observableInt = 3;
}#include "ReactiveArduinoLib.h"
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
Reactive::FromRange<int>(1, 10, 2)
>> Reactive::ToSerial<int>();
}
void loop()
{
}#include "ReactiveArduinoLib.h"
auto observableRange = Reactive::FromRangeDefer<int>(1, 5, 1);
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
observableRange
>> Reactive::ToSerial<int>();
}
void loop()
{
observableRange.Next();
delay(1000);
}#include "ReactiveArduinoLib.h"
int values[] = { 0, 1, 1, 2, 1, 5, 4 };
size_t valuesLength = sizeof(values) / sizeof(values[0]);
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
Reactive::FromArray(values, valuesLength)
>> Reactive::ToSerial<int>();
}
void loop()
{
}#include "ReactiveArduinoLib.h"
int values[] = { 0, 1, 1, 2, 1, 5, 4 };
size_t valuesLength = sizeof(values) / sizeof(values[0]);
auto observableArray = Reactive::FromArrayDefer<int>(values, valuesLength);
void setup()
{
Serial.begin(9600);
while (!Serial) delay(1);
observableArray
>> Reactive::ToSerial<int>();
}
void loop()
{
observableArray.Next();
delay(1000);
}#include "ReactiveArduinoLib.h"
auto interval= Reactive::IntervalMillis<unsigned long>(1000);
void setup()
{
interval
>> Reactive::ToSerial<unsigned long>();
}
void loop()
{
interval.Update();
}#include "ReactiveArduinoLib.h"
auto timer = Reactive::TimerMillis<unsigned long>(1000);
void setup()
{
timer
>> Reactive::ToSerial<unsigned long>();
}
void loop()
{
timer.Update();
}#include "ReactiveArduinoLib.h"
auto reactiveInput = Reactive::FromDigitalInput<int>(10, INPUT_PULLUP);
void setup()
{
reactiveInput
>> Reactive::ToSerial<int>();
}
void loop()
{
reactiveInput.Next();
}#include "ReactiveArduinoLib.h"
auto reactiveInput = Reactive::FromAnalogInput<int>(A0, INPUT_PULLUP);
void setup()
{
reactiveInput
>> Reactive::ToSerial<int>();
}
void loop()
{
reactiveInput.Next();
}