BRT Community

Please login or register.

Login with username, password and session length
Advanced search  


Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: FT812 EVE2 Drawing in a Loop (NHD-5.0-800480FT-CTXL-T)  (Read 60 times)


  • Newbie
  • *
  • Posts: 1
    • View Profile
FT812 EVE2 Drawing in a Loop (NHD-5.0-800480FT-CTXL-T)
« on: February 13, 2020, 03:27:37 PM »

I’m using a NHD-5.0-800480FT-CTXL-T display from New Haven. It features the FT812 EVE2 chipset.  I am interfacing with the LCD via an Arduino Due and the Arduino shield provided by New Haven.

I am struggling with some of the drawing primitives when I try to operate them within a loop function. Basically, what I want to do is draw rectangles at different points on the screen in different colors within a loop function.

I have managed to draw singular rectangles at different points on the screen in different colors – but only one at a time – a screen clear is necessary for it to function correctly.

If I don’t clear the screen each time before trying to draw another rectangle in the loop – I get vertical bars that appear on the screen not multiple different rectangles.

I attached a .txt file which shows the code I am referencing. I thought perhaps the “append” command would help but I don’t have a static part of the screen so it didn’t seem to work.

Any help or suggestion you can provide would be greatly appreciated. Thank you


  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Re: FT812 EVE2 Drawing in a Loop (NHD-5.0-800480FT-CTXL-T)
« Reply #1 on: February 14, 2020, 05:16:49 PM »

There are several issues with your code.

The first is that there is no way to tell how often this will be called.
If this is called directly from the arduino loop() function it will be called way too often per second.
You need to limit your calls to less what the framerate is, for example to once per 20ms.

The next thing is that this will only draw one rectangle which bounces around.

And the last issue is that for a low value of average, all if()s will be true.
Whatever the value of "average" actually is, it is not defined or changed in the function.

Start smaller?

Code: [Select]
Ft_App_WrCoCmd_Buffer(phost, CLEAR(1, 1, 1));

Ft_App_WrCoCmd_Buffer(phost, BEGIN(RECTS));

Ft_App_WrCoCmd_Buffer(phost, COLOR_RGB(255, 255, 255));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2F(10 * 16,  10 * 16));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2F(90 *16, 90 * 16));

Ft_App_WrCoCmd_Buffer(phost, COLOR_RGB(255, 0, 0));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2F(100 * 16,  10 * 16));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2F(190 *16, 100 * 16));

Ft_App_WrCoCmd_Buffer(phost, COLOR_RGB(0, 255, 0));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2F(200 * 16,  10 * 16));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2F(290 *16, 100 * 16));

Ft_App_WrCoCmd_Buffer(phost, COLOR_RGB(0, 0, 255));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2F(300 * 16,  10 * 16));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2F(390 *16, 100 * 16));

Ft_App_WrCoCmd_Buffer(phost, END());

Ft_App_WrCoCmd_Buffer(phost, DISPLAY());

I was doing some tests with Arduino earlier this evening anyways and also uploaded
a new Arduino example using PlatformIO to my Github-Repository:

The attached archive is a very slightly modified version of this.
platformio.ini: changed env, platform and board
EVE_config.h: activated EVE_NHD_50
EVE_target.h: changed EVE_CS in line 851 to "10" to match the New Haven NHD-FT81x-SHIELD

It builds just fine in Visual Studio Code using the PlatformIO plugin.
And as the main file is named src.ino in also can be opened with the Arduino IDE and builds just fine for the Due.

I can not test it however as I do not have a Due, the shield or the display.

Apart from the touch however it should work fine.
The reason why the touch probably is not working is because I do not have calibration data for the display.

Edit: I forgot to change the "SPI.setClockDivider(SPI_CLOCK_DIV2);" in src.ino
But as it turns out, this is defined as "11" for the Due and does not mean clock divided by two. :-)
This can be replaced with
Code: [Select]
SPI.setClockDivider(8); to speed things up a little.
« Last Edit: February 17, 2020, 03:48:17 PM by Rudolph »