Skip to content

Commit 9b62c2d

Browse files
committed
- updated all the examples and checked that everything still compiles
1 parent 2733efd commit 9b62c2d

File tree

46 files changed

+2402
-3124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2402
-3124
lines changed

README.md

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ It contains code for and has been used with various micro-controllers and displa
1010

1111
## Controllers
1212

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

26-
I have reports of successfully using it with:
27-
25+
I have reports of successfully using it with:
2826
- ATSAMV70
2927
- ATSAMD20
3028
- ATSAME4
@@ -36,8 +34,7 @@ I have reports of successfully using it with:
3634

3735
## Displays
3836

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

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

71-
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.
68+
First of all, support for FT80x is gone.
69+
The main reason is that this allowed a nice speed improvement modification that only works with FT81x and beyond.
7270
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.
73-
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
74-
75-
As a side effect all commands are automatically started now.
76-
77-
Second is that there are two sets of display-list building command functions now: EVE_cmd_xxx() and EVE_cmd_xxx_burst().
71+
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.
72+
As a side effect all commands are automatically started now.
73+
Second is that there are two sets of display-list building command functions now: EVE_cmd_xxx() and EVE_cmd_xxx_burst().
7874
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.
7975

8076
## Structure
8177

82-
This library currently has nine files that I hope are named to make clear what these do:
83-
84-
- EVE.h - this has all defines for FT81x / BT81x itself, so here are options, registers, commands and macros defined
85-
- EVE_commands.c - this has all the API functions that are to be called from an application
86-
- EVE_commands.h - this contains the prototypes for the functions in EVE_commands.c
87-
- 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
88-
- EVE_target.c - this has non-portable specific code for a number of supported controllers, mostly to support DMA
89-
- EVE_target.h - this has non-portable pin defines and code as "static inline" functions for all supported controllers
90-
- EVE_target.cpp - this is for Arduino C++ targets
91-
- EVE_cpp_wrapper.cpp - this is for Arduino C++ targets
92-
- EVE_cpp_wrapper.h - this is for Arduino C++ targets
78+
This library currently has nine files that I hope are named to make clear what these do:
79+
- EVE.h - this has all defines for FT81x / BT81x itself, so here are options, registers, commands and macros defined
80+
- EVE_commands.c - this has all the API functions that are to be called from an application
81+
- EVE_commands.h - this contains the prototypes for the functions in EVE_commands.c
82+
- 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
83+
- EVE_target.c - this has non-portable specific code for a number of supported controllers, mostly to support DMA
84+
- EVE_target.h - this has non-portable pin defines and code as "static inline" functions for all supported controllers
85+
- EVE_target.cpp - this is for Arduino C++ targets
86+
- EVE_cpp_wrapper.cpp - this is for Arduino C++ targets
87+
- EVE_cpp_wrapper.h - this is for Arduino C++ targets
9388

9489
## Examples
9590

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

124-
This does the same as the first example but faster.
119+
This does the same as the first example but faster.
125120
The preceding EVE_start_cmd_burst() either sets chip-select to low and sends out the three byte address.
126-
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.
121+
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.
127122

128-
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.
123+
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.
129124
These functions are optimized to push out data and nothing else.
130125

131126
The final EVE_end_cmd_burst() either pulls back the chip-select to high.
@@ -134,7 +129,7 @@ Or if we have DMA it calls EVE_start_dma_transfer() to start pushing out the buf
134129
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.
135130
So even with a small 8-bit controller that does not support DMA this is a usefull optimization for building display lists.
136131

137-
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.
132+
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.
138133
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.
139134

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

163-
But you need to check with EVE_busy() before each of these blocks.
164-
Maybe similar like this never compiled pseudo-code:
165-
158+
But you need to check with EVE_busy() before each of these blocks.
159+
Maybe similar like this never compiled pseudo-code:
160+
````
166161
thread_1ms_update_display()
167162
{
168163
static uint8_t state = 0;
@@ -193,32 +188,39 @@ thread_1ms_update_display()
193188
}
194189
}
195190
}
196-
191+
````
197192

198193
## Remarks
199194

200-
The examples in the "example_projects" drawer are for use with AtmelStudio7.
195+
The examples in the "example_projects" drawer are for use with AtmelStudio7.
201196
For Arduino I am using PlatformIO with Visual Studio Code.
202197

