Arduino TFT libraries compatibility

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Arduino TFT libraries compatibility

Post by danieleff » Fri Jun 23, 2017 6:59 am

ChrisMicro wrote:
Fri Jun 23, 2017 5:18 am
I try this with your F746 TFT implementation but it seems not to be a derivative of the Adafruit_GFX.
Yes it is.

zmemw16
Posts: 1417
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Arduino TFT libraries compatibility

Post by zmemw16 » Fri Jun 23, 2017 8:37 am

oh no it isn't :)
sorry
stephen

ChrisMicro
Posts: 297
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: Arduino TFT libraries compatibility

Post by ChrisMicro » Sat Jun 24, 2017 6:06 am

The goal of my efforts to make a GUI is the maximum reachable simplicity ... Arduino like ...
It has to be simple to use. All GUI APIs I saw are in my opinion to complicated.

So here is my proposal showed with an example placing to "virtual" LEDs on the screen and blink them:

Code: Select all

Adafruit_ILI9341 * Display; // this pointer is needed from the GUI driver

GUI_Led   Led1("up  ");
GUI_Led   Led2("down");

void setup()
{
  tft.begin();
  tft.fillScreen(LTDC_BLACK);
  tft.setRotation(1); 

  Display = &tft;
  
  Led1.setColor(COLOR_GREEN);
}


void loop(void)
{
  Led1.on();
  Led2.off();
  delay(1000);
  Led1.off();
  Led2.on();
  delay(1000);
}
I think, simplier is not possible except this *Display pointer which I don't like

ChrisMicro
Posts: 297
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: Arduino TFT libraries compatibility

Post by ChrisMicro » Sun Jun 25, 2017 5:31 am

I just added a code example on GitHub for the BluePill and a ILI9341.
This is a very initial state which I plan to extend. Do you have suggestions for any improvements?

stevestrong
Posts: 1609
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Arduino TFT libraries compatibility

Post by stevestrong » Sun Jun 25, 2017 8:40 am

ChrisMicro wrote:
Sun Jun 25, 2017 5:31 am
I just added a code example on GitHub for the BluePill and a ILI9341.
This is a very initial state which I plan to extend. Do you have suggestions for any improvements?
No suggestion yet, but it looks nice so far, I am very interested in this project.

ChrisMicro
Posts: 297
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: Arduino TFT libraries compatibility

Post by ChrisMicro » Sun Jun 25, 2017 9:36 am

No suggestion yet, but it looks nice so far, I am very interested in this project.
Thanks for your response :D

Meanwhile I came to the conclusion that it is best to have a "TFT_Adapter" class for every hardware configuration.

All hardware configuration ( like pin assignement ) has to be done in this Adapter for every hardware platform.
The rest of the software stays the same.

I have done the example for 3 different hardware platforms:

- Arduino Uno with ILI9341 parallel display shield
- BluePill with ILI9341 SPI
- STM32F746 Discovery

What do you think?

ChrisMicro
Posts: 297
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: Arduino TFT libraries compatibility

Post by ChrisMicro » Mon Jun 26, 2017 6:49 am

Now it is converted to a library.
Now there are different adapters which have to be selected before including the Gui.

Code: Select all

// choose your hardware:
#define TFT_Adapter_ILI9341_BluePill
//#define TFT_Adapter_SPFD5408_UNO
//#define TFT_Adapter_STM32F746_Discovery

#include "Gui.h"

GUI_Led   Led1("up  ");
GUI_Led   Led2("down");

....
The trade of now: The adapters are fixed to certain pins ...

ChrisMicro
Posts: 297
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: Arduino TFT libraries compatibility

Post by ChrisMicro » Thu Jun 29, 2017 6:26 am

Meanwhile I made some graphical elements

- button
- slider
- number display

Originally I wanted make the demos on small 2.4'' ILI9341 and a BluePill but I got used to the convenience of the "big" 4'' TFT of the F746 disco.

Here is a demo picture

Image

It looks a little bit basic compared to the GUIs which are around.

But take into account: My focus is on the simplicity of the programmers API.

What do you think?

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Arduino TFT libraries compatibility

Post by danieleff » Thu Jun 29, 2017 7:33 am

You are limiting yourself waaay too much with those adapters. Just tell the user to call tft.begin(...) before gui.begin(). It is standard anyway.
And now your code works with on any arduino/teensy/eps/whatever, and every gui library that extends Adafruit GFX. Without needing to do anything.

Even if you do not do that, create an example for Arduino UNO, and make a post in an general arduino forum. You will get a TON more feedback there.

(You will need "adapters" for touch, not for the screen, because they do not have a common parent class I think. But if they have the same method (TSPoint getPoint()), then do it with one C++ template class, and not many different ones.)
(do not call setRotation(). Let the user decide that.)

ChrisMicro
Posts: 297
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: Arduino TFT libraries compatibility

Post by ChrisMicro » Thu Jun 29, 2017 7:59 am

Thank your your detailed response :D
Even if you do not do that, create an example for Arduino UNO,
I bought an ILI9341 shield for the UNO. The display worked but the touch not. It seems to have a defect because only the ADC auf the Y-direction changes a little bit the X-axis not. So I gave it up ...

Regarding the touch issue:
(You will need "adapters" for touch, not for the screen, because they do not have a common parent class I think. But if they have the same method (TSPoint getPoint()), then do it with one C++ template class, and not many different ones.)
That's really somehow a problem. At the moment I solved it by reading the touch and writing the values to the gui.

This is the "interface":

Code: Select all

void loop(void)
{
  // read touch pad and tell the gui
  TSPoint p = ts.getPoint();
gui.setTouch(p.x, p.y, p.z);

value1 = slider1.getInt();
..
It disturbs a little bit the optics of "code simplicity".

Mainly there are two different touch screens:
The resistive and the capacitive. The resistive returns the touch-strength in p.z where as the F746 TFT only returns 0 and 1.
Also the values differ: the resistive returns digitalized voltages whereas the capacitive returns absolute coordinates.
To unify this and adapter really seems to be necessary.

Post Reply