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