Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. /*
  2. BUTTON MODULE
  3. Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. #pragma once
  6. #include "libs/DebounceEvent.h"
  7. #include <memory>
  8. constexpr size_t BUTTONS_MAX = 32;
  9. struct button_event_delays_t {
  10. button_event_delays_t();
  11. button_event_delays_t(unsigned long debounce, unsigned long dblclick, unsigned long lngclick, unsigned long lnglngclick);
  12. const unsigned long debounce;
  13. const unsigned long dblclick;
  14. const unsigned long lngclick;
  15. const unsigned long lnglngclick;
  16. };
  17. struct button_t {
  18. button_t(std::shared_ptr<DebounceEvent::PinBase> pin, int mode, unsigned long actions, unsigned char relayID, button_event_delays_t delays);
  19. bool state();
  20. std::unique_ptr<DebounceEvent::DebounceEvent> event_handler;
  21. button_event_delays_t event_delays;
  22. const unsigned long actions;
  23. const unsigned char relayID;
  24. };
  25. bool buttonState(unsigned char id);
  26. unsigned char buttonAction(unsigned char id, unsigned char event);
  27. void buttonMQTT(unsigned char id, uint8_t event);
  28. void buttonEvent(unsigned char id, unsigned char event);
  29. unsigned char buttonAdd(unsigned char pin, unsigned char mode, unsigned long actions, unsigned char relayID = RELAY_NONE);
  30. unsigned char buttonCount();
  31. void buttonSetup();