// ************************************************************************************************
//
// Documentation for this, and the rest of the LC libraies that make this up.
// Here's the book : https://github.com/leftCoast/LC_libraryDocs/blob/main/LC_libraries.pdf
// Search for : OIandKeys
//
// ************************************************************************************************
#include <SD.h>
#include <serialStr.h>
#include <colorRect.h>
#include <adafruit_1947.h> // Screen lib.
#include <eventMgr.h> // Interaction manager.
#include <IOandKeys.h>
#define DSP_CS 10 // Display chip select
#define MAX_TXT 650
serialStr serialMgr;
colorObj backColor; // We setup a colorObj for the backGndRect color of the display.
editLabel* ourEditLabel;
textView* ourTextView;
IOandKeys* ourIO_Keys;
char msgBuff[80];
// 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(115200);
Serial.println("IO and Keys - Type remote message here.");
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.
ourEventMgr.begin(); // We are looking for touch sceen action! Fire up the even manager.
serialMgr.setCallback(gotStr); // Who gets the incoming string?
setupScreen(); // Populate the screen.
return; // Everything fired up successfuly. Lets go! //
} //
} else { // Else the display didn't.
Serial.println("NO SCREEN!"); // Send an error out the serial port.
} //
Serial.println("Locking process."); // Tell 'em
while(true)delay(10); // Lock processor here forever.
}
void setupKeyColors(void){
kbPallette.inputKeyText.setColor(&yellow);
kbPallette.inputKeyBase.setColor(LC_CHARCOAL);
kbPallette.inputKeyHText.setColor(&black);
kbPallette.inputKeyHBase.setColor(&white);
kbPallette.contolKeyText.setColor(&yellow);
kbPallette.contolKeyBase.setColor(LC_CHARCOAL);
/*
kbPallette.contolKeyHText
kbPallette.contolKeyHBase
*/
kbPallette.deleteKeyText.setColor(&white);
kbPallette.deleteKeyBase.setColor(&red);
kbPallette.deleteKeyBase.blend(&black,20);
/*
kbPallette.deleteKeyHText
kbPallette.deleteKeyHBase
*/
}
// Extension to setup() that puts all the scren bits and things together.
void setupScreen(void) {
colorRect outline;
colorRect backGnd;
setupKeyColors();
screen->fillScreen(&black); // A command to "screen" happens (NOW). Objects update later.
outline.setColor(&black);
outline.setInset(2);
backGnd.setColor(&green);
backGnd.blend(&black,80);
ourEditLabel = new editLabel(20,170,200,20);
ourEditLabel->setTextSize(2);
//ourEditLabel->setEventSet(touchLift);
ourEditLabel->setColors(&green,&backGnd);
//ourEditLabel->beginEditing();
outline.setRect(ourEditLabel);
backGnd.setRect(ourEditLabel);
outline.insetRect(-7);
backGnd.insetRect(-5);
outline.draw();
backGnd.draw();
ourTextView = new textView(20,20,200,130);
ourTextView->setTextColors(&green,&backGnd);
outline.setRect(ourTextView);
backGnd.setRect(ourTextView);
outline.insetRect(-7);
backGnd.insetRect(-5);
outline.draw();
backGnd.draw();
ourIO_Keys = new IOandKeys(ourEditLabel,ourTextView);
ourIO_Keys->loadKeys();
viewList.addObj(ourEditLabel);
viewList.addObj(ourIO_Keys);
viewList.addObj(ourTextView);
}
// Incoming message? Display it.
void gotStr(char* inStr){
ourTextView->appendText(inStr);
ourTextView->appendText("\n");
}
// In loop, make a call to idle.
void loop() {
int numChars;
idle(); // D0 the magic.
if (ourIO_Keys->haveBuff()) { // If there's a new string to send..
ourIO_Keys->getBuff(msgBuff,80); // Grab the string.
} //
numChars = strlen(ourTextView->seeText()); // Count the chars in the display.
if (numChars>MAX_TXT) { // If we have too many?
ourTextView->deleteText(0,10); // Lop some off.
} //
}
Loading
ili9341-cap-touch
ili9341-cap-touch