#include <SD.h>
#include <adafruit_1947_Obj.h>
#include <idlers.h>
#include <screen.h>

#include <colorRect.h>
#include <label.h>
#include <mechButton.h>

mechButton  purpleButton(2);  // The mechanical button object.
label*      ourLabel;         // A global text label pointer. (Created later)

void setup() {
   
   Serial.begin(115200);                                          // Fire up serial for debugging.
   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.
   }
   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.
   }
   
   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,200,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.

   purpleButton.setCallback(purpleClick);                         // Hook the button to a calback.
}


// 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.)
 
}
Loading
ili9341-cap-touch