updated 7seg controls for new 7 seg boards
Dependencies: PixelArray WS2812 mbed
Fork of frdm_pong_table_controller by
main.h
- Committer:
- DanGibbons
- Date:
- 2017-07-10
- Revision:
- 6:5e8e2645cd93
- Parent:
- 5:2d439ccefc7d
- Child:
- 7:dc6f1f105c52
File content as of revision 6:5e8e2645cd93:
#ifndef MAIN_H #define MAIN_H #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); InterruptIn idleButton(PTB2); // 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 mainArray[11][122]; int rand_colors[] = {0x00FF00, 0x7FFF00, 0xFFFF00, 0xFF7F00, 0xFF0000, 0xFE00FF, 0x7F00FF, 0x0000FF, 0x007FFF, 0x00FFFE, 0x00FF7F}; // Score counters int robotScore; int playerScore; int scoreLimit = 3; bool finishedGame = false; int endFlashes = 3; int numFlashes; // Flags volatile int idle_flag = 0; // Robot Bream Beam value double prevRbbValue; // Previous Robot break beam value double prevPbbValue; // Previous player break beam value // FUNCTION DECLERATIONS void Setup(); // initial pattern void SetNumberPatterns(); // sets segment patterns for numbers void SetLEDArray(int x); // sets segment patterns in mainArray void WriteAnimation(); // writes scores to the LEDs void WritePxAnimation(int line_num,bool isRobot,bool colour); // writes mainArray to either LED buffer in blue or random colours void HandleGoal(bool hasRobotScored); void HandleWin(); void GoalAnimation(bool hasRobotScored); void WinAnimation(bool isRobotWinner); void CircleAnimation(bool robot, bool robotColour,bool player, bool playerColour, int numberOfRepitions); void DrainAnimation(bool robot, bool robotColour, int robotScore, bool player, bool playerColour, int playerScore); void ZeroInAnimation(bool robot, bool robotColour,bool player, bool playerColour); void ZeroOutAnimation(bool robot, bool robotColour,bool player, bool playerColour); void OneInAnimation(bool robot, bool robotColour,bool player, bool playerColour); void OneOutAnimation(bool robot, bool robotColour,bool player, bool playerColour); void TwoInAnimation(bool robot, bool robotColour,bool player, bool playerColour); void TwoOutAnimation(bool robot, bool robotColour,bool player, bool playerColour); void ThreeInAnimation(bool robot, bool robotColour,bool player, bool playerColour); void ThreeOutAnimation(bool robot, bool robotColour,bool player, bool playerColour); // ISRs void idleButtonISR(); #endif