chipKIT® Development Platform

Inspired by Arduino™

Uno32 freezes please help

Created Thu, 12 Nov 2015 09:10:17 +0000 by woerr


woerr

Thu, 12 Nov 2015 09:10:17 +0000

Hello

I am working on a project that doses seed for planting equipment. it reads ground speed and turns two motors in variable relationships to the ground speed. I am using i2c eeprom to save details. 4d systems 4.3 inch HMI connected via serial. sometimes the system runs for hours before it breaks, other times it breaks after only a few minutes. I have pasted the code to pastebin below. What happens during the freeze is that the system becomes unresponsive but does not stop all together but rather becomes very very slow. I will upload a video showing the symptoms and how it should normally work.

What I find strange is for example i have a piece of code that when pressed will set two pwm signalls to run for two seconds. when the system has frozen up, when the button is pressed the motors start running immediately but dont stop for about 30 seconds. also the readout of the screen normally reads ground speed at 5km/h but when it breaks, the speed shows over 50km/h.

[url]http://pastebin.com/qpqwpK8P[/url] [url]https://youtu.be/ecH6wGGs8uo[/url]


majenko

Thu, 12 Nov 2015 10:24:24 +0000

These kind of random problems can be a real pain to diagnose.

I would suggest taking each of the major components in turn and removing them from the equation. Start with the EEPROM (the Wire library is known to block if it can't communicate) and remove all access to it by your program - if that cures it then we know where to look. If not, then replace the Genie interface with some simple Serial.print() entries so you can see what it is doing without using the 4D screen. If that stops it slowing down and freezing then there is something with the communication with that screen that is to blame. Etc.

Once you have pinpointed the component or area that is causing the problems we can then look deeper to try and find exactly why it's causing the problem and what to do to rectify it.


woerr

Thu, 12 Nov 2015 12:16:10 +0000

I started by removing the genie library and there seems to be no more issues. Will eave the test rig running over nite to confirm.


majenko

Thu, 12 Nov 2015 12:35:31 +0000

I have had to add to that Genie library before now for the "pro" version. TBH I don't really like the way it's been written. In fact I don't like the Genie protocol at all - it's not well designed and can easily get itself out of sync.


woerr

Thu, 12 Nov 2015 12:45:49 +0000

Can you recommend an alternative low cost hmi solution?

I do have a nextion hmi that I still need to evaluate.


majenko

Thu, 12 Nov 2015 12:56:55 +0000

My main HMI solution is the Picadillo-35T from 4D. It's a PIC32 board with built in TFT screen and the same (or similar) headers as the Uno32. With that you get to directly manipulate the TFT screen in software so no need for dodgy serial communication protocols.

Plus I wrote all the software for it ;)

It's only 3.5" though, not the 4.3" you're using at the moment.

