#include <adafruit_1947.h>
#include <liveText.h>
#include <serialStr.h>
#define DSP_CS 10 // Display chip select
liveText* HelloText; // Pointer to a label object for the screen.
serialStr serialMgr; // A manaer for the serial port. Brings in complete messages.
colorObj backColor; // We setup a colorObj for the background color of the display.
// The way setup() works here is mostly for hardware setup. If that all works
// then we go on to setup the srceen object and controls.
void setup() {
Serial.begin(57600); // Fire up serial for debugging.
screen = (displayObj*) new adafruit_1947(DSP_CS,-1); // Create our screen object.
if (screen) { // We got one? Cool!
if (screen->begin()) { // Can we successfully call begin on the screen?
screen->setRotation(PORTRAIT); // Ok, set portrait. Good for handhelds.
setupScreen(); // Populate the screen.
return; // Everything fired up successfuly. Lets go!
} //
} //
Serial.println("NO SCREEN!"); // Send an error out the serial port.
while(true)delay(10); // Lock processor here forever.
}
// When the Serial port sees a message come in. It arrives here.
void newMsg(char* inStr) { HelloText->setValue(inStr); }
// Extension to setup() that puts all the scren bits and things together.
void setupScreen(void) {
int height;
// Setup background display color.
backColor.setColor(&blue); // Set this color object to blue.
backColor.blend(&black,70); // Lets darken it, mixin some black.
screen->fillScreen(&backColor); // A command to "screen" happens (NOW). Objects update later.
// Setup a label we can interact with.
HelloText = new liveText(10,10,300,16,100,true); // location, size,frame rate,loop Y/N
if (HelloText) { // If we got one..
HelloText->setValue("Hello world!"); // Set our message.
HelloText->setTextSize(2); // Make it bigger so we can read it.
HelloText->setColors(&backColor,&backColor); // Initial setting. Also sets background color.
HelloText->addAColor(0,&backColor); // Start at background color.
HelloText->addAColor(250,&yellow); // Fade to yellow.
HelloText->addAColor(2000,&yellow); // Yellow for a sec.
HelloText->addAColor(3000,&red); // Fade to red for a sec.
HelloText->addAColor(3500,&red); // Hold to red for a bit.
HelloText->addAColor(4500,&green); // Fade to green for a sec.
HelloText->addAColor(5500,&green); // Hold green for a sec.
HelloText->addAColor(6000,&backColor); // Fade to back color for a bit.
HelloText->addAColor(7000,&backColor); // Hold back color for a sec.
viewList.addObj(HelloText); // Add the object (It's a pointer) to view list to be managed.
} else { // Didn't get a label?
Serial.println("No label!"); // Tell Miss user.
while(true)delay(10); // Lock processor here forever.
} //
serialMgr.setCallback(newMsg); // Set the callback for when a message comes in from serial.
Serial.println("Type a message for the label"); // Give Miss user a hint.
}
// In loop, to run all of this, all you need is a call to idle.
void loop() { idle(); }