Skip to content

Commit

Permalink
- updated all the examples and checked that everything still compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
RudolphRiedel committed Jan 8, 2023
1 parent 2733efd commit 9b62c2d
Show file tree
Hide file tree
Showing 46 changed files with 2,402 additions and 3,124 deletions.
96 changes: 49 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ It contains code for and has been used with various micro-controllers and displa

## Controllers

I have used it so far with:

I have used it so far with:
- 8-Bit AVR, specifically the 90CAN series
- Arduino: Uno, mini-pro, ESP8266, ESP32 (DMA), Metro-M4 (DMA), STM32 Nucleo_F446RE (DMA), XMC1100
- Renesas F1L RH850
Expand All @@ -23,8 +22,7 @@ I have used it so far with:
- S32K144 (DMA)
- GD32C103CBT6 (DMA)

I have reports of successfully using it with:

I have reports of successfully using it with:
- ATSAMV70
- ATSAMD20
- ATSAME4
Expand All @@ -36,8 +34,7 @@ I have reports of successfully using it with:

## Displays

The TFTs tested so far:

The TFTs tested so far:
- FT810CB-HY50HD http://www.hotmcu.com/5-graphical-lcd-touchscreen-800x480-spi-ft810-p-286.html
- FT811CB-HY50HD http://www.hotmcu.com/5-graphical-lcd-capacitive-touch-screen-800x480-spi-ft811-p-301.html
- RVT70UQFNWC0x https://riverdi.com/product/rvt70uqfnwc0x/
Expand Down Expand Up @@ -68,28 +65,26 @@ The TFTs tested so far:

This is version 5 of this code library and there are a couple of changes from V4.

First of all, support for FT80x is gone. The main reason is that this allowed a nice speed improvement modification that only works with FT81x and beyond.
First of all, support for FT80x is gone.
The main reason is that this allowed a nice speed improvement modification that only works with FT81x and beyond.
Then there is a hard break from FT80x to FT81x with ony 256k of memory in FT80x but 1MB in FT81x. The memory map is different and all the registers are located elsewhere.
FT810, FT811, FT812, FT813, BT815, BT816, BT817 and BT818 can use the exact same code as long none of the new features of BT81x are used - and there are plenty of modules with these available to choose from

As a side effect all commands are automatically started now.

Second is that there are two sets of display-list building command functions now: EVE_cmd_xxx() and EVE_cmd_xxx_burst().
FT810, FT811, FT812, FT813, BT815, BT816, BT817 and BT818 can use the exact same code as long none of the new features of BT81x are used - and there are plenty of modules with these available to choose from.
As a side effect all commands are automatically started now.
Second is that there are two sets of display-list building command functions now: EVE_cmd_xxx() and EVE_cmd_xxx_burst().
The EVE_cmd_xxx_burst() functions are optimized for speed, these are pure data transfer functions and do not even check anymore if burst mode is active.

## Structure

This library currently has nine files that I hope are named to make clear what these do:

- EVE.h - this has all defines for FT81x / BT81x itself, so here are options, registers, commands and macros defined
- EVE_commands.c - this has all the API functions that are to be called from an application
- EVE_commands.h - this contains the prototypes for the functions in EVE_commands.c
- EVE_config.h - this has all the parameters for the numerous supported display modules, here is definded which set of parameters is to be used
- EVE_target.c - this has non-portable specific code for a number of supported controllers, mostly to support DMA
- EVE_target.h - this has non-portable pin defines and code as "static inline" functions for all supported controllers
- EVE_target.cpp - this is for Arduino C++ targets
- EVE_cpp_wrapper.cpp - this is for Arduino C++ targets
- EVE_cpp_wrapper.h - this is for Arduino C++ targets
This library currently has nine files that I hope are named to make clear what these do:
- EVE.h - this has all defines for FT81x / BT81x itself, so here are options, registers, commands and macros defined
- EVE_commands.c - this has all the API functions that are to be called from an application
- EVE_commands.h - this contains the prototypes for the functions in EVE_commands.c
- EVE_config.h - this has all the parameters for the numerous supported display modules, here is definded which set of parameters is to be used
- EVE_target.c - this has non-portable specific code for a number of supported controllers, mostly to support DMA
- EVE_target.h - this has non-portable pin defines and code as "static inline" functions for all supported controllers
- EVE_target.cpp - this is for Arduino C++ targets
- EVE_cpp_wrapper.cpp - this is for Arduino C++ targets
- EVE_cpp_wrapper.h - this is for Arduino C++ targets

## Examples