For a more powerful system there's the new Armadillo-43T from 4D - it's basically a Raspberry Pi with built in TFT screen - though that might be overkill for your needs, and maybe more difficult to interface with hardware than a microcontroller based system, since it runs a full version of Linux and X Windows. Also it takes a lot longer to boot up, etc, than a PIC32 ;) (Incidentally, we're just about to launch a 7" version of the same board with built in WiFi and Ethernet).

Of course, you can build your own HMI system with a cheap TFT screen (either SPI or better 16-bit parallel interface) and a more powerful PIC32 board (say a MAX32 or something else with one of the more meaty chips on it) and directly interface the two together. Of course that means needing display driver software etc, which might exist or might not.


woerr

Tue, 01 Dec 2015 06:48:37 +0000

I have decided to order a picadillo 35t and give that a try, What do I need to know regarding moving over, can I copy paste my current mpide code, where can I find the library, I will be reading up as much as possible until the unit arrives with us


majenko

Tue, 01 Dec 2015 14:30:18 +0000

For the display the best library to use is displaycore: http://displaycore.org


woerr

Wed, 02 Dec 2015 10:12:59 +0000

Where can I find documentation on the displaycore library. The website it seems cant load the pages.


majenko

Wed, 02 Dec 2015 11:15:15 +0000

I haven't written most of the pages yet.

There's plenty of examples in the DisplayCore library - especially for the Picadillo - they show you how to do most things. Anything you don't see and want hints on just ask.


GastonLagaffe

Wed, 02 Dec 2015 15:30:50 +0000

Salut,

I have the picadillo as well and am very pleased by the board. I created two demos for the board: one that replays the UTFT demo, the second implements a little math game. I have not yet published them as they are not completely done and I am very busy from my day job (we have a fair in London these days). But the code can be used by you to see how I did the calls.

UTFT Demo replay:

#include <Picadillo.h>

Picadillo tft;
AnalogTouch ts(LCD_XL, LCD_XR, LCD_YU, LCD_YD, 320, 480);

const char* header = "DisplayCore TFT library on Picadillo-35T";
const char* footer = "Dr. Mathias Wilhelm";
const char* solong = "Cycle complete, time(msec);";
const char* restart = "Resetart in 10 seconds";

void setup()
{
	ts.initializeDevice();
	tft.initializeDevice();
	tft.setBacklight(255);
	tft.setTextWrap(false);
	tft.setRotation(1);
	ts.setRotation(1);
	tft.fillScreen(Color::Black);
	tft.setTextColor(Color::White);
}

void loop()
{
	int buf[tft.getWidth()];
	int x, x2;
	int y, y2;
	int r;
  float ratio=tft.getWidth()/tft.getHeight();
  int wait = 2000;
	int16_t xp, yp;
	uint16_t drawColor;
	uint16_t drawClist[5] = {
		Color::Green,Color::Red,Color::Blue,Color::Yellow,Color::SkyBlue	};
	boolean play = true;
	static boolean isPressed = false;
	static uint32_t btnTs = millis();

	int xh = tft.getWidth()-2;
	int yh = tft.getHeight()-14;
	tft.fillScreen(Color::Black);
	tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
	tft.setTextColor(Color::Black);
	tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
	tft.print(header);
	tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
	tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
	tft.print(footer);


	tft.fillScreen(Color::Black);
	tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
	tft.setTextColor(Color::Black);
	tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
	tft.print(header);
	tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
	tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
	tft.print(footer);

	tft.drawRectangle(0,12,tft.getWidth(),tft.getHeight()-24, Color::Blue);
	tft.drawLine(tft.getWidth()/2, 13, tft.getWidth()/2, yh, Color::LightSlateGray);
	tft.drawLine(1, tft.getHeight()/2, xh, tft.getHeight()/2, Color::LightSlateGray);
	for (int i=10; i<xh; i+=10)
		tft.drawLine(i, tft.getHeight()/2-2, i, tft.getHeight()/2+2, Color::LightSlateGray);
	for (int i=20; i<=yh; i+=10)
		tft.drawLine(tft.getWidth()/2-2, i, tft.getWidth()/2+2, i, Color::LightSlateGray);
	tft.setTextColor(Color::Yellow);
	tft.setCursor(5, 25);
	tft.print("sin(x)");
	for (int i=1; i<xh; i++)
	{
		tft.setPixel(i,tft.getHeight()/2+(sin(((i*1.13)*3.14)/180)*95),Color::Yellow);
	}

	tft.setTextColor(Color::Red);
	tft.setCursor(5, 35);
	tft.print("cos(x)");
	for (int i=1; i<xh; i++)
	{
		tft.setPixel(i,tft.getHeight()/2+(cos(((i*1.13)*3.14)/180)*95),Color::Red);
	}

	tft.setTextColor(Color::Green);
	tft.setCursor(5, 45);
	tft.print("tan(x)");
	for (int i=1; i<xh; i++)
	{
		tft.setPixel(i,tft.getHeight()/2+(tan(((i*1.13)*3.14)/180)*5),Color::Green);
	}
	delay(wait);

	tft.fillScreen(Color::Black);
	tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Green);
	tft.setTextColor(Color::Black);
	tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
	tft.print(header);
	tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Green);
	tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
	tft.print(footer);

	tft.fillRectangle(0,12,tft.getWidth(),tft.getHeight()-24, Color::Black);
	tft.drawRectangle(0,12,tft.getWidth(),tft.getHeight()-24, Color::Blue);
	tft.drawLine(tft.getWidth()/2, 13, tft.getWidth()/2, yh, Color::LightSlateGray);
	tft.drawLine(1, tft.getHeight()/2, xh, tft.getHeight()/2, Color::LightSlateGray);

	// Draw a moving sinewave
	x=1;
	for (int i=1; i<((tft.getWidth()-2)*20); i++) 
	{
		x++;
		if (x==(tft.getWidth()-1))
			x=1;
		//    if (x==1) delay(1000);
		if (i>(tft.getWidth()-1))
		{
			if ((x==(tft.getWidth()/2))||(buf[x-1]==tft.getHeight()/2))
				drawColor = Color::Blue;
			else
				drawColor = Color::Black;
			tft.setPixel(x,buf[x-1], drawColor);
		}
		y=tft.getHeight()/2+(sin(((i*1.55)*3.14)/180)*(90-(i / 100)));
		tft.setPixel(x,y, Color::Yellow);
		buf[x-1]=y;
	}
	delay(wait);

	tft.fillScreen(Color::Black);
	tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
	tft.setTextColor(Color::Black);
	tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
	tft.print(header);
	tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
	tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
	tft.print(footer);
	// Draw some filled rectangles
	for (int i=1; i<6; i++)
	{
		tft.fillRectangle(70+(i*10), 30+(i*10), 100+(i*10), 60+(i*10),drawClist[i-1]);
	}
	delay(wait);

	// Draw some rounded filled rectangles
	tft.fillScreen(Color::Black);
	tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Green);
	tft.setTextColor(Color::Black);
	tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
	tft.print(header);
	tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Green);
	tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
	tft.print(footer);
	for (int i=1; i<6; i++)
	{
		tft.fillRoundRect(190-(i*10), 30+(i*10), 250-(i*10), 90+(i*10), 5, drawClist[i-1]);
	}
	delay(wait);

	tft.fillScreen(Color::Black);
	tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
	tft.setTextColor(Color::Black);
	tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
	tft.print(header);
	tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
	tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
	tft.print(footer);
	// Draw some filled circles
	for (int i=1; i<6; i++)
	{
		tft.fillCircle(100+(i*20),60+(i*20), 30,drawClist[i-1]);
	}
	delay(wait);

