10#ifndef M5_UNIT_INFRARED_UNIT_AS312_HPP
11#define M5_UNIT_INFRARED_UNIT_AS312_HPP
13#include <M5UnitComponent.hpp>
26class UnitAS312 :
public Component {
27 M5_UNIT_COMPONENT_HPP_BUILDER(
UnitAS312, 0x00);
69 bool begin()
override;
74 void update(
const bool force =
false)
override;
100 return _was_released;
117 bool _was_detected{};
118 bool _was_released{};
bool wasDetected() const
Rising edge detection.
Definition unit_AS312.hpp:90
void config(const config_t &cfg)
Set the config values.
Definition unit_AS312.hpp:60
config_t config() const
Gets the config values.
Definition unit_AS312.hpp:52
static constexpr uint32_t HOLD_TIME_MS
AS312 hold time in milliseconds (~2.3s)
Definition unit_AS312.hpp:31
bool readDetection(bool &detected)
Read the sensor pin state directly.
Definition unit_AS312.cpp:70
bool isDetected() const
Current detection state.
Definition unit_AS312.hpp:82
bool begin() override
Set the RX pin to input with pull-up and apply the config.
Definition unit_AS312.cpp:23
void update(const bool force=false) override
Read the sensor pin and update the detection state.
Definition unit_AS312.cpp:47
bool wasReleased() const
Falling edge detection.
Definition unit_AS312.hpp:98
UnitAS312()
Constructor.
Definition unit_AS312.hpp:44
Top level namespace of M5Stack.
Settings for begin.
Definition unit_AS312.hpp:37
uint32_t interval
Definition unit_AS312.hpp:40