updated 7seg controls for new 7 seg boards
Dependencies: PixelArray WS2812 mbed
Fork of frdm_pong_table_controller by
Diff: main.cpp
- Revision:
- 11:4a73fdc60de6
- Parent:
- 10:554301a1579b
- Child:
- 12:7f428ce8ab35
--- a/main.cpp Wed Jul 12 10:50:45 2017 +0000 +++ b/main.cpp Tue Aug 01 17:10:22 2017 +0000 @@ -39,9 +39,9 @@ idleButton.setSampleFrequency( 10000 ); // Set brightness of the 4 LED strips - robotScoreLED.setII(0xB0); + robotScoreLED.setII(0x60); robotScoreLED.useII(WS2812::GLOBAL); - playerScoreLED.setII(0xB0); + playerScoreLED.setII(0x60); playerScoreLED.useII(WS2812::GLOBAL); // Set scores to 0 @@ -76,8 +76,27 @@ if (idle_button_pressed == 1) { // button just pressed pc.printf("\nPLAY"); + + if (previous_state == 0) { + + IdleToPlayTransition(); + + } + else { + + idle_button_pressed = 0; - IdleToPlayTransition(); + DrainAnimation(true,false,true,false); + + wait(1); + + robotScore = 0; + + playerScore = 0; + + WriteScores(); + + } } @@ -86,21 +105,21 @@ // IF PLAYER HAS SCORED A GOAL if (((prevRbbValue - rbbValue) > 0.03) || (PB1==0)) { - //pc.printf("Player has scored a goal \n\r"); + pc.printf("Player has scored a goal \n\r"); HandleGoal(false); } // IF ROBOT HAS SCORED A GOAL if (((prevPbbValue - pbbValue) > 0.03) || (PB2==0)) { - //pc.printf("Robot has scored a goal \n\r"); + pc.printf("Robot has scored a goal \n\r"); HandleGoal(true); } prevRbbValue = rbbValue; prevPbbValue = pbbValue; - //pc.printf("PlayerGoal: %f, RobotGoal: %f \r\n",pbbValue,rbbValue); - //pc.printf("Player: %i v %i : Robot \r\n",playerScore,robotScore); + pc.printf("PlayerGoal: %f, RobotGoal: %f \r\n",pbbValue,rbbValue); + pc.printf("Player: %i v %i : Robot \r\n",playerScore,robotScore); } @@ -568,7 +587,7 @@ DrainAnimation(true,false,true,true); // drain both scores away with the player score in random colours // reset robot score brightness - robotScoreLED.setII(0xB0); + robotScoreLED.setII(0x60); robotScoreLED.useII(WS2812::GLOBAL); } else { @@ -587,7 +606,7 @@ DrainAnimation(true,true,true,false); // drain both scores away with the robot score in random colours // reset player score brightness - playerScoreLED.setII(0xB0); + playerScoreLED.setII(0x60); playerScoreLED.useII(WS2812::GLOBAL); } @@ -1601,7 +1620,13 @@ void idleButtonISR() { if (idle_button_pressed == 0) { - idle_flag = !idle_flag; + if (idle_flag == 0) { + previous_state = 0; + } + else { + previous_state = 1; + } + idle_flag = 1; idle_button_pressed = 1; } }