M5Unit-INFRARED 0.3.0 git rev:2148adc
Loading...
Searching...
No Matches
unit_ITR9606.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_INFRARED_UNIT_ITR9606_HPP
11#define M5_UNIT_INFRARED_UNIT_ITR9606_HPP
12
13#include <M5UnitComponent.hpp>
14
15namespace m5 {
16namespace unit {
17
25class UnitITR9606 : public Component {
26 M5_UNIT_COMPONENT_HPP_BUILDER(UnitITR9606, 0x00);
27
28public:
33 struct config_t {
36 uint32_t interval{50};
37 };
38
40 explicit UnitITR9606() : Component(0x00)
41 {
42 }
43
49 {
50 return _cfg;
51 }
56 void config(const config_t& cfg)
57 {
58 _cfg = cfg;
59 }
60
65 bool begin() override;
70 void update(const bool force = false) override;
71
74
78 inline bool isDetected() const
79 {
80 return _detected;
81 }
86 inline bool wasDetected() const
87 {
88 return _was_detected;
89 }
94 inline bool wasReleased() const
95 {
96 return _was_released;
97 }
99
102
107 bool readDetection(bool& detected);
109
110private:
111 config_t _cfg{};
112 bool _detected{};
113 bool _was_detected{};
114 bool _was_released{};
115};
116
117} // namespace unit
118} // namespace m5
119#endif
bool wasDetected() const
Rising edge detection (object entered the slot)
Definition unit_ITR9606.hpp:86
void config(const config_t &cfg)
Set the config values.
Definition unit_ITR9606.hpp:56
void update(const bool force=false) override
Read the sensor pin and update the detection state.
Definition unit_ITR9606.cpp:42
bool readDetection(bool &detected)
Read the sensor pin state directly.
Definition unit_ITR9606.cpp:65
config_t config() const
Gets the config values.
Definition unit_ITR9606.hpp:48
bool isDetected() const
Current detection state.
Definition unit_ITR9606.hpp:78
UnitITR9606()
Constructor.
Definition unit_ITR9606.hpp:40
bool begin() override
Set the RX pin to input with pull-up and apply the config.
Definition unit_ITR9606.cpp:23
bool wasReleased() const
Falling edge detection (object left the slot)
Definition unit_ITR9606.hpp:94
Top level namespace of M5Stack.
Unit-related namespace.
Settings for begin.
Definition unit_ITR9606.hpp:33
uint32_t interval
Definition unit_ITR9606.hpp:36