初版
This commit is contained in:
@@ -0,0 +1,263 @@
|
||||
#ifdef SUPPORT_MS_EXTENSIONS
|
||||
#pragma bss_seg(".lcd_lvgl_api.data.bss")
|
||||
#pragma data_seg(".lcd_lvgl_api.data")
|
||||
#pragma const_seg(".lcd_lvgl_api.text.const")
|
||||
#pragma code_seg(".lcd_lvgl_api.text")
|
||||
#endif
|
||||
|
||||
#define BOOL_DEFINE_CONFLICT
|
||||
|
||||
#include "sdk_config.h"
|
||||
|
||||
#if CONFIG_LVGL_UI_ENABLE
|
||||
#include "lvgl_v8/lvgl.h"
|
||||
#include "lvgl_v8/demos/lv_demos.h"
|
||||
#include "lvgl_v8/examples/lv_examples.h"
|
||||
#include "lcd_lvgl_api.h"
|
||||
#include "ui_core.h"
|
||||
#include "dbi.h"
|
||||
#include "lcd/lcd_drive.h"
|
||||
#include "btstack/avctp_user.h"
|
||||
#include "lcd/lcd_lvgl_api.h"
|
||||
|
||||
|
||||
struct lv_server_env {
|
||||
u8 init: 1;
|
||||
u8 key_lock : 1;
|
||||
u8 lcd_bl_idle_flag : 1;
|
||||
u8 lcd_need_keep_open: 1;
|
||||
u8 open_flag: 1;
|
||||
u16 ui_auto_shut_down_timer;
|
||||
u16 shut_down_time;
|
||||
};
|
||||
|
||||
#if TCFG_SDFILE_INSERT_FLASH_ENABLE
|
||||
#define LVGL_MODE_PHY_BASE TCFG_MODE_INSERT_FLASH_BASE
|
||||
#else
|
||||
#define LVGL_MODE_PHY_BASE 0
|
||||
#endif
|
||||
|
||||
static const u32 lv_phy_addr = LVGL_MODE_PHY_BASE;
|
||||
static u8 screen_saver_status = 0;
|
||||
static struct lv_server_env __ui_display = {0};
|
||||
#define __this (&__ui_display)
|
||||
|
||||
#define UI_TASK_NAME "ui"
|
||||
int lcd_sleep_ctrl(u8 enter);
|
||||
int lcd_sleep_status();
|
||||
void lcd_bl_open();
|
||||
static u8 lv_auto_shut_down_disable(void);
|
||||
static void lv_auto_shut_down_enable(void);
|
||||
static void lv_lcd_sleep_out(void);
|
||||
static void lv_lcd_sleep_in(void);
|
||||
void lcd_wait_busy();
|
||||
void lvgl_ui_task_suspend_resume(uint8_t state);
|
||||
int ui_disp_line_buf_uninit();
|
||||
void lv_set_lcd_keep_open_flag(u8 flag);
|
||||
void lv_set_screen_saver_status(u8 status);
|
||||
int ui_gpu_buf_release();
|
||||
void gpu_free_all_tasks();
|
||||
|
||||
#if LCD_POWER_DOWN_EN
|
||||
void lcd_reinit_wait_finish(void);
|
||||
#endif
|
||||
|
||||
u32 lv_get_phy_addr(void)
|
||||
{
|
||||
return lv_phy_addr;
|
||||
}
|
||||
|
||||
//进入屏保
|
||||
void lv_screen_saver(void *p)
|
||||
{
|
||||
if (!lcd_sleep_status()) {
|
||||
//关闭自动息屏定时器
|
||||
lv_auto_shut_down_disable();
|
||||
//lvgl挂起
|
||||
lvgl_ui_task_suspend_resume(0);
|
||||
lv_lcd_sleep_in();
|
||||
}
|
||||
}
|
||||
|
||||
//退出屏保
|
||||
int lv_screen_recover(void)
|
||||
{
|
||||
if (lv_get_screen_saver_status()) {
|
||||
|
||||
lv_lcd_sleep_out();
|
||||
__this->lcd_bl_idle_flag = 0;
|
||||
|
||||
#if LCD_POWER_DOWN_EN
|
||||
lcd_reinit_wait_finish();
|
||||
#endif
|
||||
lcd_bl_open();//开启屏幕背光
|
||||
|
||||
lv_set_screen_saver_status(0);
|
||||
|
||||
//lvgl全屏刷新
|
||||
lv_area_t area_p;
|
||||
area_p.x1 = 0;
|
||||
area_p.y1 = 0;
|
||||
area_p.x2 = lcd_get_screen_width();
|
||||
area_p.y2 = lcd_get_screen_height();
|
||||
_lv_inv_area(NULL, &area_p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t lv_get_screen_saver_status()
|
||||
{
|
||||
return screen_saver_status;
|
||||
}
|
||||
|
||||
void lv_set_screen_saver_status(u8 status)
|
||||
{
|
||||
screen_saver_status = status;
|
||||
}
|
||||
|
||||
uint8_t lv_get_ui_open_flag()
|
||||
{
|
||||
return __this->open_flag;
|
||||
}
|
||||
|
||||
void lv_set_ui_open_flag(uint8_t flag)
|
||||
{
|
||||
__this->open_flag = !!flag;
|
||||
}
|
||||
|
||||
void lv_set_lcd_keep_open_flag(uint8_t flag)
|
||||
{
|
||||
__this->lcd_need_keep_open = !!flag;
|
||||
}
|
||||
|
||||
void lv_ui_auto_shut_down_re_run(void)
|
||||
{
|
||||
#if TCFG_UI_SHUT_DOWN_TIME
|
||||
if (__this->ui_auto_shut_down_timer) {
|
||||
sys_timer_re_run(__this->ui_auto_shut_down_timer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_lcd_bl_idle_flag(u8 flag)
|
||||
{
|
||||
__this->lcd_bl_idle_flag = flag;
|
||||
}
|
||||
|
||||
static u8 lv_lcd_bl_idle_query(void)
|
||||
{
|
||||
return __this->lcd_bl_idle_flag;
|
||||
}
|
||||
REGISTER_LP_TARGET(lv_lcd_backlight_lp_target) = {
|
||||
.name = "lv_lcd_backlight",
|
||||
.is_idle = lv_lcd_bl_idle_query,
|
||||
};
|
||||
|
||||
static int ui_relate_uninit()
|
||||
{
|
||||
LV_LOG_INFO("ui relate uninit.\n");
|
||||
gpu_free_all_tasks();
|
||||
/* ui_disp_line_buf_uninit(); */
|
||||
/* ui_gpu_buf_release(); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lv_lcd_sleep_in(void)
|
||||
{
|
||||
if (!__ui_display.init) {
|
||||
return;
|
||||
}
|
||||
__this->open_flag = 0;
|
||||
|
||||
if (!lcd_sleep_status()) {
|
||||
lcd_clear(0, 0, lcd_get_screen_width() - 1, 0, lcd_get_screen_height() - 1);
|
||||
lcd_sleep_ctrl(true);//进入低功耗
|
||||
ui_relate_uninit();
|
||||
__this->lcd_bl_idle_flag = 1;
|
||||
lv_set_screen_saver_status(1);//设置屏幕处于休眠状态
|
||||
}
|
||||
}
|
||||
|
||||
static void lv_lcd_sleep_out(void)
|
||||
{
|
||||
if (!__ui_display.init) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (__this->open_flag) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_get_screen_saver_status()) {
|
||||
__this->open_flag = 1;
|
||||
lv_auto_shut_down_enable();//开启自动息屏
|
||||
lcd_sleep_ctrl(false); //退出低功耗
|
||||
lcd_wait_busy();
|
||||
}
|
||||
}
|
||||
|
||||
//开启自动息屏定时器
|
||||
static void lv_auto_shut_down_enable(void)
|
||||
{
|
||||
u32 rets;
|
||||
__asm__ volatile("%0 = rets":"=r"(rets));
|
||||
#if TCFG_UI_SHUT_DOWN_TIME
|
||||
if (!__ui_display.init) {
|
||||
return;
|
||||
}
|
||||
if (bt_get_call_status() != BT_CALL_HANGUP) {
|
||||
LV_LOG_INFO("%s call_status:%d", __func__, bt_get_call_status());
|
||||
return;
|
||||
}
|
||||
if (__this->lcd_need_keep_open) {
|
||||
LV_LOG_INFO("need keep open");
|
||||
return;
|
||||
}
|
||||
if (__this->ui_auto_shut_down_timer == 0) {
|
||||
if (__ui_display.shut_down_time == 0) {
|
||||
__ui_display.shut_down_time = 10;
|
||||
}
|
||||
if (__ui_display.shut_down_time > 20) {
|
||||
/* __ui_display.shut_down_time = 20; */
|
||||
}
|
||||
LV_LOG_INFO("[%s]time:%d rets:0x%x\n", __func__, __ui_display.shut_down_time, rets);
|
||||
__this->ui_auto_shut_down_timer = sys_timeout_add(NULL, lv_screen_saver, __ui_display.shut_down_time * 1000);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//关闭自动息屏定时器
|
||||
u8 lv_auto_shut_down_disable(void)
|
||||
{
|
||||
u32 rets;
|
||||
__asm__ volatile("%0 = rets":"=r"(rets));
|
||||
#if TCFG_UI_SHUT_DOWN_TIME
|
||||
if (__this->ui_auto_shut_down_timer) {
|
||||
LV_LOG_INFO("[%s]rets:0x%x", __func__, rets);
|
||||
sys_timeout_del(__this->ui_auto_shut_down_timer);
|
||||
__this->ui_auto_shut_down_timer = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
//初始化息屏管理
|
||||
void lv_screen_manage_init(void)
|
||||
{
|
||||
__this->init = 1;
|
||||
//添加自动熄屏定时器
|
||||
lv_auto_shut_down_enable();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif//CONFIG_LVGL_UI_ENABLE
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @file lcd_lvgl_api.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LCD_LVGL_API_H
|
||||
#define LCD_LVGL_API_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lv_screen_manage_init(void);
|
||||
int lv_screen_recover(void);
|
||||
void lv_ui_auto_shut_down_re_run(void);
|
||||
uint8_t lv_get_screen_saver_status();
|
||||
void lv_set_lcd_keep_open_flag(uint8_t flag);
|
||||
uint32_t lv_get_phy_addr(void);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,565 @@
|
||||
/**
|
||||
* @file lcd_ui_return_page.c
|
||||
* @brief jlui 页面跳转管理
|
||||
*/
|
||||
#include "app_config.h"
|
||||
#include "ui_api.h"
|
||||
|
||||
#define LOG_TAG_CONST UI
|
||||
#define LOG_TAG "[UI-return-page]"
|
||||
#define LOG_ERROR_ENABLE
|
||||
#define LOG_DEBUG_ENABLE
|
||||
#define LOG_INFO_ENABLE
|
||||
#define LOG_CHAR_ENABLE
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef SUPPORT_MS_EXTENSIONS
|
||||
#pragma bss_seg(".lcd_ui_return_page.data.bss")
|
||||
#pragma data_seg(".lcd_ui_return_page.data")
|
||||
#pragma const_seg(".lcd_ui_return_page.text.const")
|
||||
#pragma code_seg(".lcd_ui_return_page.text")
|
||||
#endif
|
||||
|
||||
#if (defined(CONFIG_JL_UI_ENABLE) && CONFIG_JL_UI_ENABLE)
|
||||
|
||||
#include "jlui_app/ui_app_effect.h"
|
||||
#include "jlgpu_math.h"
|
||||
#include "gpu_port.h"
|
||||
#include "gpu_task.h"
|
||||
|
||||
|
||||
/**********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define PAGE_RETURN_MAX 16 // 最大回溯记录
|
||||
#define PAGE_PREEMPTION_MAX 8 // 最大抢占记录
|
||||
|
||||
#define UI_RET_PAGE_LOCK() spin_lock(&ui_ret_page_lock)
|
||||
#define UI_RET_PAGE_UNLOCK() spin_unlock(&ui_ret_page_lock)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
*********************/
|
||||
struct ui_page_preemption {
|
||||
int page;
|
||||
int (*entry)(int); // 返回true,entry回调里面自定义处理;返回false或者回调为NULL,默认显示page
|
||||
int (*exit)(int); // 返回true,exit回调里面自定义处理;返回false或者回调为NULL,默认清除记录
|
||||
u8 priority;
|
||||
};
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
*********************/
|
||||
static int page_return_tab[PAGE_RETURN_MAX];
|
||||
static u8 return_index = 0;
|
||||
static struct ui_page_preemption page_preemption[PAGE_PREEMPTION_MAX];
|
||||
DEFINE_SPINLOCK(ui_ret_page_lock);
|
||||
|
||||
|
||||
void ui_return_page_hump(void)
|
||||
{
|
||||
log_debug("return_index:%d \n", return_index);
|
||||
for (int i = 0; i < return_index; i++) {
|
||||
log_debug("page[%d]:0x%x %d\n", i, page_return_tab[i], ui_id2page(page_return_tab[i]));
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================//
|
||||
// @brief:用于处理当前页面左右滑动时是返回上一级页面还是直接滑屏切换页面
|
||||
//=================================================================================//
|
||||
u8 ui_return_page_pop(u8 dir)
|
||||
{
|
||||
|
||||
UI_RET_PAGE_LOCK();
|
||||
log_debug("ui_return_page_pop:%d \n", return_index);
|
||||
if (return_index == 1) { //pop[index-1]当前,pop[index-2]上一页
|
||||
if (ui_get_current_window_id() == page_return_tab[return_index - 1]) {
|
||||
log_debug("cur:%x next:%x", ui_get_current_window_id(), page_return_tab[return_index - 1]);
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
if (return_index) {
|
||||
return_index--;
|
||||
}
|
||||
if (return_index) {
|
||||
int ret_page = page_return_tab[return_index - 1];
|
||||
#if TCFG_CHARGE_ENABLE
|
||||
if (ret_page == ID_WINDOW_BEDSIDE_WATCH || ret_page == ID_WINDOW_BATCHARGE) {
|
||||
extern u8 get_charge_online_flag(void);
|
||||
if (!get_charge_online_flag()) { //不在充电时,过滤床头时钟或者充电页面
|
||||
if (return_index) {
|
||||
return_index--;
|
||||
}
|
||||
if (return_index) {
|
||||
ret_page = page_return_tab[return_index - 1];
|
||||
} else {
|
||||
ret_page = ID_WINDOW_DIAL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
if (ui_return_page_effect_init(ret_page)) {
|
||||
ui_hide_curr_main();
|
||||
ui_show_main(ret_page);
|
||||
}
|
||||
return 1; //返回
|
||||
} else {
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
UI_SHOW_WINDOW(ID_WINDOW_DEFAULT);
|
||||
/* ui_send_event(KEY_CHANGE_PAGE, dir); */
|
||||
return 2; //滑屏
|
||||
}
|
||||
}
|
||||
//=================================================================================//
|
||||
// @brief:返回到指定页面
|
||||
//=================================================================================//
|
||||
int ui_return_page_pop_spec(u32 page_id)
|
||||
{
|
||||
UI_RET_PAGE_LOCK();
|
||||
for (int i = 0; i < return_index; i++) {
|
||||
if (page_return_tab[i] == page_id) { // 查找是否有指定页面
|
||||
return_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
ui_hide_curr_main();
|
||||
ui_show_main(page_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=================================================================================//
|
||||
// @brief:用于获取下一个页面的id
|
||||
//=================================================================================//
|
||||
u32 ui_return_page_id(void)
|
||||
{
|
||||
u32 ret_page = 0;
|
||||
UI_RET_PAGE_LOCK();
|
||||
if (return_index) {
|
||||
ret_page = page_return_tab[return_index - 1];
|
||||
}
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return ret_page;
|
||||
}
|
||||
|
||||
//=================================================================================//
|
||||
// @brief:用于获取上一个页面的id
|
||||
//=================================================================================//
|
||||
u32 ui_return_prev_page_id(void)
|
||||
{
|
||||
u32 ret_page = 0;
|
||||
UI_RET_PAGE_LOCK();
|
||||
if (return_index > 1) {
|
||||
ret_page = page_return_tab[return_index - 2];
|
||||
}
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return ret_page;
|
||||
}
|
||||
|
||||
//=================================================================================//
|
||||
// @brief:用于处理页面返回时,返回的页面存储在page_return_tab
|
||||
//=================================================================================//
|
||||
void ui_return_page_push(int page_id)
|
||||
{
|
||||
u32 rets;//, reti;
|
||||
__asm__ volatile("%0 = rets":"=r"(rets));
|
||||
log_debug("ui_return_page_push:%d, 0x%x \n", return_index, page_id);
|
||||
|
||||
UI_RET_PAGE_LOCK();
|
||||
#if 0
|
||||
// 检查所有
|
||||
for (int i = 0; i < return_index; i++) {
|
||||
if (page_return_tab[i] == page_id) {
|
||||
return_index = i + 1;
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
log_debug("ui_return_page_push, same id[%d]:0x%x, rets =%x\n", i, page_id, rets);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// 检查最后一个
|
||||
if (return_index) {
|
||||
if (page_return_tab[return_index - 1] == page_id) {
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
log_debug("ui_return_page_push, same id[%d]:0x%x, rets =%x\n", return_index - 1, page_id, rets);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (return_index == PAGE_RETURN_MAX) {
|
||||
log_error("ui_return_page_push over rets =%x,id =%x\n", rets, page_id);
|
||||
for (int i = 0; i < return_index; i++) {
|
||||
log_debug("[%d],id =%x\n", i, page_return_tab[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < return_index; i++) {
|
||||
for (int j = i + 1; j < return_index; j++) {
|
||||
if (page_return_tab[i] == page_return_tab[j]) {
|
||||
memcpy(&page_return_tab[i], &page_return_tab[j], return_index - j);
|
||||
return_index -= (j - i);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < return_index; i++) {
|
||||
log_debug("out [%d],id =%x\n", i, page_return_tab[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RELEASE_ENABLE
|
||||
if (return_index == PAGE_RETURN_MAX) {
|
||||
return_index--;
|
||||
}
|
||||
#endif
|
||||
|
||||
page_return_tab[return_index] = page_id;
|
||||
return_index++;
|
||||
|
||||
ASSERT(return_index <= PAGE_RETURN_MAX);
|
||||
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
|
||||
ui_return_page_hump();
|
||||
}
|
||||
//=================================================================================//
|
||||
// @brief:用于清除页面返回记录
|
||||
//=================================================================================//
|
||||
void ui_return_page_clear()
|
||||
{
|
||||
UI_RET_PAGE_LOCK();
|
||||
return_index = 0;
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
}
|
||||
//=================================================================================//
|
||||
// @brief:用于删除页面返回记录
|
||||
//=================================================================================//
|
||||
void ui_return_page_del(int page_id)
|
||||
{
|
||||
UI_RET_PAGE_LOCK();
|
||||
for (int i = 0; i < return_index; i++) {
|
||||
if (page_return_tab[i] == page_id) {
|
||||
u8 offset = 1;
|
||||
if (i < (return_index - 1)) {
|
||||
if (i > 1) {
|
||||
if (page_return_tab[i - 1] == page_return_tab[i + 1]) {
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
for (; i < return_index - offset; i++) {
|
||||
page_return_tab[i] = page_return_tab[i + offset];
|
||||
}
|
||||
}
|
||||
return_index -= offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
}
|
||||
//=================================================================================//
|
||||
// @brief:跳转到指定page,清空之后的page
|
||||
//=================================================================================//
|
||||
void ui_return_page_jump(int page_id, u8 clear_self)
|
||||
{
|
||||
UI_RET_PAGE_LOCK();
|
||||
for (int i = 0; i < return_index; i++) {
|
||||
if (page_return_tab[i] == page_id) {
|
||||
if (clear_self) { // 清除本身
|
||||
return_index = i;
|
||||
} else { // 保留
|
||||
return_index = i + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
}
|
||||
//=================================================================================//
|
||||
// @brief:用于从page_return_tab表中回退1
|
||||
//=================================================================================//
|
||||
u8 ui_return_page_sub(void)
|
||||
{
|
||||
u8 index = 0;
|
||||
UI_RET_PAGE_LOCK();
|
||||
if (return_index) {
|
||||
return_index--;
|
||||
index = return_index;
|
||||
}
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return index;
|
||||
}
|
||||
|
||||
#if (defined CONFIG_UI_STYLE_JL_CSC_PUBLIC_MODLS_ENABLE)
|
||||
u8 ui_return_page_add(int page_id)
|
||||
{
|
||||
u8 index = 0;
|
||||
UI_RET_PAGE_LOCK();
|
||||
page_return_tab[return_index] = page_id;
|
||||
return_index++;
|
||||
index = return_index;
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return index;
|
||||
}
|
||||
#endif
|
||||
|
||||
//=================================================================================//
|
||||
// @brief:ui_window弱函数重定义
|
||||
//=================================================================================//
|
||||
int ui_window_event_deal(void *ctr, struct element_touch_event *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case ELM_EVENT_TOUCH_R_MOVE: {
|
||||
// 返回上一个page
|
||||
struct window *window = (struct window *)ctr;
|
||||
log_info("win[0x%x] rmove \n", window->elm.id);
|
||||
UI_RET_PAGE_LOCK();
|
||||
int preempt_page = page_preemption[0].page;
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
if (preempt_page == window->elm.id) { // 打断返回
|
||||
ui_preemption_page_pop(window->elm.id);
|
||||
} else {
|
||||
ui_return_page_pop(2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ui_preemption_page_hump(void)
|
||||
{
|
||||
log_debug("preempt page hump \n");
|
||||
for (int i = 0; i < PAGE_PREEMPTION_MAX; i++) {
|
||||
if (page_preemption[i].page == 0) {
|
||||
break;
|
||||
}
|
||||
log_debug("pree[%d] : 0x%x \n", i, page_preemption[i].page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================//
|
||||
// @brief: 判断是否有抢断page
|
||||
//=================================================================================//
|
||||
int ui_preemption_page_check(void)
|
||||
{
|
||||
int ret = false;
|
||||
UI_RET_PAGE_LOCK();
|
||||
if (page_preemption[0].page) {
|
||||
/* ret = true; */
|
||||
ret = page_preemption[0].page;
|
||||
}
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return ret;
|
||||
}
|
||||
|
||||
//=================================================================================//
|
||||
// @brief: 清空抢断记录
|
||||
//=================================================================================//
|
||||
void ui_preemption_page_clean(void)
|
||||
{
|
||||
UI_RET_PAGE_LOCK();
|
||||
page_preemption[0].page = 0;
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
}
|
||||
|
||||
//=================================================================================//
|
||||
// @brief: 删除抢断记录
|
||||
//=================================================================================//
|
||||
int ui_preemption_page_del(int page_id)
|
||||
{
|
||||
int i;
|
||||
UI_RET_PAGE_LOCK();
|
||||
for (i = 0; i < PAGE_PREEMPTION_MAX; i++) {
|
||||
if (page_preemption[i].page == 0) { // 最后记录
|
||||
break;
|
||||
}
|
||||
if (page_preemption[i].page == page_id) {
|
||||
for (; i < PAGE_PREEMPTION_MAX - 1; i++) {
|
||||
memcpy(&page_preemption[i], &page_preemption[i + 1], sizeof(struct ui_page_preemption));
|
||||
}
|
||||
page_preemption[i].page = 0;
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================//
|
||||
// @brief:推送一个抢断页面
|
||||
// 可以显示时通过entry()回调执行
|
||||
//=================================================================================//
|
||||
int ui_preemption_page_push(int page_id, int (*entry)(int), int (*exit)(int), u8 priority)
|
||||
{
|
||||
u32 rets;//, reti;
|
||||
__asm__ volatile("%0 = rets":"=r"(rets));
|
||||
log_debug("__func__ %s %x page_id:%x\n", __func__, rets, page_id);
|
||||
ui_return_page_effect_set_en(false);
|
||||
int i;
|
||||
struct ui_page_preemption push_pree = {0};
|
||||
struct ui_page_preemption exit_page = {0};
|
||||
push_pree.page = page_id;
|
||||
push_pree.entry = entry;
|
||||
push_pree.exit = exit;
|
||||
push_pree.priority = priority;
|
||||
UI_RET_PAGE_LOCK();
|
||||
__match:
|
||||
for (i = 0; i < PAGE_PREEMPTION_MAX; i++) {
|
||||
if (page_preemption[i].page == 0) { // 最后记录
|
||||
break;
|
||||
}
|
||||
if (page_preemption[i].page == page_id) { // 已经有记录
|
||||
if (page_preemption[i].priority == priority) { // 优先级相同
|
||||
memcpy(&page_preemption[i], &push_pree, sizeof(struct ui_page_preemption));
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return false;
|
||||
} else { // 删除重新匹配
|
||||
for (; i < PAGE_PREEMPTION_MAX - 1; i++) {
|
||||
memcpy(&page_preemption[i], &page_preemption[i + 1], sizeof(struct ui_page_preemption));
|
||||
}
|
||||
page_preemption[i].page = 0;
|
||||
goto __match;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (page_preemption[i].priority < priority) { // 优先级更低
|
||||
break;
|
||||
}
|
||||
}
|
||||
log_debug("[%s] i:%d", __func__, i);
|
||||
if (i >= PAGE_PREEMPTION_MAX) {
|
||||
log_error("page preempt full !!! \n");
|
||||
i = PAGE_PREEMPTION_MAX - 1; // 覆盖最后一个
|
||||
}
|
||||
// 重新排序
|
||||
for (int j = PAGE_PREEMPTION_MAX - 1; j > i; j--) {
|
||||
memcpy(&page_preemption[j], &page_preemption[j - 1], sizeof(struct ui_page_preemption));
|
||||
}
|
||||
memcpy(&page_preemption[i], &push_pree, sizeof(struct ui_page_preemption));
|
||||
// 是否有抢断
|
||||
if (i == 0) {
|
||||
memcpy(&exit_page, &page_preemption[1], sizeof(struct ui_page_preemption));
|
||||
}
|
||||
ui_preemption_page_hump();
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
|
||||
// 被打断的page处理
|
||||
if (exit_page.page) {
|
||||
int ret = false;
|
||||
if (exit_page.exit) {
|
||||
ret = exit_page.exit(push_pree.page);
|
||||
}
|
||||
if (ret == false) { // 删除记录
|
||||
ui_preemption_page_del(exit_page.page);
|
||||
}
|
||||
// 跳转到打断时的page
|
||||
ui_return_page_jump(exit_page.page, 1);
|
||||
}
|
||||
|
||||
if (i == 0) { // 处在最前面,可以执行
|
||||
int ret = false;
|
||||
if (push_pree.entry) {
|
||||
ret = push_pree.entry(push_pree.page);
|
||||
}
|
||||
if (ret == false) { // 显示
|
||||
ui_hide_curr_main();
|
||||
ui_show_main(push_pree.page);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=================================================================================//
|
||||
// @brief:退出一个抢断页面
|
||||
// 如果正在执行,会调用exit()回调
|
||||
//=================================================================================//
|
||||
int ui_preemption_page_pop(int page_id)
|
||||
{
|
||||
int i;
|
||||
struct ui_page_preemption entry_page = {0};
|
||||
struct ui_page_preemption exit_page = {0};
|
||||
UI_RET_PAGE_LOCK();
|
||||
if (page_preemption[0].page == 0) { // 没有记录
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
return false;
|
||||
}
|
||||
if (page_preemption[0].page != page_id) { // 不是第一个,删除记录就可以
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
ui_preemption_page_del(page_id);
|
||||
return true;
|
||||
}
|
||||
memcpy(&exit_page, &page_preemption[0], sizeof(struct ui_page_preemption));
|
||||
// 重排序
|
||||
for (i = 0; i < PAGE_PREEMPTION_MAX - 1; i++) {
|
||||
memcpy(&page_preemption[i], &page_preemption[i + 1], sizeof(struct ui_page_preemption));
|
||||
}
|
||||
page_preemption[i].page = 0;
|
||||
memcpy(&entry_page, &page_preemption[0], sizeof(struct ui_page_preemption));
|
||||
ui_preemption_page_hump();
|
||||
UI_RET_PAGE_UNLOCK();
|
||||
|
||||
// 退出当前的page
|
||||
int ret;
|
||||
if (exit_page.exit) {
|
||||
exit_page.exit(exit_page.page);
|
||||
}
|
||||
|
||||
// 有可以执行的page处理
|
||||
if (entry_page.page) {
|
||||
// 跳转到打断时的page
|
||||
ui_return_page_jump(exit_page.page, 1);
|
||||
|
||||
ret = false;
|
||||
if (entry_page.entry) {
|
||||
ret = entry_page.entry(entry_page.page);
|
||||
}
|
||||
if (ret == false) { // 显示
|
||||
ui_hide_curr_main();
|
||||
ui_show_main(entry_page.page);
|
||||
}
|
||||
} else { // 没有就显示回正常的处理
|
||||
// 跳转到打断时的page
|
||||
ui_return_page_jump(exit_page.page, 0);
|
||||
|
||||
// 回溯
|
||||
ui_return_page_pop(2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if (defined CONFIG_UI_STYLE_JL_CSC_PUBLIC_MODLS_ENABLE)
|
||||
extern bool cpc_is_card_page(int mem_id);
|
||||
/**
|
||||
* @brief 彩屏仓接口,针对弹窗应用场景,比如充电页面,开关盖页面
|
||||
* 在卡片页面弹出时候,再返回时,还可以返回当前卡片页面
|
||||
*
|
||||
* @param page_id
|
||||
*/
|
||||
void cs_ui_popup_page(u32 page_id)
|
||||
{
|
||||
u32 rets;//, reti;
|
||||
__asm__ volatile("%0 = rets":"=r"(rets));
|
||||
log_info("cs_ui_popup_page rets:%x page_id:%x\n", rets, page_id);
|
||||
u32 cur_id = UI_GET_WINDOW_ID();
|
||||
if (cpc_is_card_page(cur_id)) {
|
||||
/*如果当前页面是卡片页面,则是压栈进入page_return_tab
|
||||
后面则返回该页面 */
|
||||
ui_return_page_push(cur_id);
|
||||
}
|
||||
|
||||
UI_HIDE_CURR_WINDOW();
|
||||
UI_SHOW_WINDOW(page_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #if (defined(CONFIG_JL_UI_ENABLE)) */
|
||||
|
||||
Reference in New Issue
Block a user