updated 7seg controls for new 7 seg boards

Dependencies:   PixelArray WS2812 mbed

Fork of frdm_pong_table_controller by Demo Team

main.h

Committer:
DanGibbons
Date:
2017-07-06
Revision:
5:2d439ccefc7d
Parent:
4:2e80bd814f57
Child:
6:5e8e2645cd93

File content as of revision 5:2d439ccefc7d:

#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);

// 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];
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;

// 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 SetCirclePattern();
void SetLEDArray(int x);
void WriteScores();
void HandleGoal(bool hasRobotScored);
void WritePxScores(int line_num, bool isRobot);
void WritePxAnimation(int line_num,bool isRobot);
void WritePxScoresRandomColours(int line_num,bool isRobot);
void WritePxGoal(unsigned int colour,bool isRobot);
void HandleWin();
void GoalAnimation(bool hasRobotScored);
void WinAnimation(bool isRobotWinner);
void FigureOf8Animation(bool robot, bool player, int numberOfRepitions);
void CircleAnimation(bool robot, bool player, int numberOfRepitions);
void DrainAnimation(bool robot, bool robotColour, int robotScore, bool player, bool playerColour, int playerScore);

#endif