// Draw some lines in a pattern
  tft.fillScreen(Color::Black);
  tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Green);
  tft.setTextColor(Color::Black);
  tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
  tft.print(header);
  tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Green);
  tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
  tft.print(footer);
  ratio = (tft.getWidth()-2)/(tft.getHeight()-24);
  for (int                 i=5; i<tft.getHeight()-12; i+=5) tft.drawLine(             1, i,             (i*ratio)-10, tft.getHeight()-12, Color::Red);
  for (int i=tft.getWidth()-12;                 i>5; i-=5) tft.drawLine(tft.getWidth(), i,             (i*ratio)-11,                 12, Color::Green);
  for (int i=tft.getWidth()-12;                 i>5; i-=5) tft.drawLine(             1, i, tft.getWidth()-(i*ratio),                 12, Color::Yellow);
  for (int                 i=5; i<tft.getHeight()-12; i+=5) tft.drawLine(tft.getWidth(), i, tft.getWidth()-(i*ratio), tft.getHeight()-12, Color::Blue);
  ratio=tft.getWidth()/tft.getHeight();

  delay(wait);

  // Draw some random circles
  tft.fillScreen(Color::Black);
  tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
  tft.setTextColor(Color::Black);
  tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
  tft.print(header);
  tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
  tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
  tft.print(footer);
  for (int i=0; i<100; i++)
  {
    x=32+random(tft.getWidth()-64);
    y=32+random(tft.getHeight()-64);
    r=random(30);
    tft.drawCircle(x, y, r, tft.color565(random(255), random(255), random(255)));
  }

  delay(wait);

