updated 7seg controls for new 7 seg boards
Dependencies: PixelArray WS2812 mbed
Fork of frdm_pong_table_controller by
Diff: main.h
- Revision:
- 4:2e80bd814f57
- Child:
- 5:2d439ccefc7d
diff -r 51604b5710f1 -r 2e80bd814f57 main.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Wed Jul 05 15:23:44 2017 +0000 @@ -0,0 +1,74 @@ +#include "mbed.h" +#include "WS2812.h" +#include "PixelArray.h" + +#define WS2812_BUF 122 +#define NUM_COLORS 6 +#define NUM_LEDS_PER_COLOR 1 + +//-------- Colours ----------- +#define RED 0x2f0000 +#define YELLOW 0x2f2f00 +#define GREEN 0x002f00 +#define LIGHTBLUE 0x002f2f +#define DARKBLUE 0x00002f +#define BLUE 0x0000ff // Player scored a goal +#define PINK 0x2f002f +#define OFF 0x000000 +#define WHITE 0xffffaa +#define ARMBLUE 0x128BAB +#define PURPLE 0xff0055 // Player has conceded a goal + +// Goal Sensors +AnalogIn robotBreakBeam(A0); +AnalogIn playerBreakBeam(A1); + +// K64F On-board LED +DigitalOut led_green(LED_GREEN, 1); + +//K64F On-board Switches +DigitalIn PB1(PTC6); +DigitalIn PB2(PTA4); + +// SERIAL +Serial pc(USBTX, USBRX); // tx, rx + +// LED STRIPS +// See the program page for information on the timing numbers +// The given numbers are for the K64F +WS2812 robotScoreLED(D3, WS2812_BUF, 0, 5, 5, 0); +WS2812 playerScoreLED(D5,WS2812_BUF, 0, 5, 5, 0); +PixelArray robotScorePx(WS2812_BUF); +PixelArray playerScorePx(WS2812_BUF); + + +// LED Variables +bool seg1A, seg1B, seg1C, seg1D, seg1E, seg1F, seg1G; +//int seg1Array[122]; +int mainArray[11][122]; + +// Score counters +int robotScore; +int playerScore; +int scoreLimit = 3; +bool finishedGame = false; +int endFlashes = 3; +int numFlashes; + +// Robot Bream Beam value +double prevRbbValue; // Previous Robot break beam value +double prevPbbValue; // Previous player break beam value + +// FUNCTION DECLERATIONS +void Setup(); +void SetNumberPatterns(); +void SetFigureOf8Pattern(); +void SetLEDArray(int x); +void WriteScores(); +void HandleGoal(bool hasRobotScored); +void WritePxScores(int line_num, bool isRobot); +void WritePxGoal(unsigned int colour,bool isRobot); +void HandleWin(); +void GoalAnimation(bool hasRobotScored); +void WinAnimation(bool isRobotWinner); +void FigureOf8Animation(); \ No newline at end of file