utft and memory pages..

Hi all, Im just starting with a 3.2" 320 x 200 sainsmart tft shield and mega bundle.

after getting the example sketches running im now working out how to use it to display different option or menu screens and navigate back and forth.

currently my approach is clunky as i am wiping the screen And deleteing all buttons before receating the frame head and tail and buttons for each menu on each call.

the utft docs tell me about setDispalyPage and SetWritePage functions..

can anyone point me in the direction of a simple example of how these calls are used? tia.

AFAIK, the non-CPLD based display controllers only have one display page :(

The one possible approach you could use with a smaller screen is to store the entire page as a bitmap on the displays SD card. Smaller screens = fewer pixels = faster bitmap load time so it might be a feasible solution.

cheers Fred, afaik which isnt much the tft is a CPLD device as the example sketches that work with it define the Utft access object as MyCPLD iirc ?? tho that may just be the authors naming convention?? any clues on how to ID to make sure, or if its a well known NO-NO

the code I have works - to a point in that after switching down back up and down again through different menu's the touch response Is wide off the mark for one tap, that is with 6 buttons on the screen a clear tap on button 6 will highlight and indicate button 3 or 4 has been depressed.. next tap is spot on.. its like 1/3 of a landscape height out for just the one tap??

I cant post the code as its on my home pc.. and hopefully i will debug it sooner or later,

just as i was rolling up the proverbial debugging sleeves i came across these page commands and stood at the fork in the road unsure of which direction to follow.. ;)

filk: Hi all, Im just starting with a 3.2" 320 x 200 sainsmart tft shield and mega bundle.

after getting the example sketches running im now working out how to use it to display different option or menu screens and navigate back and forth.

currently my approach is clunky as i am wiping the screen And deleteing all buttons before receating the frame head and tail and buttons for each menu on each call.

the utft docs tell me about setDispalyPage and SetWritePage functions..

can anyone point me in the direction of a simple example of how these calls are used? tia.

Multi-menu: no setDispalyPage :art:

Hardware: TFT 3.2" HY32D + Arduino Due

http://forum.arduino.cc/index.php?topic=271064.msg1921003#msg1921003

Many Thank TFTLCDCyg thats something to study, and it compiled and ran with just an edit of the io pins used.

i will need to study your solution a bit more is the floating positioning due to not mapping the same area of the screen for different functionality?

my own effort so far isnt as tidy codewise…


// UTFT_Demo_320x240 (C)2014 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
//
// This demo was made for modules with a screen resolution 
// of 320x240 pixels.
//
// This program requires the UTFT library.
//

#include <UTFT.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>
#include "tftmenu1.h"
// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t Dingbats1_XL[];

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// Arduino Uno / 2009:
// -------------------
// Standard Arduino Uno/2009 shield            : <display model>,A5,A4,A3,A2
// DisplayModule Arduino Uno TFT shield        : <display model>,A5,A4,A3,A2
//
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega      : <display model>,38,39,40,41
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(ITDB32S,38,39,40,41);
// Set up UTouch...
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino 2009/Uno/Leonardo shield   : 15,10,14,9,8
// Standard Arduino Mega/Due shield            : 6,5,4,3,2
// CTE TFT LCD/SD Shield for Arduino Due       : 6,5,4,3,2
// Standard chipKit Uno32/uC32                 : 20,21,22,23,24
// Standard chipKit Max32                      : 62,63,64,65,66
// AquaLEDSource All in One Super Screw Shield : 62,63,64,65,66
UTouch        myTouch(6,5,4,3,2);

// Finally we set up UTFT_Buttons :)
UTFT_Buttons  myButtons(&myGLCD, &myTouch);


// fils globals;
frametxt myframetxt;
int gotx;

void setup()
{
  randomSeed(analogRead(0));
  Serial.begin(9600);
  
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);

