#include <SD.h>
#include <adafruit_1947_Obj.h>
#include <idlers.h>
#include <screen.h>
#include <colorRect.h>
#include <label.h>
#include <mechButton.h>
#include <iconButton.h>
#define BTN_PATH "system/icons/standard/trashC32.bmp"
mechButton purpleButton(28); // The mechanical button object.
label* ourLabel; // A global text label pointer. (Created later)
void setup() {
Serial.begin(115200); // Fire up serial for debugging.
while (!Serial) {
delay(10); // wait for serial port to connect. Needed for native USB
}
Serial.println("Hello?");
if (!initScreen(ADAFRUIT_1947,ADA_1947_SHIELD_CS,PORTRAIT)) { // Init screen.
Serial.println("NO SCREEN!"); // Screen init failed. Tell user.
Serial.flush(); // Make sure the message gets out.
while(true); // Lock the process here.
}
Serial.println("GOT SCREEN!");
if (!SD.begin(ADA_1947_SHIELD_SDCS)) { // With icons, we now MUST have an SD card.
Serial.println("NO SD CARD!"); // Tell user we have no SD card.
Serial.flush(); // Make sure the message gets out.
while(true); // Lock the process here.
}
Serial.println("GOT SD CARD!");
screen->fillScreen(&blue); // Lets set the screen to.. Blue?
colorRect* aRect = new colorRect(40,40,100,100,&green); // Make a green rectangle.
viewList.addObj(aRect); // And add that rectangle to the screen.
ourLabel = new label(40,180,100,18,"Test"); // Create the text label.
ourLabel->setTextSize(2); // Set the text size.
ourLabel->setColors(&white,&blue); // Set it's colors.
viewList.addObj(ourLabel); // Add this label to the screen.
iconButton* aBtn = new iconButton(40,220,BTN_PATH); // Create an iconn button.
if (aBtn) { // If we got one..
Serial.println("GOT ICON"); // Tell the world we got one.
viewList.addObj(aBtn); // Add it to the list.
} else { // Else it was NULL..
Serial.println("NO ICON"); // Tell the world we didn't get one.
}
purpleButton.setCallback(purpleClick); // Hook the button to a callback.
}
// When the mechanical button gets clicked, or un-clicked, this function is called.
void purpleClick(void) {
if (purpleButton.trueFalse()) {
ourLabel->setValue("Test");
} else {
ourLabel->setValue("OH NO!!");
}
}
// During loop..
void loop() {
idle(); // Idlers get their time. (Buttons, screen things, etc.)
delay(1);
}
Loading
ili9341-cap-touch
ili9341-cap-touch