// Draw some random rectangles
  tft.fillScreen(Color::Black);
  tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Green);
  tft.setTextColor(Color::Black);
  tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
  tft.print(header);
  tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
  tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
  tft.print(footer);
  for (int i=0; i<100; i++)
  {
    x=2+random(tft.getWidth()-4);
    y=16+random(tft.getHeight()-40);
    x2=2+random(40);
    y2=16+random(30);
    tft.drawRectangle(x, y, x2, y2,tft.color565(random(255), random(255), random(255)));
  }

  delay(wait);

// Draw some random rounded rectangles
  tft.fillScreen(Color::Black);
  tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
  tft.setTextColor(Color::Black);
  tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
  tft.print(header);
  tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
  tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
  tft.print(footer);
  for (int i=0; i<100; i++)
  {
    x=2+random(tft.getWidth()-4);
    y=16+random(tft.getHeight()-40);
    x2=2+random(40);
    y2=16+random(30);
    tft.drawRoundRect(x, y, x2, y2,5,tft.color565(random(255), random(255), random(255)));
  }

  delay(wait);
  
  tft.fillScreen(Color::Black);
  tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Green);
  tft.setTextColor(Color::Black);
  tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
  tft.print(header);
  tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
  tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
  tft.print(footer);

  for (int i=0; i<100; i++)
  {
    x=2+random(tft.getWidth()-4);
    y=16+random(tft.getHeight()-40);
    x2=2+random(tft.getWidth()-4);
    y2=16+random(tft.getHeight()-40);
    tft.drawLine(x, y, x2, y2,tft.color565(random(255), random(255), random(255)));
  }

  delay(wait);
  
  tft.fillScreen(Color::Black);
  tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
  tft.setTextColor(Color::Black);
  tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
  tft.print(header);
  tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
  tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
  tft.print(footer);

  for (int i=0; i<10000; i++)
  {
    tft.setPixel(2+random(tft.getWidth()-4), 16+random(tft.getHeight()-40),tft.color565(random(255), random(255), random(255)));
  }

  delay(wait);

  tft.fillScreen(Color::Blue);
  tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
  tft.setTextColor(Color::Black);
  tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
  tft.print(header);
  tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
  tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
  tft.print(footer);
  tft.setCursor((tft.getWidth() - tft.stringWidth(solong))/2, tft.getHeight()/2);
  tft.print(solong);
  tft.print(millis());
  tft.setCursor((tft.getWidth() - tft.stringWidth(restart))/2, tft.getHeight()/2+10);
  tft.print(restart);
  delay(10000);

}

Math Game:

#include <Picadillo.h>

Picadillo tft;
AnalogTouch ts(LCD_XL, LCD_XR, LCD_YU, LCD_YD, 320, 480);

const char* header = "DisplayCore TFT library on Picadillo-35T";
const char* footer = "Dr. Mathias Wilhelm";

uint16_t coords[7][2] = {
	{
		240,30	}
	,{
		342,79	}
	,{
		367,189	}
	,{
		296,277	}
	,{
		184,277	}
	,{
		113,189	}
	,{
		138,79	}
};
boolean ledOn[7] = {
	true, true, true, true, true, true, true};

void setup()
{
	ts.initializeDevice();
	tft.initializeDevice();
	tft.setBacklight(255);
	tft.setTextWrap(false);
	tft.setRotation(1);
	ts.setRotation(1);
	tft.fillScreen(Color::Black);
	tft.setTextColor(Color::White);
}

