50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
#ifndef BUTTONSH
|
|
#define BUTTONSH
|
|
|
|
#include "Arduino.h"
|
|
#include <vector>
|
|
#include "JC_Button.h"
|
|
#include "board.h"
|
|
#include "led.h"
|
|
|
|
typedef enum
|
|
{
|
|
type_switch,
|
|
type_momentary
|
|
}e_switchtype;
|
|
|
|
class c_button : public ToggleButton
|
|
{
|
|
const e_ledcolor _color;
|
|
const uint8_t _index;
|
|
const e_switchtype _switchtype;
|
|
|
|
public:
|
|
c_button(uint8_t pin, e_ledcolor color, uint8_t index, e_switchtype switchtype)
|
|
: ToggleButton(pin), _color(color), _index(index), _switchtype(switchtype) {}
|
|
|
|
e_ledcolor getColor( void ){return _color;}
|
|
e_switchtype getType(void) { return _switchtype;}
|
|
uint8_t getIndex( void ) {return _index;}
|
|
bool isChanged( void ) {return changed();}
|
|
|
|
};
|
|
|
|
bool anybutton(void);
|
|
bool anyButtonChanged(void);
|
|
void initButtons(void);
|
|
void handleButtons(void);
|
|
bool allButtons(void);
|
|
bool onlyButton(e_ledcolor color);
|
|
c_button *getButton(unsigned int index);
|
|
c_button *getButton(e_ledcolor index);
|
|
|
|
std::vector<c_button *>* getButtonlist(void);
|
|
|
|
bool buttonIsPressed(e_ledcolor index);
|
|
bool buttonIsPressed(uint16_t index);
|
|
bool buttonWasPressed(e_ledcolor index);
|
|
|
|
|
|
|
|
#endif //BUTTONSH
|