From 36674b5017746bc01d15ffb63756445a589e71a1 Mon Sep 17 00:00:00 2001 From: godmial Date: Thu, 22 May 2025 16:53:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9Egd32470z-lckfb=E9=85=8D?= =?UTF-8?q?=E5=A5=97LCD=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/gd32/arm/gd32470z-lckfb/README.md | 2 +- bsp/gd32/arm/gd32470z-lckfb/SConstruct | 3 + bsp/gd32/arm/gd32470z-lckfb/board/Kconfig | 31 + .../arm/gd32470z-lckfb/board/ports/README.md | 23 + .../arm/gd32470z-lckfb/board/ports/SConscript | 25 + .../gd32470z-lckfb/board/ports/draw_panel.c | 215 ++++ .../arm/gd32470z-lckfb/board/ports/drv_lcd.c | 921 ++++++++++++++++++ .../arm/gd32470z-lckfb/board/ports/drv_lcd.h | 86 ++ .../gd32470z-lckfb/board/ports/drv_touch.c | 390 ++++++++ .../gd32470z-lckfb/board/ports/drv_touch.h | 98 ++ .../arm/gd32470z-lckfb/board/ports/font.h | 104 ++ .../GD32F4xx_Firmware_Library/SConscript | 6 + 12 files changed, 1903 insertions(+), 1 deletion(-) create mode 100644 bsp/gd32/arm/gd32470z-lckfb/board/ports/README.md create mode 100644 bsp/gd32/arm/gd32470z-lckfb/board/ports/SConscript create mode 100644 bsp/gd32/arm/gd32470z-lckfb/board/ports/draw_panel.c create mode 100644 bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.c create mode 100644 bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.h create mode 100644 bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.c create mode 100644 bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.h create mode 100644 bsp/gd32/arm/gd32470z-lckfb/board/ports/font.h diff --git a/bsp/gd32/arm/gd32470z-lckfb/README.md b/bsp/gd32/arm/gd32470z-lckfb/README.md index 93c1e6f463c..b20546911bc 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/README.md +++ b/bsp/gd32/arm/gd32470z-lckfb/README.md @@ -51,7 +51,7 @@ GD32470Z-LCKFB梁山派是立创开发板推出的一款GD32F470系列的开发 | GPIO | 支持 | PA0, PA1... ---> PIN: 0, 1...113 | | UART | 支持 | UART0 - UART7 | | **扩展模块** | **支持情况** | **备注** | -| 暂无 | 暂不支持 | 暂不支持 | +| LCD+触摸屏 | 支持 | 暂不支持中文显示(因 Keil5 编码限制),使用方法请查看bsp\gd32\arm\gd32470z-lckfb\board\ports\README.md | ## 使用说明 diff --git a/bsp/gd32/arm/gd32470z-lckfb/SConstruct b/bsp/gd32/arm/gd32470z-lckfb/SConstruct index ae4f8f787c5..310bd176250 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/SConstruct +++ b/bsp/gd32/arm/gd32470z-lckfb/SConstruct @@ -56,5 +56,8 @@ objs.extend(SConscript(os.path.join(libraries_path_prefix, gd32_library, 'SConsc # include drivers objs.extend(SConscript(os.path.join(libraries_path_prefix, 'gd32_drivers', 'SConscript'))) +# include lcd and drivers +objs.extend(SConscript(os.path.join(RTT_ROOT, 'bsp', 'gd32', 'arm', 'gd32470z-lckfb', 'board', 'ports', 'SConscript'))) + # make a building DoBuilding(TARGET, objs) diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/Kconfig b/bsp/gd32/arm/gd32470z-lckfb/board/Kconfig index 843690f0800..6d36887be55 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/board/Kconfig +++ b/bsp/gd32/arm/gd32470z-lckfb/board/Kconfig @@ -433,6 +433,37 @@ endmenu menu "Board extended module Drivers" + menuconfig BSP_USING_LCD + bool "Enable LCD" + select RT_USING_LCD + default n + if BSP_USING_LCD + + config BSP_USING_TLI + bool "Enable TLI" + default y + + config BSP_USING_SDRAM + bool "Enable SDRAM" + select RT_USING_SDRAM + default y + + config BSP_USING_TOUCH + bool "Enable TOUCH" + select RT_USING_TOUCH + default n + + config BSP_USING_GPU + bool "Enable GPU" + select RT_USING_GPU + default y + + config BSP_USING_DRAW_PANEL_EXAMPLE + bool "Enable DRAW PANEL EXAMPLE" + select RT_USING_DRAW_PANEL_EXAMPLE + default n + endif + endmenu endmenu diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/README.md b/bsp/gd32/arm/gd32470z-lckfb/board/ports/README.md new file mode 100644 index 00000000000..566f1e930d9 --- /dev/null +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/README.md @@ -0,0 +1,23 @@ +#### 1.简介 + +用于GD32F470立创开发板配套RGB LCD屏幕的驱动,支持触摸。 +#### 2.在 ENV 中的开启 +ps:建议全部开启 +``` +Hardware Drivers Config ---> + Board extended module Drivers ---> + Enable LCD ---> + - [*]Enable TLI + - [*]Enable SDRAM + - [*]Enable TOUCH + - [*]Enable GPU + - [*]Enable DRAW PANEL EXAMPLE +``` +#### 3.注意事项 +1.如果屏幕出现刷新抖动,触摸屏出现连点的情况,可以尝试在 `libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\system_gd32f4xx.c`将时钟值修改为 +`#define __SYSTEM_CLOCK_240M_PLL_25M_HXTAL (uint32_t)(240000000)`然后重新编译即可 + +#### 4.联系方式 + +- 维护:godmial +- 主页: diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/SConscript b/bsp/gd32/arm/gd32470z-lckfb/board/ports/SConscript new file mode 100644 index 00000000000..80273b4ffe8 --- /dev/null +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/SConscript @@ -0,0 +1,25 @@ +Import('RTT_ROOT') +Import('rtconfig') +from building import * + +cwd = GetCurrentDir() + +# add the general drivers. +src = Split(""" +""") + +# add lcd drivers. +if GetDepend('BSP_USING_LCD'): + src += ['drv_lcd.c'] + +if GetDepend('BSP_USING_TOUCH'): + src += ['drv_touch.c'] + +if GetDepend('BSP_USING_DRAW_PANEL_EXAMPLE'): + src += ['draw_panel.c'] + +path = [cwd] + +group = DefineGroup('Applications', src, depend = [''], CPPPATH = path) + +Return('group') diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/draw_panel.c b/bsp/gd32/arm/gd32470z-lckfb/board/ports/draw_panel.c new file mode 100644 index 00000000000..909d85e02ee --- /dev/null +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/draw_panel.c @@ -0,0 +1,215 @@ +#include +#include +#include +#include "drv_lcd.h" +#include "drv_touch.h" + +#define COLOR_MAX 14 + +//像素最大放大倍数 +#define PIXEL_SIZE_MAX 20 + +typedef struct button_struct +{ + uint16_t x; + uint16_t y; + uint16_t w; + uint16_t h; + uint16_t color; + uint16_t value; +} _widget_object_struct; + +uint16_t color_buf[COLOR_MAX] = {GRAYBLUE, BLACK, BLUE, BRED, GRED, GBLUE, RED, MAGENTA, GREEN, YELLOW, CYAN, BROWN, BRRED, GRAY}; +_widget_object_struct button_clear, button_color, button_pixel, button_eraser; + + +/********************************************************** + * 函 数 名 称:widget_object_init + * 函 数 功 能:控件对象初始化 + * 传 入 参 数:obj:要初始化的控件 + * xywh:控件的(x,y)起点坐标 w宽h高 + * color:控件颜色 + * value:控件值 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void widget_object_init(_widget_object_struct *obj, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, uint16_t value) +{ + obj->x = x; + obj->y = y; + obj->h = h; + obj->w = w; + obj->color = color; + obj->value = value; +} + + +/********************************************************** + * 函 数 名 称:ui_init + * 函 数 功 能:UI界面初始化 + * 传 入 参 数:无 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void ui_init(void) +{ + char temp_buf[20] = {0}; + + //绘制[清除]按钮 + //绘制一个圆角按钮 + tli_show_button(button_clear.x, button_clear.y, button_clear.w, button_clear.h, 12, button_clear.color); + //绘制圆角按钮的文本 + tli_show_string(button_clear.x + 20, button_clear.y + 20, WHITE, button_clear.color, 2, "clear", 0); + + //绘制[颜色]按钮 + //绘制一个圆角按钮 + tli_show_button(button_color.x, button_color.y, button_color.w, button_color.h, 12, button_color.color); + //绘制圆角按钮的文本 + tli_show_string(button_color.x + 20, button_color.y + 20, WHITE, button_color.color, 2, "color", 0); + + //绘制[像素]按钮 + //绘制一个圆角按钮 + tli_show_button(button_pixel.x, button_pixel.y, button_pixel.w, button_pixel.h, 12, button_pixel.color); + if (button_pixel.value == 0) + { + //绘制圆角按钮的文本 + tli_show_string(button_pixel.x + 20, button_pixel.y + 20, WHITE, button_pixel.color, 2, "pixel", 0); + button_pixel.value = 1; + } + else + { + //绘制居中显示的字符串 + sprintf(temp_buf, "%d", button_pixel.value); + tli_show_string(button_pixel.x + (button_pixel.w / 2) - (strlen(temp_buf) / 2 * 16), button_pixel.y + 20, WHITE, button_pixel.color, 2, (uint8_t *)temp_buf, 0); + } + + //绘制[擦除]按钮 + //绘制一个圆角按钮 + tli_show_button(button_eraser.x, button_eraser.y, button_eraser.w, button_eraser.h, 12, button_eraser.color); + //绘制圆角按钮的文本 + tli_show_string(button_eraser.x + (button_eraser.w / 2) - (strlen("eraser") / 2 * 16), button_eraser.y + 20, WHITE, button_eraser.color, 2, "eraser", 0); +} + +int draw_panel_test(void) +{ + int touch_state = 0; + char color_num = 0; + char pixel_size = 0; + + // 屏幕初始化 + lcd_disp_config(); + // 触摸初始化 + FT5206_Init(); + //全屏清屏 + tli_draw_Rectangle(0, 0, 800, 480, WHITE, 1); + + + //初始化[清除]按钮的xywh + widget_object_init(&button_clear, 800 - 130, 480 - 80, 120, 70, BLUE, 0); + //初始化[颜色]按钮的xywh + widget_object_init(&button_color, 10, 480 - 80, 120, 70, BLUE, 0); + //初始化[像素]按钮的xywh + widget_object_init(&button_pixel, 400 - 60, 480 - 80, 120, 70, BLUE, pixel_size); + //初始化[橡皮擦]按钮的xywh + widget_object_init(&button_eraser, 800 - 130 - 130, 480 - 80, 120, 70, BLUE, 0); + + //UI显示 + ui_init(); + + while (1) + { + //触摸扫描 + touch_state = FT5206_Scan(0); + //如果屏幕被触摸 + if (touch_state == 1) + { + //[颜色]按钮被按下 + if (tp_dev.x[0] >= button_color.x && tp_dev.x[0] <= (button_color.x + button_color.w)) + { + if (tp_dev.y[0] >= button_color.y && tp_dev.y[0] <= (button_color.y + button_color.h)) + { + //判断是否松手 + letgo_scan(0, button_color.x, button_color.y, (button_color.x + button_color.w), (button_color.y + button_color.h)); + //改变颜色 + color_num = (color_num + 1) % COLOR_MAX; + //重新设置[颜色]按钮的背景色 + widget_object_init(&button_color, button_color.x, button_color.y, button_color.w, button_color.h, color_buf[color_num], 0); + //UI重新显示 + ui_init(); + } + } + //[清除]按钮被按下 + if (tp_dev.x[0] >= button_clear.x && tp_dev.x[0] <= (button_clear.x + button_clear.w)) + { + if (tp_dev.y[0] >= button_clear.y && tp_dev.y[0] <= (button_clear.y + button_clear.h)) + { + //判断是否松手 + letgo_scan(0, button_clear.x, button_clear.y, (button_clear.x + button_clear.w), (button_clear.y + button_clear.h)); + //清屏为背景色 + tli_draw_Rectangle(0, 0, 800, 480, WHITE, 1); + //UI重新显示 + ui_init(); + } + } + //[像素]按钮被按下 + if (tp_dev.x[0] >= button_pixel.x && tp_dev.x[0] <= (button_pixel.x + button_pixel.w)) + { + if (tp_dev.y[0] >= button_pixel.y && tp_dev.y[0] <= (button_pixel.y + button_pixel.h)) + { + //判断是否松手 + letgo_scan(0, button_pixel.x, button_pixel.y, (button_pixel.x + button_pixel.w), (button_pixel.y + button_pixel.h)); + //像素放大倍数自增 + pixel_size++; + //如果像素放大倍数大于最大倍数 + if (pixel_size > PIXEL_SIZE_MAX) pixel_size = 1; + //重新设置[颜色]按钮的背景色 + widget_object_init(&button_pixel, button_pixel.x, button_pixel.y, button_pixel.w, button_pixel.h, button_pixel.color, pixel_size); + //UI重新显示 + ui_init(); + } + } + + //[擦除]按钮被按下 + if (tp_dev.x[0] >= button_eraser.x && tp_dev.x[0] <= (button_eraser.x + button_eraser.w)) + { + if (tp_dev.y[0] >= button_eraser.y && tp_dev.y[0] <= (button_eraser.y + button_eraser.h)) + { + //判断是否松手 + letgo_scan(0, button_eraser.x, button_eraser.y, (button_eraser.x + button_eraser.w), (button_eraser.y + button_eraser.h)); + //修改擦除按钮的状态 + button_eraser.value = !button_eraser.value; + //如果是擦除状态 + if (button_eraser.value) + { + //初始化[橡皮擦]按钮的xywh颜色修改为黑色 + widget_object_init(&button_eraser, 800 - 130 - 130, 480 - 80, 120, 70, BLACK, button_eraser.value); + } + else + { + //初始化[橡皮擦]按钮的xywh颜色修改为蓝色 + widget_object_init(&button_eraser, 800 - 130 - 130, 480 - 80, 120, 70, BLUE, button_eraser.value); + } + //UI重新显示 + ui_init(); + } + } + + //如果不是擦除状态 + if (!button_eraser.value) + { + //绘制触摸点 + //根据[颜色]按钮的背景色设置触摸点的颜色 + point_enlargement(tp_dev.x[0], tp_dev.y[0], color_buf[color_num], button_pixel.value); + } + else + { + //擦除 + point_enlargement(tp_dev.x[0], tp_dev.y[0], WHITE, button_pixel.value); + } + } + } +} +// MSH_CMD_EXPORT(draw_panel_test, draw panel test) +INIT_COMPONENT_EXPORT(draw_panel_test); \ No newline at end of file diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.c b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.c new file mode 100644 index 00000000000..b61cedda705 --- /dev/null +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.c @@ -0,0 +1,921 @@ +#include +#include "gd32f4xx.h" +#include "gd32f4xx_tli.h" +#include "drv_lcd.h" +#include "font.h" + +/******************************************************************************* + * Definitions + ******************************************************************************/ + + +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) +//Keil MDK 编译器 +uint16_t ltdc_lcd_framebuf0[800][480] __attribute__((at(LCD_FRAME_BUF_ADDR))); +#elif defined(__GNUC__) +// GCC 编译器 (如 RT-Thread 使用的 GCC) +uint16_t ltdc_lcd_framebuf0[10][10]; +#endif + +static void tli_gpio_config(void); +static void tli_config(void); +static void ipa_config(void); +static void lcd_disp_en_config(void); +static void lcd_disp_off(void); +static void lcd_disp_on(void); + +void lcd_disp_config(void) +{ + lcd_disp_en_config(); + lcd_disp_off(); + + /* configure the GPIO of TLI */ + tli_gpio_config(); + lcd_disp_on(); + + tli_config(); + tli_layer_enable(LAYER0); + tli_reload_config(TLI_FRAME_BLANK_RELOAD_EN); + tli_enable(); + ipa_config(); +} + +static void tli_config(void) +{ + tli_parameter_struct tli_init_struct; + tli_layer_parameter_struct tli_layer_init_struct; + + rcu_periph_clock_enable(RCU_TLI); + tli_gpio_config(); + /* configure PLLSAI to generate TLI clock */ + // if(ERROR == rcu_pllsai_config(216, 2, 3)){ + if (ERROR == rcu_pllsai_config(192, 2, 3)) + { + while (1); + } + rcu_tli_clock_div_config(RCU_PLLSAIR_DIV2); + + rcu_osci_on(RCU_PLLSAI_CK); + + if (ERROR == rcu_osci_stab_wait(RCU_PLLSAI_CK)) + { + while (1); + } + + /* configure TLI parameter struct */ + tli_init_struct.signalpolarity_hs = TLI_HSYN_ACTLIVE_LOW; + tli_init_struct.signalpolarity_vs = TLI_VSYN_ACTLIVE_LOW; + tli_init_struct.signalpolarity_de = TLI_DE_ACTLIVE_LOW; + tli_init_struct.signalpolarity_pixelck = TLI_PIXEL_CLOCK_TLI; + /* LCD display timing configuration */ + tli_init_struct.synpsz_hpsz = HORIZONTAL_SYNCHRONOUS_PULSE - 1; + tli_init_struct.synpsz_vpsz = VERTICAL_SYNCHRONOUS_PULSE - 1; + tli_init_struct.backpsz_hbpsz = HORIZONTAL_SYNCHRONOUS_PULSE + HORIZONTAL_BACK_PORCH - 1; + tli_init_struct.backpsz_vbpsz = VERTICAL_SYNCHRONOUS_PULSE + VERTICAL_BACK_PORCH - 1; + tli_init_struct.activesz_hasz = HORIZONTAL_SYNCHRONOUS_PULSE + HORIZONTAL_BACK_PORCH + ACTIVE_WIDTH - 1; + tli_init_struct.activesz_vasz = VERTICAL_SYNCHRONOUS_PULSE + VERTICAL_BACK_PORCH + ACTIVE_HEIGHT - 1; + tli_init_struct.totalsz_htsz = HORIZONTAL_SYNCHRONOUS_PULSE + HORIZONTAL_BACK_PORCH + ACTIVE_WIDTH + HORIZONTAL_FRONT_PORCH - 1; + tli_init_struct.totalsz_vtsz = VERTICAL_SYNCHRONOUS_PULSE + VERTICAL_BACK_PORCH + ACTIVE_HEIGHT + VERTICAL_FRONT_PORCH - 1; + /* configure LCD background R,G,B values */ + tli_init_struct.backcolor_red = 0xFF; + tli_init_struct.backcolor_green = 0xFF; + tli_init_struct.backcolor_blue = 0xFF; + tli_init(&tli_init_struct); + +#if 1 + /* TLI layer0 configuration */ + /* TLI window size configuration */ + tli_layer_init_struct.layer_window_leftpos = HORIZONTAL_SYNCHRONOUS_PULSE + HORIZONTAL_BACK_PORCH; + tli_layer_init_struct.layer_window_rightpos = (ACTIVE_WIDTH + HORIZONTAL_SYNCHRONOUS_PULSE + HORIZONTAL_BACK_PORCH - 1); + tli_layer_init_struct.layer_window_toppos = VERTICAL_SYNCHRONOUS_PULSE + VERTICAL_BACK_PORCH; + tli_layer_init_struct.layer_window_bottompos = (ACTIVE_HEIGHT + VERTICAL_SYNCHRONOUS_PULSE + VERTICAL_BACK_PORCH - 1); + /* TLI window pixel format configuration */ + tli_layer_init_struct.layer_ppf = LAYER_PPF_RGB565; + /* TLI window specified alpha configuration */ + tli_layer_init_struct.layer_sa = 255; + /* TLI layer default alpha R,G,B value configuration */ + tli_layer_init_struct.layer_default_blue = 0x00; + tli_layer_init_struct.layer_default_green = 0x00; + tli_layer_init_struct.layer_default_red = 0x00; + tli_layer_init_struct.layer_default_alpha = 0x00; + /* TLI window blend configuration */ + tli_layer_init_struct.layer_acf1 = LAYER_ACF1_SA; + tli_layer_init_struct.layer_acf2 = LAYER_ACF2_SA; + /* TLI layer frame buffer base address configuration */ + tli_layer_init_struct.layer_frame_bufaddr = (uint32_t)ltdc_lcd_framebuf0; + tli_layer_init_struct.layer_frame_line_length = ((ACTIVE_WIDTH * 2) + 3); + tli_layer_init_struct.layer_frame_buf_stride_offset = (ACTIVE_WIDTH * 2); + tli_layer_init_struct.layer_frame_total_line_number = ACTIVE_HEIGHT; + tli_layer_init(LAYER0, &tli_layer_init_struct); + tli_dither_config(TLI_DITHER_ENABLE); +#endif +} + +/*! + \brief IPA initialize and configuration + \param[in] none + \param[out] none + \retval none +*/ +static void ipa_config(void) +{ + rcu_periph_clock_enable(RCU_IPA); + nvic_irq_enable(IPA_IRQn, 0, 2); +} + +static void tli_gpio_config(void) +{ + /* enable the periphral clock */ + rcu_periph_clock_enable(RCU_GPIOA); + rcu_periph_clock_enable(RCU_GPIOB); + rcu_periph_clock_enable(RCU_GPIOC); + rcu_periph_clock_enable(RCU_GPIOD); + rcu_periph_clock_enable(RCU_GPIOF); + rcu_periph_clock_enable(RCU_GPIOG); + + /* configure HSYNC(PC6), VSYNC(PA4), PCLK(PG7), DE(PF10) */ + /* configure LCD_R7(PG6), LCD_R6(PA8), LCD_R5(PA12), LCD_R4(PA11), LCD_R3(PB0), + LCD_G7(PD3), LCD_G6(PC7), LCD_G5(PB11), LCD_G4(PB10), LCD_G3(PG10), LCD_G2(PA6), + LCD_B7(PB9), LCD_B6(PB8), LCD_B5(PA3), LCD_B4(PG12), LCD_B3(PG11) */ + gpio_af_set(GPIOA, GPIO_AF_14, GPIO_PIN_3); + gpio_af_set(GPIOA, GPIO_AF_14, GPIO_PIN_4); + gpio_af_set(GPIOA, GPIO_AF_14, GPIO_PIN_6); + gpio_af_set(GPIOA, GPIO_AF_14, GPIO_PIN_8); + gpio_af_set(GPIOA, GPIO_AF_14, GPIO_PIN_11); + gpio_af_set(GPIOA, GPIO_AF_14, GPIO_PIN_12); + + gpio_af_set(GPIOB, GPIO_AF_9, GPIO_PIN_0); + gpio_af_set(GPIOB, GPIO_AF_14, GPIO_PIN_8); + gpio_af_set(GPIOB, GPIO_AF_14, GPIO_PIN_9); + gpio_af_set(GPIOB, GPIO_AF_14, GPIO_PIN_10); + gpio_af_set(GPIOB, GPIO_AF_14, GPIO_PIN_11); + + gpio_af_set(GPIOC, GPIO_AF_14, GPIO_PIN_6); + gpio_af_set(GPIOC, GPIO_AF_14, GPIO_PIN_7); + + gpio_af_set(GPIOD, GPIO_AF_14, GPIO_PIN_3); + + gpio_af_set(GPIOF, GPIO_AF_14, GPIO_PIN_10); + + gpio_af_set(GPIOG, GPIO_AF_14, GPIO_PIN_6); + gpio_af_set(GPIOG, GPIO_AF_14, GPIO_PIN_7); + gpio_af_set(GPIOG, GPIO_AF_9, GPIO_PIN_10); + gpio_af_set(GPIOG, GPIO_AF_14, GPIO_PIN_11); + gpio_af_set(GPIOG, GPIO_AF_9, GPIO_PIN_12); + + gpio_mode_set(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_8 | GPIO_PIN_11 | GPIO_PIN_12); + gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_8 | GPIO_PIN_11 | GPIO_PIN_12); + + gpio_mode_set(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_0 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11); + gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_0 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11); + + gpio_mode_set(GPIOC, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_6 | GPIO_PIN_7); + gpio_output_options_set(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_6 | GPIO_PIN_7); + + gpio_mode_set(GPIOD, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_3); + gpio_output_options_set(GPIOD, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_3); + + gpio_mode_set(GPIOF, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_10); + gpio_output_options_set(GPIOF, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_10); + + gpio_mode_set(GPIOG, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12); + gpio_output_options_set(GPIOG, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12); +} + +/*! + \brief configure DISP ON/OFF GPIO + \param[in] none + \param[out] none + \retval none +*/ +static void lcd_disp_en_config(void) +{ + /* enable the periphral clock */ + rcu_periph_clock_enable(RCU_GPIOD); + gpio_mode_set(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_13); + gpio_output_options_set(GPIOD, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_13); +} + +/*! + \brief DISP GPIO OFF + \param[in] none + \param[out] none + \retval none +*/ +static void lcd_disp_off(void) +{ + gpio_bit_reset(GPIOD, GPIO_PIN_13); +} + +/*! + \brief DISP GPIO ON + \param[in] none + \param[out] none + \retval none +*/ +static void lcd_disp_on(void) +{ + gpio_bit_set(GPIOD, GPIO_PIN_13); +} + + +/********************************************************** + * 函 数 名 称:tli_draw_point + * 函 数 功 能:画点 + * 传 入 参 数:(x,y):起点坐标 + * color:点的颜色 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void tli_draw_point(uint16_t x, uint16_t y, uint16_t color) +{ + *(ltdc_lcd_framebuf0[0] + (LCD_WIDTH * y + x)) = color; +} + +/********************************************************** + * 函 数 名 称:tli_draw_line + * 函 数 功 能:画线 + * 传 入 参 数:(sx,sy):起点坐标 + * (ex,ey):终点坐标 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void tli_draw_line(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color) +{ + uint16_t t; + int xerr = 0, yerr = 0, delta_x, delta_y, distance; + int incx, incy, uRow, uCol; + + delta_x = ex - sx; //计算坐标增量 + delta_y = ey - sy; + uRow = sx; + uCol = sy; + if (delta_x > 0) + incx = 1; //设置单步方向 + else if (delta_x == 0) + incx = 0; //垂直线 + else + { + incx = -1; + delta_x = -delta_x; + } + if (delta_y > 0) + incy = 1; + else if (delta_y == 0) + incy = 0; //水平线 + else + { + incy = -1; + delta_y = -delta_y; + } + if (delta_x > delta_y) + distance = delta_x; //选取基本增量坐标轴 + else + distance = delta_y; + for (t = 0; t <= distance + 1; t++) //画线输出 + { + tli_draw_point(uRow, uCol, color); //画点 + xerr += delta_x; + yerr += delta_y; + if (xerr > distance) + { + xerr -= distance; + uRow += incx; + } + if (yerr > distance) + { + yerr -= distance; + uCol += incy; + } + } +} +/********************************************************** + * 函 数 名 称:tli_draw_Rectangle + * 函 数 功 能:画矩形填充 + * 传 入 参 数:(sx,sy) :起点坐标 + * (sx,sy) :终点坐标 + * color:笔画颜色 +* fill:填充标志 =1填充颜色 =0不填充 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void tli_draw_Rectangle(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color, uint16_t fill) +{ + int i = 0, j = 0; + if (fill) + { + for (i = sx; i < ex; i++) + { + for (j = sy; j < ey; j++) + { + tli_draw_point(i, j, color); + } + } + } + else + { + tli_draw_line(sx, sy, ex, sy, color); + tli_draw_line(sx, sy, sx, ey, color); + tli_draw_line(sx, ey, ex, ey, color); + tli_draw_line(ex, sy, ex, ey, color); + } +} + +/********************************************************** + * 函 数 名 称:_draw_circle_8 + * 函 数 功 能:8对称性画圆算法(内部调用) + * 传 入 参 数: (xc,yc):圆中心坐标 + (x,y):光标相对于圆心的坐标 + * c:点的颜色 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:内部调用 +**********************************************************/ +static void _draw_circle_8(int xc, int yc, int x, int y, uint16_t c) +{ + tli_draw_point(xc + x, yc + y, c); + + tli_draw_point(xc - x, yc + y, c); + + tli_draw_point(xc + x, yc - y, c); + + tli_draw_point(xc - x, yc - y, c); + + tli_draw_point(xc + y, yc + x, c); + + tli_draw_point(xc - y, yc + x, c); + + tli_draw_point(xc + y, yc - x, c); + + tli_draw_point(xc - y, yc - x, c); +} + +/********************************************************** + * 函 数 名 称:tli_draw_circle + * 函 数 功 能:在指定位置画一个指定大小的圆 + * 传 入 参 数: (xc,yc) :圆中心坐标 + * c:填充的颜色 + * r:圆半径 + * fill:填充判断标志,1-填充,0-不填充 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void tli_draw_circle(int xc, int yc, uint16_t c, int r, int fill) +{ + int x = 0, y = r, yi, d; + + d = 3 - 2 * r; + + if (fill) + { + // 如果填充(画实心圆) + while (x <= y) + { + for (yi = x; yi <= y; yi++) + _draw_circle_8(xc, yc, x, yi, c); + + if (d < 0) + { + d = d + 4 * x + 6; + } + else + { + d = d + 4 * (x - y) + 10; + y--; + } + x++; + } + } + else + { + // 如果不填充(画空心圆) + while (x <= y) + { + _draw_circle_8(xc, yc, x, y, c); + if (d < 0) + { + d = d + 4 * x + 6; + } + else + { + d = d + 4 * (x - y) + 10; + y--; + } + x++; + } + } +} + +/********************************************************** + * 函 数 名 称:_swap + * 函 数 功 能:数据交换 + * 传 入 参 数:a=交换方1 b=交换方2 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:仅内部使用 +**********************************************************/ +static void _swap(uint16_t *a, uint16_t *b) +{ + uint16_t tmp; + tmp = *a; + *a = *b; + *b = tmp; +} + +/********************************************************** + * 函 数 名 称:tli_draw_triange + * 函 数 功 能:画三角形 + * 传 入 参 数:(x0,y0):第一个边角的坐标 + * (x1,y1):顶点的坐标 + * (x2,y2):第二个边角的坐标 + * color:三角形颜色 + * fill:填充判断标志,1-填充,0-不填充 + * 函 数 返 回: + * 作 者:LCKFB + * 备 注: +**********************************************************/ + +void tli_draw_triange(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color, uint16_t fill) +{ + uint16_t a, b, y, last; + int dx01, dy01, dx02, dy02, dx12, dy12; + long sa = 0; + long sb = 0; + + if (fill == 0) + { + tli_draw_line(x0, y0, x1, y1, color); + tli_draw_line(x1, y1, x2, y2, color); + tli_draw_line(x2, y2, x0, y0, color); + } + else + { + if (y0 > y1) + { + _swap(&y0, &y1); + _swap(&x0, &x1); + } + if (y1 > y2) + { + _swap(&y2, &y1); + _swap(&x2, &x1); + } + if (y0 > y1) + { + _swap(&y0, &y1); + _swap(&x0, &x1); + } + if (y0 == y2) + { + a = b = x0; + if (x1 < a) + { + a = x1; + } + else if (x1 > b) + { + b = x1; + } + if (x2 < a) + { + a = x2; + } + else if (x2 > b) + { + b = x2; + } + tli_draw_Rectangle(a, y0, b, y0, color, 0); + return; + } + dx01 = x1 - x0; + dy01 = y1 - y0; + dx02 = x2 - x0; + dy02 = y2 - y0; + dx12 = x2 - x1; + dy12 = y2 - y1; + + if (y1 == y2) + { + last = y1; + } + else + { + last = y1 - 1; + } + for (y = y0; y <= last; y++) + { + a = x0 + sa / dy01; + b = x0 + sb / dy02; + sa += dx01; + sb += dx02; + if (a > b) + { + _swap(&a, &b); + } + tli_draw_Rectangle(a, y, b, y, color, 0); + } + sa = dx12 * (y - y1); + sb = dx02 * (y - y0); + for (; y <= y2; y++) + { + a = x1 + sa / dy12; + b = x0 + sb / dy02; + sa += dx12; + sb += dx02; + if (a > b) + { + _swap(&a, &b); + } + + tli_draw_Rectangle(a, y, b, y, color, 0); + } + } +} + + +/********************************************************** + * 函 数 名 称:point_enlargement + * 函 数 功 能:将一个点放大 + * 传 入 参 数:(x,y):点的起始坐标 + * color:点的颜色 + * magnify:点的放大倍数 最小为1 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void point_enlargement(uint16_t x, uint16_t y, uint16_t color, char magnify) +{ + tli_draw_Rectangle(x - magnify, y - magnify, x, y, color, 1); + + tli_draw_Rectangle(x, y - magnify, x + magnify, y, color, 1); + + tli_draw_Rectangle(x - magnify, y, x, y + magnify, color, 1); + + tli_draw_Rectangle(x, y, x + magnify, y + magnify, color, 1); +} + +/********************************************************** + * 函 数 名 称:LCD_ShowChar + * 函 数 功 能:显示一个字符 + * 传 入 参 数:(x,y):字符显示的起点坐标 + fc:笔画颜色 + bc:背景颜色 + num:显示的字符 + size:字符放大倍数 最小为1 + mode:是否叠加显示 0=非叠加方式 1=叠加方式 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:以16x8大小的字符作为放大模板 +**********************************************************/ +void tli_show_char(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t num, uint8_t size, uint8_t mode) +{ + uint8_t temp; + uint8_t pos, t; + uint16_t x0 = 0; + uint16_t y0 = 0; + num = num - ' '; //得到偏移后的值 + + for (pos = 0; pos < 16; pos++) + { + temp = asc2_1608[num][pos]; //调用1608字体 + for (t = 0; t < 16 / 2; t++) + { + if (!mode) + { + if (temp & 0x01) + point_enlargement(x + x0, y + y0, fc, size); //画一个点 + else + point_enlargement(x + x0, y + y0, bc, size); //画一个点 + } + else + { + if (temp & 0x01) point_enlargement(x + x0, y + y0, fc, size); //画一个点 + } + temp >>= 1; + x0 = x0 + size; + } + x0 = 0; + y0 = y0 + size; + } +} + +/********************************************************** + * 函 数 名 称:tli_Show_String + * 函 数 功 能:显示字符串 + * 传 入 参 数:(x,y):起始坐标 + * fc:笔画颜色 + * bc:背景颜色 + * size:字符放大倍数(以16作为基数放大 16*size 16*size 16*size) + * p:显示的字符串 + * mode:是否叠加显示 0=非叠加方式 1=叠加方式 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void tli_show_string(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t size, uint8_t *p, uint8_t mode) +{ + while ((*p <= '~') && (*p >= ' ')) //判断是不是非法字符 + { + if (x > (LCD_WIDTH - 1) || y > (LCD_HEIGHT - 1)) return; + + tli_show_char(x, y, fc, bc, *p, size, mode); + x += 16 * size / 2; + p++; + } +} + + +// /********************************************************** +// * 函 数 名 称:tli_show_font16 +// * 函 数 功 能:显示单个16*16大小的字体 +// * 传 入 参 数:(x,y):字体显示的起始坐标 +// * fc:字体笔画颜色 +// * bc:字体背景颜色 +// * s:字体索引 +// * mode:是否叠加显示 0=非叠加方式 1=叠加方式 +// * 函 数 返 回:无 +// * 作 者:LCKFB +// * 备 注:无 +// **********************************************************/ +// void tli_show_font16(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s, uint8_t mode) +// { +// uint8_t i, j; +// uint16_t k; +// uint16_t HZnum; +// uint16_t x0 = x; +// HZnum = sizeof(tfont16) / sizeof(typFNT_GB16); //自动统计汉字数目 + +// for (k = 0; k < HZnum; k++) +// { +// if ((tfont16[k].Index[0] == *(s)) && (tfont16[k].Index[1] == *(s + 1))) +// { +// for (i = 0; i < 16 * 2; i++) +// { +// for (j = 0; j < 8; j++) +// { +// if (!mode) +// { +// if (tfont16[k].Msk[i] & (0x80 >> j)) +// tli_draw_point(x, y, fc); //画一个点 +// else +// tli_draw_point(x, y, bc); //画一个点 +// } +// else +// { +// if (tfont16[k].Msk[i] & (0x80 >> j)) tli_draw_point(x, y, fc); //画一个点 +// } +// x++; +// if ((x - x0) == 16) +// { +// x = x0; +// y++; +// break; +// } +// } +// } +// } +// continue; //查找到对应点阵字库立即退出,防止多个汉字重复取模带来影响 +// } +// } + +// /********************************************************** +// * 函 数 名 称:tli_show_font24 +// * 函 数 功 能:显示单个24*24大小的字体 +// * 传 入 参 数:(x,y):字体显示的起始坐标 +// * fc:字体笔画颜色 +// * bc:字体背景颜色 +// * s:字体索引 +// * mode:是否叠加显示 0=非叠加方式 1=叠加方式 +// * 函 数 返 回:无 +// * 作 者:LCKFB +// * 备 注:无 +// **********************************************************/ +// void tli_show_font24(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s, uint8_t mode) +// { +// uint8_t i, j; +// uint16_t k; +// uint16_t HZnum; +// uint16_t x0 = x; +// HZnum = sizeof(tfont24) / sizeof(typFNT_GB24); //自动统计汉字数目 + +// for (k = 0; k < HZnum; k++) +// { +// if ((tfont24[k].Index[0] == *(s)) && (tfont24[k].Index[1] == *(s + 1))) +// { +// for (i = 0; i < 24 * 3; i++) +// { +// for (j = 0; j < 8; j++) +// { +// if (!mode) +// { +// if (tfont24[k].Msk[i] & (0x80 >> j)) +// tli_draw_point(x, y, fc); //画一个点 +// else +// tli_draw_point(x, y, bc); //画一个点 +// } +// else +// { +// if (tfont24[k].Msk[i] & (0x80 >> j)) tli_draw_point(x, y, fc); //画一个点 +// } +// x++; +// if ((x - x0) == 24) +// { +// x = x0; +// y++; +// break; +// } +// } +// } +// } +// continue; //查找到对应点阵字库立即退出,防止多个汉字重复取模带来影响 +// } +// } + + +// /********************************************************** +// * 函 数 名 称:tli_show_font32 +// * 函 数 功 能:显示单个32*32大小的字体 +// * 传 入 参 数:(x,y):字体显示的起始坐标 +// * fc:字体笔画颜色 +// * bc:字体背景颜色 +// * s:字体索引 +// * mode:是否叠加显示 0=非叠加方式 1=叠加方式 +// * 函 数 返 回:无 +// * 作 者:LCKFB +// * 备 注:无 +// **********************************************************/ +// void tli_show_font32(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s, uint8_t mode) +// { +// uint8_t i, j; +// uint16_t k; +// uint16_t HZnum; +// uint16_t x0 = x; +// HZnum = sizeof(tfont32) / sizeof(typFNT_GB32); //自动统计汉字数目 +// for (k = 0; k < HZnum; k++) +// { +// if ((tfont32[k].Index[0] == *(s)) && (tfont32[k].Index[1] == *(s + 1))) +// { +// for (i = 0; i < 32 * 4; i++) +// { +// for (j = 0; j < 8; j++) +// { +// if (!mode) +// { +// if (tfont32[k].Msk[i] & (0x80 >> j)) +// tli_draw_point(x, y, fc); //画一个点 +// else +// tli_draw_point(x, y, bc); //画一个点 +// } +// else +// { +// if (tfont32[k].Msk[i] & (0x80 >> j)) tli_draw_point(x, y, fc); //画一个点 +// } +// x++; +// if ((x - x0) == 32) +// { +// x = x0; +// y++; +// break; +// } +// } +// } +// } +// continue; //查找到对应点阵字库立即退出,防止多个汉字重复取模带来影响 +// } +// } + + +// /********************************************************** +// * 函 数 名 称:tli_show_Chinese_string +// * 函 数 功 能:显示中文字符串 +// * 传 入 参 数:(x,y):字符串显示的起始坐标 +// * fc:字符串笔画颜色 +// * bc:字符串背景颜色 +// * str:字符串 +// * size:字符串大小 16,24,32 +// * mode:是否叠加显示 0=非叠加方式 1=叠加方式 +// * 函 数 返 回:无 +// * 作 者:LCKFB +// * 备 注:显示的中文请确保有其字模,可去font.h查看 +// **********************************************************/ +// void tli_show_Chinese_string(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *str, uint8_t size, uint8_t mode) +// { +// while (*str != 0) //数据未结束 +// { +// if (x > (LCD_WIDTH - size) || y > (LCD_HEIGHT - size)) return; + +// if (size == 32) +// tli_show_font32(x, y, fc, bc, str, mode); +// else if (size == 24) +// tli_show_font24(x, y, fc, bc, str, mode); +// else +// tli_show_font16(x, y, fc, bc, str, mode); + +// str += 2; +// x += size; //下一个汉字偏移 +// } +// } +/********************************************************** + * 函 数 名 称:tli_show_picture + * 函 数 功 能:显示图片 + * 传 入 参 数:(x,y):显示图片的起点坐标 + * w:图片宽度 + * h:图片高度 + * pic:图片地址 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void tli_show_picture(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const unsigned char pic[]) +{ + uint16_t i, j; + uint32_t k = 0; + uint16_t x0 = x, y0 = y; + for (i = y; i < h + y0; i++) + { + for (j = x; j < w + x0; j++) + { + tli_draw_point(j, i, pic[k * 2] << 8 | pic[k * 2 + 1]); + k++; + } + } +} + + +/********************************************************** + * 函 数 名 称:tli_show_button + * 函 数 功 能:绘制一个填充的圆角按钮 + * 传 入 参 数:(x,y):按钮的左上角的起始位置 + * width:按钮宽度 + * height:按钮高度 + * radius:按钮的4个圆角半径 + * color:按钮填充颜色 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:要求w >= 2*(r+1); h >= 2*(r+1); radius > h/2 +**********************************************************/ +void tli_show_button(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t radius, uint16_t color) +{ + int i = 0; + int j = 0; + + //如果小于则绘制出来的结果不好看 + if (radius >= (height / 2)) return; + + // 绘制四个圆角 + tli_draw_circle(x + radius, y + radius, color, radius, 1); + tli_draw_circle(x + width - radius - 1, y + radius, color, radius, 1); + tli_draw_circle(x + radius, y + height - radius - 1, color, radius, 1); + tli_draw_circle(x + width - radius - 1, y + height - radius - 1, color, radius, 1); + + // 绘制边框线 + tli_draw_line(x + radius, y, x + width - radius - 1, y, color); + tli_draw_line(x + radius, y + height - 1, x + width - radius - 1, y + height - 1, color); + tli_draw_line(x, y + radius, x, y + height - radius - 1, color); + tli_draw_line(x + width - 1, y + radius, x + width - 1, y + height - radius - 1, color); + + //绘制内部颜色填充 + tli_draw_Rectangle(x + radius, y + radius, x + width - radius, y + height - radius, color, 1); + tli_draw_Rectangle(x + radius, y, x + width - radius, y + radius, color, 1); + tli_draw_Rectangle(x, y + radius, x + width, y + height - radius, color, 1); + tli_draw_Rectangle(x + radius, y + height - radius, x + width - radius, y + height, color, 1); +} + +/********************************************************** + * 函 数 名 称:tli_show_switch + * 函 数 功 能:绘制一个开关 + * 传 入 参 数:(x,y):开关左上角的起始位置 + * width:开关的宽度 + * height:开关的高度 + * on_color:开关打开之后的颜色 + * off_color:开关关闭之后的颜色 + * sw:开关的状态 =1打开 =0关闭 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:要求w >= 2*(height/2+1); 不符合要求则无法绘制 +**********************************************************/ +void tli_show_switch(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t on_color, uint16_t off_color, char sw) +{ + int radius = height / 2 - 1; + + if (width < 2 * (radius + 1)) return; + + if (sw == 0) + { + tli_show_button(x, y, width, height, radius, off_color); + tli_draw_circle(x + radius, y + radius, WHITE, radius / 2, 1); + } + else + { + tli_show_button(x, y, width, height, radius, on_color); + tli_draw_circle(x + width - radius, y + radius, WHITE, radius / 2, 1); + } +} + + + + diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.h b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.h new file mode 100644 index 00000000000..f7aae409257 --- /dev/null +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.h @@ -0,0 +1,86 @@ +#ifndef GD32F450Z_LCD_H +#define GD32F450Z_LCD_H + +#include +#include +#include +#ifdef BSP_USING_SDRAM +#include +#endif /* BSP_USING_SDRAM */ + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +#define LCD_WIDTH 800 +#define LCD_HEIGHT 480 +#define LCD_FB_BYTE_PER_PIXEL 1 + +#define HORIZONTAL_SYNCHRONOUS_PULSE 10 +#define HORIZONTAL_BACK_PORCH 150 +#define ACTIVE_WIDTH 800 +#define HORIZONTAL_FRONT_PORCH 15 + +#define VERTICAL_SYNCHRONOUS_PULSE 10 +#define VERTICAL_BACK_PORCH 140 +#define ACTIVE_HEIGHT 480 +#define VERTICAL_FRONT_PORCH 40 + + +#define LCD_FRAME_BUF_ADDR 0XC0000000 + +//画笔颜色 +#define WHITE 0xFFFF +#define BLACK 0x0000 +#define BLUE 0x001F +#define BRED 0XF81F +#define GRED 0XFFE0 +#define GBLUE 0X07FF +#define RED 0xF800 +#define MAGENTA 0xF81F +#define GREEN 0x07E0 +#define CYAN 0x7FFF +#define YELLOW 0xFFE0 +#define BROWN 0XBC40 //棕色 +#define BRRED 0XFC07 //棕红色 +#define GRAY 0X8430 //灰色 +//GUI颜色 + +#define DARKBLUE 0X01CF //深蓝色 +#define LIGHTBLUE 0X7D7C //浅蓝色 +#define GRAYBLUE 0X5458 //灰蓝色 +//以上三色为PANEL的颜色 + +#define LIGHTGREEN 0X841F //浅绿色 +//#define LIGHTGRAY 0XEF5B //浅灰色(PANNEL) +#define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色 + +#define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色) +#define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色) + + +#if defined(__CC_ARM) || defined(__ARMCC_VERSION) +// Keil MDK 编译器 +extern uint16_t ltdc_lcd_framebuf0[800][480] __attribute__((at(LCD_FRAME_BUF_ADDR))); +#elif defined(__GNUC__) +// GCC 编译器 (如 RT-Thread 使用的 GCC) +extern uint16_t ltdc_lcd_framebuf0[10][10]; +#endif + + +/******************************************************************************* + * API + ******************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + +void lcd_disp_config(void); + +#if defined(__cplusplus) +} +#endif + +#endif /* GD32F450Z_LCD_H */ diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.c b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.c new file mode 100644 index 00000000000..0ae397dff98 --- /dev/null +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.c @@ -0,0 +1,390 @@ +#include +#include +#include +#include "drv_touch.h" +#include "drv_lcd.h" + +#define DRV_DEBUG +#define LOG_TAG "drv.touch" +#include + +_m_tp_dev tp_dev; + +const uint16_t FT5206_TPX_TBL[5] = {FT_TP1_REG, FT_TP2_REG, FT_TP3_REG, FT_TP4_REG, FT_TP5_REG}; +uint8_t g_gt_tnum = 5; // 默认支持的触摸屏点数(5点触摸) + +void delay_us(uint32_t _nus) +{ + uint8_t fac_us = 0; + uint32_t ticks; + uint32_t t_old, t_now, t_cnt = 0; + uint32_t reload = SysTick->LOAD; //获取重装载值(只查询,不影响) + + fac_us = SystemCoreClock / 1000000; + ticks = _nus * fac_us - fac_us * 7 / 20; + t_old = SysTick->VAL; //获取当前值作为旧值(只查询,不影响) + + while (1) + { + /*systick为向下递减,未减到0导致重装载的情况下,新值小于旧值*/ + t_now = SysTick->VAL; //获取当前值作为新值(只查询,不影响) + + if (t_now < t_old) + { + t_cnt += t_old - t_now; //未发生重装载,cnt记录减少的值 + } + else + { + t_cnt += t_old + (reload - t_now); //重装载后,旧值已递减完毕,cnt需在再加上重装载值与新值的差值 + } + + if (t_cnt >= ticks) + { + break; //当计数cnt大于等于用户需要的ticks,即认为延时完毕,跳出循环 + } + + t_old = t_now; //获取当前值作为旧值,以供下一次循环做判断(只查询,不影响) + }; +} + + +void touch_delay_1us(uint16_t us) +{ + delay_us(us); +} + +// 控制I2C速度的延时 +void CT_Delay(void) +{ + touch_delay_1us(2); +} + +// 电容触摸芯片IIC接口初始化 +void CT_IIC_Init(void) +{ + /* enable the led clock */ + rcu_periph_clock_enable(SCL_RCU); + /* configure led GPIO port */ + gpio_mode_set(SCL_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, SCL_PIN); + gpio_output_options_set(SCL_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, SCL_PIN); + + rcu_periph_clock_enable(SDA_RCU); + gpio_mode_set(SDA_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, SDA_PIN); + gpio_output_options_set(SDA_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, SDA_PIN); +} +// 产生IIC起始信号 +void CT_IIC_Start(void) +{ + CT_SDA_OUT(); // sda线输出 + SDA_ON; + SCL_ON; // SCL=1时,SDA由1到0跳变 + touch_delay_1us(30); + SDA_OFF; // START:when CLK is high,DATA change form high to low + CT_Delay(); + SCL_OFF; // 钳住I2C总线,准备发送或接收数据 +} +// 产生IIC停止信号 +void CT_IIC_Stop(void) +{ + CT_SDA_OUT(); // sda线输出 + SCL_ON; // SCL=1时,SDA由0到1跳变 + touch_delay_1us(30); + SDA_OFF; // STOP:when CLK is high DATA change form low to high + CT_Delay(); + SDA_ON; // 发送I2C总线结束信号 +} +// 等待应答信号到来 +// 返回值:1,接收应答失败 +// 0,接收应答成功 +uint8_t CT_IIC_Wait_Ack(void) +{ + uint8_t ucErrTime = 0; + CT_SDA_IN(); // SDA设置为输入 + SDA_ON; + SCL_ON; + CT_Delay(); + while (CT_READ_SDA) + { + ucErrTime++; + if (ucErrTime > 250) + { + CT_IIC_Stop(); + return 1; + } + CT_Delay(); + } + SCL_OFF; // 时钟输出0 + return 0; +} +// 产生ACK应答 +void CT_IIC_Ack(void) +{ + SCL_OFF; + CT_SDA_OUT(); + CT_Delay(); + SDA_OFF; + CT_Delay(); + SCL_ON; + CT_Delay(); + SCL_OFF; +} +// 不产生ACK应答 +void CT_IIC_NAck(void) +{ + SCL_OFF; + CT_SDA_OUT(); + CT_Delay(); + SDA_ON; + CT_Delay(); + SCL_ON; + CT_Delay(); + SCL_OFF; +} +// IIC发送一个字节 +// 返回从机有无应答 +// 1,有应答 +// 0,无应答 +void CT_IIC_Send_Byte(uint8_t txd) +{ + uint8_t t; + CT_SDA_OUT(); + SCL_OFF; // 拉低时钟开始数据传输 + CT_Delay(); + for (t = 0; t < 8; t++) + { + // CT_IIC_SDA=(txd&0x80)>>7; + // CT_IIC_SDA((txd&0x80)>>7); + if ((txd & 0x80) >> 7) + { + gpio_bit_set(SDA_PORT, SDA_PIN); + } + else + { + gpio_bit_reset(SDA_PORT, SDA_PIN); + } + + txd <<= 1; + SCL_ON; + CT_Delay(); + SCL_OFF; + CT_Delay(); + } +} +// 读1个字节,ack=1时,发送ACK,ack=0,发送nACK +uint8_t CT_IIC_Read_Byte(unsigned char ack) +{ + volatile uint8_t i, receive = 0; + CT_SDA_IN(); // SDA设置为输入 + touch_delay_1us(30); + for (i = 0; i < 8; i++) + { + SCL_OFF; + CT_Delay(); + SCL_ON; + receive <<= 1; + + // printf("%d ",CT_READ_SDA); + if (CT_READ_SDA) + receive++; + } + // printf("\r\n receive:%0x \r\n",receive); + + if (!ack) + CT_IIC_NAck(); // 发送nACK + else + CT_IIC_Ack(); // 发送ACK + return receive; +} + +// 向FT5206写入一次数据 +uint8_t FT5206_WR_Reg(uint16_t reg, uint8_t *buf, uint8_t len) +{ + uint8_t i; + uint8_t ret = 0; + CT_IIC_Start(); + CT_IIC_Send_Byte(FT_CMD_WR); // 发送写命令 + CT_IIC_Wait_Ack(); + CT_IIC_Send_Byte(reg & 0XFF); // 发送低8位地址 + CT_IIC_Wait_Ack(); + for (i = 0; i < len; i++) + { + CT_IIC_Send_Byte(buf[i]); // 发数据 + ret = CT_IIC_Wait_Ack(); + if (ret) + break; + } + CT_IIC_Stop(); // 产生一个停止条件 + return ret; +} + +// 从FT5206读出一次数据 +void FT5206_RD_Reg(uint16_t reg, uint8_t *buf, uint8_t len) +{ + uint8_t i; + CT_IIC_Start(); + CT_IIC_Send_Byte(FT_CMD_WR); // 发送写命令 + CT_IIC_Wait_Ack(); + CT_IIC_Send_Byte(reg & 0XFF); // 发送低8位地址 + CT_IIC_Wait_Ack(); + CT_IIC_Start(); + CT_IIC_Send_Byte(FT_CMD_RD); // 发送读命令 + CT_IIC_Wait_Ack(); + for (i = 0; i < len; i++) + { + buf[i] = CT_IIC_Read_Byte(i == (len - 1) ? 0 : 1); // 发数据 + } + CT_IIC_Stop(); // 产生一个停止条件 +} + +// 初始化FT5206触摸屏 +uint8_t FT5206_Init(void) +{ + uint8_t temp[5]; + // PD11设置为上拉输入(INT) + /* enable the led clock */ + rcu_periph_clock_enable(INT_RCU); + /* configure led GPIO port */ + gpio_mode_set(INT_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, INT_PIN); + + // 初始化电容屏的I2C总线 + CT_IIC_Init(); + + FT5206_WR_Reg(FT_DEVIDE_MODE, temp, 1); // 进入正常操作模式 + FT5206_WR_Reg(FT_ID_G_MODE, temp, 1); // 查询模式 + temp[0] = 22; // 触摸有效值,22,越小越灵敏 + FT5206_WR_Reg(FT_ID_G_THGROUP, temp, 1); // 设置触摸有效值 + temp[0] = 12; // 激活周期,不能小于12,最大14 + FT5206_WR_Reg(FT_ID_G_PERIODACTIVE, temp, 1); + // 读取版本号,参考值:0x3003 + FT5206_RD_Reg(FT_ID_G_LIB_VERSION, &temp[0], 2); + printf("CTP ID:%x\r\n", ((uint16_t)temp[0] << 8) + temp[1]); + return 0; +} + +// 扫描触摸屏(采用查询方式) +// mode:0,正常扫描. +// 返回值:当前触屏状态. +// 0,触屏无触摸;1,触屏有触摸 +uint8_t FT5206_Scan(uint8_t mode) +{ + uint8_t buf[4]; + uint8_t i = 0; + uint8_t res = 0; + uint8_t temp; + uint16_t tempsta; + static uint8_t t = 0; // 控制查询间隔,从而降低CPU占用率 + t++; + if ((t % 10) == 0 || t < 10) // 空闲时,每进入10次CTP_Scan函数才检测1次,从而节省CPU使用率 + { + FT5206_RD_Reg(FT_REG_NUM_FINGER, &mode, 1); // 读取触摸点的状态 + if ((mode & 0XF) && ((mode & 0XF) <= g_gt_tnum)) + { + temp = 0XFF << (mode & 0XF); // 将点的个数转换为1的位数,匹配tp_dev.sta定义 + tempsta = tp_dev.sta; // 保存当前的tp_dev.sta值 + tp_dev.sta = (~temp) | TP_PRES_DOWN | TP_CATH_PRES; + tp_dev.x[g_gt_tnum - 1] = tp_dev.x[0]; // 保存触点0的数据,保存在最后一个上 + tp_dev.y[g_gt_tnum - 1] = tp_dev.y[0]; + // delay_1ms(4); //必要的延时,否则老是认为有按键按下 + for (i = 0; i < g_gt_tnum; i++) + { + if (tp_dev.sta & (1 << i)) // 触摸有效? + { + FT5206_RD_Reg(FT5206_TPX_TBL[i], buf, 4); // 读取XY坐标值 + if (tp_dev.touchtype & 0X01) // 横屏 + { + tp_dev.y[i] = ((uint16_t)(buf[0] & 0X0F) << 8) + buf[1]; + tp_dev.x[i] = ((uint16_t)(buf[2] & 0X0F) << 8) + buf[3]; + } + else + { + tp_dev.x[i] = (((uint16_t)(buf[0] & 0X0F) << 8) + buf[1]); + tp_dev.y[i] = ((uint16_t)(buf[2] & 0X0F) << 8) + buf[3]; + } + } + } + res = 1; + if (tp_dev.x[0] > ACTIVE_WIDTH || tp_dev.y[0] > ACTIVE_HEIGHT) // 非法数据(坐标超出了) + { + if ((mode & 0XF) > 1) // 有其他点有数据,则复第二个触点的数据到第一个触点. + { + tp_dev.x[0] = tp_dev.x[1]; + tp_dev.y[0] = tp_dev.y[1]; + t = 0; // 触发一次,则会最少连续监测10次,从而提高命中率 + } + else // 非法数据,则忽略此次数据(还原原来的) + { + tp_dev.x[0] = tp_dev.x[g_gt_tnum - 1]; + tp_dev.y[0] = tp_dev.y[g_gt_tnum - 1]; + mode = 0X80; + tp_dev.sta = tempsta; // 恢复tp_dev.sta + } + } + else + t = 0; // 触发一次,则会最少连续监测10次,从而提高命中率 + } + } + + if ((mode & 0X1F) == 0) // 无触摸点按下 + { + if (tp_dev.sta & TP_PRES_DOWN) // 之前是被按下的 + { + tp_dev.sta &= ~TP_PRES_DOWN; // 标记按键松开 + } + else // 之前就没有被按下 + { + tp_dev.x[0] = 0xffff; + tp_dev.y[0] = 0xffff; + tp_dev.sta &= 0XE0; // 清除点有效标记 + } + } + + if (t > 240) + t = 10; // 重新从10开始计数 + return res; +} + +/********************************************************** + * 函 数 名 称:letgo_scan + * 函 数 功 能:触摸松手判断 + * 传 入 参 数:contact:第几个触点(一共有5个触点) + * (sx,sy):判断触摸地的起始坐标 + * (ex,ey):判断触摸地的结束坐标 + * 函 数 返 回:无 + * 作 者:LCKFB + * 备 注:无 +**********************************************************/ +void letgo_scan(uint16_t contact, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey) +{ + //等待松手 + while (FT5206_Scan(0)) + { + //如果离开了x轴触摸范围 + if (tp_dev.x[contact] <= sx || tp_dev.x[contact] >= ex) + { + return; + } + //如果离开了y轴触摸范围 + if (tp_dev.y[contact] <= sy && tp_dev.y[contact] >= ey) + { + return; + } + } +} + +int touch_test(void) +{ + int touch_state = 0; + FT5206_Init(); + + while (1) + { + touch_state = FT5206_Scan(0); + + if (touch_state == 1) + { + rt_kprintf("touch\r\n"); + } + rt_thread_mdelay(10); + } +} +MSH_CMD_EXPORT(touch_test, touch test) diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.h b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.h new file mode 100644 index 00000000000..5cc3b623baa --- /dev/null +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.h @@ -0,0 +1,98 @@ +#ifndef __TOUCH_H__ +#define __TOUCH_H__ +#include "stdio.h" +#include "string.h" +#include "gd32f4xx.h" + + +#define SCL_RCU RCU_GPIOB +#define SCL_PORT GPIOB +#define SCL_PIN GPIO_PIN_6 +#define SCL_ON gpio_bit_set(SCL_PORT, SCL_PIN) +#define SCL_OFF gpio_bit_reset(SCL_PORT, SCL_PIN) +#define SCL_TOGGLE gpio_bit_toggle(SCL_PORT, SCL_PIN) + +#define SDA_RCU RCU_GPIOB +#define SDA_PORT GPIOB +#define SDA_PIN GPIO_PIN_7 +#define SDA_ON gpio_bit_set(SDA_PORT, SDA_PIN) +#define SDA_OFF gpio_bit_reset(SDA_PORT, SDA_PIN) +#define SDA_TOGGLE gpio_bit_toggle(SDA_PORT, SDA_PIN) + +// IO方向设置 +#define CT_SDA_IN() gpio_mode_set(SCL_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, SDA_PIN); //{GPIOF->MODER&=~(3<<(2*11));GPIOF->MODER|=0<<2*11;} //PF11输入模式 +#define CT_SDA_OUT() gpio_mode_set(SCL_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, SDA_PIN); //{GPIOF->MODER&=~(3<<(2*11));GPIOF->MODER|=1<<2*11;} //PF11输出模式 +// IO操作函数 +#define CT_IIC_SCL // PBout(0) //SCL +#define CT_IIC_SDA(val) ((val) == 1 ? SDA_ON : SDA_OFF) // PFout(11) //SDA +#define CT_READ_SDA gpio_input_bit_get(SDA_PORT, SDA_PIN) // PFin(11) //输入SDA + +#define RST_RCU RCU_GPIOD +#define RST_PORT GPIOD +#define RST_PIN GPIO_PIN_12 +#define RST_ON gpio_bit_set(RST_PORT, RST_PIN); +#define RST_OFF gpio_bit_reset(RST_PORT, RST_PIN); +#define RST_TOGGLE gpio_bit_toggle(RST_PORT, RST_PIN); + +#define INT_RCU RCU_GPIOD +#define INT_PORT GPIOD +#define INT_PIN GPIO_PIN_11 +#define INT_ON gpio_bit_set(INT_PORT, INT_PIN); +#define INT_OFF gpio_bit_reset(INT_PORT, INT_PIN); +#define INT_TOGGLE gpio_bit_toggle(INT_PORT, INT_PIN); + +// I2C读写命令 +#define FT_CMD_WR 0X70 // 写命令 +#define FT_CMD_RD 0X71 // 读命令 +// FT5206 部分寄存器定义 +#define FT_DEVIDE_MODE 0x00 // FT5206模式控制寄存器 +#define FT_REG_NUM_FINGER 0x02 // 触摸状态寄存器 +#define FT_TP1_REG 0X03 // 第一个触摸点数据地址 +#define FT_TP2_REG 0X09 // 第二个触摸点数据地址 +#define FT_TP3_REG 0X0F // 第三个触摸点数据地址 +#define FT_TP4_REG 0X15 // 第四个触摸点数据地址 +#define FT_TP5_REG 0X1B // 第五个触摸点数据地址 + +#define FT_ID_G_LIB_VERSION 0xA1 // 版本 +#define FT_ID_G_MODE 0xA4 // FT5206中断模式控制寄存器 +#define FT_ID_G_THGROUP 0x80 // 触摸有效值设置寄存器 +#define FT_ID_G_PERIODACTIVE 0x88 // 激活状态周期设置寄存器 + +#define TP_PRES_DOWN 0x80 // 触屏被按下 +#define TP_CATH_PRES 0x40 // 有按键按下了 +#define CT_MAX_TOUCH 5 // 电容屏支持的点数,固定为5点 +// 触摸屏控制器 +typedef struct +{ + // uint8_t (*init)(void); //初始化触摸屏控制器 + // uint8_t (*scan)(uint8_t); //扫描触摸屏.0,屏幕扫描;1,物理坐标; + // void (*adjust)(void); //触摸屏校准 + uint16_t x[CT_MAX_TOUCH]; // 当前坐标 + uint16_t y[CT_MAX_TOUCH]; // 电容屏有最多5组坐标,电阻屏则用x[0],y[0]代表:此次扫描时,触屏的坐标,用 + uint8_t sta; // 笔的状态 + float xfac; + float yfac; + short xoff; + short yoff; + uint8_t touchtype; +} _m_tp_dev; +extern _m_tp_dev tp_dev; // 触屏控制器在touch.c里面定义 + +// IIC所有操作函数 +void CT_IIC_Init(void); // 初始化IIC的IO口 +void CT_IIC_Start(void); // 发送IIC开始信号 +void CT_IIC_Stop(void); // 发送IIC停止信号 +void CT_IIC_Send_Byte(uint8_t txd); // IIC发送一个字节 +uint8_t CT_IIC_Read_Byte(unsigned char ack); // IIC读取一个字节 +uint8_t CT_IIC_Wait_Ack(void); // IIC等待ACK信号 +void CT_IIC_Ack(void); // IIC发送ACK信号 +void CT_IIC_NAck(void); // IIC不发送ACK信号 + +// 触摸屏操作函数 +uint8_t FT5206_WR_Reg(uint16_t reg, uint8_t *buf, uint8_t len); +void FT5206_RD_Reg(uint16_t reg, uint8_t *buf, uint8_t len); +uint8_t FT5206_Init(void); +uint8_t FT5206_Scan(uint8_t mode); +void letgo_scan(uint16_t contact, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey); + +#endif diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/font.h b/bsp/gd32/arm/gd32470z-lckfb/board/ports/font.h new file mode 100644 index 00000000000..cb5f9070a8a --- /dev/null +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/font.h @@ -0,0 +1,104 @@ +#ifndef __FONT_H +#define __FONT_H + +const unsigned char asc2_1608[95][16]={ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/ +{0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x18,0x18,0x00,0x00},/*"!",1*/ +{0x00,0x48,0x6C,0x24,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*""",2*/ +{0x00,0x00,0x00,0x24,0x24,0x24,0x7F,0x12,0x12,0x12,0x7F,0x12,0x12,0x12,0x00,0x00},/*"#",3*/ +{0x00,0x00,0x08,0x1C,0x2A,0x2A,0x0A,0x0C,0x18,0x28,0x28,0x2A,0x2A,0x1C,0x08,0x08},/*"$",4*/ +{0x00,0x00,0x00,0x22,0x25,0x15,0x15,0x15,0x2A,0x58,0x54,0x54,0x54,0x22,0x00,0x00},/*"%",5*/ +{0x00,0x00,0x00,0x0C,0x12,0x12,0x12,0x0A,0x76,0x25,0x29,0x11,0x91,0x6E,0x00,0x00},/*"&",6*/ +{0x00,0x06,0x06,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/ +{0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00},/*"(",8*/ +{0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00},/*")",9*/ +{0x00,0x00,0x00,0x00,0x08,0x08,0x6B,0x1C,0x1C,0x6B,0x08,0x08,0x00,0x00,0x00,0x00},/*"*",10*/ +{0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x7F,0x08,0x08,0x08,0x08,0x00,0x00,0x00},/*"+",11*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x04,0x03},/*",",12*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",13*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00},/*".",14*/ +{0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00},/*"/",15*/ +{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"0",16*/ +{0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"1",17*/ +{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00},/*"2",18*/ +{0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*"3",19*/ +{0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00},/*"4",20*/ +{0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*"5",21*/ +{0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"6",22*/ +{0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00},/*"7",23*/ +{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},/*"8",24*/ +{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00},/*"9",25*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00},/*":",26*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x04},/*";",27*/ +{0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00},/*"<",28*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},/*"=",29*/ +{0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00},/*">",30*/ +{0x00,0x00,0x00,0x3C,0x42,0x42,0x46,0x40,0x20,0x10,0x10,0x00,0x18,0x18,0x00,0x00},/*"?",31*/ +{0x00,0x00,0x00,0x1C,0x22,0x5A,0x55,0x55,0x55,0x55,0x2D,0x42,0x22,0x1C,0x00,0x00},/*"@",32*/ +{0x00,0x00,0x00,0x08,0x08,0x18,0x14,0x14,0x24,0x3C,0x22,0x42,0x42,0xE7,0x00,0x00},/*"A",33*/ +{0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x1E,0x22,0x42,0x42,0x42,0x22,0x1F,0x00,0x00},/*"B",34*/ +{0x00,0x00,0x00,0x7C,0x42,0x42,0x01,0x01,0x01,0x01,0x01,0x42,0x22,0x1C,0x00,0x00},/*"C",35*/ +{0x00,0x00,0x00,0x1F,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1F,0x00,0x00},/*"D",36*/ +{0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x42,0x42,0x3F,0x00,0x00},/*"E",37*/ +{0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x02,0x02,0x07,0x00,0x00},/*"F",38*/ +{0x00,0x00,0x00,0x3C,0x22,0x22,0x01,0x01,0x01,0x71,0x21,0x22,0x22,0x1C,0x00,0x00},/*"G",39*/ +{0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"H",40*/ +{0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"I",41*/ +{0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x0F},/*"J",42*/ +{0x00,0x00,0x00,0x77,0x22,0x12,0x0A,0x0E,0x0A,0x12,0x12,0x22,0x22,0x77,0x00,0x00},/*"K",43*/ +{0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x7F,0x00,0x00},/*"L",44*/ +{0x00,0x00,0x00,0x77,0x36,0x36,0x36,0x36,0x2A,0x2A,0x2A,0x2A,0x2A,0x6B,0x00,0x00},/*"M",45*/ +{0x00,0x00,0x00,0xE3,0x46,0x46,0x4A,0x4A,0x52,0x52,0x52,0x62,0x62,0x47,0x00,0x00},/*"N",46*/ +{0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1C,0x00,0x00},/*"O",47*/ +{0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x3E,0x02,0x02,0x02,0x02,0x07,0x00,0x00},/*"P",48*/ +{0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x4D,0x53,0x32,0x1C,0x60,0x00},/*"Q",49*/ +{0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x3E,0x12,0x12,0x22,0x22,0x42,0xC7,0x00,0x00},/*"R",50*/ +{0x00,0x00,0x00,0x7C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x42,0x42,0x3E,0x00,0x00},/*"S",51*/ +{0x00,0x00,0x00,0x7F,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00},/*"T",52*/ +{0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*"U",53*/ +{0x00,0x00,0x00,0xE7,0x42,0x42,0x22,0x24,0x24,0x14,0x14,0x18,0x08,0x08,0x00,0x00},/*"V",54*/ +{0x00,0x00,0x00,0x6B,0x49,0x49,0x49,0x49,0x55,0x55,0x36,0x22,0x22,0x22,0x00,0x00},/*"W",55*/ +{0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00},/*"X",56*/ +{0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00},/*"Y",57*/ +{0x00,0x00,0x00,0x7E,0x21,0x20,0x10,0x10,0x08,0x04,0x04,0x42,0x42,0x3F,0x00,0x00},/*"Z",58*/ +{0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00},/*"[",59*/ +{0x00,0x00,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x40},/*"\",60*/ +{0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00},/*"]",61*/ +{0x00,0x38,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"^",62*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF},/*"_",63*/ +{0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x78,0x44,0x42,0x42,0xFC,0x00,0x00},/*"a",65*/ +{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x26,0x1A,0x00,0x00},/*"b",66*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x02,0x02,0x02,0x44,0x38,0x00,0x00},/*"c",67*/ +{0x00,0x00,0x00,0x60,0x40,0x40,0x40,0x78,0x44,0x42,0x42,0x42,0x64,0xD8,0x00,0x00},/*"d",68*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x02,0x02,0x42,0x3C,0x00,0x00},/*"e",69*/ +{0x00,0x00,0x00,0xF0,0x88,0x08,0x08,0x7E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"f",70*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x22,0x22,0x1C,0x02,0x3C,0x42,0x42,0x3C},/*"g",71*/ +{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x3A,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"h",72*/ +{0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"i",73*/ +{0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x1E},/*"j",74*/ +{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x72,0x12,0x0A,0x16,0x12,0x22,0x77,0x00,0x00},/*"k",75*/ +{0x00,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"l",76*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x92,0x92,0x92,0x92,0x92,0xB7,0x00,0x00},/*"m",77*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3B,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"n",78*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*"o",79*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x26,0x42,0x42,0x42,0x22,0x1E,0x02,0x07},/*"p",80*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x44,0x42,0x42,0x42,0x44,0x78,0x40,0xE0},/*"q",81*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x4C,0x04,0x04,0x04,0x04,0x1F,0x00,0x00},/*"r",82*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x42,0x02,0x3C,0x40,0x42,0x3E,0x00,0x00},/*"s",83*/ +{0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x3E,0x08,0x08,0x08,0x08,0x08,0x30,0x00,0x00},/*"t",84*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x42,0x42,0x42,0x42,0x62,0xDC,0x00,0x00},/*"u",85*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x08,0x08,0x00,0x00},/*"v",86*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEB,0x49,0x49,0x55,0x55,0x22,0x22,0x00,0x00},/*"w",87*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x24,0x18,0x18,0x18,0x24,0x6E,0x00,0x00},/*"x",88*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x18,0x08,0x08,0x07},/*"y",89*/ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x22,0x10,0x08,0x08,0x44,0x7E,0x00,0x00},/*"z",90*/ +{0x00,0xC0,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x20,0x20,0xC0,0x00},/*"{",91*/ +{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},/*"|",92*/ +{0x00,0x06,0x08,0x08,0x08,0x08,0x08,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x06,0x00},/*"}",93*/ +{0x0C,0x32,0xC2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"~",94*/ + + +}; + +#endif diff --git a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/SConscript b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/SConscript index 8639928ed43..c654f46c001 100644 --- a/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/SConscript +++ b/bsp/gd32/arm/libraries/GD32F4xx_Firmware_Library/SConscript @@ -53,6 +53,12 @@ if GetDepend(['BSP_USING_SDRAM']): src += ['GD32F4xx_standard_peripheral/Source/gd32f4xx_fmc.c'] src += ['GD32F4xx_standard_peripheral/Source/gd32f4xx_exmc.c'] +if GetDepend(['BSP_USING_TLI']): + src += ['GD32F4xx_standard_peripheral/Source/gd32f4xx_tli.c'] + +if GetDepend(['BSP_USING_GPU']): + src += ['GD32F4xx_standard_peripheral/Source/gd32f4xx_ipa.c'] + path = [ cwd + '/CMSIS/GD/GD32F4xx/Include', cwd + '/CMSIS', From e1948c8baea209161db26cf886648331dee4f75f Mon Sep 17 00:00:00 2001 From: godmial Date: Fri, 23 May 2025 16:13:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?1.=E4=BD=BF=E7=94=A8RTT=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E8=A7=84=E8=8C=83=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=202.readme=E6=96=87=E4=BB=B6=E6=96=B0=E5=A2=9E=E6=B3=A8?= =?UTF-8?q?=E6=84=8F=E4=BA=8B=E9=A1=B9=E4=BB=A5=E5=8F=8A=E5=8E=9F=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arm/gd32470z-lckfb/board/ports/README.md | 39 +- .../gd32470z-lckfb/board/ports/draw_panel.c | 138 ++-- .../arm/gd32470z-lckfb/board/ports/drv_lcd.c | 706 ++++++++---------- .../arm/gd32470z-lckfb/board/ports/drv_lcd.h | 96 +-- .../gd32470z-lckfb/board/ports/drv_touch.c | 291 +++++--- .../gd32470z-lckfb/board/ports/drv_touch.h | 189 +++-- .../arm/gd32470z-lckfb/board/ports/font.h | 208 +++--- 7 files changed, 885 insertions(+), 782 deletions(-) diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/README.md b/bsp/gd32/arm/gd32470z-lckfb/board/ports/README.md index 566f1e930d9..2570ca7875c 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/board/ports/README.md +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/README.md @@ -1,8 +1,12 @@ -#### 1.简介 +#### 1. 简介 -用于GD32F470立创开发板配套RGB LCD屏幕的驱动,支持触摸。 -#### 2.在 ENV 中的开启 -ps:建议全部开启 +用于 GD32F470 立创开发板配套 RGB LCD 屏幕的驱动,支持触摸。 + +> **原作者:LCKFB** +> 本驱动最初由 LCKFB 开发,由 godmial 移植到本BSP。 + +#### 2. 在 ENV 中的开启 +ps:建议全部开启 ``` Hardware Drivers Config ---> Board extended module Drivers ---> @@ -13,11 +17,28 @@ Hardware Drivers Config ---> - [*]Enable GPU - [*]Enable DRAW PANEL EXAMPLE ``` -#### 3.注意事项 -1.如果屏幕出现刷新抖动,触摸屏出现连点的情况,可以尝试在 `libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\system_gd32f4xx.c`将时钟值修改为 -`#define __SYSTEM_CLOCK_240M_PLL_25M_HXTAL (uint32_t)(240000000)`然后重新编译即可 -#### 4.联系方式 +#### 3. 注意事项 + +1. 如果屏幕出现刷新抖动,触摸屏出现连点的情况,可以尝试在 `libraries\GD32F4xx_Firmware_Library\CMSIS\GD\GD32F4xx\Source\system_gd32f4xx.c` 将时钟值修改为 + `#define __SYSTEM_CLOCK_240M_PLL_25M_HXTAL (uint32_t)(240000000)` + 然后重新编译即可 + +2. 由于代码格式审查原因,本驱动未包含中文显示函数。但可直接移植官方源码中的中文显示函数进行使用。 + +3. 为避免 `scons` 命令编译不通过,代码使用了如下代码段以适配不同编译器: + ``` + #if defined(__CC_ARM) || defined(__ARMCC_VERSION) + // Keil MDK + uint16_t ltdc_lcd_framebuf0[800][480] __attribute__((at(LCD_FRAME_BUF_ADDR))); + #elif defined(__GNUC__) + // GCC (RT-Thread) + uint16_t ltdc_lcd_framebuf0[10][10]; // 此行为避免 scons 编译错误而添加 + #endif + + + +#### 4. 联系方式 -- 维护:godmial +- 维护:godmial - 主页: diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/draw_panel.c b/bsp/gd32/arm/gd32470z-lckfb/board/ports/draw_panel.c index 909d85e02ee..f09025f0723 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/board/ports/draw_panel.c +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/draw_panel.c @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2006-2025, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-05-23 godmial Refactor to conform to RT-Thread coding style. + */ + #include #include #include @@ -6,7 +16,7 @@ #define COLOR_MAX 14 -//像素最大放大倍数 +/* Maximum magnification of pixels */ #define PIXEL_SIZE_MAX 20 typedef struct button_struct @@ -17,24 +27,26 @@ typedef struct button_struct uint16_t h; uint16_t color; uint16_t value; -} _widget_object_struct; - -uint16_t color_buf[COLOR_MAX] = {GRAYBLUE, BLACK, BLUE, BRED, GRED, GBLUE, RED, MAGENTA, GREEN, YELLOW, CYAN, BROWN, BRRED, GRAY}; -_widget_object_struct button_clear, button_color, button_pixel, button_eraser; - - -/********************************************************** - * 函 数 名 称:widget_object_init - * 函 数 功 能:控件对象初始化 - * 传 入 参 数:obj:要初始化的控件 - * xywh:控件的(x,y)起点坐标 w宽h高 - * color:控件颜色 - * value:控件值 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ -void widget_object_init(_widget_object_struct *obj, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, uint16_t value) +} widget_object_t; + +uint16_t color_buf[COLOR_MAX] = {GRAYBLUE, BLACK, BLUE, BRED, GRED, GBLUE, RED, MAGENTA, GREEN, YELLOW, CYAN, BROWN, BRRED, GRAY}; +widget_object_t button_clear, button_color, button_pixel, button_eraser; + + +/** + * @brief Initialize a widget button with given properties. + * + * @param obj Pointer to the widget object. + * @param x X coordinate of the top-left corner. + * @param y Y coordinate of the top-left corner. + * @param w Width of the widget. + * @param h Height of the widget. + * @param color Color value of the widget. + * @param value Initial value of the widget. + * + * @return None. + */ +void widget_object_init(widget_object_t *obj, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, uint16_t value) { obj->x = x; obj->y = y; @@ -45,171 +57,131 @@ void widget_object_init(_widget_object_struct *obj, uint16_t x, uint16_t y, uint } -/********************************************************** - * 函 数 名 称:ui_init - * 函 数 功 能:UI界面初始化 - * 传 入 参 数:无 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ +/** + * @brief Initialize and display the user interface. + * + * This function draws the control buttons for clear, color, + * pixel size, and eraser on the screen. + * + * @return None. + */ void ui_init(void) { char temp_buf[20] = {0}; - //绘制[清除]按钮 - //绘制一个圆角按钮 tli_show_button(button_clear.x, button_clear.y, button_clear.w, button_clear.h, 12, button_clear.color); - //绘制圆角按钮的文本 tli_show_string(button_clear.x + 20, button_clear.y + 20, WHITE, button_clear.color, 2, "clear", 0); - //绘制[颜色]按钮 - //绘制一个圆角按钮 tli_show_button(button_color.x, button_color.y, button_color.w, button_color.h, 12, button_color.color); - //绘制圆角按钮的文本 tli_show_string(button_color.x + 20, button_color.y + 20, WHITE, button_color.color, 2, "color", 0); - //绘制[像素]按钮 - //绘制一个圆角按钮 tli_show_button(button_pixel.x, button_pixel.y, button_pixel.w, button_pixel.h, 12, button_pixel.color); if (button_pixel.value == 0) { - //绘制圆角按钮的文本 tli_show_string(button_pixel.x + 20, button_pixel.y + 20, WHITE, button_pixel.color, 2, "pixel", 0); button_pixel.value = 1; } else { - //绘制居中显示的字符串 sprintf(temp_buf, "%d", button_pixel.value); tli_show_string(button_pixel.x + (button_pixel.w / 2) - (strlen(temp_buf) / 2 * 16), button_pixel.y + 20, WHITE, button_pixel.color, 2, (uint8_t *)temp_buf, 0); } - //绘制[擦除]按钮 - //绘制一个圆角按钮 tli_show_button(button_eraser.x, button_eraser.y, button_eraser.w, button_eraser.h, 12, button_eraser.color); - //绘制圆角按钮的文本 tli_show_string(button_eraser.x + (button_eraser.w / 2) - (strlen("eraser") / 2 * 16), button_eraser.y + 20, WHITE, button_eraser.color, 2, "eraser", 0); } +/** + * @brief Main routine to test the drawing panel with touch interaction. + * + * Initializes LCD and touch interface, sets up buttons and handles user input + * to draw or erase on the screen based on touch events. + * + * @return Always returns 0. + */ int draw_panel_test(void) { int touch_state = 0; char color_num = 0; char pixel_size = 0; - // 屏幕初始化 lcd_disp_config(); - // 触摸初始化 FT5206_Init(); - //全屏清屏 - tli_draw_Rectangle(0, 0, 800, 480, WHITE, 1); - + tli_draw_rectangle(0, 0, 800, 480, WHITE, 1); - //初始化[清除]按钮的xywh widget_object_init(&button_clear, 800 - 130, 480 - 80, 120, 70, BLUE, 0); - //初始化[颜色]按钮的xywh widget_object_init(&button_color, 10, 480 - 80, 120, 70, BLUE, 0); - //初始化[像素]按钮的xywh widget_object_init(&button_pixel, 400 - 60, 480 - 80, 120, 70, BLUE, pixel_size); - //初始化[橡皮擦]按钮的xywh widget_object_init(&button_eraser, 800 - 130 - 130, 480 - 80, 120, 70, BLUE, 0); - //UI显示 ui_init(); while (1) { - //触摸扫描 touch_state = FT5206_Scan(0); - //如果屏幕被触摸 if (touch_state == 1) { - //[颜色]按钮被按下 if (tp_dev.x[0] >= button_color.x && tp_dev.x[0] <= (button_color.x + button_color.w)) { if (tp_dev.y[0] >= button_color.y && tp_dev.y[0] <= (button_color.y + button_color.h)) { - //判断是否松手 letgo_scan(0, button_color.x, button_color.y, (button_color.x + button_color.w), (button_color.y + button_color.h)); - //改变颜色 color_num = (color_num + 1) % COLOR_MAX; - //重新设置[颜色]按钮的背景色 widget_object_init(&button_color, button_color.x, button_color.y, button_color.w, button_color.h, color_buf[color_num], 0); - //UI重新显示 ui_init(); } } - //[清除]按钮被按下 if (tp_dev.x[0] >= button_clear.x && tp_dev.x[0] <= (button_clear.x + button_clear.w)) { if (tp_dev.y[0] >= button_clear.y && tp_dev.y[0] <= (button_clear.y + button_clear.h)) { - //判断是否松手 letgo_scan(0, button_clear.x, button_clear.y, (button_clear.x + button_clear.w), (button_clear.y + button_clear.h)); - //清屏为背景色 - tli_draw_Rectangle(0, 0, 800, 480, WHITE, 1); - //UI重新显示 + tli_draw_rectangle(0, 0, 800, 480, WHITE, 1); ui_init(); } } - //[像素]按钮被按下 if (tp_dev.x[0] >= button_pixel.x && tp_dev.x[0] <= (button_pixel.x + button_pixel.w)) { if (tp_dev.y[0] >= button_pixel.y && tp_dev.y[0] <= (button_pixel.y + button_pixel.h)) { - //判断是否松手 letgo_scan(0, button_pixel.x, button_pixel.y, (button_pixel.x + button_pixel.w), (button_pixel.y + button_pixel.h)); - //像素放大倍数自增 pixel_size++; - //如果像素放大倍数大于最大倍数 if (pixel_size > PIXEL_SIZE_MAX) pixel_size = 1; - //重新设置[颜色]按钮的背景色 widget_object_init(&button_pixel, button_pixel.x, button_pixel.y, button_pixel.w, button_pixel.h, button_pixel.color, pixel_size); - //UI重新显示 ui_init(); } } - //[擦除]按钮被按下 if (tp_dev.x[0] >= button_eraser.x && tp_dev.x[0] <= (button_eraser.x + button_eraser.w)) { if (tp_dev.y[0] >= button_eraser.y && tp_dev.y[0] <= (button_eraser.y + button_eraser.h)) { - //判断是否松手 letgo_scan(0, button_eraser.x, button_eraser.y, (button_eraser.x + button_eraser.w), (button_eraser.y + button_eraser.h)); - //修改擦除按钮的状态 button_eraser.value = !button_eraser.value; - //如果是擦除状态 if (button_eraser.value) { - //初始化[橡皮擦]按钮的xywh颜色修改为黑色 widget_object_init(&button_eraser, 800 - 130 - 130, 480 - 80, 120, 70, BLACK, button_eraser.value); } else { - //初始化[橡皮擦]按钮的xywh颜色修改为蓝色 widget_object_init(&button_eraser, 800 - 130 - 130, 480 - 80, 120, 70, BLUE, button_eraser.value); } - //UI重新显示 + ui_init(); } } - //如果不是擦除状态 + if (!button_eraser.value) { - //绘制触摸点 - //根据[颜色]按钮的背景色设置触摸点的颜色 - point_enlargement(tp_dev.x[0], tp_dev.y[0], color_buf[color_num], button_pixel.value); + tli_point_enlarge(tp_dev.x[0], tp_dev.y[0], color_buf[color_num], button_pixel.value); } else { - //擦除 - point_enlargement(tp_dev.x[0], tp_dev.y[0], WHITE, button_pixel.value); + tli_point_enlarge(tp_dev.x[0], tp_dev.y[0], WHITE, button_pixel.value); } } } } -// MSH_CMD_EXPORT(draw_panel_test, draw panel test) -INIT_COMPONENT_EXPORT(draw_panel_test); \ No newline at end of file + +INIT_COMPONENT_EXPORT(draw_panel_test); diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.c b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.c index b61cedda705..e8c52b30d07 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.c +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.c @@ -1,19 +1,25 @@ +/* + * Copyright (c) 2006-2025, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-05-23 godmial Refactor to conform to RT-Thread coding style. + */ + #include #include "gd32f4xx.h" #include "gd32f4xx_tli.h" #include "drv_lcd.h" #include "font.h" -/******************************************************************************* - * Definitions - ******************************************************************************/ - #if defined(__CC_ARM) || defined(__ARMCC_VERSION) -//Keil MDK 编译器 +/* Keil MDK Compiler */ uint16_t ltdc_lcd_framebuf0[800][480] __attribute__((at(LCD_FRAME_BUF_ADDR))); #elif defined(__GNUC__) -// GCC 编译器 (如 RT-Thread 使用的 GCC) +/* GCC Compiler (used by RT-Thread) */ uint16_t ltdc_lcd_framebuf0[10][10]; #endif @@ -24,6 +30,19 @@ static void lcd_disp_en_config(void); static void lcd_disp_off(void); static void lcd_disp_on(void); + +/** + * @brief Configure and initialize the LCD display. + * + * @note This function enables display power, initializes TLI GPIO and IPA, + * and sets up TLI and its layer configuration. + * + * @param None + * + * @return None + * + * @warning Should be called during system initialization phase. + */ void lcd_disp_config(void) { lcd_disp_en_config(); @@ -40,6 +59,18 @@ void lcd_disp_config(void) ipa_config(); } +/** + * @brief Initialize the TLI peripheral and layer configuration. + * + * @note This function sets up the TLI clock, background color, timing parameters, + * and layer 0 settings including framebuffer and blending configuration. + * + * @param None + * + * @return None + * + * @warning Must be called after clock and GPIO initialization. + */ static void tli_config(void) { tli_parameter_struct tli_init_struct; @@ -111,18 +142,31 @@ static void tli_config(void) #endif } -/*! - \brief IPA initialize and configuration - \param[in] none - \param[out] none - \retval none -*/ +/** + * @brief Initialize the IPA peripheral. + * + * @note Enable clock and interrupt for the IPA module. + * + * @param None + * + * @return None + */ static void ipa_config(void) { rcu_periph_clock_enable(RCU_IPA); nvic_irq_enable(IPA_IRQn, 0, 2); } +/** + * @brief Configure the GPIO pins used for TLI display. + * + * @note Includes alternate function mapping and output mode setup + * for RGB and sync signals. + * + * @param None + * + * @return None + */ static void tli_gpio_config(void) { /* enable the periphral clock */ @@ -182,12 +226,18 @@ static void tli_gpio_config(void) gpio_output_options_set(GPIOG, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12); } -/*! - \brief configure DISP ON/OFF GPIO - \param[in] none - \param[out] none - \retval none -*/ +/** + * @brief Configure the GPIO pin for DISP enable control. + * + * @note This function enables the clock for GPIOD and sets up pin 13 + * as push-pull output to control the display on/off signal. + * + * @param None + * + * @return None + * + * @warning Must be called before attempting to control the LCD display. + */ static void lcd_disp_en_config(void) { /* enable the periphral clock */ @@ -196,66 +246,86 @@ static void lcd_disp_en_config(void) gpio_output_options_set(GPIOD, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_13); } -/*! - \brief DISP GPIO OFF - \param[in] none - \param[out] none - \retval none -*/ +/** + * @brief Turn off the LCD display by resetting the DISP GPIO. + * + * @note This function clears the DISP control pin to disable + * the LCD backlight or power depending on hardware design. + * + * @param None + * + * @return None + * + * @warning Only valid if the DISP GPIO has been previously configured. + */ static void lcd_disp_off(void) { gpio_bit_reset(GPIOD, GPIO_PIN_13); } -/*! - \brief DISP GPIO ON - \param[in] none - \param[out] none - \retval none -*/ +/** + * @brief Turn on the LCD display by setting the DISP GPIO. + * + * @note This function sets the DISP control pin to enable + * the LCD backlight or power depending on hardware design. + * + * @param None + * + * @return None + * + * @warning Only valid if the DISP GPIO has been previously configured. + */ static void lcd_disp_on(void) { gpio_bit_set(GPIOD, GPIO_PIN_13); } -/********************************************************** - * 函 数 名 称:tli_draw_point - * 函 数 功 能:画点 - * 传 入 参 数:(x,y):起点坐标 - * color:点的颜色 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ +/** + * @brief Draw a pixel on the LCD at specified coordinates. + * + * @note This function writes a color value directly to the framebuffer. + * Coordinates must be within the valid LCD dimensions. + * + * @param x Horizontal coordinate of the pixel. + * @param y Vertical coordinate of the pixel. + * @param color Color of the pixel in RGB565 format. + * + * @return None + */ void tli_draw_point(uint16_t x, uint16_t y, uint16_t color) { *(ltdc_lcd_framebuf0[0] + (LCD_WIDTH * y + x)) = color; } -/********************************************************** - * 函 数 名 称:tli_draw_line - * 函 数 功 能:画线 - * 传 入 参 数:(sx,sy):起点坐标 - * (ex,ey):终点坐标 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ +/** + * @brief Draw a straight line between two points. + * + * @note Uses Bresenham's line drawing algorithm to connect two points. + * Coordinates should be within LCD bounds. + * + * @param sx Start point X coordinate. + * @param sy Start point Y coordinate. + * @param ex End point X coordinate. + * @param ey End point Y coordinate. + * @param color Line color in RGB565 format. + * + * @return None + */ void tli_draw_line(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color) { uint16_t t; int xerr = 0, yerr = 0, delta_x, delta_y, distance; int incx, incy, uRow, uCol; - delta_x = ex - sx; //计算坐标增量 + delta_x = ex - sx; delta_y = ey - sy; uRow = sx; uCol = sy; if (delta_x > 0) - incx = 1; //设置单步方向 + incx = 1; else if (delta_x == 0) - incx = 0; //垂直线 + incx = 0; else { incx = -1; @@ -264,19 +334,19 @@ void tli_draw_line(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t if (delta_y > 0) incy = 1; else if (delta_y == 0) - incy = 0; //水平线 + incy = 0; else { incy = -1; delta_y = -delta_y; } if (delta_x > delta_y) - distance = delta_x; //选取基本增量坐标轴 + distance = delta_x; else distance = delta_y; - for (t = 0; t <= distance + 1; t++) //画线输出 + for (t = 0; t <= distance + 1; t++) { - tli_draw_point(uRow, uCol, color); //画点 + tli_draw_point(uRow, uCol, color); xerr += delta_x; yerr += delta_y; if (xerr > distance) @@ -291,18 +361,22 @@ void tli_draw_line(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t } } } -/********************************************************** - * 函 数 名 称:tli_draw_Rectangle - * 函 数 功 能:画矩形填充 - * 传 入 参 数:(sx,sy) :起点坐标 - * (sx,sy) :终点坐标 - * color:笔画颜色 -* fill:填充标志 =1填充颜色 =0不填充 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ -void tli_draw_Rectangle(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color, uint16_t fill) +/** + * @brief Draw a rectangle on the screen, optionally filled. + * + * @note The rectangle is defined by top-left and bottom-right corners. + * If fill is set to 1, the rectangle will be filled with the color. + * + * @param sx X coordinate of the top-left corner. + * @param sy Y coordinate of the top-left corner. + * @param ex X coordinate of the bottom-right corner. + * @param ey Y coordinate of the bottom-right corner. + * @param color Color of the rectangle in RGB565 format. + * @param fill Fill mode: 1 = filled, 0 = only borders. + * + * @return None + */ +void tli_draw_rectangle(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color, uint16_t fill) { int i = 0, j = 0; if (fill) @@ -324,16 +398,21 @@ void tli_draw_Rectangle(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint } } -/********************************************************** - * 函 数 名 称:_draw_circle_8 - * 函 数 功 能:8对称性画圆算法(内部调用) - * 传 入 参 数: (xc,yc):圆中心坐标 - (x,y):光标相对于圆心的坐标 - * c:点的颜色 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:内部调用 -**********************************************************/ +/** + * @brief Draw eight symmetric points of a circle. + * + * @note This function is used internally to draw points in all eight + * symmetrical positions around a circle center. + * + * @param xc X coordinate of the circle center. + * @param yc Y coordinate of the circle center. + * @param x Relative X offset from the center. + * @param y Relative Y offset from the center. + * @param c Color of the point in RGB565 format. + * + * @return None + */ + static void _draw_circle_8(int xc, int yc, int x, int y, uint16_t c) { tli_draw_point(xc + x, yc + y, c); @@ -353,17 +432,20 @@ static void _draw_circle_8(int xc, int yc, int x, int y, uint16_t c) tli_draw_point(xc - y, yc - x, c); } -/********************************************************** - * 函 数 名 称:tli_draw_circle - * 函 数 功 能:在指定位置画一个指定大小的圆 - * 传 入 参 数: (xc,yc) :圆中心坐标 - * c:填充的颜色 - * r:圆半径 - * fill:填充判断标志,1-填充,0-不填充 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ +/** + * @brief Draw a circle on the screen with optional fill. + * + * @note Uses the midpoint circle algorithm to render the circle. + * When fill is enabled, the circle is drawn as a filled disk. + * + * @param xc X coordinate of the circle center. + * @param yc Y coordinate of the circle center. + * @param c Color of the circle in RGB565 format. + * @param r Radius of the circle. + * @param fill Fill mode: 1 = filled, 0 = outline only. + * + * @return None + */ void tli_draw_circle(int xc, int yc, uint16_t c, int r, int fill) { int x = 0, y = r, yi, d; @@ -372,7 +454,6 @@ void tli_draw_circle(int xc, int yc, uint16_t c, int r, int fill) if (fill) { - // 如果填充(画实心圆) while (x <= y) { for (yi = x; yi <= y; yi++) @@ -392,7 +473,6 @@ void tli_draw_circle(int xc, int yc, uint16_t c, int r, int fill) } else { - // 如果不填充(画空心圆) while (x <= y) { _draw_circle_8(xc, yc, x, y, c); @@ -410,14 +490,17 @@ void tli_draw_circle(int xc, int yc, uint16_t c, int r, int fill) } } -/********************************************************** - * 函 数 名 称:_swap - * 函 数 功 能:数据交换 - * 传 入 参 数:a=交换方1 b=交换方2 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:仅内部使用 -**********************************************************/ +/** + * @brief Swap the values of two 16-bit unsigned integers. + * + * @note This utility function is used internally to simplify sorting + * or reordering logic, such as coordinate alignment. + * + * @param a Pointer to the first variable. + * @param b Pointer to the second variable. + * + * @return None + */ static void _swap(uint16_t *a, uint16_t *b) { uint16_t tmp; @@ -426,20 +509,24 @@ static void _swap(uint16_t *a, uint16_t *b) *b = tmp; } -/********************************************************** - * 函 数 名 称:tli_draw_triange - * 函 数 功 能:画三角形 - * 传 入 参 数:(x0,y0):第一个边角的坐标 - * (x1,y1):顶点的坐标 - * (x2,y2):第二个边角的坐标 - * color:三角形颜色 - * fill:填充判断标志,1-填充,0-不填充 - * 函 数 返 回: - * 作 者:LCKFB - * 备 注: -**********************************************************/ - -void tli_draw_triange(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color, uint16_t fill) +/** + * @brief Draw a triangle with optional fill. + * + * @note The triangle is defined by three vertex points. When fill is set, + * it is rendered as a filled triangle using scan-line rasterization. + * + * @param x0 X coordinate of the first vertex. + * @param y0 Y coordinate of the first vertex. + * @param x1 X coordinate of the second vertex (typically the top). + * @param y1 Y coordinate of the second vertex. + * @param x2 X coordinate of the third vertex. + * @param y2 Y coordinate of the third vertex. + * @param color Color of the triangle in RGB565 format. + * @param fill Fill mode: 1 = filled, 0 = outline only. + * + * @return None + */ +void tli_draw_triangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color, uint16_t fill) { uint16_t a, b, y, last; int dx01, dy01, dx02, dy02, dx12, dy12; @@ -488,7 +575,7 @@ void tli_draw_triange(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16 { b = x2; } - tli_draw_Rectangle(a, y0, b, y0, color, 0); + tli_draw_rectangle(a, y0, b, y0, color, 0); return; } dx01 = x1 - x0; @@ -516,7 +603,7 @@ void tli_draw_triange(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16 { _swap(&a, &b); } - tli_draw_Rectangle(a, y, b, y, color, 0); + tli_draw_rectangle(a, y, b, y, color, 0); } sa = dx12 * (y - y1); sb = dx02 * (y - y0); @@ -531,69 +618,75 @@ void tli_draw_triange(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16 _swap(&a, &b); } - tli_draw_Rectangle(a, y, b, y, color, 0); + tli_draw_rectangle(a, y, b, y, color, 0); } } } -/********************************************************** - * 函 数 名 称:point_enlargement - * 函 数 功 能:将一个点放大 - * 传 入 参 数:(x,y):点的起始坐标 - * color:点的颜色 - * magnify:点的放大倍数 最小为1 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ -void point_enlargement(uint16_t x, uint16_t y, uint16_t color, char magnify) +/** + * @brief Enlarge a single point by drawing a square block. + * + * @note The enlarged point is drawn as a 2D cross pattern made of four + * rectangles centered at (x, y) with specified magnification. + * + * @param x X coordinate of the center point. + * @param y Y coordinate of the center point. + * @param color Color to fill the enlarged point. + * @param magnify Enlargement factor (minimum value is 1). + * + * @return None + */ +void tli_point_enlarge(uint16_t x, uint16_t y, uint16_t color, char magnify) { - tli_draw_Rectangle(x - magnify, y - magnify, x, y, color, 1); + tli_draw_rectangle(x - magnify, y - magnify, x, y, color, 1); - tli_draw_Rectangle(x, y - magnify, x + magnify, y, color, 1); + tli_draw_rectangle(x, y - magnify, x + magnify, y, color, 1); - tli_draw_Rectangle(x - magnify, y, x, y + magnify, color, 1); + tli_draw_rectangle(x - magnify, y, x, y + magnify, color, 1); - tli_draw_Rectangle(x, y, x + magnify, y + magnify, color, 1); + tli_draw_rectangle(x, y, x + magnify, y + magnify, color, 1); } -/********************************************************** - * 函 数 名 称:LCD_ShowChar - * 函 数 功 能:显示一个字符 - * 传 入 参 数:(x,y):字符显示的起点坐标 - fc:笔画颜色 - bc:背景颜色 - num:显示的字符 - size:字符放大倍数 最小为1 - mode:是否叠加显示 0=非叠加方式 1=叠加方式 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:以16x8大小的字符作为放大模板 -**********************************************************/ +/** + * @brief Display a single ASCII character at the specified position. + * + * @note Uses a fixed-size 16x8 font to render the character with optional + * enlargement and overlay mode. + * + * @param x X coordinate of the character start position. + * @param y Y coordinate of the character start position. + * @param fc Foreground color. + * @param bc Background color. + * @param num ASCII character to display. + * @param size Enlargement factor (minimum 1). + * @param mode Overlay mode: 0 = non-overlay, 1 = overlay. + * + * @return None + */ void tli_show_char(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t num, uint8_t size, uint8_t mode) { uint8_t temp; uint8_t pos, t; uint16_t x0 = 0; uint16_t y0 = 0; - num = num - ' '; //得到偏移后的值 + num = num - ' '; for (pos = 0; pos < 16; pos++) { - temp = asc2_1608[num][pos]; //调用1608字体 + temp = asc2_1608[num][pos]; for (t = 0; t < 16 / 2; t++) { if (!mode) { if (temp & 0x01) - point_enlargement(x + x0, y + y0, fc, size); //画一个点 + tli_point_enlarge(x + x0, y + y0, fc, size); else - point_enlargement(x + x0, y + y0, bc, size); //画一个点 + tli_point_enlarge(x + x0, y + y0, bc, size); } else { - if (temp & 0x01) point_enlargement(x + x0, y + y0, fc, size); //画一个点 + if (temp & 0x01) tli_point_enlarge(x + x0, y + y0, fc, size); } temp >>= 1; x0 = x0 + size; @@ -603,22 +696,24 @@ void tli_show_char(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t num } } -/********************************************************** - * 函 数 名 称:tli_Show_String - * 函 数 功 能:显示字符串 - * 传 入 参 数:(x,y):起始坐标 - * fc:笔画颜色 - * bc:背景颜色 - * size:字符放大倍数(以16作为基数放大 16*size 16*size 16*size) - * p:显示的字符串 - * mode:是否叠加显示 0=非叠加方式 1=叠加方式 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ +/** + * @brief Display a null-terminated ASCII string on the screen. + * + * @note Automatically handles line boundaries and skips illegal characters. + * + * @param x X coordinate of the start position. + * @param y Y coordinate of the start position. + * @param fc Foreground color. + * @param bc Background color. + * @param size Font enlargement factor (base size is 16x8). + * @param p Pointer to the string. + * @param mode Overlay mode: 0 = non-overlay, 1 = overlay. + * + * @return None + */ void tli_show_string(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t size, uint8_t *p, uint8_t mode) { - while ((*p <= '~') && (*p >= ' ')) //判断是不是非法字符 + while ((*p <= '~') && (*p >= ' ')) { if (x > (LCD_WIDTH - 1) || y > (LCD_HEIGHT - 1)) return; @@ -629,207 +724,20 @@ void tli_show_string(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t s } -// /********************************************************** -// * 函 数 名 称:tli_show_font16 -// * 函 数 功 能:显示单个16*16大小的字体 -// * 传 入 参 数:(x,y):字体显示的起始坐标 -// * fc:字体笔画颜色 -// * bc:字体背景颜色 -// * s:字体索引 -// * mode:是否叠加显示 0=非叠加方式 1=叠加方式 -// * 函 数 返 回:无 -// * 作 者:LCKFB -// * 备 注:无 -// **********************************************************/ -// void tli_show_font16(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s, uint8_t mode) -// { -// uint8_t i, j; -// uint16_t k; -// uint16_t HZnum; -// uint16_t x0 = x; -// HZnum = sizeof(tfont16) / sizeof(typFNT_GB16); //自动统计汉字数目 - -// for (k = 0; k < HZnum; k++) -// { -// if ((tfont16[k].Index[0] == *(s)) && (tfont16[k].Index[1] == *(s + 1))) -// { -// for (i = 0; i < 16 * 2; i++) -// { -// for (j = 0; j < 8; j++) -// { -// if (!mode) -// { -// if (tfont16[k].Msk[i] & (0x80 >> j)) -// tli_draw_point(x, y, fc); //画一个点 -// else -// tli_draw_point(x, y, bc); //画一个点 -// } -// else -// { -// if (tfont16[k].Msk[i] & (0x80 >> j)) tli_draw_point(x, y, fc); //画一个点 -// } -// x++; -// if ((x - x0) == 16) -// { -// x = x0; -// y++; -// break; -// } -// } -// } -// } -// continue; //查找到对应点阵字库立即退出,防止多个汉字重复取模带来影响 -// } -// } - -// /********************************************************** -// * 函 数 名 称:tli_show_font24 -// * 函 数 功 能:显示单个24*24大小的字体 -// * 传 入 参 数:(x,y):字体显示的起始坐标 -// * fc:字体笔画颜色 -// * bc:字体背景颜色 -// * s:字体索引 -// * mode:是否叠加显示 0=非叠加方式 1=叠加方式 -// * 函 数 返 回:无 -// * 作 者:LCKFB -// * 备 注:无 -// **********************************************************/ -// void tli_show_font24(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s, uint8_t mode) -// { -// uint8_t i, j; -// uint16_t k; -// uint16_t HZnum; -// uint16_t x0 = x; -// HZnum = sizeof(tfont24) / sizeof(typFNT_GB24); //自动统计汉字数目 - -// for (k = 0; k < HZnum; k++) -// { -// if ((tfont24[k].Index[0] == *(s)) && (tfont24[k].Index[1] == *(s + 1))) -// { -// for (i = 0; i < 24 * 3; i++) -// { -// for (j = 0; j < 8; j++) -// { -// if (!mode) -// { -// if (tfont24[k].Msk[i] & (0x80 >> j)) -// tli_draw_point(x, y, fc); //画一个点 -// else -// tli_draw_point(x, y, bc); //画一个点 -// } -// else -// { -// if (tfont24[k].Msk[i] & (0x80 >> j)) tli_draw_point(x, y, fc); //画一个点 -// } -// x++; -// if ((x - x0) == 24) -// { -// x = x0; -// y++; -// break; -// } -// } -// } -// } -// continue; //查找到对应点阵字库立即退出,防止多个汉字重复取模带来影响 -// } -// } - - -// /********************************************************** -// * 函 数 名 称:tli_show_font32 -// * 函 数 功 能:显示单个32*32大小的字体 -// * 传 入 参 数:(x,y):字体显示的起始坐标 -// * fc:字体笔画颜色 -// * bc:字体背景颜色 -// * s:字体索引 -// * mode:是否叠加显示 0=非叠加方式 1=叠加方式 -// * 函 数 返 回:无 -// * 作 者:LCKFB -// * 备 注:无 -// **********************************************************/ -// void tli_show_font32(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s, uint8_t mode) -// { -// uint8_t i, j; -// uint16_t k; -// uint16_t HZnum; -// uint16_t x0 = x; -// HZnum = sizeof(tfont32) / sizeof(typFNT_GB32); //自动统计汉字数目 -// for (k = 0; k < HZnum; k++) -// { -// if ((tfont32[k].Index[0] == *(s)) && (tfont32[k].Index[1] == *(s + 1))) -// { -// for (i = 0; i < 32 * 4; i++) -// { -// for (j = 0; j < 8; j++) -// { -// if (!mode) -// { -// if (tfont32[k].Msk[i] & (0x80 >> j)) -// tli_draw_point(x, y, fc); //画一个点 -// else -// tli_draw_point(x, y, bc); //画一个点 -// } -// else -// { -// if (tfont32[k].Msk[i] & (0x80 >> j)) tli_draw_point(x, y, fc); //画一个点 -// } -// x++; -// if ((x - x0) == 32) -// { -// x = x0; -// y++; -// break; -// } -// } -// } -// } -// continue; //查找到对应点阵字库立即退出,防止多个汉字重复取模带来影响 -// } -// } - - -// /********************************************************** -// * 函 数 名 称:tli_show_Chinese_string -// * 函 数 功 能:显示中文字符串 -// * 传 入 参 数:(x,y):字符串显示的起始坐标 -// * fc:字符串笔画颜色 -// * bc:字符串背景颜色 -// * str:字符串 -// * size:字符串大小 16,24,32 -// * mode:是否叠加显示 0=非叠加方式 1=叠加方式 -// * 函 数 返 回:无 -// * 作 者:LCKFB -// * 备 注:显示的中文请确保有其字模,可去font.h查看 -// **********************************************************/ -// void tli_show_Chinese_string(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *str, uint8_t size, uint8_t mode) -// { -// while (*str != 0) //数据未结束 -// { -// if (x > (LCD_WIDTH - size) || y > (LCD_HEIGHT - size)) return; - -// if (size == 32) -// tli_show_font32(x, y, fc, bc, str, mode); -// else if (size == 24) -// tli_show_font24(x, y, fc, bc, str, mode); -// else -// tli_show_font16(x, y, fc, bc, str, mode); - -// str += 2; -// x += size; //下一个汉字偏移 -// } -// } -/********************************************************** - * 函 数 名 称:tli_show_picture - * 函 数 功 能:显示图片 - * 传 入 参 数:(x,y):显示图片的起点坐标 - * w:图片宽度 - * h:图片高度 - * pic:图片地址 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ +/** + * @brief Display a picture at a specified position on the screen. + * + * @note The image data is expected to be in RGB565 format, with each pixel + * occupying two consecutive bytes in the array. + * + * @param x X coordinate of the top-left corner. + * @param y Y coordinate of the top-left corner. + * @param w Width of the image in pixels. + * @param h Height of the image in pixels. + * @param pic Pointer to the image data array. + * + * @return None + */ void tli_show_picture(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const unsigned char pic[]) { uint16_t i, j; @@ -846,58 +754,62 @@ void tli_show_picture(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const unsi } -/********************************************************** - * 函 数 名 称:tli_show_button - * 函 数 功 能:绘制一个填充的圆角按钮 - * 传 入 参 数:(x,y):按钮的左上角的起始位置 - * width:按钮宽度 - * height:按钮高度 - * radius:按钮的4个圆角半径 - * color:按钮填充颜色 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:要求w >= 2*(r+1); h >= 2*(r+1); radius > h/2 -**********************************************************/ +/** + * @brief Draw a filled rounded rectangle button. + * + * @note This function draws a button with four rounded corners and fills + * the background. The radius must be less than half of the height. + * + * @param x X coordinate of the top-left corner. + * @param y Y coordinate of the top-left corner. + * @param width Width of the button. + * @param height Height of the button. + * @param radius Radius of the corners. + * @param color Fill color of the button. + * + * @return None + */ void tli_show_button(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t radius, uint16_t color) { int i = 0; int j = 0; - //如果小于则绘制出来的结果不好看 + if (radius >= (height / 2)) return; - // 绘制四个圆角 + tli_draw_circle(x + radius, y + radius, color, radius, 1); tli_draw_circle(x + width - radius - 1, y + radius, color, radius, 1); tli_draw_circle(x + radius, y + height - radius - 1, color, radius, 1); tli_draw_circle(x + width - radius - 1, y + height - radius - 1, color, radius, 1); - // 绘制边框线 tli_draw_line(x + radius, y, x + width - radius - 1, y, color); tli_draw_line(x + radius, y + height - 1, x + width - radius - 1, y + height - 1, color); tli_draw_line(x, y + radius, x, y + height - radius - 1, color); tli_draw_line(x + width - 1, y + radius, x + width - 1, y + height - radius - 1, color); - //绘制内部颜色填充 - tli_draw_Rectangle(x + radius, y + radius, x + width - radius, y + height - radius, color, 1); - tli_draw_Rectangle(x + radius, y, x + width - radius, y + radius, color, 1); - tli_draw_Rectangle(x, y + radius, x + width, y + height - radius, color, 1); - tli_draw_Rectangle(x + radius, y + height - radius, x + width - radius, y + height, color, 1); + tli_draw_rectangle(x + radius, y + radius, x + width - radius, y + height - radius, color, 1); + tli_draw_rectangle(x + radius, y, x + width - radius, y + radius, color, 1); + tli_draw_rectangle(x, y + radius, x + width, y + height - radius, color, 1); + tli_draw_rectangle(x + radius, y + height - radius, x + width - radius, y + height, color, 1); } -/********************************************************** - * 函 数 名 称:tli_show_switch - * 函 数 功 能:绘制一个开关 - * 传 入 参 数:(x,y):开关左上角的起始位置 - * width:开关的宽度 - * height:开关的高度 - * on_color:开关打开之后的颜色 - * off_color:开关关闭之后的颜色 - * sw:开关的状态 =1打开 =0关闭 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:要求w >= 2*(height/2+1); 不符合要求则无法绘制 -**********************************************************/ +/** + * @brief Draw a switch (toggle) component with visual state. + * + * @note The switch has a rounded rectangle base with a circular knob + * indicating on or off state. Automatically validates layout rules. + * + * @param x X coordinate of the top-left corner. + * @param y Y coordinate of the top-left corner. + * @param width Total width of the switch. + * @param height Total height of the switch. + * @param on_color Color of the switch when turned on. + * @param off_color Color of the switch when turned off. + * @param sw Switch state: 1 = on, 0 = off. + * + * @return None + */ void tli_show_switch(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t on_color, uint16_t off_color, char sw) { int radius = height / 2 - 1; @@ -917,5 +829,3 @@ void tli_show_switch(uint16_t x, uint16_t y, uint16_t width, uint16_t height, ui } - - diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.h b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.h index f7aae409257..70284fd46d8 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.h +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_lcd.h @@ -1,5 +1,15 @@ -#ifndef GD32F450Z_LCD_H -#define GD32F450Z_LCD_H +/* + * Copyright (c) 2006-2025, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-05-23 godmial Refactor to conform to RT-Thread coding style. + */ + +#ifndef __DRV_LCD_H__ +#define __DRV_LCD_H__ #include #include @@ -12,62 +22,60 @@ * Definitions ******************************************************************************/ +/* LCD resolution and pixel format */ #define LCD_WIDTH 800 #define LCD_HEIGHT 480 #define LCD_FB_BYTE_PER_PIXEL 1 +/* Timing parameters for horizontal synchronization */ #define HORIZONTAL_SYNCHRONOUS_PULSE 10 #define HORIZONTAL_BACK_PORCH 150 #define ACTIVE_WIDTH 800 #define HORIZONTAL_FRONT_PORCH 15 +/* Timing parameters for vertical synchronization */ #define VERTICAL_SYNCHRONOUS_PULSE 10 #define VERTICAL_BACK_PORCH 140 #define ACTIVE_HEIGHT 480 #define VERTICAL_FRONT_PORCH 40 - -#define LCD_FRAME_BUF_ADDR 0XC0000000 - -//画笔颜色 -#define WHITE 0xFFFF -#define BLACK 0x0000 -#define BLUE 0x001F -#define BRED 0XF81F -#define GRED 0XFFE0 -#define GBLUE 0X07FF -#define RED 0xF800 -#define MAGENTA 0xF81F -#define GREEN 0x07E0 -#define CYAN 0x7FFF -#define YELLOW 0xFFE0 -#define BROWN 0XBC40 //棕色 -#define BRRED 0XFC07 //棕红色 -#define GRAY 0X8430 //灰色 -//GUI颜色 - -#define DARKBLUE 0X01CF //深蓝色 -#define LIGHTBLUE 0X7D7C //浅蓝色 -#define GRAYBLUE 0X5458 //灰蓝色 -//以上三色为PANEL的颜色 - -#define LIGHTGREEN 0X841F //浅绿色 -//#define LIGHTGRAY 0XEF5B //浅灰色(PANNEL) -#define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色 - -#define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色) -#define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色) - - +/* Framebuffer address in SDRAM */ +#define LCD_FRAME_BUF_ADDR 0xC0000000 /* SDRAM address for LCD frame buffer */ + +/* Pen color definitions (RGB565) */ +#define WHITE 0xFFFF /* White */ +#define BLACK 0x0000 /* Black */ +#define BLUE 0x001F /* Blue */ +#define BRED 0xF81F /* Blue-Red */ +#define GRED 0xFFE0 /* Green-Red */ +#define GBLUE 0x07FF /* Green-Blue */ +#define RED 0xF800 /* Red */ +#define MAGENTA 0xF81F /* Magenta */ +#define GREEN 0x07E0 /* Green */ +#define CYAN 0x7FFF /* Cyan */ +#define YELLOW 0xFFE0 /* Yellow */ +#define BROWN 0xBC40 /* Brown */ +#define BRRED 0xFC07 /* Brownish red */ +#define GRAY 0x8430 /* Gray */ + +/* GUI color definitions */ +#define DARKBLUE 0x01CF /* Dark blue */ +#define LIGHTBLUE 0x7D7C /* Light blue */ +#define GRAYBLUE 0x5458 /* Grayish blue */ +#define LIGHTGREEN 0x841F /* Light green */ +#define LGRAY 0xC618 /* Light gray (panel background) */ +#define LGRAYBLUE 0xA651 /* Light gray-blue (layer color) */ +#define LBBLUE 0x2B12 /* Light brown-blue (selected item reverse color) */ + +/* Frame buffer declaration based on compiler */ #if defined(__CC_ARM) || defined(__ARMCC_VERSION) -// Keil MDK 编译器 +/* Keil MDK Compiler */ extern uint16_t ltdc_lcd_framebuf0[800][480] __attribute__((at(LCD_FRAME_BUF_ADDR))); #elif defined(__GNUC__) -// GCC 编译器 (如 RT-Thread 使用的 GCC) -extern uint16_t ltdc_lcd_framebuf0[10][10]; +/* GCC Compiler (used by RT-Thread) */ +extern uint16_t ltdc_lcd_framebuf0[10][10]; /* Dummy for GCC compilation */ #endif - /******************************************************************************* * API ******************************************************************************/ @@ -76,11 +84,15 @@ extern uint16_t ltdc_lcd_framebuf0[10][10]; extern "C" { #endif - +/** + * @brief Configure the LCD display controller. + * + * @note This function initializes display timing and output settings. + */ void lcd_disp_config(void); -#if defined(__cplusplus) +#ifdef __cplusplus } #endif -#endif /* GD32F450Z_LCD_H */ +#endif /* __DRV_LCD_H__ */ diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.c b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.c index 0ae397dff98..e4fe366cdfb 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.c +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.c @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2006-2025, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-05-23 godmial Refactor to conform to RT-Thread coding style. + */ + #include #include #include @@ -11,55 +21,75 @@ _m_tp_dev tp_dev; const uint16_t FT5206_TPX_TBL[5] = {FT_TP1_REG, FT_TP2_REG, FT_TP3_REG, FT_TP4_REG, FT_TP5_REG}; -uint8_t g_gt_tnum = 5; // 默认支持的触摸屏点数(5点触摸) +uint8_t g_gt_tnum = 5; /**< Default number of supported touch points (5-point touch) */ + +/** + * @brief Delay for a specified number of microseconds. + * + * @note This function uses the SysTick timer to implement microsecond delay by polling. + * + * @param _nus Number of microseconds to delay. + */ void delay_us(uint32_t _nus) { uint8_t fac_us = 0; uint32_t ticks; uint32_t t_old, t_now, t_cnt = 0; - uint32_t reload = SysTick->LOAD; //获取重装载值(只查询,不影响) + uint32_t reload = SysTick->LOAD; fac_us = SystemCoreClock / 1000000; ticks = _nus * fac_us - fac_us * 7 / 20; - t_old = SysTick->VAL; //获取当前值作为旧值(只查询,不影响) + t_old = SysTick->VAL; while (1) { - /*systick为向下递减,未减到0导致重装载的情况下,新值小于旧值*/ - t_now = SysTick->VAL; //获取当前值作为新值(只查询,不影响) + t_now = SysTick->VAL; if (t_now < t_old) { - t_cnt += t_old - t_now; //未发生重装载,cnt记录减少的值 + t_cnt += t_old - t_now; } else { - t_cnt += t_old + (reload - t_now); //重装载后,旧值已递减完毕,cnt需在再加上重装载值与新值的差值 + t_cnt += t_old + (reload - t_now); } if (t_cnt >= ticks) { - break; //当计数cnt大于等于用户需要的ticks,即认为延时完毕,跳出循环 + break; } - t_old = t_now; //获取当前值作为旧值,以供下一次循环做判断(只查询,不影响) + t_old = t_now; }; } +/** + * @brief Delay function wrapper for touch operations. + * + * @param us Number of microseconds to delay. + */ void touch_delay_1us(uint16_t us) { delay_us(us); } -// 控制I2C速度的延时 +/** + * @brief Delay to control I2C speed. + * + * @note Used between I2C signal toggles to ensure proper timing. + */ void CT_Delay(void) { touch_delay_1us(2); } -// 电容触摸芯片IIC接口初始化 +/** + * @brief Initialize the I2C interface for the capacitive touch chip. + * + * @note Configures GPIO ports for SCL and SDA lines as outputs with pull-up resistors. + */ void CT_IIC_Init(void) { /* enable the led clock */ @@ -72,34 +102,49 @@ void CT_IIC_Init(void) gpio_mode_set(SDA_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, SDA_PIN); gpio_output_options_set(SDA_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, SDA_PIN); } -// 产生IIC起始信号 + +/** + * @brief Generate I2C start condition. + * + * @note Starts communication by pulling SDA low while SCL is high. + */ void CT_IIC_Start(void) { - CT_SDA_OUT(); // sda线输出 + CT_SDA_OUT(); SDA_ON; - SCL_ON; // SCL=1时,SDA由1到0跳变 + SCL_ON; touch_delay_1us(30); - SDA_OFF; // START:when CLK is high,DATA change form high to low + SDA_OFF; CT_Delay(); - SCL_OFF; // 钳住I2C总线,准备发送或接收数据 + SCL_OFF; } -// 产生IIC停止信号 + +/** + * @brief Generate I2C stop condition. + * + * @note Ends communication by pulling SDA high while SCL is high. + */ void CT_IIC_Stop(void) { - CT_SDA_OUT(); // sda线输出 - SCL_ON; // SCL=1时,SDA由0到1跳变 + CT_SDA_OUT(); + SCL_ON; touch_delay_1us(30); - SDA_OFF; // STOP:when CLK is high DATA change form low to high + SDA_OFF; CT_Delay(); - SDA_ON; // 发送I2C总线结束信号 + SDA_ON; } -// 等待应答信号到来 -// 返回值:1,接收应答失败 -// 0,接收应答成功 + +/** + * @brief Wait for I2C ACK signal. + * + * @return 0 if ACK received successfully, 1 if timeout occurred. + * + * @warning If ACK is not received within 250 iterations, a stop condition is generated. + */ uint8_t CT_IIC_Wait_Ack(void) { uint8_t ucErrTime = 0; - CT_SDA_IN(); // SDA设置为输入 + CT_SDA_IN(); SDA_ON; SCL_ON; CT_Delay(); @@ -113,10 +158,15 @@ uint8_t CT_IIC_Wait_Ack(void) } CT_Delay(); } - SCL_OFF; // 时钟输出0 + SCL_OFF; return 0; } -// 产生ACK应答 + +/** + * @brief Generate I2C ACK signal. + * + * @note This is used to acknowledge receipt of a byte in I2C communication. + */ void CT_IIC_Ack(void) { SCL_OFF; @@ -128,7 +178,12 @@ void CT_IIC_Ack(void) CT_Delay(); SCL_OFF; } -// 不产生ACK应答 + +/** + * @brief Generate I2C NACK signal. + * + * @note This is used to indicate the end of reading in I2C communication. + */ void CT_IIC_NAck(void) { SCL_OFF; @@ -140,20 +195,23 @@ void CT_IIC_NAck(void) CT_Delay(); SCL_OFF; } -// IIC发送一个字节 -// 返回从机有无应答 -// 1,有应答 -// 0,无应答 + + +/** + * @brief Send a byte over I2C. + * + * @param txd Byte to send. + * + * @note Sends 8 bits starting from the MSB over the SDA line. + */ void CT_IIC_Send_Byte(uint8_t txd) { uint8_t t; CT_SDA_OUT(); - SCL_OFF; // 拉低时钟开始数据传输 + SCL_OFF; CT_Delay(); for (t = 0; t < 8; t++) { - // CT_IIC_SDA=(txd&0x80)>>7; - // CT_IIC_SDA((txd&0x80)>>7); if ((txd & 0x80) >> 7) { gpio_bit_set(SDA_PORT, SDA_PIN); @@ -170,11 +228,18 @@ void CT_IIC_Send_Byte(uint8_t txd) CT_Delay(); } } -// 读1个字节,ack=1时,发送ACK,ack=0,发送nACK + +/** + * @brief Read a byte over I2C. + * + * @param ack If 1, send ACK after receiving; if 0, send NACK. + * + * @return The received byte. + */ uint8_t CT_IIC_Read_Byte(unsigned char ack) { volatile uint8_t i, receive = 0; - CT_SDA_IN(); // SDA设置为输入 + CT_SDA_IN(); touch_delay_1us(30); for (i = 0; i < 8; i++) { @@ -183,88 +248,108 @@ uint8_t CT_IIC_Read_Byte(unsigned char ack) SCL_ON; receive <<= 1; - // printf("%d ",CT_READ_SDA); if (CT_READ_SDA) receive++; } - // printf("\r\n receive:%0x \r\n",receive); if (!ack) - CT_IIC_NAck(); // 发送nACK + CT_IIC_NAck(); else - CT_IIC_Ack(); // 发送ACK + CT_IIC_Ack(); return receive; } -// 向FT5206写入一次数据 +/** + * @brief Write data to FT5206 register. + * + * @param reg Register address. + * @param buf Pointer to data buffer. + * @param len Length of data to write. + * + * @return 0 if successful, non-zero if any write fails. + */ uint8_t FT5206_WR_Reg(uint16_t reg, uint8_t *buf, uint8_t len) { uint8_t i; uint8_t ret = 0; CT_IIC_Start(); - CT_IIC_Send_Byte(FT_CMD_WR); // 发送写命令 + CT_IIC_Send_Byte(FT_CMD_WR); CT_IIC_Wait_Ack(); - CT_IIC_Send_Byte(reg & 0XFF); // 发送低8位地址 + CT_IIC_Send_Byte(reg & 0XFF); CT_IIC_Wait_Ack(); for (i = 0; i < len; i++) { - CT_IIC_Send_Byte(buf[i]); // 发数据 + CT_IIC_Send_Byte(buf[i]); ret = CT_IIC_Wait_Ack(); if (ret) break; } - CT_IIC_Stop(); // 产生一个停止条件 + CT_IIC_Stop(); return ret; } -// 从FT5206读出一次数据 +/** + * @brief Read data from FT5206 register. + * + * @param reg Register address. + * @param buf Pointer to buffer to store read data. + * @param len Number of bytes to read. + */ void FT5206_RD_Reg(uint16_t reg, uint8_t *buf, uint8_t len) { uint8_t i; CT_IIC_Start(); - CT_IIC_Send_Byte(FT_CMD_WR); // 发送写命令 + CT_IIC_Send_Byte(FT_CMD_WR); CT_IIC_Wait_Ack(); - CT_IIC_Send_Byte(reg & 0XFF); // 发送低8位地址 + CT_IIC_Send_Byte(reg & 0XFF); CT_IIC_Wait_Ack(); CT_IIC_Start(); - CT_IIC_Send_Byte(FT_CMD_RD); // 发送读命令 + CT_IIC_Send_Byte(FT_CMD_RD); CT_IIC_Wait_Ack(); for (i = 0; i < len; i++) { - buf[i] = CT_IIC_Read_Byte(i == (len - 1) ? 0 : 1); // 发数据 + buf[i] = CT_IIC_Read_Byte(i == (len - 1) ? 0 : 1); } - CT_IIC_Stop(); // 产生一个停止条件 + CT_IIC_Stop(); } -// 初始化FT5206触摸屏 +/** + * @brief Initialize the FT5206 touch screen controller. + * + * @note Initializes I2C, sets operational modes and touch sensitivity. + * + * @return 0 if initialization is successful. + */ uint8_t FT5206_Init(void) { uint8_t temp[5]; - // PD11设置为上拉输入(INT) /* enable the led clock */ rcu_periph_clock_enable(INT_RCU); /* configure led GPIO port */ gpio_mode_set(INT_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, INT_PIN); - // 初始化电容屏的I2C总线 + CT_IIC_Init(); - FT5206_WR_Reg(FT_DEVIDE_MODE, temp, 1); // 进入正常操作模式 - FT5206_WR_Reg(FT_ID_G_MODE, temp, 1); // 查询模式 - temp[0] = 22; // 触摸有效值,22,越小越灵敏 - FT5206_WR_Reg(FT_ID_G_THGROUP, temp, 1); // 设置触摸有效值 - temp[0] = 12; // 激活周期,不能小于12,最大14 + FT5206_WR_Reg(FT_DEVIDE_MODE, temp, 1); + FT5206_WR_Reg(FT_ID_G_MODE, temp, 1); + temp[0] = 22; + FT5206_WR_Reg(FT_ID_G_THGROUP, temp, 1); + temp[0] = 12; FT5206_WR_Reg(FT_ID_G_PERIODACTIVE, temp, 1); - // 读取版本号,参考值:0x3003 + FT5206_RD_Reg(FT_ID_G_LIB_VERSION, &temp[0], 2); printf("CTP ID:%x\r\n", ((uint16_t)temp[0] << 8) + temp[1]); return 0; } -// 扫描触摸屏(采用查询方式) -// mode:0,正常扫描. -// 返回值:当前触屏状态. -// 0,触屏无触摸;1,触屏有触摸 +/** + * @brief Scan the touch screen using polling. + * + * @param mode 0 for normal scan mode. + * + * @return 1 if a touch is detected, 0 otherwise. + */ uint8_t FT5206_Scan(uint8_t mode) { uint8_t buf[4]; @@ -272,25 +357,25 @@ uint8_t FT5206_Scan(uint8_t mode) uint8_t res = 0; uint8_t temp; uint16_t tempsta; - static uint8_t t = 0; // 控制查询间隔,从而降低CPU占用率 + static uint8_t t = 0; t++; - if ((t % 10) == 0 || t < 10) // 空闲时,每进入10次CTP_Scan函数才检测1次,从而节省CPU使用率 + if ((t % 10) == 0 || t < 10) { - FT5206_RD_Reg(FT_REG_NUM_FINGER, &mode, 1); // 读取触摸点的状态 + FT5206_RD_Reg(FT_REG_NUM_FINGER, &mode, 1); if ((mode & 0XF) && ((mode & 0XF) <= g_gt_tnum)) { - temp = 0XFF << (mode & 0XF); // 将点的个数转换为1的位数,匹配tp_dev.sta定义 - tempsta = tp_dev.sta; // 保存当前的tp_dev.sta值 + temp = 0XFF << (mode & 0XF); + tempsta = tp_dev.sta; tp_dev.sta = (~temp) | TP_PRES_DOWN | TP_CATH_PRES; - tp_dev.x[g_gt_tnum - 1] = tp_dev.x[0]; // 保存触点0的数据,保存在最后一个上 + tp_dev.x[g_gt_tnum - 1] = tp_dev.x[0]; tp_dev.y[g_gt_tnum - 1] = tp_dev.y[0]; - // delay_1ms(4); //必要的延时,否则老是认为有按键按下 + for (i = 0; i < g_gt_tnum; i++) { - if (tp_dev.sta & (1 << i)) // 触摸有效? + if (tp_dev.sta & (1 << i)) { - FT5206_RD_Reg(FT5206_TPX_TBL[i], buf, 4); // 读取XY坐标值 - if (tp_dev.touchtype & 0X01) // 横屏 + FT5206_RD_Reg(FT5206_TPX_TBL[i], buf, 4); + if (tp_dev.touchtype & 0X01) { tp_dev.y[i] = ((uint16_t)(buf[0] & 0X0F) << 8) + buf[1]; tp_dev.x[i] = ((uint16_t)(buf[2] & 0X0F) << 8) + buf[3]; @@ -303,67 +388,66 @@ uint8_t FT5206_Scan(uint8_t mode) } } res = 1; - if (tp_dev.x[0] > ACTIVE_WIDTH || tp_dev.y[0] > ACTIVE_HEIGHT) // 非法数据(坐标超出了) + if (tp_dev.x[0] > ACTIVE_WIDTH || tp_dev.y[0] > ACTIVE_HEIGHT) { - if ((mode & 0XF) > 1) // 有其他点有数据,则复第二个触点的数据到第一个触点. + if ((mode & 0XF) > 1) { tp_dev.x[0] = tp_dev.x[1]; tp_dev.y[0] = tp_dev.y[1]; - t = 0; // 触发一次,则会最少连续监测10次,从而提高命中率 + t = 0; } - else // 非法数据,则忽略此次数据(还原原来的) + else { tp_dev.x[0] = tp_dev.x[g_gt_tnum - 1]; tp_dev.y[0] = tp_dev.y[g_gt_tnum - 1]; mode = 0X80; - tp_dev.sta = tempsta; // 恢复tp_dev.sta + tp_dev.sta = tempsta; } } else - t = 0; // 触发一次,则会最少连续监测10次,从而提高命中率 + t = 0; } } - if ((mode & 0X1F) == 0) // 无触摸点按下 + if ((mode & 0X1F) == 0) { - if (tp_dev.sta & TP_PRES_DOWN) // 之前是被按下的 + if (tp_dev.sta & TP_PRES_DOWN) { - tp_dev.sta &= ~TP_PRES_DOWN; // 标记按键松开 + tp_dev.sta &= ~TP_PRES_DOWN; } - else // 之前就没有被按下 + else { tp_dev.x[0] = 0xffff; tp_dev.y[0] = 0xffff; - tp_dev.sta &= 0XE0; // 清除点有效标记 + tp_dev.sta &= 0XE0; } } if (t > 240) - t = 10; // 重新从10开始计数 + t = 10; return res; } -/********************************************************** - * 函 数 名 称:letgo_scan - * 函 数 功 能:触摸松手判断 - * 传 入 参 数:contact:第几个触点(一共有5个触点) - * (sx,sy):判断触摸地的起始坐标 - * (ex,ey):判断触摸地的结束坐标 - * 函 数 返 回:无 - * 作 者:LCKFB - * 备 注:无 -**********************************************************/ +/** + * @brief Detect touch release by monitoring a specific touch point. + * + * @param contact Index of touch contact to check. + * @param sx Start X coordinate. + * @param sy Start Y coordinate. + * @param ex End X coordinate. + * @param ey End Y coordinate. + * + * @note Returns when the touch point leaves the specified rectangle. + */ void letgo_scan(uint16_t contact, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey) { - //等待松手 while (FT5206_Scan(0)) { - //如果离开了x轴触摸范围 if (tp_dev.x[contact] <= sx || tp_dev.x[contact] >= ex) { return; } - //如果离开了y轴触摸范围 + if (tp_dev.y[contact] <= sy && tp_dev.y[contact] >= ey) { return; @@ -371,6 +455,13 @@ void letgo_scan(uint16_t contact, uint16_t sx, uint16_t sy, uint16_t ex, uint16_ } } +/** + * @brief Example application to test the touch screen functionality. + * + * @return Always returns 0. + * + * @warning This function runs an infinite loop and is intended for manual test only. + */ int touch_test(void) { int touch_state = 0; diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.h b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.h index 5cc3b623baa..3e11db37a28 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.h +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/drv_touch.h @@ -1,5 +1,16 @@ +/* + * Copyright (c) 2006-2025, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-05-23 godmial Refactor to conform to RT-Thread coding style. + */ + #ifndef __TOUCH_H__ #define __TOUCH_H__ + #include "stdio.h" #include "string.h" #include "gd32f4xx.h" @@ -19,14 +30,14 @@ #define SDA_OFF gpio_bit_reset(SDA_PORT, SDA_PIN) #define SDA_TOGGLE gpio_bit_toggle(SDA_PORT, SDA_PIN) -// IO方向设置 +/* IO direction settings */ #define CT_SDA_IN() gpio_mode_set(SCL_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, SDA_PIN); //{GPIOF->MODER&=~(3<<(2*11));GPIOF->MODER|=0<<2*11;} //PF11输入模式 #define CT_SDA_OUT() gpio_mode_set(SCL_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, SDA_PIN); //{GPIOF->MODER&=~(3<<(2*11));GPIOF->MODER|=1<<2*11;} //PF11输出模式 -// IO操作函数 +/* IO operations */ #define CT_IIC_SCL // PBout(0) //SCL #define CT_IIC_SDA(val) ((val) == 1 ? SDA_ON : SDA_OFF) // PFout(11) //SDA #define CT_READ_SDA gpio_input_bit_get(SDA_PORT, SDA_PIN) // PFin(11) //输入SDA - +/* Reset and interrupt pin definitions */ #define RST_RCU RCU_GPIOD #define RST_PORT GPIOD #define RST_PIN GPIO_PIN_12 @@ -41,58 +52,136 @@ #define INT_OFF gpio_bit_reset(INT_PORT, INT_PIN); #define INT_TOGGLE gpio_bit_toggle(INT_PORT, INT_PIN); -// I2C读写命令 -#define FT_CMD_WR 0X70 // 写命令 -#define FT_CMD_RD 0X71 // 读命令 -// FT5206 部分寄存器定义 -#define FT_DEVIDE_MODE 0x00 // FT5206模式控制寄存器 -#define FT_REG_NUM_FINGER 0x02 // 触摸状态寄存器 -#define FT_TP1_REG 0X03 // 第一个触摸点数据地址 -#define FT_TP2_REG 0X09 // 第二个触摸点数据地址 -#define FT_TP3_REG 0X0F // 第三个触摸点数据地址 -#define FT_TP4_REG 0X15 // 第四个触摸点数据地址 -#define FT_TP5_REG 0X1B // 第五个触摸点数据地址 - -#define FT_ID_G_LIB_VERSION 0xA1 // 版本 -#define FT_ID_G_MODE 0xA4 // FT5206中断模式控制寄存器 -#define FT_ID_G_THGROUP 0x80 // 触摸有效值设置寄存器 -#define FT_ID_G_PERIODACTIVE 0x88 // 激活状态周期设置寄存器 - -#define TP_PRES_DOWN 0x80 // 触屏被按下 -#define TP_CATH_PRES 0x40 // 有按键按下了 -#define CT_MAX_TOUCH 5 // 电容屏支持的点数,固定为5点 -// 触摸屏控制器 +/* I2C command definitions */ +#define FT_CMD_WR 0X70 /**< FT5206 write command */ +#define FT_CMD_RD 0X71 /**< FT5206 read command */ +/* FT5206 register definitions */ +#define FT_DEVIDE_MODE 0x00 /**< Mode control register */ +#define FT_REG_NUM_FINGER 0x02 /**< Touch status register */ +#define FT_TP1_REG 0x03 /**< Touch point 1 data */ +#define FT_TP2_REG 0x09 /**< Touch point 2 data */ +#define FT_TP3_REG 0x0F /**< Touch point 3 data */ +#define FT_TP4_REG 0x15 /**< Touch point 4 data */ +#define FT_TP5_REG 0x1B /**< Touch point 5 data */ +#define FT_ID_G_LIB_VERSION 0xA1 /**< Firmware version */ +#define FT_ID_G_MODE 0xA4 /**< Interrupt mode control */ +#define FT_ID_G_THGROUP 0x80 /**< Touch sensitivity */ +#define FT_ID_G_PERIODACTIVE 0x88 /**< Active period register */ + +#define TP_PRES_DOWN 0x80 /**< Touch pressed flag */ +#define TP_CATH_PRES 0x40 /**< Key press detected flag */ +#define CT_MAX_TOUCH 5 /**< Maximum number of supported touch points */ +/** + * @brief Touch point device structure. + */ typedef struct { - // uint8_t (*init)(void); //初始化触摸屏控制器 - // uint8_t (*scan)(uint8_t); //扫描触摸屏.0,屏幕扫描;1,物理坐标; - // void (*adjust)(void); //触摸屏校准 - uint16_t x[CT_MAX_TOUCH]; // 当前坐标 - uint16_t y[CT_MAX_TOUCH]; // 电容屏有最多5组坐标,电阻屏则用x[0],y[0]代表:此次扫描时,触屏的坐标,用 - uint8_t sta; // 笔的状态 - float xfac; - float yfac; - short xoff; - short yoff; - uint8_t touchtype; + uint16_t x[CT_MAX_TOUCH]; /**< X coordinates of touch points */ + uint16_t y[CT_MAX_TOUCH]; /**< Y coordinates of touch points */ + uint8_t sta; /**< Touch status flag */ + float xfac; /**< X axis scaling factor */ + float yfac; /**< Y axis scaling factor */ + short xoff; /**< X axis offset */ + short yoff; /**< Y axis offset */ + uint8_t touchtype; /**< Touch type flag */ } _m_tp_dev; -extern _m_tp_dev tp_dev; // 触屏控制器在touch.c里面定义 - -// IIC所有操作函数 -void CT_IIC_Init(void); // 初始化IIC的IO口 -void CT_IIC_Start(void); // 发送IIC开始信号 -void CT_IIC_Stop(void); // 发送IIC停止信号 -void CT_IIC_Send_Byte(uint8_t txd); // IIC发送一个字节 -uint8_t CT_IIC_Read_Byte(unsigned char ack); // IIC读取一个字节 -uint8_t CT_IIC_Wait_Ack(void); // IIC等待ACK信号 -void CT_IIC_Ack(void); // IIC发送ACK信号 -void CT_IIC_NAck(void); // IIC不发送ACK信号 - -// 触摸屏操作函数 + +extern _m_tp_dev tp_dev; + +/** + * @brief Initialize I2C GPIO lines. + */ +void CT_IIC_Init(void); + +/** + * @brief Generate I2C start condition. + */ +void CT_IIC_Start(void); + +/** + * @brief Generate I2C stop condition. + */ +void CT_IIC_Stop(void); + +/** + * @brief Send a byte over I2C. + * + * @param txd Byte to send. + */ +void CT_IIC_Send_Byte(uint8_t txd); + +/** + * @brief Read a byte over I2C. + * + * @param ack 1 to send ACK after read, 0 for NACK. + * + * @return The received byte. + */ +uint8_t CT_IIC_Read_Byte(unsigned char ack); + +/** + * @brief Wait for I2C ACK. + * + * @return 0 on success, non-zero on timeout. + */ +uint8_t CT_IIC_Wait_Ack(void); + +/** + * @brief Generate I2C ACK. + */ +void CT_IIC_Ack(void); + +/** + * @brief Generate I2C NACK. + */ +void CT_IIC_NAck(void); + +/** + * @brief Write data to FT5206 register. + * + * @param reg Register address. + * @param buf Pointer to data. + * @param len Number of bytes to write. + * + * @return 0 if success, non-zero otherwise. + */ uint8_t FT5206_WR_Reg(uint16_t reg, uint8_t *buf, uint8_t len); -void FT5206_RD_Reg(uint16_t reg, uint8_t *buf, uint8_t len); + +/** + * @brief Read data from FT5206 register. + * + * @param reg Register address. + * @param buf Buffer to store data. + * @param len Number of bytes to read. + */ +void FT5206_RD_Reg(uint16_t reg, uint8_t *buf, uint8_t len); + +/** + * @brief Initialize the FT5206 touch controller. + * + * @return 0 if successful. + */ uint8_t FT5206_Init(void); + +/** + * @brief Poll the FT5206 for touch input. + * + * @param mode Scan mode. + * + * @return 1 if touch detected, 0 otherwise. + */ uint8_t FT5206_Scan(uint8_t mode); -void letgo_scan(uint16_t contact, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey); + +/** + * @brief Wait until touch contact leaves specified area. + * + * @param contact Touch point index. + * @param sx Start X coordinate. + * @param sy Start Y coordinate. + * @param ex End X coordinate. + * @param ey End Y coordinate. + */ +void letgo_scan(uint16_t contact, uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey); + #endif diff --git a/bsp/gd32/arm/gd32470z-lckfb/board/ports/font.h b/bsp/gd32/arm/gd32470z-lckfb/board/ports/font.h index cb5f9070a8a..567068a9ee4 100644 --- a/bsp/gd32/arm/gd32470z-lckfb/board/ports/font.h +++ b/bsp/gd32/arm/gd32470z-lckfb/board/ports/font.h @@ -1,104 +1,112 @@ -#ifndef __FONT_H -#define __FONT_H +/* + * Copyright (c) 2006-2025, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2025-05-23 godmial Refactor to conform to RT-Thread coding style. + */ -const unsigned char asc2_1608[95][16]={ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/ -{0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x18,0x18,0x00,0x00},/*"!",1*/ -{0x00,0x48,0x6C,0x24,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*""",2*/ -{0x00,0x00,0x00,0x24,0x24,0x24,0x7F,0x12,0x12,0x12,0x7F,0x12,0x12,0x12,0x00,0x00},/*"#",3*/ -{0x00,0x00,0x08,0x1C,0x2A,0x2A,0x0A,0x0C,0x18,0x28,0x28,0x2A,0x2A,0x1C,0x08,0x08},/*"$",4*/ -{0x00,0x00,0x00,0x22,0x25,0x15,0x15,0x15,0x2A,0x58,0x54,0x54,0x54,0x22,0x00,0x00},/*"%",5*/ -{0x00,0x00,0x00,0x0C,0x12,0x12,0x12,0x0A,0x76,0x25,0x29,0x11,0x91,0x6E,0x00,0x00},/*"&",6*/ -{0x00,0x06,0x06,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/ -{0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00},/*"(",8*/ -{0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00},/*")",9*/ -{0x00,0x00,0x00,0x00,0x08,0x08,0x6B,0x1C,0x1C,0x6B,0x08,0x08,0x00,0x00,0x00,0x00},/*"*",10*/ -{0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x7F,0x08,0x08,0x08,0x08,0x00,0x00,0x00},/*"+",11*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x04,0x03},/*",",12*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",13*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00},/*".",14*/ -{0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00},/*"/",15*/ -{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"0",16*/ -{0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"1",17*/ -{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00},/*"2",18*/ -{0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*"3",19*/ -{0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00},/*"4",20*/ -{0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*"5",21*/ -{0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"6",22*/ -{0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00},/*"7",23*/ -{0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},/*"8",24*/ -{0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00},/*"9",25*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00},/*":",26*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x04},/*";",27*/ -{0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00},/*"<",28*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},/*"=",29*/ -{0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00},/*">",30*/ -{0x00,0x00,0x00,0x3C,0x42,0x42,0x46,0x40,0x20,0x10,0x10,0x00,0x18,0x18,0x00,0x00},/*"?",31*/ -{0x00,0x00,0x00,0x1C,0x22,0x5A,0x55,0x55,0x55,0x55,0x2D,0x42,0x22,0x1C,0x00,0x00},/*"@",32*/ -{0x00,0x00,0x00,0x08,0x08,0x18,0x14,0x14,0x24,0x3C,0x22,0x42,0x42,0xE7,0x00,0x00},/*"A",33*/ -{0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x1E,0x22,0x42,0x42,0x42,0x22,0x1F,0x00,0x00},/*"B",34*/ -{0x00,0x00,0x00,0x7C,0x42,0x42,0x01,0x01,0x01,0x01,0x01,0x42,0x22,0x1C,0x00,0x00},/*"C",35*/ -{0x00,0x00,0x00,0x1F,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1F,0x00,0x00},/*"D",36*/ -{0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x42,0x42,0x3F,0x00,0x00},/*"E",37*/ -{0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x02,0x02,0x07,0x00,0x00},/*"F",38*/ -{0x00,0x00,0x00,0x3C,0x22,0x22,0x01,0x01,0x01,0x71,0x21,0x22,0x22,0x1C,0x00,0x00},/*"G",39*/ -{0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"H",40*/ -{0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"I",41*/ -{0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x0F},/*"J",42*/ -{0x00,0x00,0x00,0x77,0x22,0x12,0x0A,0x0E,0x0A,0x12,0x12,0x22,0x22,0x77,0x00,0x00},/*"K",43*/ -{0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x7F,0x00,0x00},/*"L",44*/ -{0x00,0x00,0x00,0x77,0x36,0x36,0x36,0x36,0x2A,0x2A,0x2A,0x2A,0x2A,0x6B,0x00,0x00},/*"M",45*/ -{0x00,0x00,0x00,0xE3,0x46,0x46,0x4A,0x4A,0x52,0x52,0x52,0x62,0x62,0x47,0x00,0x00},/*"N",46*/ -{0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1C,0x00,0x00},/*"O",47*/ -{0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x3E,0x02,0x02,0x02,0x02,0x07,0x00,0x00},/*"P",48*/ -{0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x4D,0x53,0x32,0x1C,0x60,0x00},/*"Q",49*/ -{0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x3E,0x12,0x12,0x22,0x22,0x42,0xC7,0x00,0x00},/*"R",50*/ -{0x00,0x00,0x00,0x7C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x42,0x42,0x3E,0x00,0x00},/*"S",51*/ -{0x00,0x00,0x00,0x7F,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00},/*"T",52*/ -{0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*"U",53*/ -{0x00,0x00,0x00,0xE7,0x42,0x42,0x22,0x24,0x24,0x14,0x14,0x18,0x08,0x08,0x00,0x00},/*"V",54*/ -{0x00,0x00,0x00,0x6B,0x49,0x49,0x49,0x49,0x55,0x55,0x36,0x22,0x22,0x22,0x00,0x00},/*"W",55*/ -{0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00},/*"X",56*/ -{0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00},/*"Y",57*/ -{0x00,0x00,0x00,0x7E,0x21,0x20,0x10,0x10,0x08,0x04,0x04,0x42,0x42,0x3F,0x00,0x00},/*"Z",58*/ -{0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00},/*"[",59*/ -{0x00,0x00,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x40},/*"\",60*/ -{0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00},/*"]",61*/ -{0x00,0x38,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"^",62*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF},/*"_",63*/ -{0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x78,0x44,0x42,0x42,0xFC,0x00,0x00},/*"a",65*/ -{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x26,0x1A,0x00,0x00},/*"b",66*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x02,0x02,0x02,0x44,0x38,0x00,0x00},/*"c",67*/ -{0x00,0x00,0x00,0x60,0x40,0x40,0x40,0x78,0x44,0x42,0x42,0x42,0x64,0xD8,0x00,0x00},/*"d",68*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x02,0x02,0x42,0x3C,0x00,0x00},/*"e",69*/ -{0x00,0x00,0x00,0xF0,0x88,0x08,0x08,0x7E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"f",70*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x22,0x22,0x1C,0x02,0x3C,0x42,0x42,0x3C},/*"g",71*/ -{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x3A,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"h",72*/ -{0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"i",73*/ -{0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x1E},/*"j",74*/ -{0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x72,0x12,0x0A,0x16,0x12,0x22,0x77,0x00,0x00},/*"k",75*/ -{0x00,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"l",76*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x92,0x92,0x92,0x92,0x92,0xB7,0x00,0x00},/*"m",77*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3B,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00},/*"n",78*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00},/*"o",79*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x26,0x42,0x42,0x42,0x22,0x1E,0x02,0x07},/*"p",80*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x44,0x42,0x42,0x42,0x44,0x78,0x40,0xE0},/*"q",81*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x4C,0x04,0x04,0x04,0x04,0x1F,0x00,0x00},/*"r",82*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x42,0x02,0x3C,0x40,0x42,0x3E,0x00,0x00},/*"s",83*/ -{0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x3E,0x08,0x08,0x08,0x08,0x08,0x30,0x00,0x00},/*"t",84*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x42,0x42,0x42,0x42,0x62,0xDC,0x00,0x00},/*"u",85*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x08,0x08,0x00,0x00},/*"v",86*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEB,0x49,0x49,0x55,0x55,0x22,0x22,0x00,0x00},/*"w",87*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x24,0x18,0x18,0x18,0x24,0x6E,0x00,0x00},/*"x",88*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x18,0x08,0x08,0x07},/*"y",89*/ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x22,0x10,0x08,0x08,0x44,0x7E,0x00,0x00},/*"z",90*/ -{0x00,0xC0,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x20,0x20,0xC0,0x00},/*"{",91*/ -{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},/*"|",92*/ -{0x00,0x06,0x08,0x08,0x08,0x08,0x08,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x06,0x00},/*"}",93*/ -{0x0C,0x32,0xC2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"~",94*/ +#ifndef __FONT_H__ +#define __FONT_H__ - -}; +const unsigned char asc2_1608[95][16] = { + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ",0*/ + {0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, /*"!",1*/ + {0x00, 0x48, 0x6C, 0x24, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*""",2*/ + {0x00, 0x00, 0x00, 0x24, 0x24, 0x24, 0x7F, 0x12, 0x12, 0x12, 0x7F, 0x12, 0x12, 0x12, 0x00, 0x00}, /*"#",3*/ + {0x00, 0x00, 0x08, 0x1C, 0x2A, 0x2A, 0x0A, 0x0C, 0x18, 0x28, 0x28, 0x2A, 0x2A, 0x1C, 0x08, 0x08}, /*"$",4*/ + {0x00, 0x00, 0x00, 0x22, 0x25, 0x15, 0x15, 0x15, 0x2A, 0x58, 0x54, 0x54, 0x54, 0x22, 0x00, 0x00}, /*"%",5*/ + {0x00, 0x00, 0x00, 0x0C, 0x12, 0x12, 0x12, 0x0A, 0x76, 0x25, 0x29, 0x11, 0x91, 0x6E, 0x00, 0x00}, /*"&",6*/ + {0x00, 0x06, 0x06, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'",7*/ + {0x00, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x00}, /*"(",8*/ + {0x00, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x00}, /*")",9*/ + {0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x6B, 0x1C, 0x1C, 0x6B, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00}, /*"*",10*/ + {0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00}, /*"+",11*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x04, 0x03}, /*",",12*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"-",13*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00}, /*".",14*/ + {0x00, 0x00, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x00}, /*"/",15*/ + {0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00}, /*"0",16*/ + {0x00, 0x00, 0x00, 0x08, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, /*"1",17*/ + {0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x20, 0x20, 0x10, 0x08, 0x04, 0x42, 0x7E, 0x00, 0x00}, /*"2",18*/ + {0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x20, 0x18, 0x20, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00}, /*"3",19*/ + {0x00, 0x00, 0x00, 0x20, 0x30, 0x28, 0x24, 0x24, 0x22, 0x22, 0x7E, 0x20, 0x20, 0x78, 0x00, 0x00}, /*"4",20*/ + {0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x40, 0x40, 0x42, 0x22, 0x1C, 0x00, 0x00}, /*"5",21*/ + {0x00, 0x00, 0x00, 0x38, 0x24, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00}, /*"6",22*/ + {0x00, 0x00, 0x00, 0x7E, 0x22, 0x22, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00}, /*"7",23*/ + {0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, /*"8",24*/ + {0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x64, 0x58, 0x40, 0x40, 0x24, 0x1C, 0x00, 0x00}, /*"9",25*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, /*":",26*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x04}, /*";",27*/ + {0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00}, /*"<",28*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"=",29*/ + {0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00}, /*">",30*/ + {0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x46, 0x40, 0x20, 0x10, 0x10, 0x00, 0x18, 0x18, 0x00, 0x00}, /*"?",31*/ + {0x00, 0x00, 0x00, 0x1C, 0x22, 0x5A, 0x55, 0x55, 0x55, 0x55, 0x2D, 0x42, 0x22, 0x1C, 0x00, 0x00}, /*"@",32*/ + {0x00, 0x00, 0x00, 0x08, 0x08, 0x18, 0x14, 0x14, 0x24, 0x3C, 0x22, 0x42, 0x42, 0xE7, 0x00, 0x00}, /*"A",33*/ + {0x00, 0x00, 0x00, 0x1F, 0x22, 0x22, 0x22, 0x1E, 0x22, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00}, /*"B",34*/ + {0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x01, 0x01, 0x01, 0x01, 0x01, 0x42, 0x22, 0x1C, 0x00, 0x00}, /*"C",35*/ + {0x00, 0x00, 0x00, 0x1F, 0x22, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x22, 0x1F, 0x00, 0x00}, /*"D",36*/ + {0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x42, 0x42, 0x3F, 0x00, 0x00}, /*"E",37*/ + {0x00, 0x00, 0x00, 0x3F, 0x42, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00}, /*"F",38*/ + {0x00, 0x00, 0x00, 0x3C, 0x22, 0x22, 0x01, 0x01, 0x01, 0x71, 0x21, 0x22, 0x22, 0x1C, 0x00, 0x00}, /*"G",39*/ + {0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00}, /*"H",40*/ + {0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, /*"I",41*/ + {0x00, 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x0F}, /*"J",42*/ + {0x00, 0x00, 0x00, 0x77, 0x22, 0x12, 0x0A, 0x0E, 0x0A, 0x12, 0x12, 0x22, 0x22, 0x77, 0x00, 0x00}, /*"K",43*/ + {0x00, 0x00, 0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x42, 0x7F, 0x00, 0x00}, /*"L",44*/ + {0x00, 0x00, 0x00, 0x77, 0x36, 0x36, 0x36, 0x36, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x6B, 0x00, 0x00}, /*"M",45*/ + {0x00, 0x00, 0x00, 0xE3, 0x46, 0x46, 0x4A, 0x4A, 0x52, 0x52, 0x52, 0x62, 0x62, 0x47, 0x00, 0x00}, /*"N",46*/ + {0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1C, 0x00, 0x00}, /*"O",47*/ + {0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00}, /*"P",48*/ + {0x00, 0x00, 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x41, 0x4D, 0x53, 0x32, 0x1C, 0x60, 0x00}, /*"Q",49*/ + {0x00, 0x00, 0x00, 0x3F, 0x42, 0x42, 0x42, 0x3E, 0x12, 0x12, 0x22, 0x22, 0x42, 0xC7, 0x00, 0x00}, /*"R",50*/ + {0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x02, 0x04, 0x18, 0x20, 0x40, 0x42, 0x42, 0x3E, 0x00, 0x00}, /*"S",51*/ + {0x00, 0x00, 0x00, 0x7F, 0x49, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00}, /*"T",52*/ + {0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, /*"U",53*/ + {0x00, 0x00, 0x00, 0xE7, 0x42, 0x42, 0x22, 0x24, 0x24, 0x14, 0x14, 0x18, 0x08, 0x08, 0x00, 0x00}, /*"V",54*/ + {0x00, 0x00, 0x00, 0x6B, 0x49, 0x49, 0x49, 0x49, 0x55, 0x55, 0x36, 0x22, 0x22, 0x22, 0x00, 0x00}, /*"W",55*/ + {0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x18, 0x18, 0x18, 0x24, 0x24, 0x42, 0xE7, 0x00, 0x00}, /*"X",56*/ + {0x00, 0x00, 0x00, 0x77, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x00, 0x00}, /*"Y",57*/ + {0x00, 0x00, 0x00, 0x7E, 0x21, 0x20, 0x10, 0x10, 0x08, 0x04, 0x04, 0x42, 0x42, 0x3F, 0x00, 0x00}, /*"Z",58*/ + {0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00}, /*"[",59*/ + {0x00, 0x00, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40, 0x40}, /*"\",60*/ + {0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00}, /*"]",61*/ + {0x00, 0x38, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"^",62*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, /*"_",63*/ + {0x00, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`",64*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x78, 0x44, 0x42, 0x42, 0xFC, 0x00, 0x00}, /*"a",65*/ + {0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x1A, 0x26, 0x42, 0x42, 0x42, 0x26, 0x1A, 0x00, 0x00}, /*"b",66*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x02, 0x02, 0x02, 0x44, 0x38, 0x00, 0x00}, /*"c",67*/ + {0x00, 0x00, 0x00, 0x60, 0x40, 0x40, 0x40, 0x78, 0x44, 0x42, 0x42, 0x42, 0x64, 0xD8, 0x00, 0x00}, /*"d",68*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x7E, 0x02, 0x02, 0x42, 0x3C, 0x00, 0x00}, /*"e",69*/ + {0x00, 0x00, 0x00, 0xF0, 0x88, 0x08, 0x08, 0x7E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, /*"f",70*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x22, 0x22, 0x1C, 0x02, 0x3C, 0x42, 0x42, 0x3C}, /*"g",71*/ + {0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00}, /*"h",72*/ + {0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, /*"i",73*/ + {0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x1E}, /*"j",74*/ + {0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x72, 0x12, 0x0A, 0x16, 0x12, 0x22, 0x77, 0x00, 0x00}, /*"k",75*/ + {0x00, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00}, /*"l",76*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x92, 0x92, 0x92, 0x92, 0x92, 0xB7, 0x00, 0x00}, /*"m",77*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x46, 0x42, 0x42, 0x42, 0x42, 0xE7, 0x00, 0x00}, /*"n",78*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00}, /*"o",79*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x26, 0x42, 0x42, 0x42, 0x22, 0x1E, 0x02, 0x07}, /*"p",80*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x44, 0x78, 0x40, 0xE0}, /*"q",81*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x4C, 0x04, 0x04, 0x04, 0x04, 0x1F, 0x00, 0x00}, /*"r",82*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x02, 0x3C, 0x40, 0x42, 0x3E, 0x00, 0x00}, /*"s",83*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x30, 0x00, 0x00}, /*"t",84*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x42, 0x42, 0x42, 0x42, 0x62, 0xDC, 0x00, 0x00}, /*"u",85*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x14, 0x08, 0x08, 0x00, 0x00}, /*"v",86*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEB, 0x49, 0x49, 0x55, 0x55, 0x22, 0x22, 0x00, 0x00}, /*"w",87*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x24, 0x18, 0x18, 0x18, 0x24, 0x6E, 0x00, 0x00}, /*"x",88*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x42, 0x24, 0x24, 0x14, 0x18, 0x08, 0x08, 0x07}, /*"y",89*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x22, 0x10, 0x08, 0x08, 0x44, 0x7E, 0x00, 0x00}, /*"z",90*/ + {0x00, 0xC0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xC0, 0x00}, /*"{",91*/ + {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, /*"|",92*/ + {0x00, 0x06, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x00}, /*"}",93*/ + {0x0C, 0x32, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"~",94*/ +}; #endif From b006fe6ab12ac09ba78d36b5fce92fbabf3e9697 Mon Sep 17 00:00:00 2001 From: godmial Date: Sat, 24 May 2025 10:30:04 +0800 Subject: [PATCH 3/3] Add maintainer info for gd32470z-lckfb-lcd --- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index eff482b8862..ac961d3c1db 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -75,3 +75,6 @@ tag: workflow path: .github owners: supper thomas(supperthomas)<78900636@qq.com>, Bingru Zhang(Rbb666)<751061401@qq.com>, Yuqiang Wang(kurisaW)<2053731441@qq.com> +tag: gd32470z-lckfb-lcd +path: bsp/gd32/arm/gd32470z-lckfb/board/ports +owners: Wu Ying Xiang(godmial)<2633967641@qq.com>