Expand All @@ -100,7 +95,7 @@ EVE_cmd_dl(DL_CLEAR_COLOR_RGB | WHITE); // sets the background color
EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG);
EVE_color_rgb(BLACK);
EVE_cmd_text(5, 15, 28, 0, "Hello there!");
EVE_cmd_dl(DL_DISPLAY); // put in the display list to mark its end
EVE_cmd_dl(DL_DISPLAY); // put in the display list to mark the end
EVE_cmd_dl(CMD_SWAP); // tell EVE to use the new display list
while (EVE_busy());
````
Expand All @@ -121,11 +116,11 @@ EVE_end_cmd_burst();
while (EVE_busy());
````

This does the same as the first example but faster.
This does the same as the first example but faster.
The preceding EVE_start_cmd_burst() either sets chip-select to low and sends out the three byte address.
Or if DMA is available for the target you are compiling for with support code in EVE_target.c / EVE_target.cpp and EVE_target.h, it writes the address to EVE_dma_buffer and sets EVE_dma_buffer_index to 1.
Or if DMA is available for the target you are compiling for with support code in EVE_target.c / EVE_target.cpp and EVE_target.h, it writes the address to EVE_dma_buffer[] and sets EVE_dma_buffer_index to 1.

Note the trailing "_burst" in the following functions, these are special versions of these commands that can only be used within an EVE_start_cmd_burst()/EVE_end_cmd_bust() pair.
Note the trailing "_burst" in the following functions, these are special versions of these commands that can only be used within an EVE_start_cmd_burst()/EVE_end_cmd_bust() pair.
These functions are optimized to push out data and nothing else.

The final EVE_end_cmd_burst() either pulls back the chip-select to high.
Expand All @@ -134,7 +129,7 @@ Or if we have DMA it calls EVE_start_dma_transfer() to start pushing out the buf
As we have 7 commands for EVE in these simple examples, the second one has the address overhead removed from six commands and therefore needs to transfer 18 bytes less over SPI.
So even with a small 8-bit controller that does not support DMA this is a usefull optimization for building display lists.

Using DMA has one caveat: we need to limit the transfer to <4k as we are writing to the FIFO of EVEs command co-processor. This is usually not an issue though as we can shorten the display list generation with previously generated snippets that we attach to the current list with CMD_APPEND. And when we use widgets like CMD_BUTTON or CMD_CLOCK the generated display list grows by a larger amount than what we need to put into the command-FIFO so we likely reach the 8k limit of the display-list before we hit the 4k limit of the command-FIFO.
Using DMA has one caveat: we need to limit the transfer to <4k as we are writing to the FIFO of EVEs command co-processor. This is usually not an issue though as we can shorten the display list generation with previously generated snippets that we attach to the current list with CMD_APPEND. And when we use widgets like CMD_BUTTON or CMD_CLOCK the generated display list grows by a larger amount than what we need to put into the command-FIFO so we likely reach the 8k limit of the display-list before we hit the 4k limit of the command-FIFO.
It is possible to use two or more DMA transfers to the FIFO to build a single display list, either to get around the 4k limit of the FIFO or in order to distribute the workload better of the time necessary between two display renewals.

You could for example do this, spread over three consecutive calls:
Expand All @@ -160,9 +155,9 @@ EVE_cmd_dl_burst(CMD_SWAP);
EVE_end_cmd_burst();
````

But you need to check with EVE_busy() before each of these blocks.
Maybe similar like this never compiled pseudo-code:

But you need to check with EVE_busy() before each of these blocks.
Maybe similar like this never compiled pseudo-code:
````
thread_1ms_update_display()
{
static uint8_t state = 0;
Expand Down Expand Up @@ -193,32 +188,39 @@ thread_1ms_update_display()
}
}
}

````

## Remarks

The examples in the "example_projects" drawer are for use with AtmelStudio7.
The examples in the "example_projects" drawer are for use with AtmelStudio7.
For Arduino I am using PlatformIO with Visual Studio Code.

The platform the code is compiled for is automatically detected thru compiler flags in EVE_target.h.

The desired TFT is selected by adding a define for it to the build-environment, e.g. -DEVE_EVE3_50G
There is a list of available options at the start of EVE_config.h sorted by chipset.

- Provide the pins used for Chip-Select and Power-Down in EVE_target.h for the target configuration you are using
The platform the code is compiled for is automatically detected thru compiler flags in EVE_target.h.
The desired TFT is selected by adding a define for it to the build-environment, for example: "-DEVE_EVE3_50G"
There is a list of available options at the start of EVE_config.h sorted by chipset.
The pins used for Chip-Select and Power-Down are configured in the EVE_target/EVE_target_xxxx.h files like this:
````
#if !defined(EVE_CS)
#define EVE_CS 10
#endif
When compiling for AVR you need to provide the clock it is running at in order to make the _delay_ms() calls used to initialize the TFT work with the intended timing.
For other plattforms you need to provide a DELAY_MS(ms) function that works at least between 1ms and 56ms and is not performing these delays shorter than requested.
#if !defined(EVE_PDN)
#define EVE_PDN 8
#endif
````
So you can override the default settings by adding your own defines to your build-environment, for example: "-DEVE_CS=9"
When compiling for AVR you need to provide the clock it is running at in order to make the _delay_ms() calls used to initialize the TFT work with the intended timing.
For other plattforms you need to provide a DELAY_MS(ms) function that works at least between 1ms and 56ms and is not performing these delays shorter than requested.
The DELAY_MS(ms) is only used during initialization of the FT8xx/BT8xx.
See EVE_target.h for examples.
See EVE_target.h for examples.

