4#ifndef PHYPHOX_BLE_CORE_CHANNELSTORE_H
5#define PHYPHOX_BLE_CORE_CHANNELSTORE_H
16 void attach(uint8_t channels,
void* storage);
24 float value(uint8_t channel)
const;
38 Slot* slots_ =
nullptr;
39 uint8_t channels_ = 0;
50 bool decode(
const uint8_t* bytes, uint16_t len);
Definition ChannelStore.h:13
uint32_t updates(uint8_t channel) const
How many deliveries the channel has seen since start (lets a sketch poll for changes).
void attach(uint8_t channels, void *storage)
Size for channels 1 … channels (storage comes from the experiment block).
void deliver(uint8_t channel, float value)
A value arrived from the phone. Stores it, bumps the counter, fires the callbacks.
bool changed(uint8_t channel)
True once per delivery: returns whether a value arrived since the last call.
void setDefault(uint8_t channel, float value)
Pre-fill a channel with the element's default so read() returns it before any change.
float value(uint8_t channel) const
void setCallbacks(uint8_t channel, ChangeCallback onChange, PressCallback onPress)
static size_t bytesNeeded(uint8_t channels)
Definition ChannelStore.h:11
EventType
The 17-byte block phyphox writes to the event characteristic (bluetooth-low-energy....
Definition ChannelStore.h:44
@ EVENT_CLEAR
Definition ChannelStore.h:44
@ EVENT_SYNC
Definition ChannelStore.h:44
@ EVENT_PAUSE
Definition ChannelStore.h:44
@ EVENT_START
Definition ChannelStore.h:44
void(* ChangeCallback)(float value)
Callback types. Plain function pointers (captureless lambdas convert), never std::function.
Definition ElementData.h:19
void(* PressCallback)()
Definition ElementData.h:20
Definition ChannelStore.h:45
bool decode(const uint8_t *bytes, uint16_t len)
Decode 17 big-endian bytes; returns false if len < 17.
int64_t experimentTimeMs
−1 for SYNC
Definition ChannelStore.h:47
int64_t systemTimeMs
Unix time in ms.
Definition ChannelStore.h:48
EventType type
Definition ChannelStore.h:46