fixed chaingame and made simpleled game follow idx
This commit is contained in:
@@ -10,6 +10,8 @@ uint8_t patternIndex = 0;
|
|||||||
uint8_t nextPatternIndex = 1;
|
uint8_t nextPatternIndex = 1;
|
||||||
bool patternFlag = false;
|
bool patternFlag = false;
|
||||||
bool firstpattern = false;
|
bool firstpattern = false;
|
||||||
|
e_ledcolor cheatbutton = NONE;
|
||||||
|
bool cheatButtonFlag = false;
|
||||||
|
|
||||||
// uint8_t ledpattern[4][3] = {
|
// uint8_t ledpattern[4][3] = {
|
||||||
// {1, 0, 0},
|
// {1, 0, 0},
|
||||||
@@ -45,19 +47,39 @@ void HandleChainGame(void)
|
|||||||
{
|
{
|
||||||
turnOnLed(ledpattern[patternIndex]);
|
turnOnLed(ledpattern[patternIndex]);
|
||||||
patternFlag = true;
|
patternFlag = true;
|
||||||
|
cheatbutton = NONE;
|
||||||
}
|
}
|
||||||
else if (!buttonIsPressed(ledpattern[patternIndex]))
|
else if (buttonIsPressed(cheatbutton))
|
||||||
{
|
{
|
||||||
|
turnOnLed(cheatbutton);
|
||||||
|
cheatButtonFlag = true;
|
||||||
|
}
|
||||||
|
else if (!anybutton())
|
||||||
|
{
|
||||||
|
turnOffAllLed();
|
||||||
if (patternFlag)
|
if (patternFlag)
|
||||||
{
|
{
|
||||||
patternFlag = false;
|
patternFlag = false;
|
||||||
nextPattern();
|
nextPattern();
|
||||||
}
|
}
|
||||||
turnOffLed(ledpattern[patternIndex]);
|
if(cheatButtonFlag)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
turnOffAllLed();
|
cheatButtonFlag = false;
|
||||||
|
cheatbutton = NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buttonIsPressed(YELLOW2))
|
||||||
|
{
|
||||||
|
cheatbutton = YELLOW;
|
||||||
|
}
|
||||||
|
else if(buttonIsPressed(RED2))
|
||||||
|
{
|
||||||
|
cheatbutton = RED;
|
||||||
|
}
|
||||||
|
else if(buttonIsPressed(GREEN2))
|
||||||
|
{
|
||||||
|
cheatbutton = GREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (buttonIsPressed(YELLOW) | buttonIsPressed(RED) | buttonIsPressed(GREEN))
|
// if (buttonIsPressed(YELLOW) | buttonIsPressed(RED) | buttonIsPressed(GREEN))
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void initLeds(void)
|
|||||||
ledlist.init();
|
ledlist.init();
|
||||||
ledlist.AddLed(LED1, DETECT1, 1, 844, YELLOW, false);
|
ledlist.AddLed(LED1, DETECT1, 1, 844, YELLOW, false);
|
||||||
ledlist.AddLed(LED2, DETECT2, 2, 512, RED, false);
|
ledlist.AddLed(LED2, DETECT2, 2, 512, RED, false);
|
||||||
ledlist.AddLed(LED3, DETECT3, 2, 92, GREEN, false);
|
ledlist.AddLed(LED3, DETECT3, 3, 92, GREEN, false);
|
||||||
|
|
||||||
ledlist.begin();
|
ledlist.begin();
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/main.cpp
13
src/main.cpp
@@ -31,19 +31,26 @@ uint64_t GameSelectTimer = 0;
|
|||||||
void HandleIdle(void)
|
void HandleIdle(void)
|
||||||
{
|
{
|
||||||
//green button first released
|
//green button first released
|
||||||
if (buttonIsPressed(YELLOW) && !buttonIsPressed(RED) && buttonIsPressed(GREEN) && (nextGame == none))
|
if (!buttonIsPressed(YELLOW) && buttonIsPressed(RED) && buttonIsPressed(GREEN) && (nextGame == none))
|
||||||
{
|
{
|
||||||
//prepare for next game
|
//prepare for next game
|
||||||
nextGame = ChainGame;
|
nextGame = ChainGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
//yellow button first released
|
//red button first released
|
||||||
if (buttonIsPressed(YELLOW) && buttonIsPressed(RED) && !buttonIsPressed(GREEN) & (nextGame == none))
|
if (buttonIsPressed(YELLOW) && !buttonIsPressed(RED) && buttonIsPressed(GREEN) & (nextGame == none))
|
||||||
{
|
{
|
||||||
//prepare for next game
|
//prepare for next game
|
||||||
nextGame = magicSwitchBoard;
|
nextGame = magicSwitchBoard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//green button first released
|
||||||
|
if (buttonIsPressed(YELLOW) && buttonIsPressed(RED) && !buttonIsPressed(GREEN) & (nextGame == none))
|
||||||
|
{
|
||||||
|
//prepare for next game
|
||||||
|
nextGame = detectLED;
|
||||||
|
}
|
||||||
|
|
||||||
//wait for all buttons to be switched off
|
//wait for all buttons to be switched off
|
||||||
if (!anybutton())
|
if (!anybutton())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ void handleSimpleLed(void)
|
|||||||
{
|
{
|
||||||
if (button->isPressed())
|
if (button->isPressed())
|
||||||
{
|
{
|
||||||
turnOnLed(button->getColor());
|
turnOnLed(button->getIndex());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
turnOffLed(button->getColor());
|
turnOffLed(button->getIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user