void loop()
{
	int buf[tft.getWidth()];
	int x, x2;
	int y, y2;
	int r;
	int16_t xp, yp;
	uint16_t drawColor;
	uint16_t drawClist[5] = {
		Color::Green,Color::Red,Color::Blue,Color::Yellow,Color::SkyBlue	};
	boolean play = true;
	static boolean isPressed = false;
	static uint32_t btnTs = millis();
	static uint32_t scrTs;

	uint32_t xrand, yrand;

	int xh = tft.getWidth()-2;
	int yh = tft.getHeight()-14;

	ledOn = {true, true, true, true, true, true, true};
	isPressed = false;
	scrTs = 0;
	while(!isPressed){
		if ((millis()-scrTs)>1000){
			scrTs = millis();
			tft.fillScreen(Color::Black);
			xrand = random(300);
			yrand = random(200);
			x = 50 + int(xrand);
			y = 10 + int(yrand);
			tft.fillRectangle(x, y, 150, 20, Color::Red);
			tft.setCursor(x+5,y+5);
			tft.setTextColor(Color::Black);
			tft.print("Tap screen to start Game");
		}
		ts.sample();
		if (millis() - btnTs > 100) {
			btnTs = millis();
			if (ts.isPressed() != isPressed) {
				isPressed = ts.isPressed();
			}
		}
	}
	
	tft.fillScreen(Color::Black);
	tft.fillRectangle(0, 0, tft.getWidth(), 10, Color::Yellow);
	tft.setTextColor(Color::Black);
	tft.setCursor((tft.getWidth() - tft.stringWidth(header))/2, 1);
	tft.print(header);
	tft.fillRectangle(0, tft.getHeight()-10, tft.getWidth(), 10, Color::Yellow);
	tft.setCursor((tft.getWidth() - tft.stringWidth(footer))/2, tft.getHeight()-9);
	tft.print(footer);

	tft.fillRectangle(100, 290, 280, 20, Color::Red);
	tft.setCursor(200,295);
	tft.print("Quit Game");
	for (int i=0; i<7; i++){
		if (ledOn[i]) {
			tft.fillCircle(coords[i][0], coords[i][1], 15, Color::Yellow);
		} 
		else {
			tft.fillCircle(coords[i][0], coords[i][1], 15, Color::LightGray);
		}
		tft.drawCircle(coords[i][0], coords[i][1], 15, Color::Blue);
	}
	play = true;
	isPressed = false;
	btnTs = millis();

	while (play){
		int ledSel;
		ts.sample();
		if (millis() - btnTs > 100) {
			btnTs = millis();
			if (ts.isPressed() != isPressed) {
				isPressed = ts.isPressed();
				if (isPressed) {
					xp = ts.x() + 25.0;
					xp = xp * 480.0/520.0;
					yp = ts.y() - 26.0;
					yp = yp * 320.0/273.0;
					if ((xp>=100)&&(xp<=380)&&(yp>=290)&&(yp<=310)) play = false;
					ledSel = 8;
					for (int i=0; i<7; i++){
						if ((xp>=coords[i][0]-15)&&(xp<=coords[i][0]+15)&&(yp>=coords[i][1]-15)&&(yp<=coords[i][1]+15)) ledSel = i;
					}
					tft.fillRectangle(5, 25, 130, 20, Color::Black);  
					tft.setCursor(5, 25);
					tft.setTextColor(Color::White);
					tft.print(xp);
					tft.print(" ");
					tft.print(yp);
					tft.print(" ");
					tft.print(ledSel);
					if (ledSel < 8){
						ledOn[ledSel] = !ledOn[ledSel];
						switch (ledSel){
						case 0: 
							ledOn[6] = !ledOn[6];
							ledOn[1] = !ledOn[1];
							break;
						case 6:
							ledOn[5] = !ledOn[5];
							ledOn[0] = !ledOn[0];
							break;
						default:
							ledOn[ledSel-1] = !ledOn[ledSel-1];
							ledOn[ledSel+1] = !ledOn[ledSel+1];
							break;
						}
						for (int i=0; i<7; i++){
							if (ledOn[i]) {
								tft.fillCircle(coords[i][0], coords[i][1], 15, Color::Yellow);
							} 
							else {
								tft.fillCircle(coords[i][0], coords[i][1], 15, Color::LightGray);
							}
							tft.drawCircle(coords[i][0], coords[i][1], 15, Color::Blue);
						}
					}
				}
			}
		}
	}

}

