// Use the Parola library to scroll text on the display
//
// Demonstrates the use of the scrolling function to display text received
// from the serial interface
//
// User can enter text on the serial monitor and this will display as a
// scrolling message on the display.
// Speed for the display is controlled by a pot on SPEED_IN analog in.
// Scrolling direction is controlled by a switch on DIRECTION_SET digital in.
// Invert ON/OFF is set by a switch on INVERT_SET digital in.
//
// UISwitch library can be found at https://github.com/MajicDesigns/MD_UISwitch
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 15
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
uint8_t scrollSpeed = 25; // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 1000; // in milliseconds
// Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE 75
//const char Axioms[] = {
char InsertCoin[BUF_SIZE] = "HDCSIT 25A - PTC LAOS";
char ReadyToPlay[BUF_SIZE] = "Hello! Are you ready to play a game?";
char Validation[BUF_SIZE] = "Don't seek validation from others; validate yourself.";
char BeTrue[BUF_SIZE] = "Be true to yourself.";
//};
char Success[BUF_SIZE] = { "Success begins with self-belief" };
char Believe[BUF_SIZE] = { "Believe in yourself!" };
char Fear[BUF_SIZE] = { "Fear is natural; courage is taking action despite it" };
char BeTheChange[BUF_SIZE] = { "Be the change you want to see in the world!" };
char Failures[BUF_SIZE] = { "Failures are opportunities to learn." };
char NeverCompromise[BUF_SIZE] = { "Never compromise your values." };
char VisualizeSuccess[BUF_SIZE] = { "Visualize Success." };
char Forgive[BUF_SIZE] = { "Forgive." };
char BePositive[BUF_SIZE] = { "Be positive!" };
char NeverEver[BUF_SIZE] = { "Never, ever, EVER give up!" };
//char InsertCoin[BUF_SIZE] = { "Forgive yourself." };
//char InsertCoin[BUF_SIZE] = { "Forgive yourself." };
//char InsertCoin[BUF_SIZE] = { "Forgive yourself." };
//char InsertCoin[BUF_SIZE] = { "Forgive yourself." };
//char InsertCoin[BUF_SIZE] = { "Forgive yourself." };
char * Axioms[] = {
InsertCoin,
ReadyToPlay,
Validation,
BeTrue,
};
// char Axioms[] = { Fear, ReadyToPlay, Success, Validation, BeTrue, NeverEver, Believe};
unsigned long PreviousSayingMillis = 0;
bool newMessageAvailable = true;
unsigned long PreviousCountMillis =0;
unsigned long PreviousMillis = 0;
unsigned long CurrentMillis =0;
bool CountdownStart = 1;
int GameTime = 30;
char Choice;
uint8_t degC[] = { 6, 24, 36, 126, 36, 0, 0}; // Deg C
//uint8_t degC[] = { 6, 3, 3, 56, 68, 199, 68 }; // Deg C
void setup() {
Serial.begin(115200);
P.begin();
P.addChar('@', degC);
}
void loop() {
DisplayText();
//CountdownTime();
//testing();
GetSaying();
}
void DisplayText(){
if (P.displayAnimate()){
//Serial.println(Axioms[3]);
P.displayText(Axioms[0], PA_CENTER, 25, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
P.displayReset();
}
}
void CountdownTime() {
if (CountdownStart == 1){
unsigned long CurrentMillis = millis();
if (CurrentMillis - PreviousCountMillis >= 1000) {
PreviousCountMillis = CurrentMillis;
// This is where we update the display on the game clock counting down by seconds.
// And also subtract those seconds from the game timer to know when we get to the end of the game.
GameTime--;
String GameCombined = "00:" + String (GameTime);
Serial.print(GameTime);
P.setTextAlignment(PA_CENTER);
//P.println("00: ");
P.print(GameCombined);
//}
if (GameTime <= 0) {
// Sound an effect for "Game Over".
// Write "Game Over" on the display.
//DropTheClaw(); // Drop the claw wherever it is.
P.print("GAME OVER!");
CountdownStart = 0;
}
}
}
}
void GetSaying() {
unsigned long CurrentMillis = millis();
if (CurrentMillis - PreviousSayingMillis >=5000) {
PreviousSayingMillis = CurrentMillis;
//Choice = Axioms[random(7)];
//Serial.println(Axioms[random(7)]);
}
}