feat: 增加软件复位菜单和主程序侧键复位功能
虽然侧键和硬件复位按键一样难按2333
This commit is contained in:
@@ -132,6 +132,7 @@ void Page_Init(void)
|
||||
PAGE_REG(page_param1, "Param1");
|
||||
PAGE_REG(page_param2, "param2");
|
||||
PAGE_REG(page_dparam, "dparam");
|
||||
PAGE_REG(page_reset, "reset");
|
||||
// PAGE_REG(page_argv);
|
||||
// PAGE_REG(page_sys);
|
||||
// PAGE_REG(page_run);
|
||||
|
||||
@@ -23,6 +23,7 @@ enum PageID {
|
||||
page_param1,
|
||||
page_param2,
|
||||
page_dparam,
|
||||
page_reset,
|
||||
// page_argv,
|
||||
// page_sys,
|
||||
// page_run,
|
||||
@@ -35,6 +36,7 @@ typedef enum page_event {
|
||||
page_event_backward = button_event_down,
|
||||
page_event_press_short = button_event_center_sp,
|
||||
page_event_press_long = button_event_center_lp,
|
||||
page_event_side = button_event_side,
|
||||
} page_event;
|
||||
|
||||
typedef void (*CallbackFunction_t)(void);
|
||||
@@ -53,8 +55,7 @@ typedef struct {
|
||||
extern void PageRegister_##_name_(unsigned char pageID); \
|
||||
PageRegister_##_name_(_name_); \
|
||||
} while (0); \
|
||||
pagelist[_name_].Text = _text_ ;
|
||||
|
||||
pagelist[_name_].Text = _text_;
|
||||
|
||||
void Page_Register(uint8_t pageID,
|
||||
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
||||
|
||||
@@ -64,6 +64,9 @@ static void Event(page_event event)
|
||||
if (page_max > Curser && page_menu < Curser) {
|
||||
Page_Shift(Curser); // 切换到光标选中的页面
|
||||
}
|
||||
} else if (page_event_side == event) {
|
||||
// 主菜单长按产生软件复位
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
if (Curser < LINE_HEAD) {
|
||||
|
||||
100
app/page/page_reset.c
Normal file
100
app/page/page_reset.c
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "page.h"
|
||||
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END 7
|
||||
|
||||
static char Text[] = "Reset";
|
||||
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
static void Print_Menu_p(void);
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 页面初始化事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
ips200_clear();
|
||||
Print_Menu_p();
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面退出事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面循环执行的内容
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面事件
|
||||
* @param btn:发出事件的按键
|
||||
* @param event:事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
static void Event(page_event event)
|
||||
{
|
||||
Curser_Last = Curser;
|
||||
|
||||
if (page_event_forward == event) {
|
||||
// Curser++; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
// Curser--; // 光标下移
|
||||
} else if (page_event_press_long == event) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = LINE_END;
|
||||
} else if (Curser > LINE_END) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
*
|
||||
* @param pageID
|
||||
*/
|
||||
void PageRegister_page_reset(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Setup, Loop, Exit, Event);
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面自定义功能函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 打印菜单项
|
||||
*
|
||||
*/
|
||||
static void Print_Menu_p(void)
|
||||
{
|
||||
ips200_show_string(0, 0, Text);
|
||||
ips200_show_string(20, 20, "Long Press to Reset");
|
||||
}
|
||||
Reference in New Issue
Block a user