Here is an example of creating a screen:
This screen displays four cycle buttons and four check boxes plus a button to return to the main menu...
if (DueGUI_currentlyDisplayedScreen==fan_screen){
Serial.println("Setup: fan_screen");
btnFBspeed0=DueGUI.addCycleButton(300,100,249,50,clrBlue,clrWhite ,clrWhite,clrRed,clrWhite,2,"Speed",20,posCentre,BVS_28,valFBspeed[0],0,9000,500,75,0,optVisible,URNnull);
btnFBspeed1=DueGUI.addCycleButton(300,175,249,50,clrBlue,clrWhite ,clrWhite,clrRed,clrWhite,2,"Speed",20,posCentre,BVS_28,valFBspeed[1],0,9000,500,75,0,optVisible,URNnull);
btnFBspeed2=DueGUI.addCycleButton(300,250,249,50,clrBlue,clrWhite ,clrWhite,clrRed,clrWhite,2,"Speed",20,posCentre,BVS_28,valFBspeed[2],0,9000,500,75,0,optVisible,URNnull);
btnFBspeed3=DueGUI.addCycleButton(300,325,249,50,clrBlue,clrWhite ,clrWhite,clrRed,clrWhite,2,"Speed",20,posCentre,BVS_28,valFBspeed[3],0,9000,500,75,0,optVisible,URNnull);
btnFBonoff0=DueGUI.addCheckBox(50,100,199,50,clrBlue,clrWhite ,clrWhite,clrRed,clrWhite,2,"Fan on",20,posCentre,BVS_28,valFBonoff[0],cycCHECKBOX,optVisible,URNnull);
btnFBonoff1=DueGUI.addCheckBox(50,175,199,50,clrBlue,clrWhite ,clrWhite,clrRed,clrWhite,2,"Fan on",20,posCentre,BVS_28,valFBonoff[1],cycCHECKBOX,optVisible,URNnull);
btnFBonoff2=DueGUI.addCheckBox(50,250,199,50,clrBlue,clrWhite ,clrWhite,clrRed,clrWhite,2,"Fan on",20,posCentre,BVS_28,valFBonoff[2],cycCHECKBOX,optVisible,URNnull);
btnFBonoff3=DueGUI.addCheckBox(50,325,199,50,clrBlue,clrWhite ,clrWhite,clrRed,clrWhite,2,"Fan on",20,posCentre,BVS_28,valFBonoff[3],cycCHECKBOX,optVisible,URNnull);
DueGUI.addButton(600,400,150,50,clrBlue,clrWhite,clrWhite,clrRed,clrWhite,2,"Main Menu",20,posCentre,BVS_28,optVisible,URNFBmainmenu);
// Change the text in the header panel
DueGUI.GUIobject_top[pnlTitle]="Fan Screen";
}
it requires a small amount of setup in the variables section as well:
//
// Fan screen
//
// setup the fan screen's screen number definition:
#define fan_screen 2
//
//
// The following line could be byte types but they are basically variables to store the object's object number. This is purely to make things easier, you don't actually have to remember the object's number in a variable you can get the object's number from the URN using the function "findObjectByURL(URNname);".
//
int btnFBonoff0,btnFBspeed0,btnFBonoff1,btnFBspeed1,btnFBonoff2,btnFBspeed2,btnFBonoff3,btnFBspeed3;
//
//
// Here we actually setup a URN for the main menu return button. The number can be anything that fits in an integer but for ease I will be using numbers 100-199 for the main menu (screen 1), 200-299 for screen 2 etc etc
//
#define URNFBmainmenu 209
//
//
// Here we setup the arrays used to store the values of the objects starting with the defaults.
//
int valFBspeed[] = {4000,3000,500,0};
boolean valFBonoff[] = {true,false,false,true};
As the user clicks the main menu button you need to save the values of the inputs back to the arrays:
The following is added to the on button event function. You can see the URN is being checked and it is the URN defined above.
if (URN==URNFBmainmenu){
// Grab the data BEFORE you switch screens.
//
// Note the objects were created in order so we know that btnFBonoff1 is 1 more than btnFBonoff0 etc. We can use this
// to calculate object values in order to place in loops etc.
//
// store the values of the cycBoxes in variables ready to use again later
for (int i = 0; i < 4; i++){
valFBspeed[i]=DueGUI.returnIntValue(btnFBspeed0+i);
valFBonoff[i]=DueGUI.returnBoolValue(btnFBonoff0+i);
}
printvariables();
DueGUI_createScreen(main_menu);
}