M5Unit-INFRARED 0.2.0 git rev:76ad9e1
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
39 explicit UnitITR9606() : Component(0x00)
40 {
41 }
42
45 {
46 return _cfg;
47 }
49 void config(const config_t& cfg)
50 {
51 _cfg = cfg;
52 }
53
54 bool begin() override;
55 void update(const bool force = false) override;
56
59
63 inline bool isDetected() const
64 {
65 return _detected;
66 }
71 inline bool wasDetected() const
72 {
73 return _was_detected;
74 }
79 inline bool wasReleased() const
80 {
81 return _was_released;
82 }
84
87
92 bool readDetection(bool& detected);
94
95private:
96 config_t _cfg{};
97 bool _detected{};
98 bool _prev_detected{};
99 bool _was_detected{};
100 bool _was_released{};
101};
102
103} // namespace unit
104} // namespace m5
105#endif
ITR9606 infrared photointerrupter unit.
bool wasDetected() const
Rising edge detection (object entered the slot)
Definition unit_ITR9606.hpp:71
void config(const config_t &cfg)
Set the config values.
Definition unit_ITR9606.hpp:49
bool readDetection(bool &detected)
Read the sensor pin state directly.
Definition unit_ITR9606.cpp:66
config_t config() const
Gets the config values.
Definition unit_ITR9606.hpp:44
bool isDetected() const
Current detection state.
Definition unit_ITR9606.hpp:63
bool wasReleased() const
Falling edge detection (object left the slot)
Definition unit_ITR9606.hpp:79
Top level namespace of M5Stack.
Unit-related namespace.
Settings for begin.
Definition unit_ITR9606.hpp:33
uint32_t interval
Definition unit_ITR9606.hpp:36