Ciao, Mathias PS: the MathGame: Try to turn off all the 7 lights. When you press a light, its state gets inverted, but also the state of its neighbors. Best possible play is 6 moves to switch off all lights - enjoy


woerr

Mon, 11 Jan 2016 14:06:49 +0000

Hi Majenko

You said I must just ask.

I have been looking all over the place for information on coding the picadillo. So far the information is all very different and scattered with different places using different libraries. I would like to design the ui in 4d workshop and get that to work with my program like they have done here. [url]http://forum.4dsystems.com.au/forum/customer-projects-formally-anna-s-sandbox/staff-project-share-projects-to-help-or-inspire/46432-4d-pr-00001-picadillo-35t-real-time-clock-and-calendar[/url]

but the displaycore does not include the tft library that is used there.

and with the displaycore library i cant get buttons to do anything.

here is the code: [url]http://pastebin.com/X6j55dEa[/url]

The more I try understand the more confused I get between all these different libraries.


majenko

Mon, 11 Jan 2016 15:21:09 +0000

There are two distinct libraries - TFT (old and unsupported now), and DisplayCore (new and I am always adding new things).

It sounds like you want to use the gciWidget toolkit library in DisplayCore (which works slightly differently to the one in TFT). There is an example of how to use it in that toolkit library itself - it shows you how to access the widgets stored in the .GCI and .DAT files that 4D Workshop creates.

There is also some information on using it here: http://uecide.org/forum/viewtopic.php?f=13&t=470


woerr

Tue, 12 Jan 2016 15:27:05 +0000

Thanks

I have since gotten much further with my program. I have to the best of my ability created what is partially the ui I will need but it seems to be very buggy and i do not quite understand that the .render(); does not seem to render more than once if it is in the loop.

buttons are also not being cleared if I put tft.fillScreen(Color::White); in the btnpress(event *e)

any more information would be much appreciated.

here is the paste of my code so far.

http://pastebin.com/zXdauhpk


majenko

Tue, 12 Jan 2016 17:04:08 +0000

.render() only renders a button if it actually needs to - that is, if there has been a change to the button that would require updating the screen. Any other time you call render() it will just check for any touch events and not draw anything.

To force it to update the screen with the button you must first call .redraw() which tells the button "I don't care if you have changed or not - next time .render() is called you will redraw it regardless".

The problem with interacting with the TFT from within the button press events is that the event triggers before the button is redrawn, and since the state of the button has changed (you pressed it) a redraw is done. That means that you clear the screen, and then the button is drawn on top of the cleared screen.

Instead you really want to set a flag in the button event saying "I want to switch to screen X" and then in the main loop you examine that flag, switch to the right screen (if needed) clearing the screen in the process, and then "turn off" that flag (set it to 0, for example).


woerr

Wed, 13 Jan 2016 09:56:33 +0000

Thanks

It is now behaving more how I want it to, but now there is a delay in pressing the buttons. my trigger is onpress but some of the buttons I need to press 30 + times before it registers. What am I doing wrong as I dont understand quite how the ts.sample code works. I also wanted to know if the library includes userled() and leddigits().

Thank you for your time.


majenko

Wed, 13 Jan 2016 10:05:49 +0000

Userled should work fine. Leddigits, however, are a special case that require a special widget class for that hasn't been written yet. There is an LED digit font though, Open24Display.

Can you post your latest version of your loop function?

Sent from my SM-T555 using Tapatalk


