#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);
label*      ourLabel;

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");
   ourLabel->setTextSize(2);
   ourLabel->setColors(&white,&blue);
   viewList.addObj(ourLabel);

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


void purpleClick(void) {

   if (purpleButton.trueFalse()) {
      ourLabel->setValue("Test");
   } else {
      ourLabel->setValue("OH NO!!");
   }
}


// During loop..
void loop() {     
   
  idle();         // Idlers get their time.
 
}
Loading
ili9341-cap-touch