10static constexpr uint8_t FRAME_SIZE = 9;
11static constexpr uint8_t FRAME_HEAD = 0xFF;
14static constexpr uint32_t STEP_TIMEOUT_ID = 0;
15static constexpr uint32_t RESPONSE_TIMEOUT_ID = 1;
33 SUB_SENSOR(concentration)
41 void setup()
override;
42 void update()
override;
43 void dump_config()
override;
47 void set_alarm(
AlarmType type, uint16_t threshold, uint8_t decimals) {
53#ifdef USE_DFROBOT_SEN0465_TEMPERATURE_COMPENSATION
55 void add_compensation_range(int8_t low, int8_t high,
float a,
float b,
float c,
float d) {
79 bool send_command_(uint8_t command, uint8_t arg0 = 0, uint8_t arg1 = 0, uint8_t arg2 = 0, uint8_t arg3 = 0);
93#ifdef USE_DFROBOT_SEN0465_TEMPERATURE_COMPENSATION
This class simplifies creating components that periodically check a state.
Minimal static vector - saves memory by avoiding std::vector overhead.
DFRobot "Factory Calibrated Electrochemical Gas Sensor" series (SEN0465 to SEN0476).
StaticVector< CompensationRange, DFROBOT_SEN0465_COMPENSATION_RANGES > compensation_
void handle_no_response_()
uint16_t alarm_threshold_
bool send_step_request_()
Sends the request of the current step.
virtual void read_response()=0
Waits for the answer to a request, then calls either handle_response_() or handle_no_response_(),...
void step_failed_(const LogString *reason)
void retry_step_request_()
Sends the request again from a scheduled callback; a failed write counts as a failed attempt.
void handle_data_(const uint8_t *frame)
bool setup_incomplete_
A setup step gave up, so the alarm or the mode may not be what was configured.
virtual bool write_frame(const uint8_t *frame)=0
Sends one complete request frame.
uint8_t pending_command_
Command whose answer is awaited, 0 when no request is outstanding.
bool send_command_(uint8_t command, uint8_t arg0=0, uint8_t arg1=0, uint8_t arg2=0, uint8_t arg3=0)
Sends a request and waits for its answer; returns false when the request could not be sent.
void handle_response_(const uint8_t *frame)
float compensate_(float concentration, float temperature) const
Returns NAN when the temperature is outside every range.
void fail_reading_()
Publish unknown on both sensors and set the warning when a reading cannot be used.
SetupStep
Settings sent once after boot, before the first reading.
@ SETUP_STEP_ACQUIRE_MODE