Examples

The library ships four examples (also under examples/ in the repo).

Basic scheduler

Non-blocking timers with no network:

#include <Pulsync.h>

void setup() {
  pinMode(2, OUTPUT);
  Pulsync.setInterval([]() {
    digitalWrite(2, !digitalRead(2));
  }, 500);
}

void loop() { Pulsync.loop(); }

Cloud send

Pulsync.setInterval([]() {
  Pulsync.beginPayload();
  Pulsync.add("temperature", (float)(analogRead(34) * 0.1f));
  Pulsync.add("humidity", (float)(analogRead(35) * 0.05f));
  Pulsync.endPayload();
}, 10000);

Receive commands

Pulsync.onBool("set_led", [](bool state) {
  digitalWrite(2, state ? HIGH : LOW);
});

Pulsync.on("reboot", []() {
  delay(1000);
  ESP.restart();
});

Remote config

Pulsync.onConfig("readInterval", [](int value) {
  readIntervalMs = value;
}, 5000);