26 lines
525 B
C++
26 lines
525 B
C++
#ifndef BUTTON_HANDLER_H
|
|
#define BUTTON_HANDLER_H
|
|
|
|
#include <Arduino.h>
|
|
#include <Adafruit_MCP23X17.h>
|
|
|
|
class ButtonHandler {
|
|
private:
|
|
Adafruit_MCP23X17* mcp1;
|
|
Adafruit_MCP23X17* mcp2;
|
|
|
|
bool buttonStates[20];
|
|
bool lastButtonStates[20];
|
|
unsigned long lastDebounceTime[20];
|
|
|
|
public:
|
|
ButtonHandler(Adafruit_MCP23X17* mcp1, Adafruit_MCP23X17* mcp2);
|
|
void init();
|
|
void update();
|
|
bool isPressed(uint8_t buttonIndex);
|
|
bool wasPressed(uint8_t buttonIndex);
|
|
bool wasReleased(uint8_t buttonIndex);
|
|
};
|
|
|
|
#endif
|