From f67c44c78c0041520ece92eecd9004928f97cba2 Mon Sep 17 00:00:00 2001 From: RudolphRiedel <31180093+RudolphRiedel@users.noreply.github.com> Date: Mon, 27 Dec 2021 19:47:43 +0100 Subject: [PATCH] - maintenance release - EVE_init() and EVE_init_flash() return E_OK = 0x00 now and more meaningfull values in case of failure - EVE_busy() still returns 0x00 (E_OK) in case EVE is not busy and EVE_IS_BUSY instead of 1 in case it is busy - no real change in functionality --- EVE_commands.c | 113 ++-- EVE_commands.h | 29 +- EVE_config.h | 27 +- EVE_target.h | 8 +- README.md | 2 +- .../EVE_Test_Arduino_PlatformIO/src/tft.c | 614 +++++++++--------- examples/EVE_Test_ESP32_PlatformIO/src/tft.c | 614 +++++++++--------- .../src/tft.c | 614 +++++++++--------- .../EmbeddedVideoEngine/EVE_commands.c | 113 ++-- .../EmbeddedVideoEngine/EVE_commands.h | 29 +- .../EmbeddedVideoEngine/EVE_config.h | 27 +- .../EmbeddedVideoEngine/EVE_target.h | 8 +- .../EmbeddedVideoEngine/README.md | 2 +- .../EmbeddedVideoEngine/library.json | 2 +- examples/EVE_Test_SAMC21_EVE2-50G/tft.c | 614 +++++++++--------- .../src/tft.c | 614 +++++++++--------- .../EmbeddedVideoEngine/EVE_commands.c | 113 ++-- .../EmbeddedVideoEngine/EVE_commands.h | 29 +- .../EmbeddedVideoEngine/EVE_config.h | 27 +- .../EmbeddedVideoEngine/EVE_target.h | 8 +- .../EmbeddedVideoEngine/README.md | 2 +- .../EmbeddedVideoEngine/library.json | 2 +- examples/EVE_Test_SAME51_EVE3-43G/tft.c | 614 +++++++++--------- .../src/tft.c | 614 +++++++++--------- .../EmbeddedVideoEngine/EVE_commands.c | 113 ++-- .../EmbeddedVideoEngine/EVE_commands.h | 29 +- .../EmbeddedVideoEngine/EVE_config.h | 27 +- .../EmbeddedVideoEngine/EVE_target.h | 8 +- .../EmbeddedVideoEngine/README.md | 2 +- .../EmbeddedVideoEngine/library.json | 2 +- .../Display_Test1/tft.c | 614 +++++++++--------- library.json | 2 +- 32 files changed, 2996 insertions(+), 2640 deletions(-) diff --git a/EVE_commands.c b/EVE_commands.c index 420cab4..604fbd4 100644 --- a/EVE_commands.c +++ b/EVE_commands.c @@ -2,7 +2,7 @@ @file EVE_commands.c @brief contains FT8xx / BT8xx functions @version 5.0 -@date 2021-10-30 +@date 2021-12-27 @author Rudolph Riedel @section info @@ -154,6 +154,11 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - converted all TABs to SPACEs - made EVE_TOUCH_RZTHRESH in EVE_init() optional to a) remove it from EVE_config.h and b) make it configureable externally - changed EVE_init() to write 1200U to REG_TOUCH_RZTHRESH if EVE_TOUCH_RZTHRESH is not defined +- changed EVE_init() to return E_OK = 0x00 in case of success and more meaningfull values in case of failure +- changed EVE_busy() to return EVE_IS_BUSY if EVE is busy and E_OK = 0x00 if EVE is not busy - no real change in functionality +- finally removed EVE_cmd_start() after setting it to deprecatd with the first 5.0 release +- renamed EVE_cmd_execute() to EVE_execute_cmd() to be more consistent, this is is not an EVE command +- changed EVE_init_flash() to return E_OK in case of success and more meaningfull values in case of failure */ @@ -297,9 +302,12 @@ void EVE_memWrite_sram_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t } -/* Check if the graphics processor completed executing the current command list. */ -/* REG_CMDB_SPACE == 0xffc -> command fifo is empty */ -/* (REG_CMDB_SPACE & 0x03) != 0 -> we have a co-processor fault */ +/** + * @brief Check if the co-processor completed executing the current command list. + * + * @return returns E_OK in case EVE is not busy (REG_CMDB_SPACE has the value 0xffc), + * returns EVE_IS_BUSY if a DMA transfer is active or REG_CMDB_SPACE has a value smaller than 0xffc + */ uint8_t EVE_busy(void) { uint16_t space; @@ -307,12 +315,13 @@ uint8_t EVE_busy(void) #if defined (EVE_DMA) if(EVE_dma_busy) { - return 1; + return EVE_IS_BUSY; } #endif space = EVE_memRead16(REG_CMDB_SPACE); + /* (REG_CMDB_SPACE & 0x03) != 0 -> we have a co-processor fault */ if((space & 0x3) != 0) /* we have a co-processor fault, make EVE play with us again */ { #if EVE_GEN > 2 @@ -349,25 +358,14 @@ uint8_t EVE_busy(void) #endif } - return (space != 0xffc) ? 1 : 0; + return (space != 0xffc) ? EVE_IS_BUSY : E_OK; } -/* deprecated, with using REG_CMDB_WRITE commands will be automatically excecuted on the rising edge of chip select */ -/* order the command co-processor to start processing its FIFO queue and do not wait for completion */ -void EVE_cmd_start(void) -{ -#if defined (EVE_DMA) - if(EVE_dma_busy) - { - return; /* just do nothing if a dma transfer is in progress */ - } -#endif -} - - -/* wait for the co-processor to complete the FIFO queue */ -void EVE_cmd_execute(void) +/** + * @brief Wait for the co-processor to complete the FIFO queue. + */ +void EVE_execute_cmd(void) { while (EVE_busy()) {}; } @@ -481,7 +479,7 @@ void EVE_cmd_fontcachequery(uint32_t *total, int32_t *used) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()); - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(total) { @@ -507,7 +505,7 @@ void EVE_cmd_getimage(uint32_t *source, uint32_t *fmt, uint32_t *width, uint32_t spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()); - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(palette) { @@ -564,7 +562,7 @@ uint32_t EVE_cmd_pclkfreq(uint32_t ftarget, int32_t rounding) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -645,7 +643,7 @@ uint32_t EVE_cmd_flashfast(void) EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -786,7 +784,7 @@ void EVE_cmd_getprops(uint32_t *pointer, uint32_t *width, uint32_t *height) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(pointer) { @@ -814,7 +812,7 @@ uint32_t EVE_cmd_getptr(void) EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -899,7 +897,7 @@ uint32_t EVE_cmd_memcrc(uint32_t ptr, uint32_t num) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -985,7 +983,7 @@ uint32_t EVE_cmd_regread(uint32_t ptr) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -1071,12 +1069,18 @@ void EVE_cmd_videoframe(uint32_t dest, uint32_t result_ptr) /*----------------------------------------------------------------------------------------------------------------------------*/ -/*------------- patching and initialisation ----------------------------------------------------------------------------------*/ +/*------------- patching and initialization ----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ #if EVE_GEN > 2 -/* switch the FLASH attached to a BT815/BT816 to full-speed mode, returns 0 for failing to do so */ +/** + * @brief EVE flash initialization for BT81x, switches the FLASH attached to a BT81x to full-speed mode + * + * @return returns E_OK in case of success, EVE_FAIL_FLASH_STATUS_INIT if the status remains init, + * EVE_FAIL_FLASH_STATUS_DETACHED if no flash chip was found, a number of different values for failures with cmd_flashfast + * and E_NOT_OK if a not supported status is returned in REG_FLASH_STATUS. + */ uint8_t EVE_init_flash(void) { uint8_t timeout = 0; @@ -1091,7 +1095,7 @@ uint8_t EVE_init_flash(void) timeout++; if(timeout > 100) /* 100ms and still in init, lets call quits now and exit with an error */ { - return 0; + return EVE_FAIL_FLASH_STATUS_INIT; } } @@ -1102,7 +1106,7 @@ uint8_t EVE_init_flash(void) status = EVE_memRead8(REG_FLASH_STATUS); if(status != 2) /* still not in FLASH_STATUS_BASIC, time to give up */ { - return 0; + return EVE_FAIL_FLASH_STATUS_DETACHED; } } @@ -1112,17 +1116,31 @@ uint8_t EVE_init_flash(void) result = EVE_cmd_flashfast(); - return (result == 0) ? 1 : 0; - /* result == 0 - cmd_flashfast was successful */ - /* room for improvement, cmd_flashfast provided an error code but there is no way to return it without returning a value that is FALSE all the same */ + switch(result) + { + case 0x0000: + return E_OK; + case 0xE001: + return EVE_FAIL_FLASHFAST_NOT_SUPPORTED; + case 0xE002: + return EVE_FAIL_FLASHFAST_NO_HEADER_DETECTED; + case 0xE003: + return EVE_FAIL_FLASHFAST_SECTOR0_FAILED; + case 0xE004: + return EVE_FAIL_FLASHFAST_BLOB_MISMATCH; + case 0xE005: + return EVE_FAIL_FLASHFAST_SPEED_TEST; + default: /* we have an unknown error, so just return failure */ + return E_NOT_OK; + } } if(status == 3) /* FLASH_STATUS_FULL - we are already there, why has this function been called? */ { - return 1; + return E_OK; } - return 0; + return E_NOT_OK; /* REG_FLASH_STATUS returned a value other than 0/1/2/3 */ } #endif /* EVE_GEN > 2 */ @@ -1130,7 +1148,6 @@ uint8_t EVE_init_flash(void) /* FT811 / FT813 binary-blob from FTDIs AN_336 to patch the touch-engine for Goodix GT911 / GT9271 touch controllers */ #if defined (EVE_HAS_GT911) - #if defined (__AVR__) #include #else @@ -1169,7 +1186,11 @@ const uint8_t EVE_GT911_data[1184] PROGMEM = #endif -/* init, has to be executed with the SPI setup to 11 MHz or less as required by FT8xx / BT8xx */ +/** + * @brief EVE chip initialization, has to be executed with the SPI setup to 11 MHz or less as required by FT8xx / BT8xx + * + * @return returns E_OK in case of success + */ uint8_t EVE_init(void) { uint8_t chipid = 0; @@ -1212,7 +1233,7 @@ uint8_t EVE_init(void) timeout++; if(timeout > 400) { - return 0; + return EVE_FAIL_CHIPID_TIMEOUT; } } @@ -1223,7 +1244,7 @@ uint8_t EVE_init(void) timeout++; if(timeout > 50) /* experimental, 10 was the lowest value to get the BT815 started with, the touch-controller was the last to get out of reset */ { - return 0; + return EVE_FAIL_RESET_TIMEOUT; } } @@ -1314,7 +1335,7 @@ uint8_t EVE_init(void) frequency = EVE_cmd_pclkfreq(EVE_PCLK_FREQ, 0); /* setup the second PLL for the pixel-clock according to the define in EVE_config.h for the display, as close a match as possible */ if(frequency == 0) /* this failed for some reason so we return with an error */ { - return 0; + return EVE_FAIL_PCLK_FREQ; } #endif #endif @@ -1343,7 +1364,7 @@ uint8_t EVE_init(void) EVE_init_dma(); /* prepare DMA */ #endif - return 1; + return E_OK; } @@ -1795,7 +1816,7 @@ uint16_t EVE_cmd_bitmap_transform(int32_t x0, int32_t y0, int32_t x1, int32_t y1 spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -2381,7 +2402,7 @@ void EVE_cmd_getmatrix(int32_t *get_a, int32_t *get_b, int32_t *get_c, int32_t * spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(get_f) { diff --git a/EVE_commands.h b/EVE_commands.h index 1b99445..7c8aef7 100644 --- a/EVE_commands.h +++ b/EVE_commands.h @@ -2,7 +2,7 @@ @file EVE_commands.h @brief contains FT8xx / BT8xx function prototypes @version 5.0 -@date 2020-09-18 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -78,6 +78,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added prototypes for EVE_cmd_runanim(), EVE_cmd_runanim_burst() - added prototype for EVE_cmd_wait() - removed the history from before 4.0 +- added an enum with return codes to have the functions return something more meaningfull +- finally removed EVE_cmd_start() after setting it to deprecatd with the first 5.0 release +- renamed EVE_cmd_execute() to EVE_execute_cmd() to be more consistent, this is is not an EVE command */ @@ -88,6 +91,25 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #include "EVE.h" + +enum +{ + E_OK = 0, + E_NOT_OK, + EVE_FAIL_CHIPID_TIMEOUT, + EVE_FAIL_RESET_TIMEOUT, + EVE_FAIL_PCLK_FREQ, + EVE_FAIL_FLASH_STATUS_INIT, + EVE_FAIL_FLASH_STATUS_DETACHED, + EVE_FAIL_FLASHFAST_NOT_SUPPORTED, + EVE_FAIL_FLASHFAST_NO_HEADER_DETECTED, + EVE_FAIL_FLASHFAST_SECTOR0_FAILED, + EVE_FAIL_FLASHFAST_BLOB_MISMATCH, + EVE_FAIL_FLASHFAST_SPEED_TEST, + EVE_IS_BUSY +}; + + /*----------------------------------------------------------------------------------------------------------------------------*/ /*---- helper functions ------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ @@ -103,8 +125,7 @@ void EVE_memWrite32(uint32_t ftAddress, uint32_t ftData32); void EVE_memWrite_flash_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len); void EVE_memWrite_sram_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len); uint8_t EVE_busy(void); -void EVE_cmd_start(void); -void EVE_cmd_execute(void); +void EVE_execute_cmd(void); /*----------------------------------------------------------------------------------------------------------------------------*/ @@ -167,7 +188,7 @@ void EVE_cmd_videoframe(uint32_t dest, uint32_t result_ptr); /*----------------------------------------------------------------------------------------------------------------------------*/ -/*------------- patching and initialisation ----------------------------------------------------------------------------------*/ +/*------------- patching and initialization ----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ #if EVE_GEN > 2 diff --git a/EVE_config.h b/EVE_config.h index 5799419..a2b5e37 100644 --- a/EVE_config.h +++ b/EVE_config.h @@ -2,7 +2,7 @@ @file EVE_config.h @brief configuration information for some TFTs @version 5.0 -@date 2021-30-10 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -72,6 +72,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added an error message if no valid define was setup and therefore no set of parameters is configured - converted all TABs to SPACEs - removed EVE_TOUCH_RZTHRESH as it only applies to resistive touch screens and as EVE_init() still writes it if the define exists in can be configured thru project options +- added EVE_Display_Parameters_t to be used with an additional init function, still not sure how to procede exactly */ @@ -155,6 +156,30 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #endif +typedef struct +{ + uint16_t hsize; /* valid range: 12 bits / 0-4095, Thd, length of the visible part of a line (in PCLKs) - active display width */ + uint16_t vsize; /* valid range: 12 bits / 0-4095, Tvd, number of visible lines (in lines) - active display height */ + uint16_t hsync0; /* valid range: 12 bits / 0-4095, Thf, Horizontal Front Porch */ + uint16_t hsync1; /* valid range: 12 bits / 0-4095, Tvf + Tvp, Vertical Front Porch plus Vsync Pulse width */ + uint16_t hoffset; /* valid range: 12 bits / 0-4095, Thf + Thp + Thb, length of non-visible part of line (in PCLK cycles) */ + uint16_t hcycle; /* valid range: 12 bits / 0-4095, Th, total length of line (visible and non-visible) (in PCLKs) */ + uint16_t vsync0; /* valid range: 12 bits / 0-4095, Tvf, Vertical Front Porch */ + uint16_t vsync1; /* valid range: 12 bits / 0-4095, Tvf + Tvp, Vertical Front Porch plus Vsync Pulse width */ + uint16_t voffset; /* valid range: 12 bits / 0-4095, Tvf + Tvp + Tvb Number of non-visible lines (in lines) */ + uint16_t vcycle; /* valid range: 12 bits / 0-4095, Tv, total number of lines (visible and non-visible) (in lines) */ + uint8_t swizzle; /* 4 bits, controls the arrangement of the output colour pins */ + uint8_t pclkpol; /* 1 bit, 0 = rising edge, 1 = falling edge */ + uint8_t cspread; /* helps with noise, when set to 1 fewer signals are changed simultaneously, reset-default: 1 */ + uint8_t pclk; /* pixel-clock divider, 0 = no PCLK output, 1 = use second PLL for pixel-clock in BT817 / BT818 */ + uint32_t pclk_freq; /* frequency in Hz for BT817 / BT818 to be used with EVE_cmd_pclkfreq() in order to write REG_PCLK_FREQ */ + uint8_t pwm_duty; /* valid range: 0-128, backlight PWM level, 0 = off, 128 = max */ + bool has_crystal; + bool has_gt911; +} EVE_Display_Parameters_t; + + + /* display timing parameters below */ /* ----------- 320 x 240 ----------- */ diff --git a/EVE_target.h b/EVE_target.h index 4666413..25db54a 100644 --- a/EVE_target.h +++ b/EVE_target.h @@ -2,7 +2,7 @@ @file EVE_target.h @brief target specific includes, definitions and functions @version 5.0 -@date 2021-12-04 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -84,6 +84,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added a few lines for STM32H7 - made the pin defines for all targets that have one optional - split the ATSAMC21 and ATSAMx51 targets into separate sections +- updated the explanation of how DMA works */ @@ -111,9 +112,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH EVE_init() calls EVE_init_dma() which sets up the DMA channel and enables an IRQ for end of DMA. EVE_start_cmd_burst() resets the DMA buffer instead of transferring the first bytes by SPI. EVE_end_cmd_burst() just calls EVE_start_dma_transfer() which triggers the transfer of the SPI buffer by DMA. - EVE_cmd_start() just instantly returns if there is an active DMA transfer. EVE_busy() does nothing but to report that EVE is busy if there is an active DMA transfer. - At the end of the DMA transfer an IRQ is executed which clears the DMA active state, calls EVE_cs_clear() and EVE_cmd_start(). + At the end of the DMA transfer an IRQ is executed which clears the DMA active state and calls EVE_cs_clear() by which the + command buffer is executed by the command co-processor. */ @@ -641,6 +642,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH /* note: target as set by AtmelStudio, valid are all from the same family */ #include "sam.h" + #include #if !defined (EVE_CS) #define EVE_CS_PORT 0 diff --git a/README.md b/README.md index 04804fc..9799dbe 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ There is a list of available options at the start of EVE_config.h sorted by chip When compiling for AVR you need to provide the clock it is running at in order to make the _delay_ms() calls used to initialise 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 initialisation of the FT8xx/BT8xx. +The DELAY_MS(ms) is only used during initialization of the FT8xx/BT8xx. See EVE_target.h for examples. In Addition you need to initialise the pins used for Chip-Select and PowerDown in your hardware correctly to output. diff --git a/examples/EVE_Test_Arduino_PlatformIO/src/tft.c b/examples/EVE_Test_Arduino_PlatformIO/src/tft.c index 8822170..cb971f0 100644 --- a/examples/EVE_Test_Arduino_PlatformIO/src/tft.c +++ b/examples/EVE_Test_Arduino_PlatformIO/src/tft.c @@ -1,8 +1,8 @@ /* @file tft.c / tft.cpp @brief TFT handling functions for EVE_Test project -@version 1.17 -@date 2021-09-18 +@version 1.18 +@date 2021-12-27 @author Rudolph Riedel @section History @@ -73,6 +73,9 @@ 1.17 - replaced the UTF-8 font with a freshly generated one and adjusted the parameters for the .xfont file +1.18 +- several minor changes + */ #include "EVE.h" @@ -83,16 +86,16 @@ /* some pre-definded colors */ -#define RED 0xff0000UL -#define ORANGE 0xffa500UL -#define GREEN 0x00ff00UL -#define BLUE 0x0000ffUL -#define BLUE_1 0x5dade2L -#define YELLOW 0xffff00UL -#define PINK 0xff00ffUL -#define PURPLE 0x800080UL -#define WHITE 0xffffffUL -#define BLACK 0x000000UL +#define RED 0xff0000UL +#define ORANGE 0xffa500UL +#define GREEN 0x00ff00UL +#define BLUE 0x0000ffUL +#define BLUE_1 0x5dade2L +#define YELLOW 0xffff00UL +#define PINK 0xff00ffUL +#define PURPLE 0x800080UL +#define WHITE 0xffffffUL +#define BLACK 0x000000UL /* memory-map defines */ #define MEM_FONT 0x000f7e00 /* the .xfont file for the UTF-8 font is copied here */ @@ -115,282 +118,286 @@ void touch_calibrate(void) /* send pre-recorded touch calibration values, depending on the display the code is compiled for */ #if defined (EVE_CFAF240400C1_030SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); #endif #if defined (EVE_CFAF320240F_035T) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); #endif #if defined (EVE_CFAF480128A0_039TC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); #endif #if defined (EVE_CFAF800480E0_050SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); #endif #if defined (EVE_PAF90) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); #endif #if defined (EVE_RiTFT43) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); #endif #if defined (EVE_EVE2_38) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); #endif #if defined (EVE_EVE2_35G) || defined (EVE_EVE3_35G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_43G) || defined (EVE_EVE3_43G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); #endif #if defined (EVE_EVE2_50G) || defined (EVE_EVE3_50G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_70G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); #endif #if defined (EVE_NHD_35) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); #endif #if defined (EVE_RVT70) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); #endif #if defined (EVE_FT811CB_HY50HD) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); #endif #if defined (EVE_ADAM101) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); #endif /* activate this if you are using a module for the first time or if you need to re-calibrate it */ /* 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 */ - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); - EVE_cmd_calibrate(); - EVE_cmd_dl(DL_DISPLAY); - EVE_cmd_dl(CMD_SWAP); - EVE_cmd_execute(); - - 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); - - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_dl(TAG(0)); - - EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); - EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); - EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); - EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); - EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); - EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); - - EVE_cmd_setbase(16L); - EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); - EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); - EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); - EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); - EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); - EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); - - EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl(CMD_SWAP); /* make this list active */ - EVE_cmd_execute(); - - while(1); + /* calibrate touch and displays values to screen */ + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); + EVE_cmd_calibrate(); + EVE_cmd_dl(DL_DISPLAY); + EVE_cmd_dl(CMD_SWAP); + while (EVE_busy()) {}; + + 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); + + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_dl(TAG(0)); + + EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); + EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); + EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); + EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); + EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); + EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); + + EVE_cmd_setbase(16L); + EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); + EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); + EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); + EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); + EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); + EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); + + EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl(CMD_SWAP); /* make this list active */ + while (EVE_busy()) {}; + + while(1); #endif } void initStaticBackground(void) { - EVE_cmd_dl(CMD_DLSTART); /* Start the display list */ + 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(TAG(0)); /* do not use the following objects for touch-detection */ - EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ + EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ - EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */ + EVE_cmd_dl(VERTEX_FORMAT(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 */ + /* 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(DL_COLOR_RGB | BLUE_1); - EVE_cmd_dl(VERTEX2F(0,0)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + EVE_cmd_dl(DL_COLOR_RGB | BLUE_1); + EVE_cmd_dl(VERTEX2F(0,0)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); - /* display the logo */ - EVE_cmd_dl(DL_COLOR_RGB | WHITE); - EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); - EVE_cmd_dl(DL_END); + /* display the logo */ + EVE_cmd_dl(DL_COLOR_RGB | WHITE); + EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); + EVE_cmd_dl(DL_END); - /* draw a black line to separate things */ - EVE_cmd_dl(DL_COLOR_RGB | BLACK); - EVE_cmd_dl(DL_BEGIN | EVE_LINES); - EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + /* draw a black line to separate things */ + EVE_cmd_dl(DL_COLOR_RGB | BLACK); + EVE_cmd_dl(DL_BEGIN | EVE_LINES); + EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); #if (TEST_UTF8 != 0) && (EVE_GEN > 2) - EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ - EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ + EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); #else - EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); #endif - /* add the static text to the list */ + /* add the static text to the list */ #if defined (EVE_DMA) - EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); + EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); #endif - EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); - EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); - EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); + EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); + EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); + EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); - EVE_cmd_text(125, EVE_VSIZE - 35, 26, 0, "us"); - EVE_cmd_text(125, EVE_VSIZE - 20, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 35, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 20, 26, 0, "us"); - while (EVE_busy()) {}; + while (EVE_busy()) {}; - num_dl_static = EVE_memRead16(REG_CMD_DL); + num_dl_static = EVE_memRead16(REG_CMD_DL); - EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); - while (EVE_busy()) {}; + EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); + while (EVE_busy()) {}; } void TFT_init(void) { - if(EVE_init() != 0) - { - tft_active = 1; - - EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ - touch_calibrate(); - -#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ - #if 0 - /* this is only needed once to transfer the flash-image to the external flash */ - uint32_t datasize; - - EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ - datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ - EVE_cmd_flashupdate(0,0,4096); /* write blob first */ - EVE_init_flash(); - EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ - #endif - - 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 */ + if(E_OK == EVE_init()) + { + tft_active = 1; + + EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ + touch_calibrate(); + +#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ + #if 0 + /* this is only needed once to transfer the flash-image to the external flash */ + uint32_t datasize; + + EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ + datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ + EVE_cmd_flashupdate(0,0,4096); /* write blob first */ + if (E_OK == EVE_init_flash()) + { + EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ + } + #endif + + 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 */ + } #endif // TEST_UTF8 - EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ - EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); + EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ + EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); - initStaticBackground(); - } + initStaticBackground(); + } } @@ -400,105 +407,108 @@ uint16_t display_list_size = 0; /* check for touch events and setup vars for TFT_display() */ void TFT_touch(void) { - uint8_t tag; - static uint8_t toggle_lock = 0; - - if(EVE_busy()) /* is EVE still processing the last display list? */ - { - return; - } - - display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ - - tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ - - switch(tag) - { - case 0: - toggle_lock = 0; - break; - - case 10: /* use button on top as on/off radio-switch */ - if(toggle_lock == 0) - { - toggle_lock = 42; - if(toggle_state == 0) - { - toggle_state = EVE_OPT_FLAT; - } - else - { - toggle_state = 0; - } - } - break; - } + uint8_t tag; + static uint8_t toggle_lock = 0; + + if(tft_active != 0) + { + if(EVE_IS_BUSY == EVE_busy()) /* is EVE still processing the last display list? */ + { + return; + } + + display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ + + tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ + + switch(tag) + { + case 0: + toggle_lock = 0; + break; + + case 10: /* use button on top as on/off radio-switch */ + if(0 == toggle_lock) + { + toggle_lock = 42; + if(0 == toggle_state) + { + toggle_state = EVE_OPT_FLAT; + } + else + { + toggle_state = 0; + } + } + break; + } + } } /* - dynamic portion of display-handling, meant to be called every 20ms or more + 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 defined (EVE_DMA) - uint16_t cmd_fifo_size; - cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ - #endif - - EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ - - EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ - EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ - /* display a button */ - EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); - EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); - EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ - EVE_cmd_rotate_burst(rotate); - EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ - EVE_cmd_dl_burst(CMD_SETMATRIX); - - if(toggle_state != 0) - { - rotate += 256; - } - - EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); - EVE_cmd_dl_burst(DL_END); - - EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ - - /* print profiling values */ - EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); - - #if defined (EVE_DMA) - EVE_cmd_number_burst(120, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ - #endif - EVE_cmd_number_burst(120, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ - EVE_cmd_number_burst(120, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|5, num_profile_a); /* duration in �s of TFT_loop() for the touch-event part */ - EVE_cmd_number_burst(120, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|5, num_profile_b); /* duration in �s of TFT_loop() for the display-list part */ - - EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ - - EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ - } + static int32_t rotate = 0; + + + if(tft_active != 0) + { + #if defined (EVE_DMA) + uint16_t cmd_fifo_size; + cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ + #endif + + EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ + + EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ + EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ + /* display a button */ + EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); + EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); + EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ + EVE_cmd_rotate_burst(rotate); + EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ + EVE_cmd_dl_burst(CMD_SETMATRIX); + + if(toggle_state != 0) + { + rotate += 256; + } + + EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); + EVE_cmd_dl_burst(DL_END); + + EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ + + /* print profiling values */ + EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); + + #if defined (EVE_DMA) + EVE_cmd_number_burst(100, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ + #endif + EVE_cmd_number_burst(100, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ + EVE_cmd_number_burst(100, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|4, num_profile_a); /* duration in us of TFT_loop() for the touch-event part */ + EVE_cmd_number_burst(100, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|4, num_profile_b); /* duration in us of TFT_loop() for the display-list part */ + + EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ + + EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ + } } diff --git a/examples/EVE_Test_ESP32_PlatformIO/src/tft.c b/examples/EVE_Test_ESP32_PlatformIO/src/tft.c index 8822170..cb971f0 100644 --- a/examples/EVE_Test_ESP32_PlatformIO/src/tft.c +++ b/examples/EVE_Test_ESP32_PlatformIO/src/tft.c @@ -1,8 +1,8 @@ /* @file tft.c / tft.cpp @brief TFT handling functions for EVE_Test project -@version 1.17 -@date 2021-09-18 +@version 1.18 +@date 2021-12-27 @author Rudolph Riedel @section History @@ -73,6 +73,9 @@ 1.17 - replaced the UTF-8 font with a freshly generated one and adjusted the parameters for the .xfont file +1.18 +- several minor changes + */ #include "EVE.h" @@ -83,16 +86,16 @@ /* some pre-definded colors */ -#define RED 0xff0000UL -#define ORANGE 0xffa500UL -#define GREEN 0x00ff00UL -#define BLUE 0x0000ffUL -#define BLUE_1 0x5dade2L -#define YELLOW 0xffff00UL -#define PINK 0xff00ffUL -#define PURPLE 0x800080UL -#define WHITE 0xffffffUL -#define BLACK 0x000000UL +#define RED 0xff0000UL +#define ORANGE 0xffa500UL +#define GREEN 0x00ff00UL +#define BLUE 0x0000ffUL +#define BLUE_1 0x5dade2L +#define YELLOW 0xffff00UL +#define PINK 0xff00ffUL +#define PURPLE 0x800080UL +#define WHITE 0xffffffUL +#define BLACK 0x000000UL /* memory-map defines */ #define MEM_FONT 0x000f7e00 /* the .xfont file for the UTF-8 font is copied here */ @@ -115,282 +118,286 @@ void touch_calibrate(void) /* send pre-recorded touch calibration values, depending on the display the code is compiled for */ #if defined (EVE_CFAF240400C1_030SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); #endif #if defined (EVE_CFAF320240F_035T) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); #endif #if defined (EVE_CFAF480128A0_039TC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); #endif #if defined (EVE_CFAF800480E0_050SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); #endif #if defined (EVE_PAF90) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); #endif #if defined (EVE_RiTFT43) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); #endif #if defined (EVE_EVE2_38) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); #endif #if defined (EVE_EVE2_35G) || defined (EVE_EVE3_35G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_43G) || defined (EVE_EVE3_43G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); #endif #if defined (EVE_EVE2_50G) || defined (EVE_EVE3_50G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_70G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); #endif #if defined (EVE_NHD_35) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); #endif #if defined (EVE_RVT70) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); #endif #if defined (EVE_FT811CB_HY50HD) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); #endif #if defined (EVE_ADAM101) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); #endif /* activate this if you are using a module for the first time or if you need to re-calibrate it */ /* 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 */ - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); - EVE_cmd_calibrate(); - EVE_cmd_dl(DL_DISPLAY); - EVE_cmd_dl(CMD_SWAP); - EVE_cmd_execute(); - - 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); - - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_dl(TAG(0)); - - EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); - EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); - EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); - EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); - EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); - EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); - - EVE_cmd_setbase(16L); - EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); - EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); - EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); - EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); - EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); - EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); - - EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl(CMD_SWAP); /* make this list active */ - EVE_cmd_execute(); - - while(1); + /* calibrate touch and displays values to screen */ + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); + EVE_cmd_calibrate(); + EVE_cmd_dl(DL_DISPLAY); + EVE_cmd_dl(CMD_SWAP); + while (EVE_busy()) {}; + + 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); + + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_dl(TAG(0)); + + EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); + EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); + EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); + EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); + EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); + EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); + + EVE_cmd_setbase(16L); + EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); + EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); + EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); + EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); + EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); + EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); + + EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl(CMD_SWAP); /* make this list active */ + while (EVE_busy()) {}; + + while(1); #endif } void initStaticBackground(void) { - EVE_cmd_dl(CMD_DLSTART); /* Start the display list */ + 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(TAG(0)); /* do not use the following objects for touch-detection */ - EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ + EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ - EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */ + EVE_cmd_dl(VERTEX_FORMAT(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 */ + /* 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(DL_COLOR_RGB | BLUE_1); - EVE_cmd_dl(VERTEX2F(0,0)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + EVE_cmd_dl(DL_COLOR_RGB | BLUE_1); + EVE_cmd_dl(VERTEX2F(0,0)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); - /* display the logo */ - EVE_cmd_dl(DL_COLOR_RGB | WHITE); - EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); - EVE_cmd_dl(DL_END); + /* display the logo */ + EVE_cmd_dl(DL_COLOR_RGB | WHITE); + EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); + EVE_cmd_dl(DL_END); - /* draw a black line to separate things */ - EVE_cmd_dl(DL_COLOR_RGB | BLACK); - EVE_cmd_dl(DL_BEGIN | EVE_LINES); - EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + /* draw a black line to separate things */ + EVE_cmd_dl(DL_COLOR_RGB | BLACK); + EVE_cmd_dl(DL_BEGIN | EVE_LINES); + EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); #if (TEST_UTF8 != 0) && (EVE_GEN > 2) - EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ - EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ + EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); #else - EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); #endif - /* add the static text to the list */ + /* add the static text to the list */ #if defined (EVE_DMA) - EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); + EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); #endif - EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); - EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); - EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); + EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); + EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); + EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); - EVE_cmd_text(125, EVE_VSIZE - 35, 26, 0, "us"); - EVE_cmd_text(125, EVE_VSIZE - 20, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 35, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 20, 26, 0, "us"); - while (EVE_busy()) {}; + while (EVE_busy()) {}; - num_dl_static = EVE_memRead16(REG_CMD_DL); + num_dl_static = EVE_memRead16(REG_CMD_DL); - EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); - while (EVE_busy()) {}; + EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); + while (EVE_busy()) {}; } void TFT_init(void) { - if(EVE_init() != 0) - { - tft_active = 1; - - EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ - touch_calibrate(); - -#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ - #if 0 - /* this is only needed once to transfer the flash-image to the external flash */ - uint32_t datasize; - - EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ - datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ - EVE_cmd_flashupdate(0,0,4096); /* write blob first */ - EVE_init_flash(); - EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ - #endif - - 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 */ + if(E_OK == EVE_init()) + { + tft_active = 1; + + EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ + touch_calibrate(); + +#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ + #if 0 + /* this is only needed once to transfer the flash-image to the external flash */ + uint32_t datasize; + + EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ + datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ + EVE_cmd_flashupdate(0,0,4096); /* write blob first */ + if (E_OK == EVE_init_flash()) + { + EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ + } + #endif + + 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 */ + } #endif // TEST_UTF8 - EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ - EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); + EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ + EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); - initStaticBackground(); - } + initStaticBackground(); + } } @@ -400,105 +407,108 @@ uint16_t display_list_size = 0; /* check for touch events and setup vars for TFT_display() */ void TFT_touch(void) { - uint8_t tag; - static uint8_t toggle_lock = 0; - - if(EVE_busy()) /* is EVE still processing the last display list? */ - { - return; - } - - display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ - - tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ - - switch(tag) - { - case 0: - toggle_lock = 0; - break; - - case 10: /* use button on top as on/off radio-switch */ - if(toggle_lock == 0) - { - toggle_lock = 42; - if(toggle_state == 0) - { - toggle_state = EVE_OPT_FLAT; - } - else - { - toggle_state = 0; - } - } - break; - } + uint8_t tag; + static uint8_t toggle_lock = 0; + + if(tft_active != 0) + { + if(EVE_IS_BUSY == EVE_busy()) /* is EVE still processing the last display list? */ + { + return; + } + + display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ + + tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ + + switch(tag) + { + case 0: + toggle_lock = 0; + break; + + case 10: /* use button on top as on/off radio-switch */ + if(0 == toggle_lock) + { + toggle_lock = 42; + if(0 == toggle_state) + { + toggle_state = EVE_OPT_FLAT; + } + else + { + toggle_state = 0; + } + } + break; + } + } } /* - dynamic portion of display-handling, meant to be called every 20ms or more + 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 defined (EVE_DMA) - uint16_t cmd_fifo_size; - cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ - #endif - - EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ - - EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ - EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ - /* display a button */ - EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); - EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); - EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ - EVE_cmd_rotate_burst(rotate); - EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ - EVE_cmd_dl_burst(CMD_SETMATRIX); - - if(toggle_state != 0) - { - rotate += 256; - } - - EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); - EVE_cmd_dl_burst(DL_END); - - EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ - - /* print profiling values */ - EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); - - #if defined (EVE_DMA) - EVE_cmd_number_burst(120, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ - #endif - EVE_cmd_number_burst(120, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ - EVE_cmd_number_burst(120, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|5, num_profile_a); /* duration in �s of TFT_loop() for the touch-event part */ - EVE_cmd_number_burst(120, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|5, num_profile_b); /* duration in �s of TFT_loop() for the display-list part */ - - EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ - - EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ - } + static int32_t rotate = 0; + + + if(tft_active != 0) + { + #if defined (EVE_DMA) + uint16_t cmd_fifo_size; + cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ + #endif + + EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ + + EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ + EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ + /* display a button */ + EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); + EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); + EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ + EVE_cmd_rotate_burst(rotate); + EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ + EVE_cmd_dl_burst(CMD_SETMATRIX); + + if(toggle_state != 0) + { + rotate += 256; + } + + EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); + EVE_cmd_dl_burst(DL_END); + + EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ + + /* print profiling values */ + EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); + + #if defined (EVE_DMA) + EVE_cmd_number_burst(100, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ + #endif + EVE_cmd_number_burst(100, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ + EVE_cmd_number_burst(100, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|4, num_profile_a); /* duration in us of TFT_loop() for the touch-event part */ + EVE_cmd_number_burst(100, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|4, num_profile_b); /* duration in us of TFT_loop() for the display-list part */ + + EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ + + EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ + } } diff --git a/examples/EVE_Test_SAMC21_DMA_EVE3-50G_Dev_PlatformIO/src/tft.c b/examples/EVE_Test_SAMC21_DMA_EVE3-50G_Dev_PlatformIO/src/tft.c index 8822170..cb971f0 100644 --- a/examples/EVE_Test_SAMC21_DMA_EVE3-50G_Dev_PlatformIO/src/tft.c +++ b/examples/EVE_Test_SAMC21_DMA_EVE3-50G_Dev_PlatformIO/src/tft.c @@ -1,8 +1,8 @@ /* @file tft.c / tft.cpp @brief TFT handling functions for EVE_Test project -@version 1.17 -@date 2021-09-18 +@version 1.18 +@date 2021-12-27 @author Rudolph Riedel @section History @@ -73,6 +73,9 @@ 1.17 - replaced the UTF-8 font with a freshly generated one and adjusted the parameters for the .xfont file +1.18 +- several minor changes + */ #include "EVE.h" @@ -83,16 +86,16 @@ /* some pre-definded colors */ -#define RED 0xff0000UL -#define ORANGE 0xffa500UL -#define GREEN 0x00ff00UL -#define BLUE 0x0000ffUL -#define BLUE_1 0x5dade2L -#define YELLOW 0xffff00UL -#define PINK 0xff00ffUL -#define PURPLE 0x800080UL -#define WHITE 0xffffffUL -#define BLACK 0x000000UL +#define RED 0xff0000UL +#define ORANGE 0xffa500UL +#define GREEN 0x00ff00UL +#define BLUE 0x0000ffUL +#define BLUE_1 0x5dade2L +#define YELLOW 0xffff00UL +#define PINK 0xff00ffUL +#define PURPLE 0x800080UL +#define WHITE 0xffffffUL +#define BLACK 0x000000UL /* memory-map defines */ #define MEM_FONT 0x000f7e00 /* the .xfont file for the UTF-8 font is copied here */ @@ -115,282 +118,286 @@ void touch_calibrate(void) /* send pre-recorded touch calibration values, depending on the display the code is compiled for */ #if defined (EVE_CFAF240400C1_030SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); #endif #if defined (EVE_CFAF320240F_035T) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); #endif #if defined (EVE_CFAF480128A0_039TC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); #endif #if defined (EVE_CFAF800480E0_050SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); #endif #if defined (EVE_PAF90) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); #endif #if defined (EVE_RiTFT43) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); #endif #if defined (EVE_EVE2_38) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); #endif #if defined (EVE_EVE2_35G) || defined (EVE_EVE3_35G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_43G) || defined (EVE_EVE3_43G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); #endif #if defined (EVE_EVE2_50G) || defined (EVE_EVE3_50G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_70G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); #endif #if defined (EVE_NHD_35) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); #endif #if defined (EVE_RVT70) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); #endif #if defined (EVE_FT811CB_HY50HD) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); #endif #if defined (EVE_ADAM101) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); #endif /* activate this if you are using a module for the first time or if you need to re-calibrate it */ /* 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 */ - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); - EVE_cmd_calibrate(); - EVE_cmd_dl(DL_DISPLAY); - EVE_cmd_dl(CMD_SWAP); - EVE_cmd_execute(); - - 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); - - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_dl(TAG(0)); - - EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); - EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); - EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); - EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); - EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); - EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); - - EVE_cmd_setbase(16L); - EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); - EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); - EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); - EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); - EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); - EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); - - EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl(CMD_SWAP); /* make this list active */ - EVE_cmd_execute(); - - while(1); + /* calibrate touch and displays values to screen */ + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); + EVE_cmd_calibrate(); + EVE_cmd_dl(DL_DISPLAY); + EVE_cmd_dl(CMD_SWAP); + while (EVE_busy()) {}; + + 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); + + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_dl(TAG(0)); + + EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); + EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); + EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); + EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); + EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); + EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); + + EVE_cmd_setbase(16L); + EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); + EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); + EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); + EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); + EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); + EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); + + EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl(CMD_SWAP); /* make this list active */ + while (EVE_busy()) {}; + + while(1); #endif } void initStaticBackground(void) { - EVE_cmd_dl(CMD_DLSTART); /* Start the display list */ + 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(TAG(0)); /* do not use the following objects for touch-detection */ - EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ + EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ - EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */ + EVE_cmd_dl(VERTEX_FORMAT(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 */ + /* 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(DL_COLOR_RGB | BLUE_1); - EVE_cmd_dl(VERTEX2F(0,0)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + EVE_cmd_dl(DL_COLOR_RGB | BLUE_1); + EVE_cmd_dl(VERTEX2F(0,0)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); - /* display the logo */ - EVE_cmd_dl(DL_COLOR_RGB | WHITE); - EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); - EVE_cmd_dl(DL_END); + /* display the logo */ + EVE_cmd_dl(DL_COLOR_RGB | WHITE); + EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); + EVE_cmd_dl(DL_END); - /* draw a black line to separate things */ - EVE_cmd_dl(DL_COLOR_RGB | BLACK); - EVE_cmd_dl(DL_BEGIN | EVE_LINES); - EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + /* draw a black line to separate things */ + EVE_cmd_dl(DL_COLOR_RGB | BLACK); + EVE_cmd_dl(DL_BEGIN | EVE_LINES); + EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); #if (TEST_UTF8 != 0) && (EVE_GEN > 2) - EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ - EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ + EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); #else - EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); #endif - /* add the static text to the list */ + /* add the static text to the list */ #if defined (EVE_DMA) - EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); + EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); #endif - EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); - EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); - EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); + EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); + EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); + EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); - EVE_cmd_text(125, EVE_VSIZE - 35, 26, 0, "us"); - EVE_cmd_text(125, EVE_VSIZE - 20, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 35, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 20, 26, 0, "us"); - while (EVE_busy()) {}; + while (EVE_busy()) {}; - num_dl_static = EVE_memRead16(REG_CMD_DL); + num_dl_static = EVE_memRead16(REG_CMD_DL); - EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); - while (EVE_busy()) {}; + EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); + while (EVE_busy()) {}; } void TFT_init(void) { - if(EVE_init() != 0) - { - tft_active = 1; - - EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ - touch_calibrate(); - -#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ - #if 0 - /* this is only needed once to transfer the flash-image to the external flash */ - uint32_t datasize; - - EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ - datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ - EVE_cmd_flashupdate(0,0,4096); /* write blob first */ - EVE_init_flash(); - EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ - #endif - - 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 */ + if(E_OK == EVE_init()) + { + tft_active = 1; + + EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ + touch_calibrate(); + +#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ + #if 0 + /* this is only needed once to transfer the flash-image to the external flash */ + uint32_t datasize; + + EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ + datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ + EVE_cmd_flashupdate(0,0,4096); /* write blob first */ + if (E_OK == EVE_init_flash()) + { + EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ + } + #endif + + 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 */ + } #endif // TEST_UTF8 - EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ - EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); + EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ + EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); - initStaticBackground(); - } + initStaticBackground(); + } } @@ -400,105 +407,108 @@ uint16_t display_list_size = 0; /* check for touch events and setup vars for TFT_display() */ void TFT_touch(void) { - uint8_t tag; - static uint8_t toggle_lock = 0; - - if(EVE_busy()) /* is EVE still processing the last display list? */ - { - return; - } - - display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ - - tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ - - switch(tag) - { - case 0: - toggle_lock = 0; - break; - - case 10: /* use button on top as on/off radio-switch */ - if(toggle_lock == 0) - { - toggle_lock = 42; - if(toggle_state == 0) - { - toggle_state = EVE_OPT_FLAT; - } - else - { - toggle_state = 0; - } - } - break; - } + uint8_t tag; + static uint8_t toggle_lock = 0; + + if(tft_active != 0) + { + if(EVE_IS_BUSY == EVE_busy()) /* is EVE still processing the last display list? */ + { + return; + } + + display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ + + tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ + + switch(tag) + { + case 0: + toggle_lock = 0; + break; + + case 10: /* use button on top as on/off radio-switch */ + if(0 == toggle_lock) + { + toggle_lock = 42; + if(0 == toggle_state) + { + toggle_state = EVE_OPT_FLAT; + } + else + { + toggle_state = 0; + } + } + break; + } + } } /* - dynamic portion of display-handling, meant to be called every 20ms or more + 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 defined (EVE_DMA) - uint16_t cmd_fifo_size; - cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ - #endif - - EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ - - EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ - EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ - /* display a button */ - EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); - EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); - EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ - EVE_cmd_rotate_burst(rotate); - EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ - EVE_cmd_dl_burst(CMD_SETMATRIX); - - if(toggle_state != 0) - { - rotate += 256; - } - - EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); - EVE_cmd_dl_burst(DL_END); - - EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ - - /* print profiling values */ - EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); - - #if defined (EVE_DMA) - EVE_cmd_number_burst(120, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ - #endif - EVE_cmd_number_burst(120, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ - EVE_cmd_number_burst(120, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|5, num_profile_a); /* duration in �s of TFT_loop() for the touch-event part */ - EVE_cmd_number_burst(120, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|5, num_profile_b); /* duration in �s of TFT_loop() for the display-list part */ - - EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ - - EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ - } + static int32_t rotate = 0; + + + if(tft_active != 0) + { + #if defined (EVE_DMA) + uint16_t cmd_fifo_size; + cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ + #endif + + EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ + + EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ + EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ + /* display a button */ + EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); + EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); + EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ + EVE_cmd_rotate_burst(rotate); + EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ + EVE_cmd_dl_burst(CMD_SETMATRIX); + + if(toggle_state != 0) + { + rotate += 256; + } + + EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); + EVE_cmd_dl_burst(DL_END); + + EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ + + /* print profiling values */ + EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); + + #if defined (EVE_DMA) + EVE_cmd_number_burst(100, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ + #endif + EVE_cmd_number_burst(100, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ + EVE_cmd_number_burst(100, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|4, num_profile_a); /* duration in us of TFT_loop() for the touch-event part */ + EVE_cmd_number_burst(100, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|4, num_profile_b); /* duration in us of TFT_loop() for the display-list part */ + + EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ + + EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ + } } diff --git a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_commands.c b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_commands.c index a360173..dc36d8a 100644 --- a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_commands.c +++ b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_commands.c @@ -2,7 +2,7 @@ @file EVE_commands.c @brief contains FT8xx / BT8xx functions @version 5.0 -@date 2021-10-30 +@date 2021-12-27 @author Rudolph Riedel @section info @@ -154,6 +154,11 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - converted all TABs to SPACEs - made EVE_TOUCH_RZTHRESH in EVE_init() optional to a) remove it from EVE_config.h and b) make it configureable externally - changed EVE_init() to write 1200U to REG_TOUCH_RZTHRESH if EVE_TOUCH_RZTHRESH is not defined +- changed EVE_init() to return E_OK = 0x00 in case of success and more meaningfull values in case of failure +- changed EVE_busy() to return EVE_IS_BUSY if EVE is busy and E_OK = 0x00 if EVE is not busy - no real change in functionality +- finally removed EVE_cmd_start() after setting it to deprecatd with the first 5.0 release +- renamed EVE_cmd_execute() to EVE_execute_cmd() to be more consistent, this is is not an EVE command +- changed EVE_init_flash() to return E_OK in case of success and more meaningfull values in case of failure */ @@ -297,9 +302,12 @@ void EVE_memWrite_sram_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t } -/* Check if the graphics processor completed executing the current command list. */ -/* REG_CMDB_SPACE == 0xffc -> command fifo is empty */ -/* (REG_CMDB_SPACE & 0x03) != 0 -> we have a co-processor fault */ +/** + * @brief Check if the co-processor completed executing the current command list. + * + * @return returns E_OK in case EVE is not busy (REG_CMDB_SPACE has the value 0xffc), + * returns EVE_IS_BUSY if a DMA transfer is active or REG_CMDB_SPACE has a value smaller than 0xffc + */ uint8_t EVE_busy(void) { uint16_t space; @@ -307,12 +315,13 @@ uint8_t EVE_busy(void) #if defined (EVE_DMA) if(EVE_dma_busy) { - return 1; + return EVE_IS_BUSY; } #endif space = EVE_memRead16(REG_CMDB_SPACE); + /* (REG_CMDB_SPACE & 0x03) != 0 -> we have a co-processor fault */ if((space & 0x3) != 0) /* we have a co-processor fault, make EVE play with us again */ { #if EVE_GEN > 2 @@ -349,25 +358,14 @@ uint8_t EVE_busy(void) #endif } - return (space != 0xffc) ? 1 : 0; + return (space != 0xffc) ? EVE_IS_BUSY : E_OK; } -/* deprecated, with using REG_CMDB_WRITE commands will be automatically excecuted on the rising edge of chip select */ -/* order the command co-processor to start processing its FIFO queue and do not wait for completion */ -void EVE_cmd_start(void) -{ -#if defined (EVE_DMA) - if(EVE_dma_busy) - { - return; /* just do nothing if a dma transfer is in progress */ - } -#endif -} - - -/* wait for the co-processor to complete the FIFO queue */ -void EVE_cmd_execute(void) +/** + * @brief Wait for the co-processor to complete the FIFO queue. + */ +void EVE_execute_cmd(void) { while (EVE_busy()) {}; } @@ -481,7 +479,7 @@ void EVE_cmd_fontcachequery(uint32_t *total, int32_t *used) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()); - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(total) { @@ -507,7 +505,7 @@ void EVE_cmd_getimage(uint32_t *source, uint32_t *fmt, uint32_t *width, uint32_t spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()); - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(palette) { @@ -564,7 +562,7 @@ uint32_t EVE_cmd_pclkfreq(uint32_t ftarget, int32_t rounding) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -645,7 +643,7 @@ uint32_t EVE_cmd_flashfast(void) EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -786,7 +784,7 @@ void EVE_cmd_getprops(uint32_t *pointer, uint32_t *width, uint32_t *height) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(pointer) { @@ -814,7 +812,7 @@ uint32_t EVE_cmd_getptr(void) EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -899,7 +897,7 @@ uint32_t EVE_cmd_memcrc(uint32_t ptr, uint32_t num) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -985,7 +983,7 @@ uint32_t EVE_cmd_regread(uint32_t ptr) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -1071,12 +1069,18 @@ void EVE_cmd_videoframe(uint32_t dest, uint32_t result_ptr) /*----------------------------------------------------------------------------------------------------------------------------*/ -/*------------- patching and initialisation ----------------------------------------------------------------------------------*/ +/*------------- patching and initialization ----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ #if EVE_GEN > 2 -/* switch the FLASH attached to a BT815/BT816 to full-speed mode, returns 0 for failing to do so */ +/** + * @brief EVE flash initialization for BT81x, switches the FLASH attached to a BT81x to full-speed mode + * + * @return returns E_OK in case of success, EVE_FAIL_FLASH_STATUS_INIT if the status remains init, + * EVE_FAIL_FLASH_STATUS_DETACHED if no flash chip was found, a number of different values for failures with cmd_flashfast + * and E_NOT_OK if a not supported status is returned in REG_FLASH_STATUS. + */ uint8_t EVE_init_flash(void) { uint8_t timeout = 0; @@ -1091,7 +1095,7 @@ uint8_t EVE_init_flash(void) timeout++; if(timeout > 100) /* 100ms and still in init, lets call quits now and exit with an error */ { - return 0; + return EVE_FAIL_FLASH_STATUS_INIT; } } @@ -1102,7 +1106,7 @@ uint8_t EVE_init_flash(void) status = EVE_memRead8(REG_FLASH_STATUS); if(status != 2) /* still not in FLASH_STATUS_BASIC, time to give up */ { - return 0; + return EVE_FAIL_FLASH_STATUS_DETACHED; } } @@ -1112,17 +1116,31 @@ uint8_t EVE_init_flash(void) result = EVE_cmd_flashfast(); - return (result == 0) ? 1 : 0; - /* result == 0 - cmd_flashfast was successful */ - /* room for improvement, cmd_flashfast provided an error code but there is no way to return it without returning a value that is FALSE all the same */ + switch(result) + { + case 0x0000: + return E_OK; + case 0xE001: + return EVE_FAIL_FLASHFAST_NOT_SUPPORTED; + case 0xE002: + return EVE_FAIL_FLASHFAST_NO_HEADER_DETECTED; + case 0xE003: + return EVE_FAIL_FLASHFAST_SECTOR0_FAILED; + case 0xE004: + return EVE_FAIL_FLASHFAST_BLOB_MISMATCH; + case 0xE005: + return EVE_FAIL_FLASHFAST_SPEED_TEST; + default: /* we have an unknown error, so just return failure */ + return E_NOT_OK; + } } if(status == 3) /* FLASH_STATUS_FULL - we are already there, why has this function been called? */ { - return 1; + return E_OK; } - return 0; + return E_NOT_OK; /* REG_FLASH_STATUS returned a value other than 0/1/2/3 */ } #endif /* EVE_GEN > 2 */ @@ -1130,7 +1148,6 @@ uint8_t EVE_init_flash(void) /* FT811 / FT813 binary-blob from FTDIs AN_336 to patch the touch-engine for Goodix GT911 / GT9271 touch controllers */ #if defined (EVE_HAS_GT911) - #if defined (__AVR__) #include #else @@ -1169,7 +1186,11 @@ const uint8_t EVE_GT911_data[1184] PROGMEM = #endif -/* init, has to be executed with the SPI setup to 11 MHz or less as required by FT8xx / BT8xx */ +/** + * @brief EVE chip initialization, has to be executed with the SPI setup to 11 MHz or less as required by FT8xx / BT8xx + * + * @return returns E_OK in case of success + */ uint8_t EVE_init(void) { uint8_t chipid = 0; @@ -1212,7 +1233,7 @@ uint8_t EVE_init(void) timeout++; if(timeout > 400) { - return 0; + return EVE_FAIL_CHIPID_TIMEOUT; } } @@ -1223,7 +1244,7 @@ uint8_t EVE_init(void) timeout++; if(timeout > 50) /* experimental, 10 was the lowest value to get the BT815 started with, the touch-controller was the last to get out of reset */ { - return 0; + return EVE_FAIL_RESET_TIMEOUT; } } @@ -1314,7 +1335,7 @@ uint8_t EVE_init(void) frequency = EVE_cmd_pclkfreq(EVE_PCLK_FREQ, 0); /* setup the second PLL for the pixel-clock according to the define in EVE_config.h for the display, as close a match as possible */ if(frequency == 0) /* this failed for some reason so we return with an error */ { - return 0; + return EVE_FAIL_PCLK_FREQ; } #endif #endif @@ -1343,7 +1364,7 @@ uint8_t EVE_init(void) EVE_init_dma(); /* prepare DMA */ #endif - return 1; + return E_OK; } @@ -1795,7 +1816,7 @@ uint16_t EVE_cmd_bitmap_transform(int32_t x0, int32_t y0, int32_t x1, int32_t y1 spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -2381,7 +2402,7 @@ void EVE_cmd_getmatrix(int32_t *get_a, int32_t *get_b, int32_t *get_c, int32_t * spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(get_f) { diff --git a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_commands.h b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_commands.h index 0899617..a273f2d 100644 --- a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_commands.h +++ b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_commands.h @@ -2,7 +2,7 @@ @file EVE_commands.h @brief contains FT8xx / BT8xx function prototypes @version 5.0 -@date 2020-09-18 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -78,6 +78,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added prototypes for EVE_cmd_runanim(), EVE_cmd_runanim_burst() - added prototype for EVE_cmd_wait() - removed the history from before 4.0 +- added an enum with return codes to have the functions return something more meaningfull +- finally removed EVE_cmd_start() after setting it to deprecatd with the first 5.0 release +- renamed EVE_cmd_execute() to EVE_execute_cmd() to be more consistent, this is is not an EVE command */ @@ -88,6 +91,25 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #include "EVE.h" + +enum +{ + E_OK = 0, + E_NOT_OK, + EVE_FAIL_CHIPID_TIMEOUT, + EVE_FAIL_RESET_TIMEOUT, + EVE_FAIL_PCLK_FREQ, + EVE_FAIL_FLASH_STATUS_INIT, + EVE_FAIL_FLASH_STATUS_DETACHED, + EVE_FAIL_FLASHFAST_NOT_SUPPORTED, + EVE_FAIL_FLASHFAST_NO_HEADER_DETECTED, + EVE_FAIL_FLASHFAST_SECTOR0_FAILED, + EVE_FAIL_FLASHFAST_BLOB_MISMATCH, + EVE_FAIL_FLASHFAST_SPEED_TEST, + EVE_IS_BUSY +}; + + /*----------------------------------------------------------------------------------------------------------------------------*/ /*---- helper functions ------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ @@ -103,8 +125,7 @@ void EVE_memWrite32(uint32_t ftAddress, uint32_t ftData32); void EVE_memWrite_flash_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len); void EVE_memWrite_sram_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len); uint8_t EVE_busy(void); -void EVE_cmd_start(void); -void EVE_cmd_execute(void); +void EVE_execute_cmd(void); /*----------------------------------------------------------------------------------------------------------------------------*/ @@ -167,7 +188,7 @@ void EVE_cmd_videoframe(uint32_t dest, uint32_t result_ptr); /*----------------------------------------------------------------------------------------------------------------------------*/ -/*------------- patching and initialisation ----------------------------------------------------------------------------------*/ +/*------------- patching and initialization ----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ #if EVE_GEN > 2 diff --git a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_config.h b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_config.h index 230aabc..9df9448 100644 --- a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_config.h +++ b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_config.h @@ -2,7 +2,7 @@ @file EVE_config.h @brief configuration information for some TFTs @version 5.0 -@date 2021-30-10 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -72,6 +72,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added an error message if no valid define was setup and therefore no set of parameters is configured - converted all TABs to SPACEs - removed EVE_TOUCH_RZTHRESH as it only applies to resistive touch screens and as EVE_init() still writes it if the define exists in can be configured thru project options +- added EVE_Display_Parameters_t to be used with an additional init function, still not sure how to procede exactly */ @@ -155,6 +156,30 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #endif +typedef struct +{ + uint16_t hsize; /* valid range: 12 bits / 0-4095, Thd, length of the visible part of a line (in PCLKs) - active display width */ + uint16_t vsize; /* valid range: 12 bits / 0-4095, Tvd, number of visible lines (in lines) - active display height */ + uint16_t hsync0; /* valid range: 12 bits / 0-4095, Thf, Horizontal Front Porch */ + uint16_t hsync1; /* valid range: 12 bits / 0-4095, Tvf + Tvp, Vertical Front Porch plus Vsync Pulse width */ + uint16_t hoffset; /* valid range: 12 bits / 0-4095, Thf + Thp + Thb, length of non-visible part of line (in PCLK cycles) */ + uint16_t hcycle; /* valid range: 12 bits / 0-4095, Th, total length of line (visible and non-visible) (in PCLKs) */ + uint16_t vsync0; /* valid range: 12 bits / 0-4095, Tvf, Vertical Front Porch */ + uint16_t vsync1; /* valid range: 12 bits / 0-4095, Tvf + Tvp, Vertical Front Porch plus Vsync Pulse width */ + uint16_t voffset; /* valid range: 12 bits / 0-4095, Tvf + Tvp + Tvb Number of non-visible lines (in lines) */ + uint16_t vcycle; /* valid range: 12 bits / 0-4095, Tv, total number of lines (visible and non-visible) (in lines) */ + uint8_t swizzle; /* 4 bits, controls the arrangement of the output colour pins */ + uint8_t pclkpol; /* 1 bit, 0 = rising edge, 1 = falling edge */ + uint8_t cspread; /* helps with noise, when set to 1 fewer signals are changed simultaneously, reset-default: 1 */ + uint8_t pclk; /* pixel-clock divider, 0 = no PCLK output, 1 = use second PLL for pixel-clock in BT817 / BT818 */ + uint32_t pclk_freq; /* frequency in Hz for BT817 / BT818 to be used with EVE_cmd_pclkfreq() in order to write REG_PCLK_FREQ */ + uint8_t pwm_duty; /* valid range: 0-128, backlight PWM level, 0 = off, 128 = max */ + bool has_crystal; + bool has_gt911; +} EVE_Display_Parameters_t; + + + /* display timing parameters below */ /* ----------- 320 x 240 ----------- */ diff --git a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_target.h b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_target.h index c36d2ac..75ac1da 100644 --- a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_target.h +++ b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/EVE_target.h @@ -2,7 +2,7 @@ @file EVE_target.h @brief target specific includes, definitions and functions @version 5.0 -@date 2021-12-04 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -84,6 +84,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added a few lines for STM32H7 - made the pin defines for all targets that have one optional - split the ATSAMC21 and ATSAMx51 targets into separate sections +- updated the explanation of how DMA works */ @@ -111,9 +112,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH EVE_init() calls EVE_init_dma() which sets up the DMA channel and enables an IRQ for end of DMA. EVE_start_cmd_burst() resets the DMA buffer instead of transferring the first bytes by SPI. EVE_end_cmd_burst() just calls EVE_start_dma_transfer() which triggers the transfer of the SPI buffer by DMA. - EVE_cmd_start() just instantly returns if there is an active DMA transfer. EVE_busy() does nothing but to report that EVE is busy if there is an active DMA transfer. - At the end of the DMA transfer an IRQ is executed which clears the DMA active state, calls EVE_cs_clear() and EVE_cmd_start(). + At the end of the DMA transfer an IRQ is executed which clears the DMA active state and calls EVE_cs_clear() by which the + command buffer is executed by the command co-processor. */ @@ -641,6 +642,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH /* note: target as set by AtmelStudio, valid are all from the same family */ #include "sam.h" + #include #if !defined (EVE_CS) #define EVE_CS_PORT 0 diff --git a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/README.md b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/README.md index 3a9429e..5e308b4 100644 --- a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/README.md +++ b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/README.md @@ -147,7 +147,7 @@ There is a list of available options at the start of EVE_config.h sorted by chip When compiling for AVR you need to provide the clock it is running at in order to make the _delay_ms() calls used to initialise 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 initialisation of the FT8xx/BT8xx. +The DELAY_MS(ms) is only used during initialization of the FT8xx/BT8xx. See EVE_target.h for examples. In Addition you need to initialise the pins used for Chip-Select and PowerDown in your hardware correctly to output. diff --git a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/library.json b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/library.json index 189ff78..5adbeba 100644 --- a/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/library.json +++ b/examples/EVE_Test_SAMC21_EVE2-50G/EmbeddedVideoEngine/library.json @@ -1,6 +1,6 @@ { "name": "EmbeddedVideoEngine", - "version": "5.0.1", + "version": "5.0.2", "keywords": "TFT, SPI, EVE2, EVE3, EVE4 ,Bridgetek, F81x, FT813, BT81x, BT815, BT817", "description": "Code library for EVE2/EVE3/EVE4 graphics controller ICs from FTDI/Bridgetek", "repository": { diff --git a/examples/EVE_Test_SAMC21_EVE2-50G/tft.c b/examples/EVE_Test_SAMC21_EVE2-50G/tft.c index 8f129bf..a71ad82 100644 --- a/examples/EVE_Test_SAMC21_EVE2-50G/tft.c +++ b/examples/EVE_Test_SAMC21_EVE2-50G/tft.c @@ -1,8 +1,8 @@ /* @file tft.c / tft.cpp @brief TFT handling functions for EVE_Test project -@version 1.17 -@date 2021-09-18 +@version 1.18 +@date 2021-12-27 @author Rudolph Riedel @section History @@ -73,6 +73,9 @@ 1.17 - replaced the UTF-8 font with a freshly generated one and adjusted the parameters for the .xfont file +1.18 +- several minor changes + */ #include "EmbeddedVideoEngine/EVE.h" @@ -83,16 +86,16 @@ /* some pre-definded colors */ -#define RED 0xff0000UL -#define ORANGE 0xffa500UL -#define GREEN 0x00ff00UL -#define BLUE 0x0000ffUL -#define BLUE_1 0x5dade2L -#define YELLOW 0xffff00UL -#define PINK 0xff00ffUL -#define PURPLE 0x800080UL -#define WHITE 0xffffffUL -#define BLACK 0x000000UL +#define RED 0xff0000UL +#define ORANGE 0xffa500UL +#define GREEN 0x00ff00UL +#define BLUE 0x0000ffUL +#define BLUE_1 0x5dade2L +#define YELLOW 0xffff00UL +#define PINK 0xff00ffUL +#define PURPLE 0x800080UL +#define WHITE 0xffffffUL +#define BLACK 0x000000UL /* memory-map defines */ #define MEM_FONT 0x000f7e00 /* the .xfont file for the UTF-8 font is copied here */ @@ -115,282 +118,286 @@ void touch_calibrate(void) /* send pre-recorded touch calibration values, depending on the display the code is compiled for */ #if defined (EVE_CFAF240400C1_030SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); #endif #if defined (EVE_CFAF320240F_035T) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); #endif #if defined (EVE_CFAF480128A0_039TC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); #endif #if defined (EVE_CFAF800480E0_050SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); #endif #if defined (EVE_PAF90) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); #endif #if defined (EVE_RiTFT43) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); #endif #if defined (EVE_EVE2_38) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); #endif #if defined (EVE_EVE2_35G) || defined (EVE_EVE3_35G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_43G) || defined (EVE_EVE3_43G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); #endif #if defined (EVE_EVE2_50G) || defined (EVE_EVE3_50G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_70G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); #endif #if defined (EVE_NHD_35) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); #endif #if defined (EVE_RVT70) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); #endif #if defined (EVE_FT811CB_HY50HD) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); #endif #if defined (EVE_ADAM101) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); #endif /* activate this if you are using a module for the first time or if you need to re-calibrate it */ /* 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 */ - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); - EVE_cmd_calibrate(); - EVE_cmd_dl(DL_DISPLAY); - EVE_cmd_dl(CMD_SWAP); - EVE_cmd_execute(); - - 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); - - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_dl(TAG(0)); - - EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); - EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); - EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); - EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); - EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); - EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); - - EVE_cmd_setbase(16L); - EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); - EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); - EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); - EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); - EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); - EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); - - EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl(CMD_SWAP); /* make this list active */ - EVE_cmd_execute(); - - while(1); + /* calibrate touch and displays values to screen */ + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); + EVE_cmd_calibrate(); + EVE_cmd_dl(DL_DISPLAY); + EVE_cmd_dl(CMD_SWAP); + while (EVE_busy()) {}; + + 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); + + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_dl(TAG(0)); + + EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); + EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); + EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); + EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); + EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); + EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); + + EVE_cmd_setbase(16L); + EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); + EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); + EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); + EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); + EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); + EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); + + EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl(CMD_SWAP); /* make this list active */ + while (EVE_busy()) {}; + + while(1); #endif } void initStaticBackground(void) { - EVE_cmd_dl(CMD_DLSTART); /* Start the display list */ + 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(TAG(0)); /* do not use the following objects for touch-detection */ - EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ + EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ - EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */ + EVE_cmd_dl(VERTEX_FORMAT(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 */ + /* 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(DL_COLOR_RGB | BLUE_1); - EVE_cmd_dl(VERTEX2F(0,0)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + EVE_cmd_dl(DL_COLOR_RGB | BLUE_1); + EVE_cmd_dl(VERTEX2F(0,0)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); - /* display the logo */ - EVE_cmd_dl(DL_COLOR_RGB | WHITE); - EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); - EVE_cmd_dl(DL_END); + /* display the logo */ + EVE_cmd_dl(DL_COLOR_RGB | WHITE); + EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); + EVE_cmd_dl(DL_END); - /* draw a black line to separate things */ - EVE_cmd_dl(DL_COLOR_RGB | BLACK); - EVE_cmd_dl(DL_BEGIN | EVE_LINES); - EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + /* draw a black line to separate things */ + EVE_cmd_dl(DL_COLOR_RGB | BLACK); + EVE_cmd_dl(DL_BEGIN | EVE_LINES); + EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); #if (TEST_UTF8 != 0) && (EVE_GEN > 2) - EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ - EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ + EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); #else - EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); #endif - /* add the static text to the list */ + /* add the static text to the list */ #if defined (EVE_DMA) - EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); + EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); #endif - EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); - EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); - EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); + EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); + EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); + EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); - EVE_cmd_text(125, EVE_VSIZE - 35, 26, 0, "us"); - EVE_cmd_text(125, EVE_VSIZE - 20, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 35, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 20, 26, 0, "us"); - while (EVE_busy()) {}; + while (EVE_busy()) {}; - num_dl_static = EVE_memRead16(REG_CMD_DL); + num_dl_static = EVE_memRead16(REG_CMD_DL); - EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); - while (EVE_busy()) {}; + EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); + while (EVE_busy()) {}; } void TFT_init(void) { - if(EVE_init() != 0) - { - tft_active = 1; - - EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ - touch_calibrate(); - -#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ - #if 0 - /* this is only needed once to transfer the flash-image to the external flash */ - uint32_t datasize; - - EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ - datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ - EVE_cmd_flashupdate(0,0,4096); /* write blob first */ - EVE_init_flash(); - EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ - #endif - - 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 */ + if(E_OK == EVE_init()) + { + tft_active = 1; + + EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ + touch_calibrate(); + +#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ + #if 0 + /* this is only needed once to transfer the flash-image to the external flash */ + uint32_t datasize; + + EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ + datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ + EVE_cmd_flashupdate(0,0,4096); /* write blob first */ + if (E_OK == EVE_init_flash()) + { + EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ + } + #endif + + 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 */ + } #endif // TEST_UTF8 - EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ - EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); + EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ + EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); - initStaticBackground(); - } + initStaticBackground(); + } } @@ -400,105 +407,108 @@ uint16_t display_list_size = 0; /* check for touch events and setup vars for TFT_display() */ void TFT_touch(void) { - uint8_t tag; - static uint8_t toggle_lock = 0; - - if(EVE_busy()) /* is EVE still processing the last display list? */ - { - return; - } - - display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ - - tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ - - switch(tag) - { - case 0: - toggle_lock = 0; - break; - - case 10: /* use button on top as on/off radio-switch */ - if(toggle_lock == 0) - { - toggle_lock = 42; - if(toggle_state == 0) - { - toggle_state = EVE_OPT_FLAT; - } - else - { - toggle_state = 0; - } - } - break; - } + uint8_t tag; + static uint8_t toggle_lock = 0; + + if(tft_active != 0) + { + if(EVE_IS_BUSY == EVE_busy()) /* is EVE still processing the last display list? */ + { + return; + } + + display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ + + tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ + + switch(tag) + { + case 0: + toggle_lock = 0; + break; + + case 10: /* use button on top as on/off radio-switch */ + if(0 == toggle_lock) + { + toggle_lock = 42; + if(0 == toggle_state) + { + toggle_state = EVE_OPT_FLAT; + } + else + { + toggle_state = 0; + } + } + break; + } + } } /* - dynamic portion of display-handling, meant to be called every 20ms or more + 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 defined (EVE_DMA) - uint16_t cmd_fifo_size; - cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ - #endif - - EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ - - EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ - EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ - /* display a button */ - EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); - EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); - EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ - EVE_cmd_rotate_burst(rotate); - EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ - EVE_cmd_dl_burst(CMD_SETMATRIX); - - if(toggle_state != 0) - { - rotate += 256; - } - - EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); - EVE_cmd_dl_burst(DL_END); - - EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ - - /* print profiling values */ - EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); - - #if defined (EVE_DMA) - EVE_cmd_number_burst(120, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ - #endif - EVE_cmd_number_burst(120, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ - EVE_cmd_number_burst(120, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|5, num_profile_a); /* duration in �s of TFT_loop() for the touch-event part */ - EVE_cmd_number_burst(120, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|5, num_profile_b); /* duration in �s of TFT_loop() for the display-list part */ - - EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ - - EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ - } + static int32_t rotate = 0; + + + if(tft_active != 0) + { + #if defined (EVE_DMA) + uint16_t cmd_fifo_size; + cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ + #endif + + EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ + + EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ + EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ + /* display a button */ + EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); + EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); + EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ + EVE_cmd_rotate_burst(rotate); + EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ + EVE_cmd_dl_burst(CMD_SETMATRIX); + + if(toggle_state != 0) + { + rotate += 256; + } + + EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); + EVE_cmd_dl_burst(DL_END); + + EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ + + /* print profiling values */ + EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); + + #if defined (EVE_DMA) + EVE_cmd_number_burst(100, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ + #endif + EVE_cmd_number_burst(100, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ + EVE_cmd_number_burst(100, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|4, num_profile_a); /* duration in us of TFT_loop() for the touch-event part */ + EVE_cmd_number_burst(100, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|4, num_profile_b); /* duration in us of TFT_loop() for the display-list part */ + + EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ + + EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ + } } diff --git a/examples/EVE_Test_SAME51_DMA_EVE3-50G_Dev_PlatformIO/src/tft.c b/examples/EVE_Test_SAME51_DMA_EVE3-50G_Dev_PlatformIO/src/tft.c index 8822170..cb971f0 100644 --- a/examples/EVE_Test_SAME51_DMA_EVE3-50G_Dev_PlatformIO/src/tft.c +++ b/examples/EVE_Test_SAME51_DMA_EVE3-50G_Dev_PlatformIO/src/tft.c @@ -1,8 +1,8 @@ /* @file tft.c / tft.cpp @brief TFT handling functions for EVE_Test project -@version 1.17 -@date 2021-09-18 +@version 1.18 +@date 2021-12-27 @author Rudolph Riedel @section History @@ -73,6 +73,9 @@ 1.17 - replaced the UTF-8 font with a freshly generated one and adjusted the parameters for the .xfont file +1.18 +- several minor changes + */ #include "EVE.h" @@ -83,16 +86,16 @@ /* some pre-definded colors */ -#define RED 0xff0000UL -#define ORANGE 0xffa500UL -#define GREEN 0x00ff00UL -#define BLUE 0x0000ffUL -#define BLUE_1 0x5dade2L -#define YELLOW 0xffff00UL -#define PINK 0xff00ffUL -#define PURPLE 0x800080UL -#define WHITE 0xffffffUL -#define BLACK 0x000000UL +#define RED 0xff0000UL +#define ORANGE 0xffa500UL +#define GREEN 0x00ff00UL +#define BLUE 0x0000ffUL +#define BLUE_1 0x5dade2L +#define YELLOW 0xffff00UL +#define PINK 0xff00ffUL +#define PURPLE 0x800080UL +#define WHITE 0xffffffUL +#define BLACK 0x000000UL /* memory-map defines */ #define MEM_FONT 0x000f7e00 /* the .xfont file for the UTF-8 font is copied here */ @@ -115,282 +118,286 @@ void touch_calibrate(void) /* send pre-recorded touch calibration values, depending on the display the code is compiled for */ #if defined (EVE_CFAF240400C1_030SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); #endif #if defined (EVE_CFAF320240F_035T) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); #endif #if defined (EVE_CFAF480128A0_039TC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); #endif #if defined (EVE_CFAF800480E0_050SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); #endif #if defined (EVE_PAF90) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); #endif #if defined (EVE_RiTFT43) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); #endif #if defined (EVE_EVE2_38) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); #endif #if defined (EVE_EVE2_35G) || defined (EVE_EVE3_35G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_43G) || defined (EVE_EVE3_43G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); #endif #if defined (EVE_EVE2_50G) || defined (EVE_EVE3_50G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_70G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); #endif #if defined (EVE_NHD_35) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); #endif #if defined (EVE_RVT70) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); #endif #if defined (EVE_FT811CB_HY50HD) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); #endif #if defined (EVE_ADAM101) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); #endif /* activate this if you are using a module for the first time or if you need to re-calibrate it */ /* 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 */ - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); - EVE_cmd_calibrate(); - EVE_cmd_dl(DL_DISPLAY); - EVE_cmd_dl(CMD_SWAP); - EVE_cmd_execute(); - - 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); - - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_dl(TAG(0)); - - EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); - EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); - EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); - EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); - EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); - EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); - - EVE_cmd_setbase(16L); - EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); - EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); - EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); - EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); - EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); - EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); - - EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl(CMD_SWAP); /* make this list active */ - EVE_cmd_execute(); - - while(1); + /* calibrate touch and displays values to screen */ + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); + EVE_cmd_calibrate(); + EVE_cmd_dl(DL_DISPLAY); + EVE_cmd_dl(CMD_SWAP); + while (EVE_busy()) {}; + + 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); + + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_dl(TAG(0)); + + EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); + EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); + EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); + EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); + EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); + EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); + + EVE_cmd_setbase(16L); + EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); + EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); + EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); + EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); + EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); + EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); + + EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl(CMD_SWAP); /* make this list active */ + while (EVE_busy()) {}; + + while(1); #endif } void initStaticBackground(void) { - EVE_cmd_dl(CMD_DLSTART); /* Start the display list */ + 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(TAG(0)); /* do not use the following objects for touch-detection */ - EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ + EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ - EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */ + EVE_cmd_dl(VERTEX_FORMAT(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 */ + /* 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(DL_COLOR_RGB | BLUE_1); - EVE_cmd_dl(VERTEX2F(0,0)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + EVE_cmd_dl(DL_COLOR_RGB | BLUE_1); + EVE_cmd_dl(VERTEX2F(0,0)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); - /* display the logo */ - EVE_cmd_dl(DL_COLOR_RGB | WHITE); - EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); - EVE_cmd_dl(DL_END); + /* display the logo */ + EVE_cmd_dl(DL_COLOR_RGB | WHITE); + EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); + EVE_cmd_dl(DL_END); - /* draw a black line to separate things */ - EVE_cmd_dl(DL_COLOR_RGB | BLACK); - EVE_cmd_dl(DL_BEGIN | EVE_LINES); - EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + /* draw a black line to separate things */ + EVE_cmd_dl(DL_COLOR_RGB | BLACK); + EVE_cmd_dl(DL_BEGIN | EVE_LINES); + EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); #if (TEST_UTF8 != 0) && (EVE_GEN > 2) - EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ - EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ + EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); #else - EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); #endif - /* add the static text to the list */ + /* add the static text to the list */ #if defined (EVE_DMA) - EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); + EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); #endif - EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); - EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); - EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); + EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); + EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); + EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); - EVE_cmd_text(125, EVE_VSIZE - 35, 26, 0, "us"); - EVE_cmd_text(125, EVE_VSIZE - 20, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 35, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 20, 26, 0, "us"); - while (EVE_busy()) {}; + while (EVE_busy()) {}; - num_dl_static = EVE_memRead16(REG_CMD_DL); + num_dl_static = EVE_memRead16(REG_CMD_DL); - EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); - while (EVE_busy()) {}; + EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); + while (EVE_busy()) {}; } void TFT_init(void) { - if(EVE_init() != 0) - { - tft_active = 1; - - EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ - touch_calibrate(); - -#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ - #if 0 - /* this is only needed once to transfer the flash-image to the external flash */ - uint32_t datasize; - - EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ - datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ - EVE_cmd_flashupdate(0,0,4096); /* write blob first */ - EVE_init_flash(); - EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ - #endif - - 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 */ + if(E_OK == EVE_init()) + { + tft_active = 1; + + EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ + touch_calibrate(); + +#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ + #if 0 + /* this is only needed once to transfer the flash-image to the external flash */ + uint32_t datasize; + + EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ + datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ + EVE_cmd_flashupdate(0,0,4096); /* write blob first */ + if (E_OK == EVE_init_flash()) + { + EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ + } + #endif + + 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 */ + } #endif // TEST_UTF8 - EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ - EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); + EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ + EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); - initStaticBackground(); - } + initStaticBackground(); + } } @@ -400,105 +407,108 @@ uint16_t display_list_size = 0; /* check for touch events and setup vars for TFT_display() */ void TFT_touch(void) { - uint8_t tag; - static uint8_t toggle_lock = 0; - - if(EVE_busy()) /* is EVE still processing the last display list? */ - { - return; - } - - display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ - - tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ - - switch(tag) - { - case 0: - toggle_lock = 0; - break; - - case 10: /* use button on top as on/off radio-switch */ - if(toggle_lock == 0) - { - toggle_lock = 42; - if(toggle_state == 0) - { - toggle_state = EVE_OPT_FLAT; - } - else - { - toggle_state = 0; - } - } - break; - } + uint8_t tag; + static uint8_t toggle_lock = 0; + + if(tft_active != 0) + { + if(EVE_IS_BUSY == EVE_busy()) /* is EVE still processing the last display list? */ + { + return; + } + + display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ + + tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ + + switch(tag) + { + case 0: + toggle_lock = 0; + break; + + case 10: /* use button on top as on/off radio-switch */ + if(0 == toggle_lock) + { + toggle_lock = 42; + if(0 == toggle_state) + { + toggle_state = EVE_OPT_FLAT; + } + else + { + toggle_state = 0; + } + } + break; + } + } } /* - dynamic portion of display-handling, meant to be called every 20ms or more + 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 defined (EVE_DMA) - uint16_t cmd_fifo_size; - cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ - #endif - - EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ - - EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ - EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ - /* display a button */ - EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); - EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); - EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ - EVE_cmd_rotate_burst(rotate); - EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ - EVE_cmd_dl_burst(CMD_SETMATRIX); - - if(toggle_state != 0) - { - rotate += 256; - } - - EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); - EVE_cmd_dl_burst(DL_END); - - EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ - - /* print profiling values */ - EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); - - #if defined (EVE_DMA) - EVE_cmd_number_burst(120, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ - #endif - EVE_cmd_number_burst(120, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ - EVE_cmd_number_burst(120, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|5, num_profile_a); /* duration in �s of TFT_loop() for the touch-event part */ - EVE_cmd_number_burst(120, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|5, num_profile_b); /* duration in �s of TFT_loop() for the display-list part */ - - EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ - - EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ - } + static int32_t rotate = 0; + + + if(tft_active != 0) + { + #if defined (EVE_DMA) + uint16_t cmd_fifo_size; + cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ + #endif + + EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ + + EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ + EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ + /* display a button */ + EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); + EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); + EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ + EVE_cmd_rotate_burst(rotate); + EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ + EVE_cmd_dl_burst(CMD_SETMATRIX); + + if(toggle_state != 0) + { + rotate += 256; + } + + EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); + EVE_cmd_dl_burst(DL_END); + + EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ + + /* print profiling values */ + EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); + + #if defined (EVE_DMA) + EVE_cmd_number_burst(100, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ + #endif + EVE_cmd_number_burst(100, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ + EVE_cmd_number_burst(100, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|4, num_profile_a); /* duration in us of TFT_loop() for the touch-event part */ + EVE_cmd_number_burst(100, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|4, num_profile_b); /* duration in us of TFT_loop() for the display-list part */ + + EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ + + EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ + } } diff --git a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_commands.c b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_commands.c index a360173..dc36d8a 100644 --- a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_commands.c +++ b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_commands.c @@ -2,7 +2,7 @@ @file EVE_commands.c @brief contains FT8xx / BT8xx functions @version 5.0 -@date 2021-10-30 +@date 2021-12-27 @author Rudolph Riedel @section info @@ -154,6 +154,11 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - converted all TABs to SPACEs - made EVE_TOUCH_RZTHRESH in EVE_init() optional to a) remove it from EVE_config.h and b) make it configureable externally - changed EVE_init() to write 1200U to REG_TOUCH_RZTHRESH if EVE_TOUCH_RZTHRESH is not defined +- changed EVE_init() to return E_OK = 0x00 in case of success and more meaningfull values in case of failure +- changed EVE_busy() to return EVE_IS_BUSY if EVE is busy and E_OK = 0x00 if EVE is not busy - no real change in functionality +- finally removed EVE_cmd_start() after setting it to deprecatd with the first 5.0 release +- renamed EVE_cmd_execute() to EVE_execute_cmd() to be more consistent, this is is not an EVE command +- changed EVE_init_flash() to return E_OK in case of success and more meaningfull values in case of failure */ @@ -297,9 +302,12 @@ void EVE_memWrite_sram_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t } -/* Check if the graphics processor completed executing the current command list. */ -/* REG_CMDB_SPACE == 0xffc -> command fifo is empty */ -/* (REG_CMDB_SPACE & 0x03) != 0 -> we have a co-processor fault */ +/** + * @brief Check if the co-processor completed executing the current command list. + * + * @return returns E_OK in case EVE is not busy (REG_CMDB_SPACE has the value 0xffc), + * returns EVE_IS_BUSY if a DMA transfer is active or REG_CMDB_SPACE has a value smaller than 0xffc + */ uint8_t EVE_busy(void) { uint16_t space; @@ -307,12 +315,13 @@ uint8_t EVE_busy(void) #if defined (EVE_DMA) if(EVE_dma_busy) { - return 1; + return EVE_IS_BUSY; } #endif space = EVE_memRead16(REG_CMDB_SPACE); + /* (REG_CMDB_SPACE & 0x03) != 0 -> we have a co-processor fault */ if((space & 0x3) != 0) /* we have a co-processor fault, make EVE play with us again */ { #if EVE_GEN > 2 @@ -349,25 +358,14 @@ uint8_t EVE_busy(void) #endif } - return (space != 0xffc) ? 1 : 0; + return (space != 0xffc) ? EVE_IS_BUSY : E_OK; } -/* deprecated, with using REG_CMDB_WRITE commands will be automatically excecuted on the rising edge of chip select */ -/* order the command co-processor to start processing its FIFO queue and do not wait for completion */ -void EVE_cmd_start(void) -{ -#if defined (EVE_DMA) - if(EVE_dma_busy) - { - return; /* just do nothing if a dma transfer is in progress */ - } -#endif -} - - -/* wait for the co-processor to complete the FIFO queue */ -void EVE_cmd_execute(void) +/** + * @brief Wait for the co-processor to complete the FIFO queue. + */ +void EVE_execute_cmd(void) { while (EVE_busy()) {}; } @@ -481,7 +479,7 @@ void EVE_cmd_fontcachequery(uint32_t *total, int32_t *used) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()); - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(total) { @@ -507,7 +505,7 @@ void EVE_cmd_getimage(uint32_t *source, uint32_t *fmt, uint32_t *width, uint32_t spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()); - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(palette) { @@ -564,7 +562,7 @@ uint32_t EVE_cmd_pclkfreq(uint32_t ftarget, int32_t rounding) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -645,7 +643,7 @@ uint32_t EVE_cmd_flashfast(void) EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -786,7 +784,7 @@ void EVE_cmd_getprops(uint32_t *pointer, uint32_t *width, uint32_t *height) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(pointer) { @@ -814,7 +812,7 @@ uint32_t EVE_cmd_getptr(void) EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -899,7 +897,7 @@ uint32_t EVE_cmd_memcrc(uint32_t ptr, uint32_t num) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -985,7 +983,7 @@ uint32_t EVE_cmd_regread(uint32_t ptr) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -1071,12 +1069,18 @@ void EVE_cmd_videoframe(uint32_t dest, uint32_t result_ptr) /*----------------------------------------------------------------------------------------------------------------------------*/ -/*------------- patching and initialisation ----------------------------------------------------------------------------------*/ +/*------------- patching and initialization ----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ #if EVE_GEN > 2 -/* switch the FLASH attached to a BT815/BT816 to full-speed mode, returns 0 for failing to do so */ +/** + * @brief EVE flash initialization for BT81x, switches the FLASH attached to a BT81x to full-speed mode + * + * @return returns E_OK in case of success, EVE_FAIL_FLASH_STATUS_INIT if the status remains init, + * EVE_FAIL_FLASH_STATUS_DETACHED if no flash chip was found, a number of different values for failures with cmd_flashfast + * and E_NOT_OK if a not supported status is returned in REG_FLASH_STATUS. + */ uint8_t EVE_init_flash(void) { uint8_t timeout = 0; @@ -1091,7 +1095,7 @@ uint8_t EVE_init_flash(void) timeout++; if(timeout > 100) /* 100ms and still in init, lets call quits now and exit with an error */ { - return 0; + return EVE_FAIL_FLASH_STATUS_INIT; } } @@ -1102,7 +1106,7 @@ uint8_t EVE_init_flash(void) status = EVE_memRead8(REG_FLASH_STATUS); if(status != 2) /* still not in FLASH_STATUS_BASIC, time to give up */ { - return 0; + return EVE_FAIL_FLASH_STATUS_DETACHED; } } @@ -1112,17 +1116,31 @@ uint8_t EVE_init_flash(void) result = EVE_cmd_flashfast(); - return (result == 0) ? 1 : 0; - /* result == 0 - cmd_flashfast was successful */ - /* room for improvement, cmd_flashfast provided an error code but there is no way to return it without returning a value that is FALSE all the same */ + switch(result) + { + case 0x0000: + return E_OK; + case 0xE001: + return EVE_FAIL_FLASHFAST_NOT_SUPPORTED; + case 0xE002: + return EVE_FAIL_FLASHFAST_NO_HEADER_DETECTED; + case 0xE003: + return EVE_FAIL_FLASHFAST_SECTOR0_FAILED; + case 0xE004: + return EVE_FAIL_FLASHFAST_BLOB_MISMATCH; + case 0xE005: + return EVE_FAIL_FLASHFAST_SPEED_TEST; + default: /* we have an unknown error, so just return failure */ + return E_NOT_OK; + } } if(status == 3) /* FLASH_STATUS_FULL - we are already there, why has this function been called? */ { - return 1; + return E_OK; } - return 0; + return E_NOT_OK; /* REG_FLASH_STATUS returned a value other than 0/1/2/3 */ } #endif /* EVE_GEN > 2 */ @@ -1130,7 +1148,6 @@ uint8_t EVE_init_flash(void) /* FT811 / FT813 binary-blob from FTDIs AN_336 to patch the touch-engine for Goodix GT911 / GT9271 touch controllers */ #if defined (EVE_HAS_GT911) - #if defined (__AVR__) #include #else @@ -1169,7 +1186,11 @@ const uint8_t EVE_GT911_data[1184] PROGMEM = #endif -/* init, has to be executed with the SPI setup to 11 MHz or less as required by FT8xx / BT8xx */ +/** + * @brief EVE chip initialization, has to be executed with the SPI setup to 11 MHz or less as required by FT8xx / BT8xx + * + * @return returns E_OK in case of success + */ uint8_t EVE_init(void) { uint8_t chipid = 0; @@ -1212,7 +1233,7 @@ uint8_t EVE_init(void) timeout++; if(timeout > 400) { - return 0; + return EVE_FAIL_CHIPID_TIMEOUT; } } @@ -1223,7 +1244,7 @@ uint8_t EVE_init(void) timeout++; if(timeout > 50) /* experimental, 10 was the lowest value to get the BT815 started with, the touch-controller was the last to get out of reset */ { - return 0; + return EVE_FAIL_RESET_TIMEOUT; } } @@ -1314,7 +1335,7 @@ uint8_t EVE_init(void) frequency = EVE_cmd_pclkfreq(EVE_PCLK_FREQ, 0); /* setup the second PLL for the pixel-clock according to the define in EVE_config.h for the display, as close a match as possible */ if(frequency == 0) /* this failed for some reason so we return with an error */ { - return 0; + return EVE_FAIL_PCLK_FREQ; } #endif #endif @@ -1343,7 +1364,7 @@ uint8_t EVE_init(void) EVE_init_dma(); /* prepare DMA */ #endif - return 1; + return E_OK; } @@ -1795,7 +1816,7 @@ uint16_t EVE_cmd_bitmap_transform(int32_t x0, int32_t y0, int32_t x1, int32_t y1 spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -2381,7 +2402,7 @@ void EVE_cmd_getmatrix(int32_t *get_a, int32_t *get_b, int32_t *get_c, int32_t * spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(get_f) { diff --git a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_commands.h b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_commands.h index 0899617..a273f2d 100644 --- a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_commands.h +++ b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_commands.h @@ -2,7 +2,7 @@ @file EVE_commands.h @brief contains FT8xx / BT8xx function prototypes @version 5.0 -@date 2020-09-18 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -78,6 +78,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added prototypes for EVE_cmd_runanim(), EVE_cmd_runanim_burst() - added prototype for EVE_cmd_wait() - removed the history from before 4.0 +- added an enum with return codes to have the functions return something more meaningfull +- finally removed EVE_cmd_start() after setting it to deprecatd with the first 5.0 release +- renamed EVE_cmd_execute() to EVE_execute_cmd() to be more consistent, this is is not an EVE command */ @@ -88,6 +91,25 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #include "EVE.h" + +enum +{ + E_OK = 0, + E_NOT_OK, + EVE_FAIL_CHIPID_TIMEOUT, + EVE_FAIL_RESET_TIMEOUT, + EVE_FAIL_PCLK_FREQ, + EVE_FAIL_FLASH_STATUS_INIT, + EVE_FAIL_FLASH_STATUS_DETACHED, + EVE_FAIL_FLASHFAST_NOT_SUPPORTED, + EVE_FAIL_FLASHFAST_NO_HEADER_DETECTED, + EVE_FAIL_FLASHFAST_SECTOR0_FAILED, + EVE_FAIL_FLASHFAST_BLOB_MISMATCH, + EVE_FAIL_FLASHFAST_SPEED_TEST, + EVE_IS_BUSY +}; + + /*----------------------------------------------------------------------------------------------------------------------------*/ /*---- helper functions ------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ @@ -103,8 +125,7 @@ void EVE_memWrite32(uint32_t ftAddress, uint32_t ftData32); void EVE_memWrite_flash_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len); void EVE_memWrite_sram_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len); uint8_t EVE_busy(void); -void EVE_cmd_start(void); -void EVE_cmd_execute(void); +void EVE_execute_cmd(void); /*----------------------------------------------------------------------------------------------------------------------------*/ @@ -167,7 +188,7 @@ void EVE_cmd_videoframe(uint32_t dest, uint32_t result_ptr); /*----------------------------------------------------------------------------------------------------------------------------*/ -/*------------- patching and initialisation ----------------------------------------------------------------------------------*/ +/*------------- patching and initialization ----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ #if EVE_GEN > 2 diff --git a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_config.h b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_config.h index 230aabc..9df9448 100644 --- a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_config.h +++ b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_config.h @@ -2,7 +2,7 @@ @file EVE_config.h @brief configuration information for some TFTs @version 5.0 -@date 2021-30-10 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -72,6 +72,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added an error message if no valid define was setup and therefore no set of parameters is configured - converted all TABs to SPACEs - removed EVE_TOUCH_RZTHRESH as it only applies to resistive touch screens and as EVE_init() still writes it if the define exists in can be configured thru project options +- added EVE_Display_Parameters_t to be used with an additional init function, still not sure how to procede exactly */ @@ -155,6 +156,30 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #endif +typedef struct +{ + uint16_t hsize; /* valid range: 12 bits / 0-4095, Thd, length of the visible part of a line (in PCLKs) - active display width */ + uint16_t vsize; /* valid range: 12 bits / 0-4095, Tvd, number of visible lines (in lines) - active display height */ + uint16_t hsync0; /* valid range: 12 bits / 0-4095, Thf, Horizontal Front Porch */ + uint16_t hsync1; /* valid range: 12 bits / 0-4095, Tvf + Tvp, Vertical Front Porch plus Vsync Pulse width */ + uint16_t hoffset; /* valid range: 12 bits / 0-4095, Thf + Thp + Thb, length of non-visible part of line (in PCLK cycles) */ + uint16_t hcycle; /* valid range: 12 bits / 0-4095, Th, total length of line (visible and non-visible) (in PCLKs) */ + uint16_t vsync0; /* valid range: 12 bits / 0-4095, Tvf, Vertical Front Porch */ + uint16_t vsync1; /* valid range: 12 bits / 0-4095, Tvf + Tvp, Vertical Front Porch plus Vsync Pulse width */ + uint16_t voffset; /* valid range: 12 bits / 0-4095, Tvf + Tvp + Tvb Number of non-visible lines (in lines) */ + uint16_t vcycle; /* valid range: 12 bits / 0-4095, Tv, total number of lines (visible and non-visible) (in lines) */ + uint8_t swizzle; /* 4 bits, controls the arrangement of the output colour pins */ + uint8_t pclkpol; /* 1 bit, 0 = rising edge, 1 = falling edge */ + uint8_t cspread; /* helps with noise, when set to 1 fewer signals are changed simultaneously, reset-default: 1 */ + uint8_t pclk; /* pixel-clock divider, 0 = no PCLK output, 1 = use second PLL for pixel-clock in BT817 / BT818 */ + uint32_t pclk_freq; /* frequency in Hz for BT817 / BT818 to be used with EVE_cmd_pclkfreq() in order to write REG_PCLK_FREQ */ + uint8_t pwm_duty; /* valid range: 0-128, backlight PWM level, 0 = off, 128 = max */ + bool has_crystal; + bool has_gt911; +} EVE_Display_Parameters_t; + + + /* display timing parameters below */ /* ----------- 320 x 240 ----------- */ diff --git a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_target.h b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_target.h index c36d2ac..75ac1da 100644 --- a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_target.h +++ b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/EVE_target.h @@ -2,7 +2,7 @@ @file EVE_target.h @brief target specific includes, definitions and functions @version 5.0 -@date 2021-12-04 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -84,6 +84,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added a few lines for STM32H7 - made the pin defines for all targets that have one optional - split the ATSAMC21 and ATSAMx51 targets into separate sections +- updated the explanation of how DMA works */ @@ -111,9 +112,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH EVE_init() calls EVE_init_dma() which sets up the DMA channel and enables an IRQ for end of DMA. EVE_start_cmd_burst() resets the DMA buffer instead of transferring the first bytes by SPI. EVE_end_cmd_burst() just calls EVE_start_dma_transfer() which triggers the transfer of the SPI buffer by DMA. - EVE_cmd_start() just instantly returns if there is an active DMA transfer. EVE_busy() does nothing but to report that EVE is busy if there is an active DMA transfer. - At the end of the DMA transfer an IRQ is executed which clears the DMA active state, calls EVE_cs_clear() and EVE_cmd_start(). + At the end of the DMA transfer an IRQ is executed which clears the DMA active state and calls EVE_cs_clear() by which the + command buffer is executed by the command co-processor. */ @@ -641,6 +642,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH /* note: target as set by AtmelStudio, valid are all from the same family */ #include "sam.h" + #include #if !defined (EVE_CS) #define EVE_CS_PORT 0 diff --git a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/README.md b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/README.md index 3a9429e..5e308b4 100644 --- a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/README.md +++ b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/README.md @@ -147,7 +147,7 @@ There is a list of available options at the start of EVE_config.h sorted by chip When compiling for AVR you need to provide the clock it is running at in order to make the _delay_ms() calls used to initialise 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 initialisation of the FT8xx/BT8xx. +The DELAY_MS(ms) is only used during initialization of the FT8xx/BT8xx. See EVE_target.h for examples. In Addition you need to initialise the pins used for Chip-Select and PowerDown in your hardware correctly to output. diff --git a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/library.json b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/library.json index 189ff78..5adbeba 100644 --- a/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/library.json +++ b/examples/EVE_Test_SAME51_EVE3-43G/EmbeddedVideoEngine/library.json @@ -1,6 +1,6 @@ { "name": "EmbeddedVideoEngine", - "version": "5.0.1", + "version": "5.0.2", "keywords": "TFT, SPI, EVE2, EVE3, EVE4 ,Bridgetek, F81x, FT813, BT81x, BT815, BT817", "description": "Code library for EVE2/EVE3/EVE4 graphics controller ICs from FTDI/Bridgetek", "repository": { diff --git a/examples/EVE_Test_SAME51_EVE3-43G/tft.c b/examples/EVE_Test_SAME51_EVE3-43G/tft.c index 8f129bf..a71ad82 100644 --- a/examples/EVE_Test_SAME51_EVE3-43G/tft.c +++ b/examples/EVE_Test_SAME51_EVE3-43G/tft.c @@ -1,8 +1,8 @@ /* @file tft.c / tft.cpp @brief TFT handling functions for EVE_Test project -@version 1.17 -@date 2021-09-18 +@version 1.18 +@date 2021-12-27 @author Rudolph Riedel @section History @@ -73,6 +73,9 @@ 1.17 - replaced the UTF-8 font with a freshly generated one and adjusted the parameters for the .xfont file +1.18 +- several minor changes + */ #include "EmbeddedVideoEngine/EVE.h" @@ -83,16 +86,16 @@ /* some pre-definded colors */ -#define RED 0xff0000UL -#define ORANGE 0xffa500UL -#define GREEN 0x00ff00UL -#define BLUE 0x0000ffUL -#define BLUE_1 0x5dade2L -#define YELLOW 0xffff00UL -#define PINK 0xff00ffUL -#define PURPLE 0x800080UL -#define WHITE 0xffffffUL -#define BLACK 0x000000UL +#define RED 0xff0000UL +#define ORANGE 0xffa500UL +#define GREEN 0x00ff00UL +#define BLUE 0x0000ffUL +#define BLUE_1 0x5dade2L +#define YELLOW 0xffff00UL +#define PINK 0xff00ffUL +#define PURPLE 0x800080UL +#define WHITE 0xffffffUL +#define BLACK 0x000000UL /* memory-map defines */ #define MEM_FONT 0x000f7e00 /* the .xfont file for the UTF-8 font is copied here */ @@ -115,282 +118,286 @@ void touch_calibrate(void) /* send pre-recorded touch calibration values, depending on the display the code is compiled for */ #if defined (EVE_CFAF240400C1_030SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); #endif #if defined (EVE_CFAF320240F_035T) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); #endif #if defined (EVE_CFAF480128A0_039TC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); #endif #if defined (EVE_CFAF800480E0_050SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); #endif #if defined (EVE_PAF90) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); #endif #if defined (EVE_RiTFT43) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); #endif #if defined (EVE_EVE2_38) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); #endif #if defined (EVE_EVE2_35G) || defined (EVE_EVE3_35G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_43G) || defined (EVE_EVE3_43G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); #endif #if defined (EVE_EVE2_50G) || defined (EVE_EVE3_50G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_70G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); #endif #if defined (EVE_NHD_35) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); #endif #if defined (EVE_RVT70) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); #endif #if defined (EVE_FT811CB_HY50HD) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); #endif #if defined (EVE_ADAM101) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); #endif /* activate this if you are using a module for the first time or if you need to re-calibrate it */ /* 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 */ - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); - EVE_cmd_calibrate(); - EVE_cmd_dl(DL_DISPLAY); - EVE_cmd_dl(CMD_SWAP); - EVE_cmd_execute(); - - 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); - - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_dl(TAG(0)); - - EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); - EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); - EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); - EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); - EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); - EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); - - EVE_cmd_setbase(16L); - EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); - EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); - EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); - EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); - EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); - EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); - - EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl(CMD_SWAP); /* make this list active */ - EVE_cmd_execute(); - - while(1); + /* calibrate touch and displays values to screen */ + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); + EVE_cmd_calibrate(); + EVE_cmd_dl(DL_DISPLAY); + EVE_cmd_dl(CMD_SWAP); + while (EVE_busy()) {}; + + 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); + + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_dl(TAG(0)); + + EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); + EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); + EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); + EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); + EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); + EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); + + EVE_cmd_setbase(16L); + EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); + EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); + EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); + EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); + EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); + EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); + + EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl(CMD_SWAP); /* make this list active */ + while (EVE_busy()) {}; + + while(1); #endif } void initStaticBackground(void) { - EVE_cmd_dl(CMD_DLSTART); /* Start the display list */ + 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(TAG(0)); /* do not use the following objects for touch-detection */ - EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ + EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ - EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */ + EVE_cmd_dl(VERTEX_FORMAT(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 */ + /* 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(DL_COLOR_RGB | BLUE_1); - EVE_cmd_dl(VERTEX2F(0,0)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + EVE_cmd_dl(DL_COLOR_RGB | BLUE_1); + EVE_cmd_dl(VERTEX2F(0,0)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); - /* display the logo */ - EVE_cmd_dl(DL_COLOR_RGB | WHITE); - EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); - EVE_cmd_dl(DL_END); + /* display the logo */ + EVE_cmd_dl(DL_COLOR_RGB | WHITE); + EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); + EVE_cmd_dl(DL_END); - /* draw a black line to separate things */ - EVE_cmd_dl(DL_COLOR_RGB | BLACK); - EVE_cmd_dl(DL_BEGIN | EVE_LINES); - EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + /* draw a black line to separate things */ + EVE_cmd_dl(DL_COLOR_RGB | BLACK); + EVE_cmd_dl(DL_BEGIN | EVE_LINES); + EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); #if (TEST_UTF8 != 0) && (EVE_GEN > 2) - EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ - EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ + EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); #else - EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); #endif - /* add the static text to the list */ + /* add the static text to the list */ #if defined (EVE_DMA) - EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); + EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); #endif - EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); - EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); - EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); + EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); + EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); + EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); - EVE_cmd_text(125, EVE_VSIZE - 35, 26, 0, "us"); - EVE_cmd_text(125, EVE_VSIZE - 20, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 35, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 20, 26, 0, "us"); - while (EVE_busy()) {}; + while (EVE_busy()) {}; - num_dl_static = EVE_memRead16(REG_CMD_DL); + num_dl_static = EVE_memRead16(REG_CMD_DL); - EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); - while (EVE_busy()) {}; + EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); + while (EVE_busy()) {}; } void TFT_init(void) { - if(EVE_init() != 0) - { - tft_active = 1; - - EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ - touch_calibrate(); - -#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ - #if 0 - /* this is only needed once to transfer the flash-image to the external flash */ - uint32_t datasize; - - EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ - datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ - EVE_cmd_flashupdate(0,0,4096); /* write blob first */ - EVE_init_flash(); - EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ - #endif - - 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 */ + if(E_OK == EVE_init()) + { + tft_active = 1; + + EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ + touch_calibrate(); + +#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ + #if 0 + /* this is only needed once to transfer the flash-image to the external flash */ + uint32_t datasize; + + EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ + datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ + EVE_cmd_flashupdate(0,0,4096); /* write blob first */ + if (E_OK == EVE_init_flash()) + { + EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ + } + #endif + + 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 */ + } #endif // TEST_UTF8 - EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ - EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); + EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ + EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); - initStaticBackground(); - } + initStaticBackground(); + } } @@ -400,105 +407,108 @@ uint16_t display_list_size = 0; /* check for touch events and setup vars for TFT_display() */ void TFT_touch(void) { - uint8_t tag; - static uint8_t toggle_lock = 0; - - if(EVE_busy()) /* is EVE still processing the last display list? */ - { - return; - } - - display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ - - tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ - - switch(tag) - { - case 0: - toggle_lock = 0; - break; - - case 10: /* use button on top as on/off radio-switch */ - if(toggle_lock == 0) - { - toggle_lock = 42; - if(toggle_state == 0) - { - toggle_state = EVE_OPT_FLAT; - } - else - { - toggle_state = 0; - } - } - break; - } + uint8_t tag; + static uint8_t toggle_lock = 0; + + if(tft_active != 0) + { + if(EVE_IS_BUSY == EVE_busy()) /* is EVE still processing the last display list? */ + { + return; + } + + display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ + + tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ + + switch(tag) + { + case 0: + toggle_lock = 0; + break; + + case 10: /* use button on top as on/off radio-switch */ + if(0 == toggle_lock) + { + toggle_lock = 42; + if(0 == toggle_state) + { + toggle_state = EVE_OPT_FLAT; + } + else + { + toggle_state = 0; + } + } + break; + } + } } /* - dynamic portion of display-handling, meant to be called every 20ms or more + 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 defined (EVE_DMA) - uint16_t cmd_fifo_size; - cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ - #endif - - EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ - - EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ - EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ - /* display a button */ - EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); - EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); - EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ - EVE_cmd_rotate_burst(rotate); - EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ - EVE_cmd_dl_burst(CMD_SETMATRIX); - - if(toggle_state != 0) - { - rotate += 256; - } - - EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); - EVE_cmd_dl_burst(DL_END); - - EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ - - /* print profiling values */ - EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); - - #if defined (EVE_DMA) - EVE_cmd_number_burst(120, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ - #endif - EVE_cmd_number_burst(120, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ - EVE_cmd_number_burst(120, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|5, num_profile_a); /* duration in �s of TFT_loop() for the touch-event part */ - EVE_cmd_number_burst(120, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|5, num_profile_b); /* duration in �s of TFT_loop() for the display-list part */ - - EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ - - EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ - } + static int32_t rotate = 0; + + + if(tft_active != 0) + { + #if defined (EVE_DMA) + uint16_t cmd_fifo_size; + cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ + #endif + + EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ + + EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ + EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ + /* display a button */ + EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); + EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); + EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ + EVE_cmd_rotate_burst(rotate); + EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ + EVE_cmd_dl_burst(CMD_SETMATRIX); + + if(toggle_state != 0) + { + rotate += 256; + } + + EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); + EVE_cmd_dl_burst(DL_END); + + EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ + + /* print profiling values */ + EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); + + #if defined (EVE_DMA) + EVE_cmd_number_burst(100, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ + #endif + EVE_cmd_number_burst(100, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ + EVE_cmd_number_burst(100, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|4, num_profile_a); /* duration in us of TFT_loop() for the touch-event part */ + EVE_cmd_number_burst(100, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|4, num_profile_b); /* duration in us of TFT_loop() for the display-list part */ + + EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ + + EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ + } } diff --git a/examples/EVE_Test_STM32_RiTFT50_PlatformIO/src/tft.c b/examples/EVE_Test_STM32_RiTFT50_PlatformIO/src/tft.c index 8822170..cb971f0 100644 --- a/examples/EVE_Test_STM32_RiTFT50_PlatformIO/src/tft.c +++ b/examples/EVE_Test_STM32_RiTFT50_PlatformIO/src/tft.c @@ -1,8 +1,8 @@ /* @file tft.c / tft.cpp @brief TFT handling functions for EVE_Test project -@version 1.17 -@date 2021-09-18 +@version 1.18 +@date 2021-12-27 @author Rudolph Riedel @section History @@ -73,6 +73,9 @@ 1.17 - replaced the UTF-8 font with a freshly generated one and adjusted the parameters for the .xfont file +1.18 +- several minor changes + */ #include "EVE.h" @@ -83,16 +86,16 @@ /* some pre-definded colors */ -#define RED 0xff0000UL -#define ORANGE 0xffa500UL -#define GREEN 0x00ff00UL -#define BLUE 0x0000ffUL -#define BLUE_1 0x5dade2L -#define YELLOW 0xffff00UL -#define PINK 0xff00ffUL -#define PURPLE 0x800080UL -#define WHITE 0xffffffUL -#define BLACK 0x000000UL +#define RED 0xff0000UL +#define ORANGE 0xffa500UL +#define GREEN 0x00ff00UL +#define BLUE 0x0000ffUL +#define BLUE_1 0x5dade2L +#define YELLOW 0xffff00UL +#define PINK 0xff00ffUL +#define PURPLE 0x800080UL +#define WHITE 0xffffffUL +#define BLACK 0x000000UL /* memory-map defines */ #define MEM_FONT 0x000f7e00 /* the .xfont file for the UTF-8 font is copied here */ @@ -115,282 +118,286 @@ void touch_calibrate(void) /* send pre-recorded touch calibration values, depending on the display the code is compiled for */ #if defined (EVE_CFAF240400C1_030SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); #endif #if defined (EVE_CFAF320240F_035T) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); #endif #if defined (EVE_CFAF480128A0_039TC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); #endif #if defined (EVE_CFAF800480E0_050SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); #endif #if defined (EVE_PAF90) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); #endif #if defined (EVE_RiTFT43) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); #endif #if defined (EVE_EVE2_38) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); #endif #if defined (EVE_EVE2_35G) || defined (EVE_EVE3_35G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_43G) || defined (EVE_EVE3_43G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); #endif #if defined (EVE_EVE2_50G) || defined (EVE_EVE3_50G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_70G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); #endif #if defined (EVE_NHD_35) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); #endif #if defined (EVE_RVT70) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); #endif #if defined (EVE_FT811CB_HY50HD) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); #endif #if defined (EVE_ADAM101) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); #endif /* activate this if you are using a module for the first time or if you need to re-calibrate it */ /* 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 */ - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); - EVE_cmd_calibrate(); - EVE_cmd_dl(DL_DISPLAY); - EVE_cmd_dl(CMD_SWAP); - EVE_cmd_execute(); - - 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); - - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_dl(TAG(0)); - - EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); - EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); - EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); - EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); - EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); - EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); - - EVE_cmd_setbase(16L); - EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); - EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); - EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); - EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); - EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); - EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); - - EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl(CMD_SWAP); /* make this list active */ - EVE_cmd_execute(); - - while(1); + /* calibrate touch and displays values to screen */ + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); + EVE_cmd_calibrate(); + EVE_cmd_dl(DL_DISPLAY); + EVE_cmd_dl(CMD_SWAP); + while (EVE_busy()) {}; + + 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); + + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_dl(TAG(0)); + + EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); + EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); + EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); + EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); + EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); + EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); + + EVE_cmd_setbase(16L); + EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); + EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); + EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); + EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); + EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); + EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); + + EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl(CMD_SWAP); /* make this list active */ + while (EVE_busy()) {}; + + while(1); #endif } void initStaticBackground(void) { - EVE_cmd_dl(CMD_DLSTART); /* Start the display list */ + 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(TAG(0)); /* do not use the following objects for touch-detection */ - EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ + EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ - EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */ + EVE_cmd_dl(VERTEX_FORMAT(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 */ + /* 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(DL_COLOR_RGB | BLUE_1); - EVE_cmd_dl(VERTEX2F(0,0)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + EVE_cmd_dl(DL_COLOR_RGB | BLUE_1); + EVE_cmd_dl(VERTEX2F(0,0)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); - /* display the logo */ - EVE_cmd_dl(DL_COLOR_RGB | WHITE); - EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); - EVE_cmd_dl(DL_END); + /* display the logo */ + EVE_cmd_dl(DL_COLOR_RGB | WHITE); + EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); + EVE_cmd_dl(DL_END); - /* draw a black line to separate things */ - EVE_cmd_dl(DL_COLOR_RGB | BLACK); - EVE_cmd_dl(DL_BEGIN | EVE_LINES); - EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + /* draw a black line to separate things */ + EVE_cmd_dl(DL_COLOR_RGB | BLACK); + EVE_cmd_dl(DL_BEGIN | EVE_LINES); + EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); #if (TEST_UTF8 != 0) && (EVE_GEN > 2) - EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ - EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ + EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); #else - EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); #endif - /* add the static text to the list */ + /* add the static text to the list */ #if defined (EVE_DMA) - EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); + EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); #endif - EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); - EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); - EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); + EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); + EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); + EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); - EVE_cmd_text(125, EVE_VSIZE - 35, 26, 0, "us"); - EVE_cmd_text(125, EVE_VSIZE - 20, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 35, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 20, 26, 0, "us"); - while (EVE_busy()) {}; + while (EVE_busy()) {}; - num_dl_static = EVE_memRead16(REG_CMD_DL); + num_dl_static = EVE_memRead16(REG_CMD_DL); - EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); - while (EVE_busy()) {}; + EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); + while (EVE_busy()) {}; } void TFT_init(void) { - if(EVE_init() != 0) - { - tft_active = 1; - - EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ - touch_calibrate(); - -#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ - #if 0 - /* this is only needed once to transfer the flash-image to the external flash */ - uint32_t datasize; - - EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ - datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ - EVE_cmd_flashupdate(0,0,4096); /* write blob first */ - EVE_init_flash(); - EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ - #endif - - 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 */ + if(E_OK == EVE_init()) + { + tft_active = 1; + + EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ + touch_calibrate(); + +#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ + #if 0 + /* this is only needed once to transfer the flash-image to the external flash */ + uint32_t datasize; + + EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ + datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ + EVE_cmd_flashupdate(0,0,4096); /* write blob first */ + if (E_OK == EVE_init_flash()) + { + EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ + } + #endif + + 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 */ + } #endif // TEST_UTF8 - EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ - EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); + EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ + EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); - initStaticBackground(); - } + initStaticBackground(); + } } @@ -400,105 +407,108 @@ uint16_t display_list_size = 0; /* check for touch events and setup vars for TFT_display() */ void TFT_touch(void) { - uint8_t tag; - static uint8_t toggle_lock = 0; - - if(EVE_busy()) /* is EVE still processing the last display list? */ - { - return; - } - - display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ - - tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ - - switch(tag) - { - case 0: - toggle_lock = 0; - break; - - case 10: /* use button on top as on/off radio-switch */ - if(toggle_lock == 0) - { - toggle_lock = 42; - if(toggle_state == 0) - { - toggle_state = EVE_OPT_FLAT; - } - else - { - toggle_state = 0; - } - } - break; - } + uint8_t tag; + static uint8_t toggle_lock = 0; + + if(tft_active != 0) + { + if(EVE_IS_BUSY == EVE_busy()) /* is EVE still processing the last display list? */ + { + return; + } + + display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ + + tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ + + switch(tag) + { + case 0: + toggle_lock = 0; + break; + + case 10: /* use button on top as on/off radio-switch */ + if(0 == toggle_lock) + { + toggle_lock = 42; + if(0 == toggle_state) + { + toggle_state = EVE_OPT_FLAT; + } + else + { + toggle_state = 0; + } + } + break; + } + } } /* - dynamic portion of display-handling, meant to be called every 20ms or more + 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 defined (EVE_DMA) - uint16_t cmd_fifo_size; - cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ - #endif - - EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ - - EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ - EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ - /* display a button */ - EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); - EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); - EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ - EVE_cmd_rotate_burst(rotate); - EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ - EVE_cmd_dl_burst(CMD_SETMATRIX); - - if(toggle_state != 0) - { - rotate += 256; - } - - EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); - EVE_cmd_dl_burst(DL_END); - - EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ - - /* print profiling values */ - EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); - - #if defined (EVE_DMA) - EVE_cmd_number_burst(120, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ - #endif - EVE_cmd_number_burst(120, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ - EVE_cmd_number_burst(120, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|5, num_profile_a); /* duration in �s of TFT_loop() for the touch-event part */ - EVE_cmd_number_burst(120, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|5, num_profile_b); /* duration in �s of TFT_loop() for the display-list part */ - - EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ - - EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ - } + static int32_t rotate = 0; + + + if(tft_active != 0) + { + #if defined (EVE_DMA) + uint16_t cmd_fifo_size; + cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ + #endif + + EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ + + EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ + EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ + /* display a button */ + EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); + EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); + EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ + EVE_cmd_rotate_burst(rotate); + EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ + EVE_cmd_dl_burst(CMD_SETMATRIX); + + if(toggle_state != 0) + { + rotate += 256; + } + + EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); + EVE_cmd_dl_burst(DL_END); + + EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ + + /* print profiling values */ + EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); + + #if defined (EVE_DMA) + EVE_cmd_number_burst(100, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ + #endif + EVE_cmd_number_burst(100, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ + EVE_cmd_number_burst(100, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|4, num_profile_a); /* duration in us of TFT_loop() for the touch-event part */ + EVE_cmd_number_burst(100, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|4, num_profile_b); /* duration in us of TFT_loop() for the display-list part */ + + EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ + + EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ + } } diff --git a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_commands.c b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_commands.c index a360173..dc36d8a 100644 --- a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_commands.c +++ b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_commands.c @@ -2,7 +2,7 @@ @file EVE_commands.c @brief contains FT8xx / BT8xx functions @version 5.0 -@date 2021-10-30 +@date 2021-12-27 @author Rudolph Riedel @section info @@ -154,6 +154,11 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - converted all TABs to SPACEs - made EVE_TOUCH_RZTHRESH in EVE_init() optional to a) remove it from EVE_config.h and b) make it configureable externally - changed EVE_init() to write 1200U to REG_TOUCH_RZTHRESH if EVE_TOUCH_RZTHRESH is not defined +- changed EVE_init() to return E_OK = 0x00 in case of success and more meaningfull values in case of failure +- changed EVE_busy() to return EVE_IS_BUSY if EVE is busy and E_OK = 0x00 if EVE is not busy - no real change in functionality +- finally removed EVE_cmd_start() after setting it to deprecatd with the first 5.0 release +- renamed EVE_cmd_execute() to EVE_execute_cmd() to be more consistent, this is is not an EVE command +- changed EVE_init_flash() to return E_OK in case of success and more meaningfull values in case of failure */ @@ -297,9 +302,12 @@ void EVE_memWrite_sram_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t } -/* Check if the graphics processor completed executing the current command list. */ -/* REG_CMDB_SPACE == 0xffc -> command fifo is empty */ -/* (REG_CMDB_SPACE & 0x03) != 0 -> we have a co-processor fault */ +/** + * @brief Check if the co-processor completed executing the current command list. + * + * @return returns E_OK in case EVE is not busy (REG_CMDB_SPACE has the value 0xffc), + * returns EVE_IS_BUSY if a DMA transfer is active or REG_CMDB_SPACE has a value smaller than 0xffc + */ uint8_t EVE_busy(void) { uint16_t space; @@ -307,12 +315,13 @@ uint8_t EVE_busy(void) #if defined (EVE_DMA) if(EVE_dma_busy) { - return 1; + return EVE_IS_BUSY; } #endif space = EVE_memRead16(REG_CMDB_SPACE); + /* (REG_CMDB_SPACE & 0x03) != 0 -> we have a co-processor fault */ if((space & 0x3) != 0) /* we have a co-processor fault, make EVE play with us again */ { #if EVE_GEN > 2 @@ -349,25 +358,14 @@ uint8_t EVE_busy(void) #endif } - return (space != 0xffc) ? 1 : 0; + return (space != 0xffc) ? EVE_IS_BUSY : E_OK; } -/* deprecated, with using REG_CMDB_WRITE commands will be automatically excecuted on the rising edge of chip select */ -/* order the command co-processor to start processing its FIFO queue and do not wait for completion */ -void EVE_cmd_start(void) -{ -#if defined (EVE_DMA) - if(EVE_dma_busy) - { - return; /* just do nothing if a dma transfer is in progress */ - } -#endif -} - - -/* wait for the co-processor to complete the FIFO queue */ -void EVE_cmd_execute(void) +/** + * @brief Wait for the co-processor to complete the FIFO queue. + */ +void EVE_execute_cmd(void) { while (EVE_busy()) {}; } @@ -481,7 +479,7 @@ void EVE_cmd_fontcachequery(uint32_t *total, int32_t *used) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()); - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(total) { @@ -507,7 +505,7 @@ void EVE_cmd_getimage(uint32_t *source, uint32_t *fmt, uint32_t *width, uint32_t spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()); - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(palette) { @@ -564,7 +562,7 @@ uint32_t EVE_cmd_pclkfreq(uint32_t ftarget, int32_t rounding) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -645,7 +643,7 @@ uint32_t EVE_cmd_flashfast(void) EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -786,7 +784,7 @@ void EVE_cmd_getprops(uint32_t *pointer, uint32_t *width, uint32_t *height) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(pointer) { @@ -814,7 +812,7 @@ uint32_t EVE_cmd_getptr(void) EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -899,7 +897,7 @@ uint32_t EVE_cmd_memcrc(uint32_t ptr, uint32_t num) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -985,7 +983,7 @@ uint32_t EVE_cmd_regread(uint32_t ptr) spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -1071,12 +1069,18 @@ void EVE_cmd_videoframe(uint32_t dest, uint32_t result_ptr) /*----------------------------------------------------------------------------------------------------------------------------*/ -/*------------- patching and initialisation ----------------------------------------------------------------------------------*/ +/*------------- patching and initialization ----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ #if EVE_GEN > 2 -/* switch the FLASH attached to a BT815/BT816 to full-speed mode, returns 0 for failing to do so */ +/** + * @brief EVE flash initialization for BT81x, switches the FLASH attached to a BT81x to full-speed mode + * + * @return returns E_OK in case of success, EVE_FAIL_FLASH_STATUS_INIT if the status remains init, + * EVE_FAIL_FLASH_STATUS_DETACHED if no flash chip was found, a number of different values for failures with cmd_flashfast + * and E_NOT_OK if a not supported status is returned in REG_FLASH_STATUS. + */ uint8_t EVE_init_flash(void) { uint8_t timeout = 0; @@ -1091,7 +1095,7 @@ uint8_t EVE_init_flash(void) timeout++; if(timeout > 100) /* 100ms and still in init, lets call quits now and exit with an error */ { - return 0; + return EVE_FAIL_FLASH_STATUS_INIT; } } @@ -1102,7 +1106,7 @@ uint8_t EVE_init_flash(void) status = EVE_memRead8(REG_FLASH_STATUS); if(status != 2) /* still not in FLASH_STATUS_BASIC, time to give up */ { - return 0; + return EVE_FAIL_FLASH_STATUS_DETACHED; } } @@ -1112,17 +1116,31 @@ uint8_t EVE_init_flash(void) result = EVE_cmd_flashfast(); - return (result == 0) ? 1 : 0; - /* result == 0 - cmd_flashfast was successful */ - /* room for improvement, cmd_flashfast provided an error code but there is no way to return it without returning a value that is FALSE all the same */ + switch(result) + { + case 0x0000: + return E_OK; + case 0xE001: + return EVE_FAIL_FLASHFAST_NOT_SUPPORTED; + case 0xE002: + return EVE_FAIL_FLASHFAST_NO_HEADER_DETECTED; + case 0xE003: + return EVE_FAIL_FLASHFAST_SECTOR0_FAILED; + case 0xE004: + return EVE_FAIL_FLASHFAST_BLOB_MISMATCH; + case 0xE005: + return EVE_FAIL_FLASHFAST_SPEED_TEST; + default: /* we have an unknown error, so just return failure */ + return E_NOT_OK; + } } if(status == 3) /* FLASH_STATUS_FULL - we are already there, why has this function been called? */ { - return 1; + return E_OK; } - return 0; + return E_NOT_OK; /* REG_FLASH_STATUS returned a value other than 0/1/2/3 */ } #endif /* EVE_GEN > 2 */ @@ -1130,7 +1148,6 @@ uint8_t EVE_init_flash(void) /* FT811 / FT813 binary-blob from FTDIs AN_336 to patch the touch-engine for Goodix GT911 / GT9271 touch controllers */ #if defined (EVE_HAS_GT911) - #if defined (__AVR__) #include #else @@ -1169,7 +1186,11 @@ const uint8_t EVE_GT911_data[1184] PROGMEM = #endif -/* init, has to be executed with the SPI setup to 11 MHz or less as required by FT8xx / BT8xx */ +/** + * @brief EVE chip initialization, has to be executed with the SPI setup to 11 MHz or less as required by FT8xx / BT8xx + * + * @return returns E_OK in case of success + */ uint8_t EVE_init(void) { uint8_t chipid = 0; @@ -1212,7 +1233,7 @@ uint8_t EVE_init(void) timeout++; if(timeout > 400) { - return 0; + return EVE_FAIL_CHIPID_TIMEOUT; } } @@ -1223,7 +1244,7 @@ uint8_t EVE_init(void) timeout++; if(timeout > 50) /* experimental, 10 was the lowest value to get the BT815 started with, the touch-controller was the last to get out of reset */ { - return 0; + return EVE_FAIL_RESET_TIMEOUT; } } @@ -1314,7 +1335,7 @@ uint8_t EVE_init(void) frequency = EVE_cmd_pclkfreq(EVE_PCLK_FREQ, 0); /* setup the second PLL for the pixel-clock according to the define in EVE_config.h for the display, as close a match as possible */ if(frequency == 0) /* this failed for some reason so we return with an error */ { - return 0; + return EVE_FAIL_PCLK_FREQ; } #endif #endif @@ -1343,7 +1364,7 @@ uint8_t EVE_init(void) EVE_init_dma(); /* prepare DMA */ #endif - return 1; + return E_OK; } @@ -1795,7 +1816,7 @@ uint16_t EVE_cmd_bitmap_transform(int32_t x0, int32_t y0, int32_t x1, int32_t y1 spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ cmdoffset -= 4; cmdoffset &= 0x0fff; return (EVE_memRead32(EVE_RAM_CMD + cmdoffset)); @@ -2381,7 +2402,7 @@ void EVE_cmd_getmatrix(int32_t *get_a, int32_t *get_b, int32_t *get_c, int32_t * spi_transmit_32(0); EVE_cs_clear(); while (EVE_busy()) {}; - cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the graphics processor write pointer */ + cmdoffset = EVE_memRead16(REG_CMD_WRITE); /* read the co-processor write pointer */ if(get_f) { diff --git a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_commands.h b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_commands.h index 0899617..a273f2d 100644 --- a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_commands.h +++ b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_commands.h @@ -2,7 +2,7 @@ @file EVE_commands.h @brief contains FT8xx / BT8xx function prototypes @version 5.0 -@date 2020-09-18 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -78,6 +78,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added prototypes for EVE_cmd_runanim(), EVE_cmd_runanim_burst() - added prototype for EVE_cmd_wait() - removed the history from before 4.0 +- added an enum with return codes to have the functions return something more meaningfull +- finally removed EVE_cmd_start() after setting it to deprecatd with the first 5.0 release +- renamed EVE_cmd_execute() to EVE_execute_cmd() to be more consistent, this is is not an EVE command */ @@ -88,6 +91,25 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #include "EVE.h" + +enum +{ + E_OK = 0, + E_NOT_OK, + EVE_FAIL_CHIPID_TIMEOUT, + EVE_FAIL_RESET_TIMEOUT, + EVE_FAIL_PCLK_FREQ, + EVE_FAIL_FLASH_STATUS_INIT, + EVE_FAIL_FLASH_STATUS_DETACHED, + EVE_FAIL_FLASHFAST_NOT_SUPPORTED, + EVE_FAIL_FLASHFAST_NO_HEADER_DETECTED, + EVE_FAIL_FLASHFAST_SECTOR0_FAILED, + EVE_FAIL_FLASHFAST_BLOB_MISMATCH, + EVE_FAIL_FLASHFAST_SPEED_TEST, + EVE_IS_BUSY +}; + + /*----------------------------------------------------------------------------------------------------------------------------*/ /*---- helper functions ------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ @@ -103,8 +125,7 @@ void EVE_memWrite32(uint32_t ftAddress, uint32_t ftData32); void EVE_memWrite_flash_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len); void EVE_memWrite_sram_buffer(uint32_t ftAddress, const uint8_t *data, uint32_t len); uint8_t EVE_busy(void); -void EVE_cmd_start(void); -void EVE_cmd_execute(void); +void EVE_execute_cmd(void); /*----------------------------------------------------------------------------------------------------------------------------*/ @@ -167,7 +188,7 @@ void EVE_cmd_videoframe(uint32_t dest, uint32_t result_ptr); /*----------------------------------------------------------------------------------------------------------------------------*/ -/*------------- patching and initialisation ----------------------------------------------------------------------------------*/ +/*------------- patching and initialization ----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------*/ #if EVE_GEN > 2 diff --git a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_config.h b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_config.h index 230aabc..9df9448 100644 --- a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_config.h +++ b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_config.h @@ -2,7 +2,7 @@ @file EVE_config.h @brief configuration information for some TFTs @version 5.0 -@date 2021-30-10 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -72,6 +72,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added an error message if no valid define was setup and therefore no set of parameters is configured - converted all TABs to SPACEs - removed EVE_TOUCH_RZTHRESH as it only applies to resistive touch screens and as EVE_init() still writes it if the define exists in can be configured thru project options +- added EVE_Display_Parameters_t to be used with an additional init function, still not sure how to procede exactly */ @@ -155,6 +156,30 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH #endif +typedef struct +{ + uint16_t hsize; /* valid range: 12 bits / 0-4095, Thd, length of the visible part of a line (in PCLKs) - active display width */ + uint16_t vsize; /* valid range: 12 bits / 0-4095, Tvd, number of visible lines (in lines) - active display height */ + uint16_t hsync0; /* valid range: 12 bits / 0-4095, Thf, Horizontal Front Porch */ + uint16_t hsync1; /* valid range: 12 bits / 0-4095, Tvf + Tvp, Vertical Front Porch plus Vsync Pulse width */ + uint16_t hoffset; /* valid range: 12 bits / 0-4095, Thf + Thp + Thb, length of non-visible part of line (in PCLK cycles) */ + uint16_t hcycle; /* valid range: 12 bits / 0-4095, Th, total length of line (visible and non-visible) (in PCLKs) */ + uint16_t vsync0; /* valid range: 12 bits / 0-4095, Tvf, Vertical Front Porch */ + uint16_t vsync1; /* valid range: 12 bits / 0-4095, Tvf + Tvp, Vertical Front Porch plus Vsync Pulse width */ + uint16_t voffset; /* valid range: 12 bits / 0-4095, Tvf + Tvp + Tvb Number of non-visible lines (in lines) */ + uint16_t vcycle; /* valid range: 12 bits / 0-4095, Tv, total number of lines (visible and non-visible) (in lines) */ + uint8_t swizzle; /* 4 bits, controls the arrangement of the output colour pins */ + uint8_t pclkpol; /* 1 bit, 0 = rising edge, 1 = falling edge */ + uint8_t cspread; /* helps with noise, when set to 1 fewer signals are changed simultaneously, reset-default: 1 */ + uint8_t pclk; /* pixel-clock divider, 0 = no PCLK output, 1 = use second PLL for pixel-clock in BT817 / BT818 */ + uint32_t pclk_freq; /* frequency in Hz for BT817 / BT818 to be used with EVE_cmd_pclkfreq() in order to write REG_PCLK_FREQ */ + uint8_t pwm_duty; /* valid range: 0-128, backlight PWM level, 0 = off, 128 = max */ + bool has_crystal; + bool has_gt911; +} EVE_Display_Parameters_t; + + + /* display timing parameters below */ /* ----------- 320 x 240 ----------- */ diff --git a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_target.h b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_target.h index c36d2ac..75ac1da 100644 --- a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_target.h +++ b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/EVE_target.h @@ -2,7 +2,7 @@ @file EVE_target.h @brief target specific includes, definitions and functions @version 5.0 -@date 2021-12-04 +@date 2021-12-27 @author Rudolph Riedel @section LICENSE @@ -84,6 +84,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH - added a few lines for STM32H7 - made the pin defines for all targets that have one optional - split the ATSAMC21 and ATSAMx51 targets into separate sections +- updated the explanation of how DMA works */ @@ -111,9 +112,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH EVE_init() calls EVE_init_dma() which sets up the DMA channel and enables an IRQ for end of DMA. EVE_start_cmd_burst() resets the DMA buffer instead of transferring the first bytes by SPI. EVE_end_cmd_burst() just calls EVE_start_dma_transfer() which triggers the transfer of the SPI buffer by DMA. - EVE_cmd_start() just instantly returns if there is an active DMA transfer. EVE_busy() does nothing but to report that EVE is busy if there is an active DMA transfer. - At the end of the DMA transfer an IRQ is executed which clears the DMA active state, calls EVE_cs_clear() and EVE_cmd_start(). + At the end of the DMA transfer an IRQ is executed which clears the DMA active state and calls EVE_cs_clear() by which the + command buffer is executed by the command co-processor. */ @@ -641,6 +642,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH /* note: target as set by AtmelStudio, valid are all from the same family */ #include "sam.h" + #include #if !defined (EVE_CS) #define EVE_CS_PORT 0 diff --git a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/README.md b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/README.md index 3a9429e..5e308b4 100644 --- a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/README.md +++ b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/README.md @@ -147,7 +147,7 @@ There is a list of available options at the start of EVE_config.h sorted by chip When compiling for AVR you need to provide the clock it is running at in order to make the _delay_ms() calls used to initialise 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 initialisation of the FT8xx/BT8xx. +The DELAY_MS(ms) is only used during initialization of the FT8xx/BT8xx. See EVE_target.h for examples. In Addition you need to initialise the pins used for Chip-Select and PowerDown in your hardware correctly to output. diff --git a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/library.json b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/library.json index 189ff78..5adbeba 100644 --- a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/library.json +++ b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/EmbeddedVideoEngine/library.json @@ -1,6 +1,6 @@ { "name": "EmbeddedVideoEngine", - "version": "5.0.1", + "version": "5.0.2", "keywords": "TFT, SPI, EVE2, EVE3, EVE4 ,Bridgetek, F81x, FT813, BT81x, BT815, BT817", "description": "Code library for EVE2/EVE3/EVE4 graphics controller ICs from FTDI/Bridgetek", "repository": { diff --git a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/tft.c b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/tft.c index 8f129bf..a71ad82 100644 --- a/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/tft.c +++ b/examples/EVE_Test_XMEGA128A1_GEN4-FT813-50CTP/Display_Test1/tft.c @@ -1,8 +1,8 @@ /* @file tft.c / tft.cpp @brief TFT handling functions for EVE_Test project -@version 1.17 -@date 2021-09-18 +@version 1.18 +@date 2021-12-27 @author Rudolph Riedel @section History @@ -73,6 +73,9 @@ 1.17 - replaced the UTF-8 font with a freshly generated one and adjusted the parameters for the .xfont file +1.18 +- several minor changes + */ #include "EmbeddedVideoEngine/EVE.h" @@ -83,16 +86,16 @@ /* some pre-definded colors */ -#define RED 0xff0000UL -#define ORANGE 0xffa500UL -#define GREEN 0x00ff00UL -#define BLUE 0x0000ffUL -#define BLUE_1 0x5dade2L -#define YELLOW 0xffff00UL -#define PINK 0xff00ffUL -#define PURPLE 0x800080UL -#define WHITE 0xffffffUL -#define BLACK 0x000000UL +#define RED 0xff0000UL +#define ORANGE 0xffa500UL +#define GREEN 0x00ff00UL +#define BLUE 0x0000ffUL +#define BLUE_1 0x5dade2L +#define YELLOW 0xffff00UL +#define PINK 0xff00ffUL +#define PURPLE 0x800080UL +#define WHITE 0xffffffUL +#define BLACK 0x000000UL /* memory-map defines */ #define MEM_FONT 0x000f7e00 /* the .xfont file for the UTF-8 font is copied here */ @@ -115,282 +118,286 @@ void touch_calibrate(void) /* send pre-recorded touch calibration values, depending on the display the code is compiled for */ #if defined (EVE_CFAF240400C1_030SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000ed11); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00001139); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff76809); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010690); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffadf2e); #endif #if defined (EVE_CFAF320240F_035T) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00005614); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000009e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff43422); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000001d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffbda4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00f8f2ef); #endif #if defined (EVE_CFAF480128A0_039TC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00010485); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0000017f); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffb0bd3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000073); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000e293); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00069904); #endif #if defined (EVE_CFAF800480E0_050SC) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000107f9); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xffffff8c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff451ae); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000000d2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000feac); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffcfaaf); #endif #if defined (EVE_PAF90) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00000159); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x0001019c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff93625); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00010157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00000000); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000c101); #endif #if defined (EVE_RiTFT43) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000062cd); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xfffffe45); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff45e0a); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001a3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00005b33); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFbb870); #endif #if defined (EVE_EVE2_38) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x00007bed); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000001b0); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfff60aa5); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x00000095); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xffffdcda); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x00829c08); #endif #if defined (EVE_EVE2_35G) || defined (EVE_EVE3_35G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_43G) || defined (EVE_EVE3_43G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000a1ff); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000680); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xffe54cc2); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xffffff53); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000912c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xfffe628d); #endif #if defined (EVE_EVE2_50G) || defined (EVE_EVE3_50G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000109E4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000007A6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFEC1EBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x0000072C); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0001096A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFF469CF); #endif #if defined (EVE_EVE2_70G) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000105BC); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFA8A); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0x00004670); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF75); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010074); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xFFFF14C8); #endif #if defined (EVE_NHD_35) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000f78b); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000427); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffcedf8); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xfffffba4); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x0000f756); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0009279e); #endif #if defined (EVE_RVT70) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000074df); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x000000e6); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xfffd5474); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0x000001af); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00007e79); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0xffe9a63c); #endif #if defined (EVE_FT811CB_HY50HD) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 66353); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 712); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 4293876677); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 4294966157); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 67516); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 418276); #endif #if defined (EVE_ADAM101) - EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); - EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); - EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); - EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); - EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); - EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); + EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x000101E3); + EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0x00000114); + EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF5EEBA); + EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF5E); + EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0x00010226); + EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x0000C783); #endif /* activate this if you are using a module for the first time or if you need to re-calibrate it */ /* 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 */ - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); - EVE_cmd_calibrate(); - EVE_cmd_dl(DL_DISPLAY); - EVE_cmd_dl(CMD_SWAP); - EVE_cmd_execute(); - - 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); - - EVE_cmd_dl(CMD_DLSTART); - EVE_cmd_dl(DL_CLEAR_RGB | BLACK); - EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); - EVE_cmd_dl(TAG(0)); - - EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); - EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); - EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); - EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); - EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); - EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); - - EVE_cmd_setbase(16L); - EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); - EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); - EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); - EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); - EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); - EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); - - EVE_cmd_dl(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl(CMD_SWAP); /* make this list active */ - EVE_cmd_execute(); - - while(1); + /* calibrate touch and displays values to screen */ + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_text((EVE_HSIZE/2), 50, 26, EVE_OPT_CENTER, "Please tap on the dot."); + EVE_cmd_calibrate(); + EVE_cmd_dl(DL_DISPLAY); + EVE_cmd_dl(CMD_SWAP); + while (EVE_busy()) {}; + + 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); + + EVE_cmd_dl(CMD_DLSTART); + EVE_cmd_dl(DL_CLEAR_RGB | BLACK); + EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); + EVE_cmd_dl(TAG(0)); + + EVE_cmd_text(5, 15, 26, 0, "TOUCH_TRANSFORM_A:"); + EVE_cmd_text(5, 30, 26, 0, "TOUCH_TRANSFORM_B:"); + EVE_cmd_text(5, 45, 26, 0, "TOUCH_TRANSFORM_C:"); + EVE_cmd_text(5, 60, 26, 0, "TOUCH_TRANSFORM_D:"); + EVE_cmd_text(5, 75, 26, 0, "TOUCH_TRANSFORM_E:"); + EVE_cmd_text(5, 90, 26, 0, "TOUCH_TRANSFORM_F:"); + + EVE_cmd_setbase(16L); + EVE_cmd_number(310, 15, 26, EVE_OPT_RIGHTX|8, touch_a); + EVE_cmd_number(310, 30, 26, EVE_OPT_RIGHTX|8, touch_b); + EVE_cmd_number(310, 45, 26, EVE_OPT_RIGHTX|8, touch_c); + EVE_cmd_number(310, 60, 26, EVE_OPT_RIGHTX|8, touch_d); + EVE_cmd_number(310, 75, 26, EVE_OPT_RIGHTX|8, touch_e); + EVE_cmd_number(310, 90, 26, EVE_OPT_RIGHTX|8, touch_f); + + EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl(CMD_SWAP); /* make this list active */ + while (EVE_busy()) {}; + + while(1); #endif } void initStaticBackground(void) { - EVE_cmd_dl(CMD_DLSTART); /* Start the display list */ + 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(TAG(0)); /* do not use the following objects for touch-detection */ - EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ + EVE_cmd_bgcolor(0x00c0c0c0); /* light grey */ - EVE_cmd_dl(VERTEX_FORMAT(0)); /* reduce precision for VERTEX2F to 1 pixel instead of 1/16 pixel default */ + EVE_cmd_dl(VERTEX_FORMAT(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 */ + /* 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(DL_COLOR_RGB | BLUE_1); - EVE_cmd_dl(VERTEX2F(0,0)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + EVE_cmd_dl(DL_COLOR_RGB | BLUE_1); + EVE_cmd_dl(VERTEX2F(0,0)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); - /* display the logo */ - EVE_cmd_dl(DL_COLOR_RGB | WHITE); - EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); - EVE_cmd_dl(DL_END); + /* display the logo */ + EVE_cmd_dl(DL_COLOR_RGB | WHITE); + EVE_cmd_dl(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_setbitmap(MEM_LOGO, EVE_ARGB1555, 56, 56); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE - 58, 5)); + EVE_cmd_dl(DL_END); - /* draw a black line to separate things */ - EVE_cmd_dl(DL_COLOR_RGB | BLACK); - EVE_cmd_dl(DL_BEGIN | EVE_LINES); - EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); - EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); - EVE_cmd_dl(DL_END); + /* draw a black line to separate things */ + EVE_cmd_dl(DL_COLOR_RGB | BLACK); + EVE_cmd_dl(DL_BEGIN | EVE_LINES); + EVE_cmd_dl(VERTEX2F(0,LAYOUT_Y1-2)); + EVE_cmd_dl(VERTEX2F(EVE_HSIZE,LAYOUT_Y1-2)); + EVE_cmd_dl(DL_END); #if (TEST_UTF8 != 0) && (EVE_GEN > 2) - EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ - EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_setfont2(12,MEM_FONT,32); /* assign bitmap handle to a custom font */ + EVE_cmd_text(EVE_HSIZE/2, 15, 12, EVE_OPT_CENTERX, "EVE Demo"); #else - EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); + EVE_cmd_text(EVE_HSIZE/2, 15, 29, EVE_OPT_CENTERX, "EVE Demo"); #endif - /* add the static text to the list */ + /* add the static text to the list */ #if defined (EVE_DMA) - EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); + EVE_cmd_text(10, EVE_VSIZE - 65, 26, 0, "Bytes:"); #endif - EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); - EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); - EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); + EVE_cmd_text(10, EVE_VSIZE - 50, 26, 0, "DL-size:"); + EVE_cmd_text(10, EVE_VSIZE - 35, 26, 0, "Time1:"); + EVE_cmd_text(10, EVE_VSIZE - 20, 26, 0, "Time2:"); - EVE_cmd_text(125, EVE_VSIZE - 35, 26, 0, "us"); - EVE_cmd_text(125, EVE_VSIZE - 20, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 35, 26, 0, "us"); + EVE_cmd_text(105, EVE_VSIZE - 20, 26, 0, "us"); - while (EVE_busy()) {}; + while (EVE_busy()) {}; - num_dl_static = EVE_memRead16(REG_CMD_DL); + num_dl_static = EVE_memRead16(REG_CMD_DL); - EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); - while (EVE_busy()) {}; + EVE_cmd_memcpy(MEM_DL_STATIC, EVE_RAM_DL, num_dl_static); + while (EVE_busy()) {}; } void TFT_init(void) { - if(EVE_init() != 0) - { - tft_active = 1; - - EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ - touch_calibrate(); - -#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ - #if 0 - /* this is only needed once to transfer the flash-image to the external flash */ - uint32_t datasize; - - EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ - datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ - EVE_cmd_flashupdate(0,0,4096); /* write blob first */ - EVE_init_flash(); - EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ - #endif - - 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 */ + if(E_OK == EVE_init()) + { + tft_active = 1; + + EVE_memWrite8(REG_PWM_DUTY, 0x30); /* setup backlight, range is from 0 = off to 0x80 = max */ + touch_calibrate(); + +#if (TEST_UTF8 != 0) && (EVE_GEN > 2) /* we need a BT81x for this */ + #if 0 + /* this is only needed once to transfer the flash-image to the external flash */ + uint32_t datasize; + + EVE_cmd_inflate(0, flash, sizeof(flash)); /* de-compress flash-image to RAM_G */ + datasize = EVE_cmd_getptr(); /* we unpacked to RAM_G address 0x0000, so the first address after the unpacked data also is the size */ + EVE_cmd_flashupdate(0,0,4096); /* write blob first */ + if (E_OK == EVE_init_flash()) + { + EVE_cmd_flashupdate(0,0,(datasize|4095)+1); /* size must be a multiple of 4096, so set the lower 12 bits and add 1 */ + } + #endif + + 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 */ + } #endif // TEST_UTF8 - EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ - EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); + EVE_cmd_inflate(MEM_LOGO, logo, sizeof(logo)); /* load logo into gfx-memory and de-compress it */ + EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic)); - initStaticBackground(); - } + initStaticBackground(); + } } @@ -400,105 +407,108 @@ uint16_t display_list_size = 0; /* check for touch events and setup vars for TFT_display() */ void TFT_touch(void) { - uint8_t tag; - static uint8_t toggle_lock = 0; - - if(EVE_busy()) /* is EVE still processing the last display list? */ - { - return; - } - - display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ - - tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ - - switch(tag) - { - case 0: - toggle_lock = 0; - break; - - case 10: /* use button on top as on/off radio-switch */ - if(toggle_lock == 0) - { - toggle_lock = 42; - if(toggle_state == 0) - { - toggle_state = EVE_OPT_FLAT; - } - else - { - toggle_state = 0; - } - } - break; - } + uint8_t tag; + static uint8_t toggle_lock = 0; + + if(tft_active != 0) + { + if(EVE_IS_BUSY == EVE_busy()) /* is EVE still processing the last display list? */ + { + return; + } + + display_list_size = EVE_memRead16(REG_CMD_DL); /* debug-information, get the size of the last generated display-list */ + + tag = EVE_memRead8(REG_TOUCH_TAG); /* read the value for the first touch point */ + + switch(tag) + { + case 0: + toggle_lock = 0; + break; + + case 10: /* use button on top as on/off radio-switch */ + if(0 == toggle_lock) + { + toggle_lock = 42; + if(0 == toggle_state) + { + toggle_state = EVE_OPT_FLAT; + } + else + { + toggle_state = 0; + } + } + break; + } + } } /* - dynamic portion of display-handling, meant to be called every 20ms or more + 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 defined (EVE_DMA) - uint16_t cmd_fifo_size; - cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ - #endif - - EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ - - EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ - EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ - /* display a button */ - EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); - EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); - EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ - EVE_cmd_rotate_burst(rotate); - EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ - EVE_cmd_dl_burst(CMD_SETMATRIX); - - if(toggle_state != 0) - { - rotate += 256; - } - - EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); - EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); - EVE_cmd_dl_burst(DL_END); - - EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ - - /* print profiling values */ - EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); - - #if defined (EVE_DMA) - EVE_cmd_number_burst(120, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ - #endif - EVE_cmd_number_burst(120, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ - EVE_cmd_number_burst(120, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|5, num_profile_a); /* duration in �s of TFT_loop() for the touch-event part */ - EVE_cmd_number_burst(120, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|5, num_profile_b); /* duration in �s of TFT_loop() for the display-list part */ - - EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the graphics processor to show the list */ - EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ - - EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ - } + static int32_t rotate = 0; + + + if(tft_active != 0) + { + #if defined (EVE_DMA) + uint16_t cmd_fifo_size; + cmd_fifo_size = EVE_dma_buffer_index*4; /* without DMA there is no way to tell how many bytes are written to the cmd-fifo */ + #endif + + EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */ + + EVE_cmd_dl_burst(CMD_DLSTART); /* start the display list */ + EVE_cmd_dl_burst(DL_CLEAR_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_append_burst(MEM_DL_STATIC, num_dl_static); /* insert static part of display-list from copy in gfx-mem */ + /* display a button */ + EVE_cmd_dl_burst(DL_COLOR_RGB | 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_button_burst(20,20,80,30, 28, toggle_state,"Touch!"); + EVE_cmd_dl_burst(TAG(0)); /* 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_dl_burst(CMD_LOADIDENTITY); + EVE_cmd_translate_burst(65536 * 70, 65536 * 50); /* shift off-center */ + EVE_cmd_rotate_burst(rotate); + EVE_cmd_translate_burst(65536 * -70, 65536 * -50); /* shift back */ + EVE_cmd_dl_burst(CMD_SETMATRIX); + + if(toggle_state != 0) + { + rotate += 256; + } + + EVE_cmd_dl_burst(DL_BEGIN | EVE_BITMAPS); + EVE_cmd_dl_burst(VERTEX2F(EVE_HSIZE - 100, (LAYOUT_Y1))); + EVE_cmd_dl_burst(DL_END); + + EVE_cmd_dl_burst(RESTORE_CONTEXT()); /* reset the transformation matrix to default values */ + + /* print profiling values */ + EVE_cmd_dl_burst(DL_COLOR_RGB | BLACK); + + #if defined (EVE_DMA) + EVE_cmd_number_burst(100, EVE_VSIZE - 65, 26, EVE_OPT_RIGHTX, cmd_fifo_size); /* number of bytes written to the cmd-fifo */ + #endif + EVE_cmd_number_burst(100, EVE_VSIZE - 50, 26, EVE_OPT_RIGHTX, display_list_size); /* number of bytes written to the display-list by the command co-pro */ + EVE_cmd_number_burst(100, EVE_VSIZE - 35, 26, EVE_OPT_RIGHTX|4, num_profile_a); /* duration in us of TFT_loop() for the touch-event part */ + EVE_cmd_number_burst(100, EVE_VSIZE - 20, 26, EVE_OPT_RIGHTX|4, num_profile_b); /* duration in us of TFT_loop() for the display-list part */ + + EVE_cmd_dl_burst(DL_DISPLAY); /* instruct the co-processor to show the list */ + EVE_cmd_dl_burst(CMD_SWAP); /* make this list active */ + + EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */ + } } diff --git a/library.json b/library.json index 189ff78..5adbeba 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EmbeddedVideoEngine", - "version": "5.0.1", + "version": "5.0.2", "keywords": "TFT, SPI, EVE2, EVE3, EVE4 ,Bridgetek, F81x, FT813, BT81x, BT815, BT817", "description": "Code library for EVE2/EVE3/EVE4 graphics controller ICs from FTDI/Bridgetek", "repository": {