modified games
This commit is contained in:
@@ -4,28 +4,31 @@
|
||||
#include "Arduino.h"
|
||||
#include "JC_Button.h"
|
||||
|
||||
|
||||
std::vector<c_button *> buttonlist;
|
||||
|
||||
c_button button1(SWITCH1, YELLOW);
|
||||
c_button button2(SWITCH2, RED);
|
||||
c_button button3(SWITCH3, GREEN);
|
||||
c_button button1(SWITCH1, YELLOW, 1);
|
||||
c_button button2(SWITCH2, RED, 2);
|
||||
c_button button3(SWITCH3, GREEN, 3);
|
||||
c_button button4(SWITCH12, YELLOW2, 4);
|
||||
c_button button5(SWITCH22, RED2, 5);
|
||||
c_button button6(SWITCH32, GREEN2, 6);
|
||||
|
||||
|
||||
void buttonbegin( c_button *thisbutton )
|
||||
void buttonbegin(c_button *thisbutton)
|
||||
{
|
||||
thisbutton->begin();
|
||||
buttonlist.push_back(thisbutton);
|
||||
}
|
||||
|
||||
void initButtons( void )
|
||||
void initButtons(void)
|
||||
{
|
||||
buttonbegin(&button1);
|
||||
buttonbegin(&button2);
|
||||
buttonbegin(&button3);
|
||||
buttonbegin(&button4);
|
||||
buttonbegin(&button5);
|
||||
buttonbegin(&button6);
|
||||
}
|
||||
|
||||
|
||||
void handleButtons(void)
|
||||
{
|
||||
for (auto &&i : buttonlist)
|
||||
@@ -47,22 +50,54 @@ bool anybutton(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
c_button* getButton(unsigned int index)
|
||||
bool buttonIsPressed(e_ledcolor index)
|
||||
{
|
||||
if(index > buttonlist.size())
|
||||
c_button *thisbutton = getButton(index);
|
||||
if (thisbutton == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return thisbutton->isPressed();
|
||||
}
|
||||
}
|
||||
|
||||
bool buttonWasPressed(e_ledcolor index)
|
||||
{
|
||||
c_button *thisbutton = getButton(index);
|
||||
if (thisbutton == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return thisbutton->wasPressed();
|
||||
}
|
||||
}
|
||||
|
||||
c_button *getButton(unsigned int index)
|
||||
{
|
||||
if (index > buttonlist.size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return buttonlist[index-1];
|
||||
return buttonlist[index - 1];
|
||||
}
|
||||
|
||||
c_button* getButton(e_ledcolor color)
|
||||
c_button *getButton(e_ledcolor color)
|
||||
{
|
||||
for(auto&& button : buttonlist)
|
||||
for (auto &&button : buttonlist)
|
||||
{
|
||||
if(button->getColor() == color)
|
||||
if (button->getColor() == color)
|
||||
{
|
||||
return button;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<c_button *> *getButtonlist(void)
|
||||
{
|
||||
return &buttonlist;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user