Files
espurna/code/espurna/button.h
Maxim Prokhorov 2ff50169b9 Static configuration for LED and Buttons
- use similar to relay & wifi, configuration through helper methods that
  use indexed defines
- clock cycles for led delay polling
- button mode defaults
2020-01-22 01:44:50 +03:00

42 lines
1.1 KiB
C++

/*
BUTTON MODULE
Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
*/
#pragma once
#include <DebounceEvent.h>
struct button_t {
// TODO: dblclick and debounce delays - right now a global setting, independent of ID
static unsigned long DebounceDelay;
static unsigned long DblclickDelay;
// Use built-in indexed definitions to configure DebounceEvent
button_t(unsigned char index);
// Provide custom DebounceEvent parameters instead
button_t(unsigned char pin, unsigned char mode, unsigned long actions, unsigned char relayID);
bool state();
std::unique_ptr<DebounceEvent> event;
unsigned long actions;
unsigned char relayID;
};
bool buttonState(unsigned char id);
unsigned char buttonAction(unsigned char id, unsigned char event);
void buttonMQTT(unsigned char id, uint8_t event);
void buttonEvent(unsigned char id, unsigned char event);
unsigned char buttonAdd(unsigned char pin, unsigned char mode, unsigned long actions, unsigned char relayID = RELAY_NONE);
unsigned char buttonCount();
void buttonSetup();