11#define SUB_SENSOR_WITH_DEDUP(name, dedup_type) \
13 ld24xx::SensorWithDedup<dedup_type> *name##_sensor_{nullptr}; \
16 void set_##name##_sensor(sensor::Sensor *sensor) { \
17 this->name##_sensor_ = new ld24xx::SensorWithDedup<dedup_type>(sensor); \
21#define LOG_SENSOR_WITH_DEDUP_SAFE(tag, name, sensor) \
22 if ((sensor) != nullptr) { \
23 LOG_SENSOR(tag, name, (sensor)->sens); \
26#define SAFE_PUBLISH_SENSOR(sensor, value) \
27 if ((sensor) != nullptr) { \
28 (sensor)->publish_state_if_not_dup(value); \
31#define SAFE_PUBLISH_SENSOR_UNKNOWN(sensor) \
32 if ((sensor) != nullptr) { \
33 (sensor)->publish_state_unknown(); \
36#define highbyte(val) (uint8_t)((val) >> 8)
37#define lowbyte(val) (uint8_t)((val) &0xff)
Helper class to deduplicate items in a series of values.
void publish_state_unknown()
Deduplicator< T > publish_dedup
SensorWithDedup(sensor::Sensor *sens)
void publish_state_if_not_dup(T state)
Base-class for all sensors.
void publish_state(float state)
Publish a new state to the front-end.
Providing packet encoding functions for exchanging data with a remote host.