203-
The platform the code is compiled for is automatically detected thru compiler flags in EVE_target.h.
204-
205-
The desired TFT is selected by adding a define for it to the build-environment, e.g. -DEVE_EVE3_50G
206-
There is a list of available options at the start of EVE_config.h sorted by chipset.
207-
208-
- Provide the pins used for Chip-Select and Power-Down in EVE_target.h for the target configuration you are using
198+
The platform the code is compiled for is automatically detected thru compiler flags in EVE_target.h.
199+
The desired TFT is selected by adding a define for it to the build-environment, for example: "-DEVE_EVE3_50G"
200+
There is a list of available options at the start of EVE_config.h sorted by chipset.
201+
The pins used for Chip-Select and Power-Down are configured in the EVE_target/EVE_target_xxxx.h files like this:
202+
````
203+
#if !defined(EVE_CS)
204+
#define EVE_CS 10
205+
#endif
209206
210-
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.
211-
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.
207+
#if !defined(EVE_PDN)
208+
#define EVE_PDN 8
209+
#endif
210+
````
211+
So you can override the default settings by adding your own defines to your build-environment, for example: "-DEVE_CS=9"
212+
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.
213+
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.
212214
The DELAY_MS(ms) is only used during initialization of the FT8xx/BT8xx.
213-
See EVE_target.h for examples.
215+
See EVE_target.h for examples.
214216

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

219221
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
220-
or to not generate display lists that are longer than 8kB.
221-
My library does not check and re-check the command-FIFO on every step.
222+
or to not generate display lists that are longer than 8kB.
223+
My library does not check and re-check the command-FIFO on every step.
222224
This is optimized for speed, so the training wheels are off.
223225

224226
## Post questions here

examples/EVE_Test_Arduino_PlatformIO/src/tft.c

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
@file tft.c / tft.cpp
2+
@file tft.c
33
@brief TFT handling functions for EVE_Test project
4-
@version 1.20
5-
@date 2022-12-10
4+
@version 1.21
5+
@date 2023-01-08
66
@author Rudolph Riedel
77
88
@section History
@@ -19,12 +19,16 @@
1919
- renamed PINK to MAGENTA
2020
2121
1.20
22+
- several minor changes
23+
24+
1.21
2225
- several minor changes
2326
2427
*/
2528

2629
#include "EVE.h"
2730
#include "tft_data.h"
31+
#include "tft.h"
2832

2933

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

50-
5154
#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 */
5255

53-
uint32_t num_dl_static; /* amount of bytes in the static part of our display-list */
56+
uint32_t num_dl_static = 0; /* amount of bytes in the static part of our display-list */
5457
uint8_t tft_active = 0;
55-
uint16_t num_profile_a, num_profile_b;
58+
uint16_t num_profile_a = 0;
59+
uint16_t num_profile_b = 0;
5660

5761
#define LAYOUT_Y1 66
5862

5963

64+
void touch_calibrate(void);
65+
void initStaticBackground(void);
66+
67+
6068
void touch_calibrate(void)
6169
{
6270

@@ -210,6 +218,8 @@ void touch_calibrate(void)
210218
/* write down the numbers on the screen and either place them in one of the pre-defined blocks above or make a new block */
211219
#if 0
212220
/* calibrate touch and displays values to screen */
221+
222+
#if 1
213223
EVE_cmd_dl(CMD_DLSTART);
214224
EVE_cmd_dl(DL_CLEAR_COLOR_RGB | BLACK);
215225
EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG);
@@ -218,15 +228,16 @@ void touch_calibrate(void)
218228
EVE_cmd_dl(DL_DISPLAY);
219229
EVE_cmd_dl(CMD_SWAP);
220230
EVE_execute_cmd();
231+
#else
232+
EVE_calibrate_manual(EVE_HSIZE, EVE_VSIZE);
233+
#endif
221234

