change chainbutton to index instead of color
This commit is contained in:
@@ -63,6 +63,19 @@ bool buttonIsPressed(e_ledcolor index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool buttonIsPressed(uint16_t index)
|
||||||
|
{
|
||||||
|
c_button *thisbutton = getButton(index);
|
||||||
|
if (thisbutton == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return thisbutton->isPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool buttonWasPressed(e_ledcolor index)
|
bool buttonWasPressed(e_ledcolor index)
|
||||||
{
|
{
|
||||||
c_button *thisbutton = getButton(index);
|
c_button *thisbutton = getButton(index);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ c_button *getButton(e_ledcolor index);
|
|||||||
std::vector<c_button *>* getButtonlist(void);
|
std::vector<c_button *>* getButtonlist(void);
|
||||||
|
|
||||||
bool buttonIsPressed(e_ledcolor index);
|
bool buttonIsPressed(e_ledcolor index);
|
||||||
|
bool buttonIsPressed(uint16_t index);
|
||||||
bool buttonWasPressed(e_ledcolor index);
|
bool buttonWasPressed(e_ledcolor index);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,30 +2,29 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "buttons.h"
|
#include "buttons.h"
|
||||||
|
|
||||||
// extern c_button button1;
|
|
||||||
// extern c_button button2;
|
|
||||||
// extern c_button button3;
|
|
||||||
|
|
||||||
uint8_t patternIndex = 0;
|
uint8_t patternIndex = 0;
|
||||||
//uint8_t nextPatternIndex = 1;
|
|
||||||
bool patternFlag = false;
|
bool patternFlag = false;
|
||||||
bool firstpattern = false;
|
bool firstpattern = false;
|
||||||
e_ledcolor cheatbutton = NONE;
|
//e_ledcolor cheatbutton = NONE;
|
||||||
|
uint16_t cheatbutton = 0;
|
||||||
bool cheatButtonFlag = false;
|
bool cheatButtonFlag = false;
|
||||||
|
|
||||||
// uint8_t ledpattern[4][3] = {
|
|
||||||
// {1, 0, 0},
|
|
||||||
// {0, 0, 1},
|
|
||||||
// {1, 0, 0},
|
|
||||||
// {0, 1, 0},
|
|
||||||
// };
|
|
||||||
|
|
||||||
e_ledcolor ledpattern[4] =
|
// e_ledcolor ledpattern[4] =
|
||||||
{
|
// {
|
||||||
YELLOW,
|
// YELLOW,
|
||||||
GREEN,
|
// GREEN,
|
||||||
YELLOW,
|
// YELLOW,
|
||||||
RED};
|
// RED};
|
||||||
|
|
||||||
|
uint16_t ledpattern[4] =
|
||||||
|
{
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
};
|
||||||
|
|
||||||
int patternlength = sizeof(ledpattern) / sizeof(ledpattern[0]);
|
int patternlength = sizeof(ledpattern) / sizeof(ledpattern[0]);
|
||||||
|
|
||||||
@@ -86,16 +85,16 @@ void HandleChainGame(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//check cheatbuttons
|
//check cheatbuttons
|
||||||
if (buttonIsPressed(YELLOW2) && (cheatbutton == NONE))
|
if (buttonIsPressed(1) && (cheatbutton == NONE))
|
||||||
{
|
{
|
||||||
cheatbutton = YELLOW;
|
cheatbutton = 1;
|
||||||
}
|
}
|
||||||
else if (buttonIsPressed(RED2) && (cheatbutton == NONE))
|
else if (buttonIsPressed(2) && (cheatbutton == NONE))
|
||||||
{
|
{
|
||||||
cheatbutton = RED;
|
cheatbutton = 2;
|
||||||
}
|
}
|
||||||
else if (buttonIsPressed(GREEN2) && (cheatbutton == NONE))
|
else if (buttonIsPressed(3) && (cheatbutton == NONE))
|
||||||
{
|
{
|
||||||
cheatbutton = GREEN;
|
cheatbutton = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user