Skip to content

Commit

Permalink
Added Serial input
Browse files Browse the repository at this point in the history
Code for first finals match
  • Loading branch information
rsammelson committed Mar 25, 2017
1 parent d38523c commit 14ca139
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 77 deletions.
9 changes: 6 additions & 3 deletions Run_Bling.ino
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ void runBling (int order[]) {
Serial.print("d");
Reset();
Serial.println("one");
// if (Serial.available() > 0) {
// setTeam();
// }
if (Serial.available() > 0) {
bool a = serialInterp();
if (a) {
return;
}
}
}
}
117 changes: 44 additions & 73 deletions _0-_Main_Bling.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <Fonts/FreeSerif12pt7b.h>
#include <EEPROM.h>

// --------------------------------------- begin define --------------------------------------- //

#define MATRIX 6
#define pixyRingPin 8
#define gearStringPin 7
Expand Down Expand Up @@ -41,14 +43,21 @@ const bool oneOfEach = true;
#define WHITE matrix.Color(255, 255, 255)
#define BLACK matrix.Color(0, 0, 0)

#define TESTING false

//#define VERTICAL_FONT

// ---------------------------------------- end define ---------------------------------------- //

bool testing = false;

//Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(WIDTH, HEIGHT, 1, NUMBER, MATRIX, NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_COLUMNS + NEO_TILE_ZIGZAG + NEO_MATRIX_COLUMNS + NEO_MATRIX_TOP + NEO_MATRIX_BOTTOM + NEO_MATRIX_ZIGZAG + NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(WIDTH, HEIGHT, 1, NUMBER, MATRIX, NEO_TILE_BOTTOM + NEO_TILE_RIGHT + NEO_TILE_COLUMNS + NEO_TILE_ZIGZAG + NEO_MATRIX_COLUMNS + NEO_MATRIX_TOP + NEO_MATRIX_BOTTOM + NEO_MATRIX_ZIGZAG + NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixyRing = Adafruit_NeoPixel(pixyRingNum, pixyRingPin, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel gearString = Adafruit_NeoPixel(gearStringNum, gearStringPin, NEO_GRB + NEO_KHZ800);

int ledNumber;
//bool noSerial = true;