222-
uint32_t touch_a, touch_b, touch_c, touch_d, touch_e, touch_f;
223-
224-
touch_a = EVE_memRead32(REG_TOUCH_TRANSFORM_A);
225-
touch_b = EVE_memRead32(REG_TOUCH_TRANSFORM_B);
226-
touch_c = EVE_memRead32(REG_TOUCH_TRANSFORM_C);
227-
touch_d = EVE_memRead32(REG_TOUCH_TRANSFORM_D);
228-
touch_e = EVE_memRead32(REG_TOUCH_TRANSFORM_E);
229-
touch_f = EVE_memRead32(REG_TOUCH_TRANSFORM_F);
235+
uint32_t touch_a = EVE_memRead32(REG_TOUCH_TRANSFORM_A);
236+
uint32_t touch_b = EVE_memRead32(REG_TOUCH_TRANSFORM_B);
237+
uint32_t touch_c = EVE_memRead32(REG_TOUCH_TRANSFORM_C);
238+
uint32_t touch_d = EVE_memRead32(REG_TOUCH_TRANSFORM_D);
239+
uint32_t touch_e = EVE_memRead32(REG_TOUCH_TRANSFORM_E);
240+
uint32_t touch_f = EVE_memRead32(REG_TOUCH_TRANSFORM_F);
230241

231242
EVE_cmd_dl(CMD_DLSTART);
232243
EVE_cmd_dl(DL_CLEAR_COLOR_RGB | BLACK);
@@ -260,25 +271,25 @@ void touch_calibrate(void)
260271
void initStaticBackground(void)
261272
{
262273
EVE_cmd_dl(CMD_DLSTART); /* Start the display list */
263-
EVE_cmd_dl(TAG(0)); /* do not use the following objects for touch-detection */
274+
EVE_cmd_dl(DL_TAG); /* no tag = 0 - do not use the following objects for touch-detection */
264275

265-
EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */
276+
EVE_cmd_bgcolor(0x00c0c0c0UL); /* light grey */
266277

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

269280
/* draw a rectangle on top */
270281
EVE_cmd_dl(DL_BEGIN | EVE_RECTS);
271-
EVE_cmd_dl(LINE_WIDTH(1*16)); /* size is in 1/16 pixel */
282+
EVE_cmd_dl(LINE_WIDTH(1U*16U)); /* size is in 1/16 pixel */
272283

273284
EVE_color_rgb(BLUE_1);
274-
EVE_cmd_dl(VERTEX2F(0,0));
285+
EVE_cmd_dl(DL_VERTEX2F); /* set to 0 / 0 */
275286
EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2));
276287
EVE_cmd_dl(DL_END);
277288

278289
/* display the logo */
279290
EVE_color_rgb(WHITE);
280291
EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS);
281-
EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56);
292+
EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56U, 56U);
282293
EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5));
283294
EVE_cmd_dl(DL_END);
284295

@@ -341,7 +352,7 @@ void TFT_init(void)
341352

342353
if (E_OK == EVE_init_flash())
343354
{
344-
EVE_cmd_flashread(MEM_FONT, 84928, 320); /* copy .xfont from FLASH to RAM_G, offset and length are from the .map file */
355+
EVE_cmd_flashread(MEM_FONT, 61376, 320); /* copy .xfont from FLASH to RAM_G, offset and length are from the .map file */
345356
}
346357

347358
#endif /* TEST_UTF8 */
@@ -353,7 +364,6 @@ void TFT_init(void)
353364
}
354365
}
355366

356-
357367
uint16_t toggle_state = 0;
358368
uint16_t display_list_size = 0;
359369

@@ -394,19 +404,20 @@ void TFT_touch(void)
394404
}
395405
}
396406
break;
407+
default:
408+
break;
397409
}
398410
}
399411
}
400412

401-
402413
/*
403414
dynamic portion of display-handling, meant to be called every 20ms or more
404415
*/
405416
void TFT_display(void)
406417
{
407418
static int32_t rotate = 0;
408419

409-
if(tft_active != 0)
420+
if(tft_active != 0U)
410421
{
411422
#if defined (EVE_DMA)
412423
uint16_t cmd_fifo_size;
@@ -418,18 +429,18 @@ void TFT_display(void)
418429
EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */
419430
EVE_cmd_dl_burst(DL_CLEAR_COLOR_RGB | WHITE); /* set the default clear color to white */
420431
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 */
421-
EVE_cmd_dl_burst(TAG(0));
432+
EVE_cmd_dl_burst(DL_TAG);
422433

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

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

434445
EVE_cmd_dl_burst(DL_SAVE_CONTEXT);
435446
EVE_cmd_dl_burst(CMD_LOADIDENTITY);
@@ -438,7 +449,7 @@ void TFT_display(void)
438449
EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */
439450
EVE_cmd_dl_burst(CMD_SETMATRIX);
440451

441-
if(toggle_state != 0)
452+
if(toggle_state != 0U)
442453
{
443454
rotate += 256;
444455
}

0 commit comments

Comments
 (0)