If you want forum members to read your code, its best to post it in line, between code tags, like below and as described in the forum guide in the "please read" sticky post. Most forum members use smart phones and tablets to view the forum most of the time, and can't open .ino files.
// RGB matrix Panel - Version: 1.1.0
#include <RGBmatrixPanel.h>
#include <gamma.h>
// USE THIS ON ARDUINO MEGA
#define OE 9
#define LAT 10
#define CLK 11
#define A A0
#define B A1
#define C A2
#define D A3
int colorRed, colorBlue, colorBlack, colorGreen, colorWhite;
int Matchnum,Racknum;
int BreakerMatchBalls,MatchInnings,MatchDeads,RackerMatchBalls;
int BreakerRackBalls,RackInnings,RackDeads,RackerRackBalls;
int MatchSplit1,MatchSplit2,pos,data;
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64);
const byte numChars = 64;
char receivedChars[numChars];
boolean newData = false;
void setup() {
//virtual serial port bluetooth configuration
Serial3.begin(9600);
Serial3.println("<BT Arduino is ready>");
matrix.begin(); {
colorRed = matrix.Color333(1, 0, 0);
colorBlue = matrix.Color333(0, 0, 3);
colorGreen = matrix.Color333(0, 2, 0);
colorBlack = matrix.Color333(0, 0, 0);
colorWhite = matrix.Color333(2, 2, 2);
// fill the screen with 'black'
matrix.fillScreen(colorBlack);
// layout the screen
matrix.drawRect(0, 0, matrix.width(),matrix.height(), colorGreen); // green frame
matrix.drawLine(1, 10, matrix.width()-2,10,colorRed); // red horiz line 1
matrix.drawLine(1, 20, matrix.width()-8,20,colorRed); // red horiz line 2
matrix.drawLine(14,1,14,9,colorRed); // red vert 1 row 1
matrix.drawLine(34,1,34,9,colorRed); // red vert 2 row 2
matrix.drawLine(14,11,14,19,colorRed); // red vert 1 row 2
matrix.drawLine(28,11,28,19,colorRed); // red vert 2 row 2
matrix.drawLine(42,11,42,19,colorRed); // red vert 3 row 2
matrix.drawLine(56,11,56,19,colorRed); // red vert 4 row 2
matrix.drawLine(14,21,14,30,colorRed); // red vert 1 row 3
matrix.drawLine(28,21,28,30,colorRed); // red vert 2 row 3
matrix.drawLine(42,21,42,30,colorRed); // red vert 3 row 3
matrix.drawLine(56,21,56,30,colorRed); // red vert 4 row 3
// fill in the constant text
matrix.setTextSize(1); // size 1 == 8 pixels high
matrix.setTextWrap(false); // Don't wrap at end of line - will do ourselves
matrix.setTextColor(colorBlue); // Match label
matrix.setCursor(2,2);
matrix.print("M");
matrix.setTextColor(colorGreen); // Rack label
matrix.setCursor(16,2);
matrix.print("R");
} //matrix
} //setup
void loop() {
recvWithStartEndMarkers();
showNewData();
} //loop
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
if (Serial3.available() > 0) {
while (Serial3.available() > 0 && newData == false) {
rc = Serial3.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
} //recvWithStartEndMarkers
void showNewData() {
if (newData == true) {
/*Serial3.print("Data ... ");
Serial3.println(receivedChars);*/
newData = false;
ParseRcvdData();
}
} //showNewData
void ParseRcvdData(){
int pos = atoi(&receivedChars[0]);
int data = atoi(&receivedChars[3]);
ConvertToScreenLoc(pos,data); //rowx,posx,datay
} //ParseRcvdData
void ConvertToScreenLoc(int pos,int data){
switch(pos){
case 11: Matchnum=data;break;
case 12:Racknum=data;break;
case 13:MatchSplit1=data;break;
case 14:MatchSplit2=data;break;
case 21:BreakerMatchBalls=data;break;
case 22:MatchInnings=data;break;
case 23:MatchDeads=data;break;
case 24:RackerMatchBalls=data;break;
case 31:BreakerRackBalls=data;break;
case 32:RackInnings=data;break;
case 33:RackDeads=data;break;
case 34:RackerRackBalls=data;break;
}
WriteToMatrix();
} //ConvertToScreenLoc
void WriteToMatrix(){
// setup for the variabes positioning
// Match #
matrix.fillRect(8,2,5,7,colorBlack); //Clear previous data
matrix.setTextColor(colorBlue);
matrix.setCursor(8,2);
matrix.print(Matchnum);
//Racknum
matrix.setTextColor(colorGreen);
matrix.fillRect(22,2,11,7,colorBlack);
if (Racknum > 9)
{
matrix.setCursor(22,2);
matrix.print(Racknum);
}
else
{
matrix.setCursor(25,2);
matrix.print(Racknum);
}
// Night Split
/* 3 pieces. matchsplit1 is our score
a dash
Matchsplit2 is Opp score */
matrix.fillRect(36,2,27,7,colorBlack);
matrix.setTextColor(colorWhite);
matrix.drawLine(48,6,49,6,colorWhite); // dash btwn split
if (MatchSplit1 > 9)
{
matrix.setCursor(36,2);
matrix.print(MatchSplit1);
}
else
{
matrix.setCursor(42,2);
matrix.print(MatchSplit1);
}
matrix.setCursor(51,2);
matrix.print(MatchSplit2);
//BreakerMatchBalls
matrix.fillRect(2,12,11,7,colorBlack);
matrix.setTextColor(colorBlue);
if (BreakerMatchBalls > 9)
{
matrix.setCursor(2,12);
matrix.print(BreakerMatchBalls);
}
else
{
matrix.setCursor(5,12);
matrix.print(BreakerMatchBalls);
}
// MatchInnings 16,12
matrix.fillRect(16,12,11,7,colorBlack);
if (MatchInnings > 9)
{
matrix.setCursor(16,12);
matrix.print(MatchInnings);
}
else
{
matrix.setCursor(19,12);
matrix.print(MatchInnings);
}
// MatchDeads 30,12
matrix.fillRect(30,12,11,7,colorBlack);
if (MatchDeads > 9)
{
matrix.setCursor(30,12);
matrix.print(MatchDeads);
}
else
{
matrix.setCursor(33,12);
matrix.print(MatchDeads);
}
// RackerMatchBalls 44,12
matrix.fillRect(44,12,11,7,colorBlack);
if (RackerMatchBalls > 9)
{
matrix.setCursor(44,12);
matrix.print(RackerMatchBalls);
}
else
{
matrix.setCursor(47,12);
matrix.print(RackerMatchBalls);
}
// enter data for current rack
matrix.fillRect(2,22,11,7,colorBlack);
matrix.setTextColor(colorGreen);
// Breaker Rack Balls
if (BreakerRackBalls > 9)
{
matrix.setCursor(2,22); // Breaker Rack Balls
matrix.print(BreakerRackBalls);
}
else
{
matrix.setCursor(5,22); // Racker Rack Balls
matrix.print(BreakerRackBalls);
}
//RackInnings
matrix.fillRect(16,22,11,7,colorBlack);
if (RackInnings > 9)
{
matrix.setCursor(16,22);
matrix.print(RackInnings);
}
else
{
matrix.setCursor(19,22); // Racker Rack Balls
matrix.print(RackInnings);
}
// RackDeads
matrix.fillRect(30,22,11,7,colorBlack);
if (RackDeads > 9)
{
matrix.setCursor(30,22);
matrix.print(RackDeads);
}
else
{
matrix.setCursor(33,22); // Racker Rack Balls
matrix.print(RackDeads);
}
//RackerRackBalls
matrix.fillRect(44,22,11,7,colorBlack);
if (RackerRackBalls > 9)
{
matrix.setCursor(44,22); // Racker Rack Balls
matrix.print(RackerRackBalls);
}
else
{
matrix.setCursor(47,22); // Racker Rack Balls
matrix.print(RackerRackBalls);
}
} //WriteToMatrix