In Addition you need to initialize the pins used for Chip-Select and Power-Down in your hardware correctly to output.
Plus setup the SPI accordingly, mode-0, 8-bit, MSB-first, not more than 11MHz for the init.
A couple of targets already have a function EVE_init_spi() in EVE_target.c.
In Addition you need to initialize the pins used for Chip-Select and Power-Down in your hardware correctly to output.
Plus setup the SPI accordingly, mode-0, 8-bit, MSB-first, not more than 11MHz for the init.
A couple of targets already have a function EVE_init_spi() in EVE_target.c or EVE_cpp_target.cpp.

A word of "warning", you have to take a little care yourself to for example not send more than 4kB at once to the command co-processor
or to not generate display lists that are longer than 8kB.
My library does not check and re-check the command-FIFO on every step.
or to not generate display lists that are longer than 8kB.
My library does not check and re-check the command-FIFO on every step.
This is optimized for speed, so the training wheels are off.

## Post questions here
Expand Down
71 changes: 41 additions & 30 deletions examples/EVE_Test_Arduino_PlatformIO/src/tft.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
@file tft.c / tft.cpp
@file tft.c
@brief TFT handling functions for EVE_Test project
@version 1.20
@date 2022-12-10
@version 1.21
@date 2023-01-08
@author Rudolph Riedel
@section History
Expand All @@ -19,12 +19,16 @@
- renamed PINK to MAGENTA
1.20
- several minor changes
1.21
- several minor changes
*/

#include "EVE.h"
#include "tft_data.h"
#include "tft.h"


#define TEST_UTF8 0
Expand All @@ -47,16 +51,20 @@
#define MEM_LOGO 0x000f8000 /* start-address of logo, needs 6272 bytes of memory */
#define MEM_PIC1 0x000fa000 /* start of 100x100 pixel test image, ARGB565, needs 20000 bytes of memory */


#define MEM_DL_STATIC (EVE_RAM_G_SIZE - 4096) /* 0xff000 - start-address of the static part of the display-list, upper 4k of gfx-mem */

uint32_t num_dl_static; /* amount of bytes in the static part of our display-list */
uint32_t num_dl_static = 0; /* amount of bytes in the static part of our display-list */
uint8_t tft_active = 0;
uint16_t num_profile_a, num_profile_b;
uint16_t num_profile_a = 0;
uint16_t num_profile_b = 0;

#define LAYOUT_Y1 66


void touch_calibrate(void);
void initStaticBackground(void);


void touch_calibrate(void)
{

Expand Down Expand Up @@ -210,6 +218,8 @@ void touch_calibrate(void)
/* write down the numbers on the screen and either place them in one of the pre-defined blocks above or make a new block */
#if 0
/* calibrate touch and displays values to screen */

#if 1
EVE_cmd_dl(CMD_DLSTART);
EVE_cmd_dl(DL_CLEAR_COLOR_RGB | BLACK);
EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG);
Expand All @@ -218,15 +228,16 @@ void touch_calibrate(void)
EVE_cmd_dl(DL_DISPLAY);
EVE_cmd_dl(CMD_SWAP);
EVE_execute_cmd();
#else
EVE_calibrate_manual(EVE_HSIZE, EVE_VSIZE);
#endif

uint32_t touch_a, touch_b, touch_c, touch_d, touch_e, touch_f;

touch_a = EVE_memRead32(REG_TOUCH_TRANSFORM_A);
touch_b = EVE_memRead32(REG_TOUCH_TRANSFORM_B);
touch_c = EVE_memRead32(REG_TOUCH_TRANSFORM_C);
touch_d = EVE_memRead32(REG_TOUCH_TRANSFORM_D);
touch_e = EVE_memRead32(REG_TOUCH_TRANSFORM_E);
touch_f = EVE_memRead32(REG_TOUCH_TRANSFORM_F);
uint32_t touch_a = EVE_memRead32(REG_TOUCH_TRANSFORM_A);
uint32_t touch_b = EVE_memRead32(REG_TOUCH_TRANSFORM_B);
uint32_t touch_c = EVE_memRead32(REG_TOUCH_TRANSFORM_C);
uint32_t touch_d = EVE_memRead32(REG_TOUCH_TRANSFORM_D);
uint32_t touch_e = EVE_memRead32(REG_TOUCH_TRANSFORM_E);
uint32_t touch_f = EVE_memRead32(REG_TOUCH_TRANSFORM_F);

