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