const String subteams[23] = {"Shout-", " out", "to our", "sub-", " teams", "Media", "Chair-", " mans", "CAD", "Anim-", " ation",
"Wood-", " work-", " ing", "Fund-", " rais-", " ing", "Out-", " reach", "Scout-", " ing", "Spirit"
Expand Down Expand Up @@ -118,13 +127,15 @@ void credits (String Messages[], uint16_t colors[], int LoopSize, int Delay = 0,

// ==============================================

// put your setup code here, to run once:
void setup() {
// put your setup code here, to run once:
Serial.begin(250000);
Serial.setTimeout(5);
Serial.println('\n');
ledNumber = WIDTH * HEIGHT * NUMBER;
setupPins();
// loadBitmap();
// load bitmap doesn't work
// loadBitmap();
matrix.begin();
matrix.show();
gearString.begin();
Expand All @@ -136,87 +147,47 @@ void setup() {
Serial.println("Microseconds: " + String(micros()));
brightnessControl();
randSeed();
blingSelect();

// printBitmap(firstLogo);
// if (testing) {
// noSerial = false;
// }
}

// put your main code here, to run repeatedly:
void loop() {
// put your main code here, to run repeatedly:
// int co[] = {0, 0, 255};
// printText("hi", co, 10, false);
// theaterChase(3, 0, matrix.Color(0, 255, 0), true);
// strobePixel(1000, 0, matrix.Color(255, 255, 255));
// rectangleZoom(0,0,32,16, matrix.Color(255, 0, 0), 0);
// matrix.fillScreen(matrix.Color(200, 200, 200));
// matrix.show();
// matrix.clear();
// matrix.show();
// rDraw(800, matrix.Color(0, 255, 255), 9, 0, true);
// matrix.clear();
// updateScreen();
// delay(300);

// if (digitalRead(gearSensePin) == LOW) {
// Serial.println("on***");
// pixelAlert();
// Serial.println("off***");
// }
// delay(99);
// printToString(gearString, 200, 0, 200);
// zigZag(5000, matrix.Color(255, 0, 0));


// runBling(blingPrograms);
// Reset();
// blingSelect(); delay(100);
// drawTriangleCenter(matrix.width() / 4, matrix.height() / 2, 3, matrix.Color(255, 0, 0));
// screenSaver(10000, 6, 6, 7, 50);
// updateScreen();
// delay(10000);
// Reset();
// Serial.println("done");
// delay(1000);

// spot(7000, 5, 10, true);
// Reset();
// delay(1000);
// if running bling
if (!testing) {
Serial.println("Starting Bling...");
bling();
} else { // if testing
Serial.println("Starting Test...");
test();
}
if (Serial.available() > 0) {
serialInterp();
}
}

bling();
// for running bling
void bling () {
blingSelect();
runBling(blingPrograms);
Reset();
delay(100);
}

// for running test code
void test () {
// sinWaveM(matrix.Color(255, 255, 255), 0, 2500, 25, 2);
// Reset();
// delay(2000);

// creditsPrint ("PhyXT", matrix.Color(255, 0, 0), 100, true, "Gears", matrix.Color(0, 255, 0), true, "GO", matrix.Color(0, 0, 255));
// String m1[] = {"1", "22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"};
/*
int loopSize = sizeof(subteams) / sizeof(subteams[0]);
Serial.println("Loop size: " + String(loopSize));
uint16_t c1[] = {matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255), matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255),matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255)};
credits (subteams, c1, 0, 20, loopSize, true);
Reset();
delay(2500);*/

// audioBar(5000, 4);
// Reset();
// delay(2500);


// drawShip(20, 7, 2, WHITE);

// for (float i = 0; i <= 2; i += 0.1) {
// drawShip(20, 7, i, WHITE);
// matrix.clear();
// }
// delay(2500);
// Reset();
// delay(500);
}

void bling () {
runBling(blingPrograms);
for (float i = 0; i <= 2; i += 0.1) {
drawShip(20, 7, i, WHITE);
matrix.clear();
}
delay(2500);
Reset();
blingSelect();
delay(100);
delay(500);
}
74 changes: 73 additions & 1 deletion _Basic_Control.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void Reset () {
clearScreen();
updateScreen();
progBright = false;
// matrix.setFont(&FONT);
// matrix.setFont(&FONT);
}

void setupPins () {
Expand All @@ -52,3 +52,75 @@ void brightOver (int b) {
progBright = true;
bright = b;
}

bool serialInterp () {
// if (noSerial) {
// Serial.println("Serial is disabled");
// return false;
// }
while (Serial.available() > 0) {
Serial.readString();
}
Serial.println("What would you like to do?");
Serial.println("\ttest");
Serial.println("\tbling");
Serial.println("\tteam");
String in = serialIn();
Serial.println(in);
in.toUpperCase();
if (in == "TEST" || in == "TEST\n") {
if (serialBool("Would you like to enter test mode? ")) {
testing = true;
return true;
} else {
return false;
}
} else if (in == "BLING" || in == "BLING\n") {
if (serialBool("Would you like to enable bling? ")) {
testing = false;
return true;
} else {
return false;
}
} else if (in == "TEAM" || in == "TEAM\n") {
Serial.print("Team Slot Number: ");
int teamS = Serial.parseInt();
Serial.println(teamS);
if (serialBool("Would you like to enable bling? ")) {
testing = false;
return true;
} else {
return false;
}
}
}

/*
else if (in == "DISABLE" || in == "DISABLE\n") {
if (serialBool("Would you like to disable Serial? ")) {
noSerial = true;
return true;
} else {
return false;
}
*/

bool serialBool (String message) {
Serial.print(message);
String in = serialIn();
Serial.println(in);
in.toUpperCase();
if (in == "Y" || in == "YES") {
Serial.println("Yes");
return true;
} else {
Serial.println("No");
return false;
}
}

String serialIn () {
while (Serial.available() < 1) {}
return Serial.readString();
}

0 comments on commit 14ca139

Please sign in to comment.