mcu_ab568x/userboot240328/app/platform/gui/gui.c
2025-05-30 18:03:10 +08:00

70 lines
2.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "include.h"
#define TRACE_EN 1
#if TRACE_EN
#define TRACE(...) printf(__VA_ARGS__)
#else
#define TRACE(...)
#endif
//推屏缓存大小(双份)
#define GUI_LINES_BUF_SIZE (GUI_SCREEN_WIDTH * GUI_LINES_CNT * 2 * 2)
//以下缓存大小一般情况下不需要修改
#define GUI_ELE_BUF_SIZE 2048 //element缓存
#define GUI_WGT_BUF_SIZE 6144 //widget缓存
#define GUI_MAXSIZE_TEMPBUF 0x3800 //中间临时计算缓存14k
#define GUI_MAXSIZE_PARBUF 2048 //PAR解码缓存
#define GUI_MAX_FONT_SIZE 128 //单个字最大尺寸
static u8 gui_lines_buf[GUI_LINES_BUF_SIZE] AT(.disp.buf); //推屏缓存(双份)
static u8 gui_temp_buf[GUI_MAXSIZE_TEMPBUF] AT(.disp.buf); //中间计算缓存
static u8 gui_element_buf[GUI_ELE_BUF_SIZE] AT(.disp.buf); //Element Buf
static u8 gui_widget_buf[GUI_WGT_BUF_SIZE] AT(.disp.buf); //Widgets Buf
void gui_sleep(void)
{
if (!sys_cb.gui_sleep_sta) {
os_gui_draw_w4_done(); //关tft前要等当前帧刷完
tft_exit();
ctp_exit();
power_gate_3v3_off();
sys_cb.gui_sleep_sta = 1;
//printf("gui_sleep\n");
}
}
void gui_wakeup(void)
{
if (sys_cb.gui_sleep_sta) {
power_gate_3v3_on();
tft_init();
ctp_init();
gui_widget_refresh();
sys_cb.gui_sleep_sta = 0;
//printf("gui_wakeup\n");
}
}
//蓝屏
AT(.com_text.hwio)
void gui_halt(u32 halt_no)
{
int i;
tft_frame_end();
for (i=0; i<20000; i++) {
asm("nop"); //足够的延时保证前面SPI推完
}
tft_frame_start();
for (i=0; i<GUI_SCREEN_HEIGHT; i++) {
de_fill_rgb565(gui_lines_buf, COLOR_BLUE, GUI_SCREEN_WIDTH);
if (i >= GUI_SCREEN_CENTER_Y - 5 && i < GUI_SCREEN_CENTER_Y + 5) {
de_fill_num(gui_lines_buf + GUI_SCREEN_CENTER_X * 2 - 96, halt_no, i - (GUI_SCREEN_CENTER_Y - 5));
}
tft_spi_send(gui_lines_buf, GUI_SCREEN_WIDTH * 2);
}
tft_frame_end();
}