156 lines
4.9 KiB
C
156 lines
4.9 KiB
C
#include "include.h"
|
||
#include "app_variable.h"
|
||
|
||
|
||
|
||
#define TRACE_EN 0
|
||
|
||
#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 0x1000 //element缓存
|
||
#if (FLASH_SIZE == FSIZE_4M)||(FLASH_SIZE == FSIZE_8M)
|
||
#define GUI_WGT_BUF_SIZE 0x2800 //widget缓存
|
||
#else
|
||
#define GUI_WGT_BUF_SIZE 0x3000 //widget缓存
|
||
#endif
|
||
#define GUI_MAXSIZE_TEMPBUF 0x5000 //中间临时计算缓存14k
|
||
#define GUI_MAXSIZE_PARBUF 4096 //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
|
||
|
||
//GUI初始化配置表
|
||
static const gui_init_param_t tbl_gui_init_param = {
|
||
.screen_width = GUI_SCREEN_WIDTH,
|
||
.screen_height = GUI_SCREEN_HEIGHT,
|
||
.element_buf = gui_element_buf,
|
||
.widget_buf = gui_widget_buf,
|
||
.element_buf_size = GUI_ELE_BUF_SIZE,
|
||
.widget_buf_size = GUI_WGT_BUF_SIZE,
|
||
.temp_buf = gui_temp_buf,
|
||
.temp_buf_size = GUI_MAXSIZE_TEMPBUF,
|
||
.lines_buf = gui_lines_buf,
|
||
.lines_buf_size = GUI_LINES_BUF_SIZE,
|
||
.lines_count = GUI_LINES_CNT,
|
||
.maxsize_parbuf = GUI_MAXSIZE_PARBUF,
|
||
.font_res_addr = UI_BUF_FONT_SYS,
|
||
.max_font_size = GUI_MAX_FONT_SIZE,
|
||
.font_wspace = GUI_FONT_W_SPACE,
|
||
.font_hspace = GUI_FONT_H_SPACE,
|
||
};
|
||
|
||
//GUI相关初始化
|
||
void gui_init(void)
|
||
{
|
||
// printf("gui_init\n");
|
||
power_gate_3v3_on();
|
||
ctp_init();
|
||
tft_init();
|
||
os_gui_init(&tbl_gui_init_param);
|
||
compos_init();
|
||
sys_cb.sleep_en = 1; //允许进休眠
|
||
sys_cb.gui_sleep_sta = 0;
|
||
}
|
||
|
||
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;
|
||
bsp_motor_stop(MOTOR_PORT);
|
||
// printf("gui_sleep\n");
|
||
sys_cb.sleep_exit_tick = tick_get();
|
||
sys_cb.off_show_count = 0;
|
||
sys_cb.off_show_clock = 1;
|
||
|
||
/* 在解锁界面灭屏,返回进入密码锁的上一级页面 */
|
||
if (SysVariable.password_need && func_cb.sta == FUNC_PASSWORD_SUB_DISP) {
|
||
func_directly_back_to();
|
||
SysVariable.password_reentry_clear = true;
|
||
}
|
||
#ifdef __SCREEN_DARK_CLOCK_SHOW__
|
||
if(SysVariable.always_display && SysVariable.always_display_show_flag == false && get_sport_pause_state())//在熄屏时钟界面
|
||
{
|
||
//SysVariable.always_display_show_flag = true;
|
||
//task_stack_del(task_stack_find(FUNC_SCREEN_DARK_CLOCK));
|
||
func_switch_to_assign_screen(func_screen_clock_back(),false); //返回上一级界面
|
||
}
|
||
#endif
|
||
}
|
||
}
|
||
|
||
void gui_wakeup(void)
|
||
{
|
||
if (sys_cb.gui_sleep_sta) {
|
||
|
||
sys_clk_set(SYS_CLK_SEL);
|
||
|
||
power_gate_3v3_on();
|
||
//tft_init();
|
||
ctp_init();
|
||
#if (CTP_SELECT_SPT5113C | CTP_SPT5113C)
|
||
if(get_ctp_chip_ID() == CTP_STP5113_CHIP_ID)
|
||
{
|
||
//SPT5113C运行
|
||
spt5113c_start_work_with_freqset(spt5113c_freq_save_get());
|
||
ctp_irq_init();
|
||
}
|
||
#endif
|
||
tft_init();
|
||
gui_widget_refresh();
|
||
sys_cb.gui_sleep_sta = 0;
|
||
sys_cb.off_show_clock = 0;
|
||
// printf("gui_wakeup\n");
|
||
sys_cb.sleep_exit_tick = tick_get();
|
||
sys_cb.tft_idle_count = 5;
|
||
sys_clk_set(SYS_CLK_SEL);
|
||
}
|
||
}
|
||
|
||
AT(.com_text.gui)
|
||
bool gui_get_auto_power_en(void)
|
||
{
|
||
if(sys_cb.tft_idle_count){
|
||
return 0;
|
||
}else{
|
||
return 1;
|
||
}
|
||
//return GUI_AUTO_POWER_EN;
|
||
}
|
||
|
||
//蓝屏
|
||
AT(.com_text.hwio)
|
||
void gui_halt(u32 halt_no)
|
||
{
|
||
int i;
|
||
tft_bglight_en(); //打开背光
|
||
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();
|
||
}
|