//set up touch
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
//set up buttons
myButtons.setTextFont(BigFont);
myButtons.setSymbolFont(Dingbats1_XL);




}
void frame()
{
  // Clear the screen and draw the frame
  myGLCD.clrScr();

  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 319, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 226, 319, 239);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.setBackColor(64, 64, 64);
  myGLCD.setColor(255,255,0);

  myGLCD.setColor(0, 0, 255);
  myGLCD.drawRect(0, 14, 319, 225);


  myGLCD.print(myframetxt.header, CENTER, 1);
  myGLCD.print(myframetxt.tail, CENTER, 227);

}

void mainmenu()
{
	int but1, but2, but3, but4, but5, but6, pressed_button;
	boolean default_colors = true;
        myframetxt.header ="BrweKontroller Mark1 V1.00 Testing *";
        myframetxt.tail = "An ongoing PhatFil development for BEER!";
        myframetxt.menuid=0;
	myButtons.deleteAllButtons(); 
        frame();
        
	but1 = myButtons.addButton( 10,  15, 300,  30, "Settings");
        Serial.print("but1 = ");
        Serial.println(but1);
	but2 = myButtons.addButton( 10,  50, 300,  30, "Start Filling Hlt");
        Serial.print("but2 = ");
        Serial.println(but2);
	but3 = myButtons.addButton( 10, 85, 300,  30, "Start Heating HLT");
        Serial.print("but3 = ");
        Serial.println(but3);
	but4 = myButtons.addButton( 10, 120, 300,  30, "Strike The Mash");
        Serial.print("but4 = ");
        Serial.println(but4);
	but5 = myButtons.addButton( 10, 155, 300,  30, "Heat Sparge target");
        Serial.print("but5 = ");
        Serial.println(but5);
	but6 = myButtons.addButton( 10, 190, 300,  30, "Start Sparge");
        Serial.print("but6 = ");
        Serial.println(but6);	
	
	myButtons.drawButtons();
	while(1)
	{
		if (myTouch.dataAvailable() == true)
		{
			pressed_button = myButtons.checkButtons();
                        Serial.println(pressed_button);

			if (pressed_button == but1) {
		            settingsmenu();
                            break;		
			}
			else if(pressed_button == but2) {
				
			}
			else if(pressed_button == but3) {
				
			}
			else if(pressed_button == but4) {
				
			}
			else if(pressed_button == but5) {
				
			}
			else if(pressed_button == but6) {
				
			}				
		}
	}
}

void settingsmenu()
{
	int but1, but2, but3, but4, but5, but6, pressed_button;
	boolean default_colors = true;
        myframetxt.header ="BrweKontroller Mark1 V1.00 Testing *";
        myframetxt.tail = "Settings click here to exit..";
        myframetxt.menuid=1;
        myButtons.deleteAllButtons();

	frame();
        but1 = myButtons.addButton( 10,  15, 300,  30, "Set HLT Fill level");
	but2 = myButtons.addButton( 10,  50, 300,  30, "Set Strike Temp");
	but3 = myButtons.addButton( 10, 85, 300,  30, "Set Strike Volume");
        but4 = myButtons.addButton( 10, 120, 300,  30, "Set Mash Durration");
	but5 = myButtons.addButton( 10, 155, 300,  30, "Set sparge Temp");
	but6 = myButtons.addButton( 10, 190, 300,  30, "Set Sparge Volume");
	
	myButtons.drawButtons();
	while(1)
	{
		if (myTouch.dataAvailable() == true)
		{
                        gotx = myTouch.getX();  
                        if (gotx > 195)
                         {
                           break;	
                         }
		      
                        pressed_button = myButtons.checkButtons();


			if (pressed_button == but1) {
				
			}
			else if(pressed_button == but2) {
				
			}
			else if(pressed_button == but3) {
				
			}
			else if(pressed_button == but4) {
				
			}
			else if(pressed_button == but5) {
				
			}
			else if(pressed_button == but6) {
				
			}									

		}
	}
}




void loop()
{

mainmenu();

}

every now and again however a press at one point on the screen registers as another part?? only the once and then returns to normal? hmmmm

Make each page it's own function that is wrapped in a while loop. Make sure your buttons to change the pages, are in that same while loop.

There are however some proper menu libraries in the arduino playground if you do a search for arduino menus.

Thanks HM am looking at the menu lib now..