woerr

Wed, 13 Jan 2016 13:22:53 +0000

Hi Majenko

Here is my current program.

http://pastebin.com/ykt9jTQ3

it is working very well, The code is not as simplified as your examples but I am not so clued up with programming yet. userleds are rendering but I havent figured out how to change the states yet.

alarmled1.setValue(true); alarmled1.setValue(1);

the obove dont seem to do anything.

My next struggle will be to find a suitable font to replace leddigits() as I had their colors and size set up very nicely in workshop.


majenko

Wed, 13 Jan 2016 15:21:33 +0000

You don't want to be defining a new AnalogTouch object inside your loop. It's not achieving anything.

For the userleds you should just set the value. A gciWidget is made up of a number of frames of animation. The value you set on a gciWidget selects the frame that is being displayed. For something with 2 frames like an LED it should be 0 for off and 1 for on.


majenko

Wed, 13 Jan 2016 15:38:23 +0000

I just noticed my example gciWidget sketch has the extra AnalogTouch in it - no idea how that got there...


woerr

Thu, 14 Jan 2016 07:42:34 +0000

Is there any way to make the font larger than tft.setFont(Fonts::Open24Display40);

if not I guess I will need to make a custom font.

Also is there a keyboard() handler?


majenko

Thu, 14 Jan 2016 10:20:32 +0000

The problem with big fonts is that they use too much space. They contain lots of characters that you may not use. To get bigger you need to just have a subsection of the font, such as the numbers 0 to 9, so that it doesn't waste space.

There is a FontMaker application (java) in the Tools folder of the DisplayCore Github repository that can be used to create new fonts, but it is incomplete at the moment. You can have a play though.

There is no on-screen keyboard support yet. At the moment you have to emulate it manually with separate buttons.

Sent from my SM-T555 using Tapatalk


woerr

Fri, 15 Jan 2016 11:20:29 +0000

I am now looking for a way to not print decimals using the tft.print()


majenko

Fri, 15 Jan 2016 11:37:17 +0000

How do you mean "not" print decimals?


woerr

Fri, 15 Jan 2016 20:51:12 +0000

if i say tft.print 100 it displays 100.0000


majenko

Fri, 15 Jan 2016 21:18:36 +0000

Then the variable you are printing must be a floating point type (float).

You have two options - one is to just not have decimals by changing the type to one that doesn't have decimals (cast it to int). The other is to tell print to print 0 decimal places.

tft.print((int)myFloatValue);
// or
tft.print(myFloatValue, 0);

The print function is inherited from the Print class which is the standard Arduino print that you get in Serial etc.


woerr

Sat, 16 Jan 2016 07:58:51 +0000

Thats why I though it was strange, because the value is an int.

I will try the other method.


majenko

Sat, 16 Jan 2016 12:21:24 +0000

You could also format a string with sprintf to give you the exact format you want...

Sent from my SM-T555 using Tapatalk


woerr

Fri, 05 Feb 2016 09:51:25 +0000

Hi there,

My program has come a long way and is interacting nicely, on one of the pages I have a few numbers that are updated very frequently and need to use a buffer. So I have one buffer running nicely as in the double buffer example but I do not know how to do multiple buffers per page. If anybody could assist it would be greatly appreciated.


woerr

Fri, 05 Feb 2016 10:01:27 +0000

never mind, I figured it out just doubling up the code.

		fb.setCursor(3, 2);									// Then place the text over the top.
		fb.fillScreen(Color::White);
		fb.setTextColor(Color::Black, Color::Black);
		fb.print(kph);
		fb.draw(tft, 150, 2);								        // Finally output the framebuffer to the screen.
		
		fb.setCursor(3, 2);									// Then place the text over the top.
		fb.fillScreen(Color::White);
		fb.setTextColor(Color::Black, Color::Black);
		fb.print(millis());
		fb.draw(tft, 150, 130);							 	// Finally output the framebuffer to the screen.