134 lines
3.4 KiB
C
134 lines
3.4 KiB
C
#include "include.h"
|
||
#include "func.h"
|
||
#include "m_sportInfo.h"
|
||
#include "api.h"
|
||
#include "ancs_msg.h"
|
||
#include "m_storage.h"
|
||
#include "app_variable.h"
|
||
#if TRACE_EN
|
||
#define TRACE(...) printf(__VA_ARGS__)
|
||
#else
|
||
#define TRACE(...)
|
||
#endif
|
||
|
||
typedef struct f_keytest_t_ {
|
||
u32 enter_tick;
|
||
} f_keytest_t;
|
||
|
||
enum {
|
||
COMPO_ID_BTN_LEF = 1,
|
||
COMPO_ID_BTN_CEN,
|
||
COMPO_ID_BTN_RIG,
|
||
};
|
||
|
||
/* 工厂模式按键测试运行状态:true正在运行,false未在运行 */
|
||
static bool key_test_run_state = false;
|
||
static void func_key_test_run_state_set(bool state)
|
||
{
|
||
key_test_run_state = state;
|
||
}
|
||
|
||
static bool func_key_test_run_state_get(void)
|
||
{
|
||
return key_test_run_state;
|
||
}
|
||
|
||
compo_form_t *func_keytest_form_create(void)
|
||
{
|
||
|
||
compo_form_t *frm = compo_form_create(true);
|
||
|
||
compo_shape_t *rect = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,14);
|
||
compo_shape_set_color(rect,COLOR_RED);
|
||
compo_setid(rect, COMPO_ID_BTN_LEF);
|
||
compo_shape_set_location(rect, GUI_SCREEN_CENTER_X, 50+25, 216, 75);
|
||
|
||
compo_shape_t *rect1 = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,14);
|
||
compo_shape_set_color(rect1,COLOR_RED);
|
||
compo_setid(rect1, COMPO_ID_BTN_CEN);
|
||
compo_shape_set_location(rect1, GUI_SCREEN_CENTER_X, 130+25, 216, 75);
|
||
|
||
compo_shape_t *rect2 = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,14);
|
||
compo_shape_set_color(rect2,COLOR_RED);
|
||
compo_setid(rect2, COMPO_ID_BTN_RIG);
|
||
compo_shape_set_location(rect2, GUI_SCREEN_CENTER_X, 210+25, 216, 75);
|
||
return frm;
|
||
}
|
||
|
||
static void func_keytest_process(void)
|
||
{
|
||
func_process();
|
||
}
|
||
|
||
static void func_keytest_message(size_msg_t msg)
|
||
{
|
||
compo_shape_t *rect = compo_getobj_byid(COMPO_ID_BTN_LEF);
|
||
compo_shape_t *rect1 = compo_getobj_byid(COMPO_ID_BTN_CEN);
|
||
compo_shape_t *rect2 = compo_getobj_byid(COMPO_ID_BTN_RIG);
|
||
|
||
/* 检测窗体是否被外部改变,只允许用户主动改变退出 */
|
||
if (func_cb.sta != FUNC_SUB_KEY) {
|
||
func_cb.sta = FUNC_SUB_KEY;
|
||
}
|
||
|
||
switch (msg) {
|
||
case MSG_CTP_CLICK:
|
||
break;
|
||
case MSG_CTP_SHORT_UP:
|
||
break;
|
||
case KEY_RIGHT:
|
||
compo_shape_set_color(rect,COLOR_GREEN);
|
||
break;
|
||
case KEY_LEFT:
|
||
compo_shape_set_color(rect1,COLOR_GREEN);
|
||
break;
|
||
case KEY_BACK:
|
||
compo_shape_set_color(rect2,COLOR_GREEN);
|
||
break;
|
||
case MSG_CTP_SHORT_RIGHT:
|
||
func_message(msg);
|
||
|
||
/* 右滑退出厂测模式 */
|
||
if (func_cb.sta == FUNC_FACTORY_TEST) {
|
||
func_key_test_run_state_set(false);
|
||
}
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_DOWN:
|
||
break;
|
||
|
||
case MSG_CTP_LONG:
|
||
break;
|
||
|
||
default:
|
||
// func_message(msg);
|
||
break;
|
||
}
|
||
}
|
||
|
||
static void func_keytest_enter(void)
|
||
{
|
||
func_cb.f_cb = func_zalloc(sizeof(f_keytest_t));
|
||
func_cb.frm_main = func_keytest_form_create();
|
||
}
|
||
|
||
static void func_keytest_exit(void)
|
||
{
|
||
func_cb.last = FUNC_SUB_KEY;
|
||
}
|
||
|
||
void func_keytest(void)
|
||
{
|
||
printf("%s\n", __func__);
|
||
func_keytest_enter();
|
||
|
||
/* 按键测试过程除用户主动退出外 不响应外部窗体切换 */
|
||
func_key_test_run_state_set(true);
|
||
|
||
while (func_key_test_run_state_get()) {
|
||
func_keytest_process();
|
||
func_keytest_message(msg_dequeue());
|
||
}
|
||
func_keytest_exit();
|
||
}
|