206 lines
5.8 KiB
C
206 lines
5.8 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_camera_t_ {
|
||
u32 enter_tick;
|
||
} f_camera_t;
|
||
|
||
enum {
|
||
COMPO_ID_BTN_CAMERA = 1,
|
||
};
|
||
|
||
/* 拍照界面亮屏最小时间 */
|
||
#define FUNC_CAMERA_SHOW_MIN_TIME 600 // 60s
|
||
static u32 camera_temp_sleep_time = 0;
|
||
|
||
//创建相机窗体,创建窗体中不要使用功能结构体 func_cb.f_cb
|
||
compo_form_t *func_camera_form_create(void)
|
||
{
|
||
//新建窗体和背景
|
||
compo_form_t *frm = compo_form_create(true);
|
||
|
||
//设置标题栏
|
||
compo_form_set_mode(frm, COMPO_FORM_MODE_SHOW_TITLE | COMPO_FORM_MODE_SHOW_TIME);
|
||
compo_form_set_title(frm, i18n[STR_CAMERA]);
|
||
if((SysVariable.ble_state == TRUE))
|
||
{
|
||
compo_form_add_image(frm, UI_BUF_CAMERA_CAMERA_BIN, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y+ 5);
|
||
}
|
||
else{
|
||
compo_form_add_image(frm, UI_BUF_CAMERA_ICON_CAMERA_BIN, GUI_SCREEN_CENTER_X-3, GUI_SCREEN_CENTER_Y-13);
|
||
//创建文本
|
||
compo_textbox_t *txt = compo_textbox_create(frm, 110);
|
||
// compo_textbox_set_align_center(txt, true);
|
||
compo_textbox_set_multiline(txt, true);
|
||
compo_textbox_set_location(txt, GUI_SCREEN_CENTER_X, 125,106,45);
|
||
compo_textbox_set_autosize(txt, false);
|
||
compo_textbox_set_autoroll_mode(txt, TEXT_AUTOROLL_MODE_SROLL_CIRC);
|
||
compo_textbox_set(txt, i18n[STR_CONNECT_PHONE]);//STR_CAMERA_DISCONNECTION
|
||
}
|
||
|
||
|
||
//创建按钮
|
||
compo_button_t *btn = compo_button_create(frm);
|
||
compo_setid(btn, COMPO_ID_BTN_CAMERA);
|
||
compo_button_set_location(btn, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y+ 5, 54, 54);
|
||
// //新建按钮
|
||
// compo_button_t *btn;
|
||
// btn = compo_button_create_by_image(frm, UI_BUF_COMMON_BUTTON_BIN);
|
||
// compo_button_set_pos(btn, 160, 336);
|
||
|
||
//创建文本
|
||
// compo_textbox_t *txt = compo_textbox_create(frm, 110);
|
||
// // compo_textbox_set_align_center(txt, true);
|
||
// compo_textbox_set_multiline(txt, false);
|
||
// compo_textbox_set_location(txt, 120, 115,100,20);
|
||
// compo_textbox_set_autosize(txt, false);
|
||
// compo_textbox_set_autoroll_mode(txt, TEXT_AUTOROLL_MODE_SROLL_CIRC);
|
||
// compo_textbox_set(txt, i18n[STR_CAMERA_DISCONNECTION]);
|
||
return frm;
|
||
}
|
||
|
||
|
||
//按键事件处理
|
||
static void func_camera_click(void)
|
||
{
|
||
int id = compo_get_button_id();
|
||
switch (id) {
|
||
case COMPO_ID_BTN_CAMERA:
|
||
if(ble_is_connected()){
|
||
printf("COMPO_ID_BTN_CAMERA");
|
||
sys_cb.motor_flag = 1;
|
||
set_func_motor(80,2,2,1);
|
||
PROTOCOL_TaskPhoto_Start();
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
// compo_form_add_image(frm, UI_BUF_CAMERA_ICON_CAMERA_BIN, GUI_SCREEN_CENTER_X-10, GUI_SCREEN_CENTER_Y-25);
|
||
|
||
// static void func_camera_animation(void)
|
||
// {
|
||
// f_camera_t *f_logo_switching = (f_camera_t *)func_cb.f_cb;
|
||
// if(tick_check_expire(func_cb.enter_tick, 5000)) {
|
||
// func_cb.sta = FUNC_CLOCK;
|
||
// }
|
||
// }
|
||
//相机功能事件处理
|
||
static void func_camera_process(void)
|
||
{
|
||
// func_camera_animation();
|
||
func_process();
|
||
}
|
||
|
||
/* true:公共处理占用中,false:空闲 */
|
||
volatile bool camera_event_state = false;
|
||
volatile bool func_camera_sta_get(void)
|
||
{
|
||
return camera_event_state;
|
||
}
|
||
|
||
//相机功能消息处理
|
||
static void func_camera_message(size_msg_t msg)
|
||
{
|
||
switch (msg) {
|
||
case MSG_CTP_CLICK:
|
||
func_camera_click();
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_UP:
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_DOWN:
|
||
break;
|
||
|
||
case MSG_CTP_LONG:
|
||
break;
|
||
case KU_BACK:
|
||
camera_event_state = true;
|
||
func_back_to();
|
||
camera_event_state = false;
|
||
break;
|
||
case MSG_CTP_SHORT_LEFT:
|
||
case MSG_CTP_SHORT_RIGHT:
|
||
camera_event_state = true;
|
||
func_message(msg);
|
||
camera_event_state = false;
|
||
break;
|
||
|
||
default:
|
||
func_message(msg);
|
||
break;
|
||
}
|
||
}
|
||
|
||
//进入相机功能
|
||
static void func_camera_enter(void)
|
||
{
|
||
func_cb.f_cb = func_zalloc(sizeof(f_camera_t));
|
||
func_cb.frm_main = func_camera_form_create();
|
||
// func_cb.enter_tick = tick_get();
|
||
if(ble_is_connected()){
|
||
SysVariable.rockFlag = true;
|
||
DeviveControlAppOpenCamera(DEV_CAMERA_OPEN);
|
||
}
|
||
}
|
||
|
||
//退出相机功能
|
||
static void func_camera_exit(void)
|
||
{
|
||
SysVariable.rockFlag = false;
|
||
|
||
/* 临时更改过亮屏时间,恢复原本时间 */
|
||
if (camera_temp_sleep_time) {
|
||
SysVariable.sleep_time = camera_temp_sleep_time;
|
||
SysVariable.guioff_delay = SysVariable.sleep_time;
|
||
SysVariable.sleep_delay = SysVariable.sleep_time;
|
||
}
|
||
|
||
if (SysVariable.password_allow_push)
|
||
SysVariable.password_allow_push = false;
|
||
|
||
DeviveControlAppOpenCamera(DEV_CAMERA_CLOSE);
|
||
func_cb.last = FUNC_CAMERA;
|
||
camera_event_state = false;
|
||
bsp_motor_stop(MOTOR_PORT);
|
||
}
|
||
|
||
//相机功能
|
||
void func_camera(void)
|
||
{
|
||
printf("%s\n", __func__);
|
||
func_camera_enter();
|
||
|
||
/* 如果亮屏时间小于一分钟,临时改成亮屏至少一分钟 */
|
||
if (SysVariable.sleep_time < FUNC_CAMERA_SHOW_MIN_TIME) {
|
||
camera_temp_sleep_time = SysVariable.sleep_time;
|
||
|
||
SysVariable.sleep_time = FUNC_CAMERA_SHOW_MIN_TIME;
|
||
SysVariable.guioff_delay = SysVariable.sleep_time;
|
||
SysVariable.sleep_delay = SysVariable.sleep_time;
|
||
} else {
|
||
camera_temp_sleep_time = 0;
|
||
}
|
||
|
||
while (func_cb.sta == FUNC_CAMERA) {
|
||
func_camera_process();
|
||
func_camera_message(msg_dequeue());
|
||
}
|
||
func_camera_exit();
|
||
}
|