EVE_cmd_dl(CMD_DLSTART);
EVE_cmd_dl(DL_CLEAR_COLOR_RGB | BLACK);
Expand Down Expand Up @@ -260,25 +271,25 @@ void touch_calibrate(void)
void initStaticBackground(void)
{
EVE_cmd_dl(CMD_DLSTART); /* Start the display list */
EVE_cmd_dl(TAG(0)); /* do not use the following objects for touch-detection */
EVE_cmd_dl(DL_TAG); /* no tag = 0 - do not use the following objects for touch-detection */

EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */
EVE_cmd_bgcolor(0x00c0c0c0UL); /* light grey */

EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */
EVE_cmd_dl(DL_VERTEX_FORMAT); /* set to 0 - reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */

/* draw a rectangle on top */
EVE_cmd_dl(DL_BEGIN | EVE_RECTS);
EVE_cmd_dl(LINE_WIDTH(1*16)); /* size is in 1/16 pixel */
EVE_cmd_dl(LINE_WIDTH(1U*16U)); /* size is in 1/16 pixel */

EVE_color_rgb(BLUE_1);
EVE_cmd_dl(VERTEX2F(0,0));
EVE_cmd_dl(DL_VERTEX2F); /* set to 0 / 0 */
EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2));
EVE_cmd_dl(DL_END);

/* display the logo */
EVE_color_rgb(WHITE);
EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS);
EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56);
EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56U, 56U);
EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5));
EVE_cmd_dl(DL_END);

Expand Down Expand Up @@ -341,7 +352,7 @@ void TFT_init(void)

if (E_OK == EVE_init_flash())
{
EVE_cmd_flashread(MEM_FONT, 84928, 320); /* copy .xfont from FLASH to RAM_G, offset and length are from the .map file */
EVE_cmd_flashread(MEM_FONT, 61376, 320); /* copy .xfont from FLASH to RAM_G, offset and length are from the .map file */
}

#endif /* TEST_UTF8 */
Expand All @@ -353,7 +364,6 @@ void TFT_init(void)
}
}


uint16_t toggle_state = 0;
uint16_t display_list_size = 0;

Expand Down Expand Up @@ -394,19 +404,20 @@ void TFT_touch(void)
}
}
break;
default:
break;
}
}
}


/*
dynamic portion of display-handling, meant to be called every 20ms or more
*/
void TFT_display(void)
{
static int32_t rotate = 0;

if(tft_active != 0)
if(tft_active != 0U)
{
#if defined (EVE_DMA)
uint16_t cmd_fifo_size;
Expand All @@ -418,18 +429,18 @@ void TFT_display(void)
EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */
EVE_cmd_dl_burst(DL_CLEAR_COLOR_RGB | WHITE); /* set the default clear color to white */
EVE_cmd_dl_burst(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); /* clear the screen - this and the previous prevent artifacts between lists, Attributes are the color, stencil and tag buffers */
EVE_cmd_dl_burst(TAG(0));
EVE_cmd_dl_burst(DL_TAG);

EVE_cmd_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */
/* display a button */
EVE_color_rgb_burst(WHITE);
EVE_cmd_fgcolor_burst(0x00c0c0c0); /* some grey */
EVE_cmd_dl_burst(TAG(10)); /* assign tag-value '10' to the button that follows */
EVE_cmd_fgcolor_burst(0x00c0c0c0UL); /* some grey */
EVE_cmd_dl_burst(DL_TAG+10U); /* assign tag-value '10' to the button that follows */
EVE_cmd_button_burst(20,20,80,30, 28, toggle_state,"Touch!");
EVE_cmd_dl_burst(TAG(0)); /* no touch */
EVE_cmd_dl_burst(DL_TAG); /* no touch */

/* display a picture and rotate it when the button on top is activated */
EVE_cmd_setbitmap_burst(MEM_PIC1, EVE_RGB565, 100, 100);
EVE_cmd_setbitmap_burst(MEM_PIC1, EVE_RGB565, 100U, 100U);

EVE_cmd_dl_burst(DL_SAVE_CONTEXT);
EVE_cmd_dl_burst(CMD_LOADIDENTITY);
Expand All @@ -438,7 +449,7 @@ void TFT_display(void)
EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */
EVE_cmd_dl_burst(CMD_SETMATRIX);

if(toggle_state != 0)
if(toggle_state != 0U)
{
rotate += 256;
}
Expand Down
Loading

0 comments on commit 9b62c2d

Please sign in to comment.