ESPHome  2024.12.2
wiegand.h
Go to the documentation of this file.
1 #pragma once
2 
6 #include "esphome/core/hal.h"
7 
8 namespace esphome {
9 namespace wiegand {
10 
11 class Wiegand;
12 
13 struct WiegandStore {
16  volatile uint64_t value{0};
17  volatile uint32_t last_bit_time{0};
18  volatile bool done{true};
19  volatile uint8_t count{0};
20 
21  static void d0_gpio_intr(WiegandStore *arg);
22  static void d1_gpio_intr(WiegandStore *arg);
23 };
24 
25 class WiegandTagTrigger : public Trigger<std::string> {};
26 
27 class WiegandRawTrigger : public Trigger<uint8_t, uint64_t> {};
28 
29 class WiegandKeyTrigger : public Trigger<uint8_t> {};
30 
32  public:
33  float get_setup_priority() const override { return setup_priority::HARDWARE; }
34  void setup() override;
35  void loop() override;
36  void dump_config() override;
37 
38  void set_d0_pin(InternalGPIOPin *pin) { this->d0_pin_ = pin; };
39  void set_d1_pin(InternalGPIOPin *pin) { this->d1_pin_ = pin; };
40  void register_tag_trigger(WiegandTagTrigger *trig) { this->tag_triggers_.push_back(trig); }
41  void register_raw_trigger(WiegandRawTrigger *trig) { this->raw_triggers_.push_back(trig); }
42  void register_key_trigger(WiegandKeyTrigger *trig) { this->key_triggers_.push_back(trig); }
43 
44  protected:
47  WiegandStore store_{};
48  std::vector<WiegandTagTrigger *> tag_triggers_;
49  std::vector<WiegandRawTrigger *> raw_triggers_;
50  std::vector<WiegandKeyTrigger *> key_triggers_;
51 };
52 
53 } // namespace wiegand
54 } // namespace esphome
void setup()
void loop()
InternalGPIOPin * d1_pin_
Definition: wiegand.h:46
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
Definition: gpio.h:66
void register_raw_trigger(WiegandRawTrigger *trig)
Definition: wiegand.h:41
interface for components that provide keypresses
Definition: key_provider.h:10
ISRInternalGPIOPin d0
Definition: wiegand.h:14
volatile uint8_t count
Definition: wiegand.h:19
std::vector< WiegandRawTrigger * > raw_triggers_
Definition: wiegand.h:49
std::vector< WiegandTagTrigger * > tag_triggers_
Definition: wiegand.h:48
InternalGPIOPin * d0_pin_
Definition: wiegand.h:45
void set_d1_pin(InternalGPIOPin *pin)
Definition: wiegand.h:39
volatile uint64_t value
Definition: wiegand.h:16
void set_d0_pin(InternalGPIOPin *pin)
Definition: wiegand.h:38
float get_setup_priority() const override
Definition: wiegand.h:33
static void d0_gpio_intr(WiegandStore *arg)
Definition: wiegand.cpp:11
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition: component.cpp:18
ISRInternalGPIOPin d1
Definition: wiegand.h:15
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
std::vector< WiegandKeyTrigger * > key_triggers_
Definition: wiegand.h:50
void register_key_trigger(WiegandKeyTrigger *trig)
Definition: wiegand.h:42
void register_tag_trigger(WiegandTagTrigger *trig)
Definition: wiegand.h:40
static void d1_gpio_intr(WiegandStore *arg)
Definition: wiegand.cpp:20
volatile uint32_t last_bit_time
Definition: wiegand.h:17