change chainbutton to index instead of color

This commit is contained in:
2020-12-25 13:28:49 +01:00
parent 4c9ee88508
commit 009903ec17
3 changed files with 36 additions and 23 deletions

View File

@@ -2,30 +2,29 @@
#include "Arduino.h"
#include "buttons.h"
// extern c_button button1;
// extern c_button button2;
// extern c_button button3;
uint8_t patternIndex = 0;
//uint8_t nextPatternIndex = 1;
bool patternFlag = false;
bool firstpattern = false;
e_ledcolor cheatbutton = NONE;
//e_ledcolor cheatbutton = NONE;
uint16_t cheatbutton = 0;
bool cheatButtonFlag = false;
// uint8_t ledpattern[4][3] = {
// {1, 0, 0},
// {0, 0, 1},
// {1, 0, 0},
// {0, 1, 0},
// };
e_ledcolor ledpattern[4] =
{
YELLOW,
GREEN,
YELLOW,
RED};
// e_ledcolor ledpattern[4] =
// {
// YELLOW,
// GREEN,
// YELLOW,
// RED};
uint16_t ledpattern[4] =
{
1,
3,
1,
2
};
int patternlength = sizeof(ledpattern) / sizeof(ledpattern[0]);
@@ -86,16 +85,16 @@ void HandleChainGame(void)
}
//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;
}
}