ESPHome  2024.12.2
rdm6300.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include <cinttypes>
9 #include <vector>
10 
11 namespace esphome {
12 namespace rdm6300 {
13 
14 class RDM6300BinarySensor;
15 class RDM6300Trigger;
16 
18  public:
19  void loop() override;
20 
21  void register_card(RDM6300BinarySensor *obj) { this->cards_.push_back(obj); }
22  void register_trigger(RDM6300Trigger *trig) { this->triggers_.push_back(trig); }
23 
24  float get_setup_priority() const override { return setup_priority::DATA; }
25 
26  protected:
27  int8_t read_state_{-1};
28  uint8_t buffer_[6]{};
29  std::vector<RDM6300BinarySensor *> cards_;
30  std::vector<RDM6300Trigger *> triggers_;
31  uint32_t last_id_{0};
32 };
33 
35  public:
36  void set_id(uint32_t id) { id_ = id; }
37 
38  bool process(uint32_t id) {
39  if (this->id_ == id) {
40  this->publish_state(true);
41  yield();
42  this->publish_state(false);
43  return true;
44  }
45  return false;
46  }
47 
48  protected:
49  uint32_t id_;
50 };
51 
52 class RDM6300Trigger : public Trigger<uint32_t> {
53  public:
54  void process(uint32_t uid) { this->trigger(uid); }
55 };
56 
57 } // namespace rdm6300
58 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void process(uint32_t uid)
Definition: rdm6300.h:54
void register_trigger(RDM6300Trigger *trig)
Definition: rdm6300.h:22
T id(T value)
Helper function to make id(var) known from lambdas work in custom components.
Definition: helpers.h:728
float get_setup_priority() const override
Definition: rdm6300.h:24
std::vector< RDM6300Trigger * > triggers_
Definition: rdm6300.h:30
void IRAM_ATTR HOT yield()
Definition: core.cpp:24
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
std::vector< RDM6300BinarySensor * > cards_
Definition: rdm6300.h:29
void register_card(RDM6300BinarySensor *obj)
Definition: rdm6300.h:21