I hope it comes over as very simple to follow...
This is the basic program, all this one does is create a single screen called main_menu, a panel displayed on all screens:
A full demo showing the objects in action is in the download.
//////////////////////////////////////////////////////////////////////////////////////////
// Due GUI Object demonstration sketch
//////////////////////////////////////////////////////////////////////////////////////////
//
// (c) 2013 Darren Hill (Cowasaki)
//
// Version 0.10
//
// This program is not as yet complete. There are a number of missing features and features not fully implemented.
// There is also the possibility that anything implemented in this pre-release version may be implemented in a different
// way in any subsequent version
//
// Many thanks to those persons that created the original UTFT library - Henning
//
// BASIC PROGRAM.
//////////////////////////////////////////////////////////////////////////////////////////
// Setup and initialise DUEGUI
//////////////////////////////////////////////////////////////////////////////////////////
//
#include <DUEGUI.h>
DUEGUI DueGUI(CTE70); // which is: DUEGUI TFT1(CTE70,25,26,27,28);
//////////////////////////////////////////////////////////////////////////////////////////
// Setup for the external RTC library
//////////////////////////////////////////////////////////////////////////////////////////
//
#include <rtc_clock.h>
RTC_clock rtc_clock(RC);
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
int hh,mm,ss,dow,dd,mon,yyyy;
//////////////////////////////////////////////////////////////////////////////////////////
// Setup variables for Due GUI
//////////////////////////////////////////////////////////////////////////////////////////
//
// variables for screens etc
int DueGUI_currentlyDisplayedScreen=0;
#define URNnull 0
// Every screen
int pnlTitle;
//
// Main menu screen
#define main_menu 1
/
//////////////////////////////////////////////////////////////////////////////////////////
// Due GUI Interupt routine and variables
//////////////////////////////////////////////////////////////////////////////////////////
//
// fast ticks for Due GUI interupt
volatile int l;
volatile int btnFound;
//
// DueGUI Interupt handler routine
//
void DueGUI_tickHandler(){
//
// We don't want timer called whilst it's being handled.
//
DueGUI.stopTimer(DueGUI_timer);
//
// routine is called several times per second ie "ticksPerSecond".
// l is incremented each time and by checking this against "ticksPerSecond"
// we can make sure that once a second events are only called once per second.
//
l+=1;
//
// This is the "once per second" event routine.
//
if (l==ticksPerSecond){
// second passed
l=0;
if (DueGUI.anyClockVisible) {
rtc_clock.get_time(&hh,&mm,&ss);
rtc_clock.get_date(&dow,&yyyy,&mon,&dd);
//
// Insert below the set and redraw clock functions:
//
// Clocks that are only shown on some screens
if (DueGUI_currentlyDisplayedScreen==main_menu){
}
}
}
if ((DueGUI.dataAvailable()==true) || (DueGUI.anyButtonPressed==true)){
btnFound=DueGUI.checkAllButtons();
if (btnFound!=-1){
DueGUI_OnButtonPress(btnFound);
}
}
// Ok interupt handler is finished.
//
TC_GetStatus(TC1, 0);
DueGUI.restartTimer(DueGUI_timer);
}
//////////////////////////////////////////////////////////////////////////////////////////
// DueGUI On button press routine
//////////////////////////////////////////////////////////////////////////////////////////
//
void DueGUI_OnButtonPress(int btnFound){
// Serial.print("Button found : ");
// Serial.println(btnFound);
//
// Find the URN of the button that was found.
//
int URN=DueGUI.GUIobject_UniqueReference[btnFound];
}
//////////////////////////////////////////////////////////////////////////////////////////
// DueGUI display a new screen
//////////////////////////////////////////////////////////////////////////////////////////
//
void DueGUI_createScreen(int screen){
// First stop interupts whilst we build screen
DueGUI.stopTimer(DueGUI_timer);
// Set global variable to record which screen is in view
DueGUI_currentlyDisplayedScreen=screen;
// Clear all the data and the screen
DueGUI.clearAllObjects();
DueGUI.clrScr();
// Setup anything that is on EVERY screen
// NOTE: pnlTitle's text is left blank as it is filled in by each screens functions.
pnlTitle= DueGUI.addPanel(0,0,799,50,clrBlue,clrWhite,clrWhite,2,"",280,8,BVS_34,optVisible,URNnull);
if (DueGUI_currentlyDisplayedScreen==main_menu){
Serial.println("Setup: main_menu");
DueGUI.GUIobject_top[pnlTitle]="Main Menu";
}
// ok draw all the new objects that are supposed to be visible
DueGUI.redrawAllObjects();
// we can restart the interupts now
DueGUI.restartTimer(DueGUI_timer);
};
//////////////////////////////////////////////////////////////////////////////////////////
// DueGUI demo setup() function
//////////////////////////////////////////////////////////////////////////////////////////
//
void setup(){
//
// Initialise serial on the programming port (this section is for debugging)....
Serial.begin(115200); Serial.println("\n\nSERIAL CONNECTED AT 115200\n\n");
//
// Initialise for RTC
rtc_clock.init(); rtc_clock.set_time(__TIME__); rtc_clock.set_date(__DATE__);
//
// Initialise DueGUI
DueGUI.InitGUI(6,5,32,3,2,52,2,51);
// Display "main_menu" screen
DueGUI_createScreen(main_menu);
}
//////////////////////////////////////////////////////////////////////////////////////////
// DueGUI demo loop() function
//////////////////////////////////////////////////////////////////////////////////////////
//
void loop(){
// Do things here :-)
}