Changed to JC_button lib
This commit is contained in:
74
src/main.cpp
74
src/main.cpp
@@ -1,20 +1,24 @@
|
||||
#include <Arduino.h>
|
||||
#include "buttons.h"
|
||||
//#include "buttons.h"
|
||||
#include "board.h"
|
||||
#include "chainGame.h"
|
||||
#include "detectled.h"
|
||||
#include "magicSwitchBoard.h"
|
||||
#include "buttons.h"
|
||||
#include "JC_Button.h"
|
||||
#include "vector"
|
||||
|
||||
buttons button1(SWITCH12, 100, 1000, 1);
|
||||
buttons button2(SWITCH22, 100, 1000, 2);
|
||||
buttons button3(SWITCH32, 100, 1000, 3);
|
||||
buttons button4(SWITCH1, 100, 1000, 4);
|
||||
buttons button5(SWITCH2, 100, 1000, 5);
|
||||
buttons button6(SWITCH3, 100, 1000, 6);
|
||||
// extern ToggleButton button1;
|
||||
// extern ToggleButton button2;
|
||||
// extern ToggleButton button3;
|
||||
extern ToggleButton button4;
|
||||
extern ToggleButton button5;
|
||||
extern ToggleButton button6;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
none,
|
||||
powerOff,
|
||||
ChainGame,
|
||||
magicSwitchBoard,
|
||||
detectLED,
|
||||
@@ -31,28 +35,8 @@ void setup()
|
||||
pinMode(LED2, OUTPUT);
|
||||
pinMode(LED3, OUTPUT);
|
||||
|
||||
initbuttons();
|
||||
|
||||
initButtons();
|
||||
initDetectLed();
|
||||
|
||||
while (anybutton())
|
||||
{
|
||||
digitalWrite(LED1, 1);
|
||||
digitalWrite(LED2, 1);
|
||||
digitalWrite(LED3, 1);
|
||||
if (button4.raw())
|
||||
{
|
||||
currentGame = ChainGame;
|
||||
}
|
||||
if (button5.raw())
|
||||
{
|
||||
currentGame = magicSwitchBoard;
|
||||
}
|
||||
if (button6.raw())
|
||||
{
|
||||
currentGame = detectLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
@@ -78,5 +62,39 @@ void loop()
|
||||
{
|
||||
HandleChainGame();
|
||||
}
|
||||
break;
|
||||
|
||||
case none:
|
||||
{
|
||||
|
||||
digitalWrite(LED1, 0);
|
||||
digitalWrite(LED2, 0);
|
||||
digitalWrite(LED3, 0);
|
||||
if (button4.isPressed())
|
||||
{
|
||||
digitalWrite(LED1, 1);
|
||||
}
|
||||
if (button5.isPressed())
|
||||
{
|
||||
currentGame = magicSwitchBoard;
|
||||
digitalWrite(LED2, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentGame = ChainGame;
|
||||
}
|
||||
|
||||
if (button6.isPressed())
|
||||
{
|
||||
digitalWrite(LED3, 1);
|
||||
}
|
||||
|
||||
while(anybutton());
|
||||
// if (button6.isPressed())
|
||||
// {
|
||||
// currentGame = detectLED;
|
||||
// }
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user