797 lines
28 KiB
C
797 lines
28 KiB
C
#include "include.h"
|
|
#include "func.h"
|
|
#include "m_sportInfo.h"
|
|
#include "app_variable.h"
|
|
|
|
#if TRACE_EN
|
|
#define TRACE(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define TRACE(...)
|
|
#endif
|
|
|
|
typedef int (*chart_data_get)(uint8_t param);
|
|
|
|
/* 总页面数 */
|
|
#define ACTIVITY_PAGE_TOTAL_NUM (4)
|
|
|
|
/* 圆弧相关参数 */
|
|
#define ACTIVITY_ARC_WIDTH (24)
|
|
#define ACTIVITY_ARC_STEP_SIZE (204)
|
|
#define ACTIVITY_ARC_HEAT_SIZE (148)
|
|
#define ACTIVITY_ARC_TIME_SIZE (92)
|
|
|
|
#define ACTIVITY_ARC_ANIM_LOADING_STEP (1 << 0)
|
|
#define ACTIVITY_ARC_ANIM_LOADING_HEAT (1 << 1)
|
|
#define ACTIVITY_ARC_ANIM_LOADING_TIME (1 << 2)
|
|
#define ACTIVITY_ARC_ANIM_LOADING_COMPLETE (ACTIVITY_ARC_ANIM_LOADING_STEP | ACTIVITY_ARC_ANIM_LOADING_HEAT | ACTIVITY_ARC_ANIM_LOADING_TIME)
|
|
|
|
/* 图表相关参数 */
|
|
#define ACTIVITY_CHART_START_X (22) // 图表起始X轴坐标
|
|
#define ACTIVITY_CHART_START_Y (100) // 图表起始Y轴坐标
|
|
#define ACTIVITY_CHART_RADIUS (2) // 图表打点柱子圆角
|
|
#define ACTIVITY_CHART_BAR_WIDTH (4) // 图表柱子宽度
|
|
#define ACTIVITY_CHART_BAR_HEIGHT (88) // 图表柱子高度
|
|
#define ACTIVITY_CHART_COLUMN_MAX (24) // 图表打点数据每小时一根
|
|
|
|
/* 页面坐标参数 */
|
|
#define TITLE_TXT_X (180)
|
|
#define TIME_UNIT_TXT_X (24)
|
|
#define TIME_UNIT_TXT_Y ((GUI_SCREEN_HEIGHT * 3) + 252)
|
|
|
|
/* 组件ID */
|
|
enum
|
|
{
|
|
/* 标题时间更新 */
|
|
COMPO_ID_TITLE_TIME = 0x01,
|
|
COMPO_ID_TITLE_STEP_TIME,
|
|
COMPO_ID_TITLE_HEAT_TIME,
|
|
COMPO_ID_TITLE_MINU_TIME,
|
|
|
|
/* 圆弧数据 */
|
|
COMPO_ID_ARC_STEP = 0x10,
|
|
COMPO_ID_ARC_HEAT,
|
|
COMPO_ID_ARC_TIME,
|
|
|
|
/* 文本数据 */
|
|
COMPO_ID_TXT_STEP = 0x20,
|
|
COMPO_ID_TXT_HEAT,
|
|
COMPO_ID_TXT_TIME,
|
|
COMPO_ID_TXT_TIME_UNIT,
|
|
};
|
|
|
|
/* 页面ID */
|
|
typedef enum
|
|
{
|
|
ACTIVITY_PAGE_MAIN = 0x01,
|
|
ACTIVITY_PAGE_STEP,
|
|
ACTIVITY_PAGE_HEAT,
|
|
ACTIVITY_PAGE_TIME,
|
|
} activity_page_e;
|
|
|
|
typedef struct f_activity_t_
|
|
{
|
|
/* 页面移动模块 */
|
|
page_tp_move_t *ptm;
|
|
|
|
/* 页面指示器 */
|
|
widget_icon_t *indicator[ACTIVITY_PAGE_TOTAL_NUM];
|
|
|
|
/* 步数图表 */
|
|
widget_rect_t *step_rect[ACTIVITY_CHART_COLUMN_MAX];
|
|
|
|
/* 热量图表 */
|
|
widget_rect_t *heat_rect[ACTIVITY_CHART_COLUMN_MAX];
|
|
|
|
/* 运动时间图表 */
|
|
widget_rect_t *time_rect[ACTIVITY_CHART_COLUMN_MAX];
|
|
|
|
/* 进场动画 */
|
|
u8 anim_loading_cnt;
|
|
u8 anim_loading_state;
|
|
u32 anim_loading_tick;
|
|
|
|
/* 页面数据刷新 */
|
|
u32 data_refresh_tick;
|
|
u32 indicator_refresh_tick;
|
|
} f_activity_t;
|
|
|
|
/*-----------------各项详细数据获取 START-----------------*/
|
|
#define FUNC_ACTIVITY_SIMULATE_DATA_EN 0
|
|
#if FUNC_ACTIVITY_SIMULATE_DATA_EN
|
|
static const uint8_t record_step[ACTIVITY_CHART_COLUMN_MAX] = {0, 0, 0, 0, 0, 125, 120, 111, 45, 150, 109, 231, 98, 198, 78, 98, 135, 88, 234, 0, 0, 0, 0, 0};
|
|
static const uint8_t record_heat[ACTIVITY_CHART_COLUMN_MAX] = {0, 0, 0, 0, 0, 12, 3, 111, 45, 26, 2, 26, 6, 26, 78, 0, 4, 88, 7, 0, 0, 0, 0, 0};
|
|
static const uint8_t record_time[ACTIVITY_CHART_COLUMN_MAX] = {0, 0, 0, 0, 0, 0, 16, 6, 0, 2, 1, 18, 0, 0, 0, 14, 6, 8, 0, 0, 0, 0, 0, 0};
|
|
#endif
|
|
|
|
static int step_record_data_get(uint8_t hour)
|
|
{
|
|
#if FUNC_ACTIVITY_SIMULATE_DATA_EN
|
|
return record_step[hour];
|
|
#else
|
|
return SysVariable.curSportRecord.RecordPedo[hour];
|
|
#endif
|
|
}
|
|
static int heat_record_data_get(uint8_t hour)
|
|
{
|
|
#if FUNC_ACTIVITY_SIMULATE_DATA_EN
|
|
return record_heat[hour];
|
|
#else
|
|
return SysVariable.curSportRecord.RecordCalorie[hour];
|
|
#endif
|
|
}
|
|
static int time_record_data_get(uint8_t hour)
|
|
{
|
|
#if FUNC_ACTIVITY_SIMULATE_DATA_EN
|
|
return record_time[hour];
|
|
#else
|
|
return SysVariable.curSportRecord.RecordTime[hour];
|
|
#endif
|
|
}
|
|
|
|
static int activity_step_data_get(void)
|
|
{
|
|
#if FUNC_ACTIVITY_SIMULATE_DATA_EN
|
|
return 8000;
|
|
#else
|
|
return SysVariable.curSportRecord.pedo;
|
|
#endif
|
|
}
|
|
static int activity_heat_data_get(void)
|
|
{
|
|
#if FUNC_ACTIVITY_SIMULATE_DATA_EN
|
|
return 268;
|
|
#else
|
|
return getCalorie(SysVariable.curSportRecord.pedo) / 1000;
|
|
#endif
|
|
}
|
|
static int activity_time_data_get(void)
|
|
{
|
|
#if FUNC_ACTIVITY_SIMULATE_DATA_EN
|
|
return 68;
|
|
#else
|
|
int minute = (SysVariable.pedoInfo.hour * 60) + SysVariable.pedoInfo.minute + (SysVariable.pedoInfo.second / 60);
|
|
|
|
return minute;
|
|
#endif
|
|
}
|
|
|
|
static uint8_t activity_step_percent_data_get(void)
|
|
{
|
|
int percent = activity_step_data_get() * 100 / SysVariable.curSportRecord.goalPedo;
|
|
|
|
if (percent >= 100) {
|
|
percent = 100;
|
|
}
|
|
return percent;
|
|
}
|
|
static uint8_t activity_heat_percent_data_get(void)
|
|
{
|
|
int percent = (activity_heat_data_get() * 100) / SysVariable.curSportRecord.goalCalorie;
|
|
|
|
if (percent >= 100) {
|
|
percent = 100;
|
|
}
|
|
return percent;
|
|
}
|
|
static uint8_t activity_time_percent_data_get(void)
|
|
{
|
|
int percent = (activity_time_data_get() * 100) / SysVariable.curSportRecord.goalTime;
|
|
|
|
if (percent >= 100) {
|
|
percent = 100;
|
|
}
|
|
return percent;
|
|
}
|
|
/*-----------------各项详细数据获取 END-----------------*/
|
|
|
|
static void func_activity_indicator_update(void)
|
|
{
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
|
|
if (f_activity->ptm->drag_flag == true) {
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < ACTIVITY_PAGE_TOTAL_NUM; i++) {
|
|
if (f_activity->indicator[i] == NULL) {
|
|
return;
|
|
}
|
|
widget_icon_set(f_activity->indicator[i], UI_BUF_ACTIVITY_UNSELECT_BIN);
|
|
}
|
|
|
|
int page_offset = compo_page_move_get_offset(f_activity->ptm) * -1;
|
|
int page_idx = page_offset / GUI_SCREEN_HEIGHT;
|
|
if (page_idx < 0 || page_idx >= ACTIVITY_PAGE_TOTAL_NUM) {
|
|
page_idx = 0;
|
|
}
|
|
widget_icon_set(f_activity->indicator[page_idx], UI_BUF_ACTIVITY_SELECT_BIN);
|
|
}
|
|
|
|
static void func_activity_indicator_create(compo_form_t *frm)
|
|
{
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
|
|
if (f_activity == NULL) {
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < ACTIVITY_PAGE_TOTAL_NUM; i++) {
|
|
f_activity->indicator[i] = widget_icon_create(frm->page, UI_BUF_ACTIVITY_UNSELECT_BIN);
|
|
widget_set_pos(f_activity->indicator[i], GUI_SCREEN_CENTER_X + 112, (GUI_SCREEN_CENTER_Y - (74 - i * 11)));
|
|
}
|
|
func_activity_indicator_update();
|
|
}
|
|
|
|
static void func_activity_title_create(compo_form_t *frm, activity_page_e page)
|
|
{
|
|
/* 时间 */
|
|
char text_buf[TEXTBOX_TEXT_BUF_LEN / 5] = {0};
|
|
if (SysVariable.deviceInfo.timeType == TIME_TYPE_12_HOUR)
|
|
sprintf(text_buf, "%02d:%02d%s", get_autoformat_hour(SysVariable.Rtc.hour), SysVariable.Rtc.min, SysVariable.Rtc.hour >= 12 ? "PM" : "AM");
|
|
else
|
|
sprintf(text_buf, "%02d:%02d", SysVariable.Rtc.hour, SysVariable.Rtc.min);
|
|
compo_textbox_t *txt_time = compo_textbox_create(frm, 8);
|
|
compo_textbox_set_align_center(txt_time, false);
|
|
compo_textbox_set_right_align(txt_time, true);
|
|
compo_textbox_set(txt_time, text_buf);
|
|
|
|
/* 标题文本 */
|
|
compo_textbox_t *txt_title = compo_textbox_create(frm, 30);
|
|
compo_textbox_set_align_center(txt_title, false);
|
|
|
|
if (page == ACTIVITY_PAGE_MAIN)
|
|
{
|
|
/* 设置标题文本 */
|
|
compo_textbox_set_location(txt_title, 28, 9, 100, 30);
|
|
compo_textbox_set(txt_title, i18n[STR_MOTION_DATA]);
|
|
|
|
/* 设置时间 */
|
|
compo_setid(txt_time, COMPO_ID_TITLE_TIME);
|
|
compo_textbox_set_location(txt_time, 122, 9, 90, 30);
|
|
}
|
|
else
|
|
{
|
|
int start_pos_y = GUI_SCREEN_HEIGHT * (page - ACTIVITY_PAGE_MAIN);
|
|
|
|
/* 设置标题ICON */
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_ICON_DATA_BIN, GUI_SCREEN_CENTER_X - 81, start_pos_y + (GUI_SCREEN_CENTER_Y - 104));
|
|
|
|
/* 设置标题文本 */
|
|
compo_textbox_set_location(txt_title, TITLE_TXT_X, start_pos_y + 42, 130, 30);
|
|
// compo_textbox_set_right_align(txt_title, true);
|
|
if (page == ACTIVITY_PAGE_STEP) {
|
|
compo_textbox_set_forecolor(txt_title, make_color(248, 21, 78));
|
|
compo_textbox_set(txt_title, i18n[STR_STEPS]);
|
|
} else if (page == ACTIVITY_PAGE_HEAT) {
|
|
compo_textbox_set_forecolor(txt_title, make_color(134, 242, 6));
|
|
compo_textbox_set(txt_title, i18n[STR_HEAT]);
|
|
} else {
|
|
compo_textbox_set_forecolor(txt_title, make_color(16, 255, 230));
|
|
compo_textbox_set(txt_title, i18n[STR_EXERCISE_DURATION]);
|
|
}
|
|
area_t rel_textbox_area = widget_text_get_box_area_rel(txt_title->txt);
|
|
area_t rel_text_area = widget_text_get_area(txt_title->txt);
|
|
if(rel_text_area.wid+TITLE_TXT_X>212)
|
|
{
|
|
u8 pos_x;
|
|
pos_x=rel_text_area.wid+TITLE_TXT_X-212;
|
|
if(pos_x>=98)
|
|
{
|
|
pos_x=98;
|
|
}
|
|
compo_textbox_set_pos(txt_title,TITLE_TXT_X-pos_x,start_pos_y + 42);
|
|
}
|
|
|
|
/* 设置时间 */
|
|
compo_setid(txt_time, COMPO_ID_TITLE_STEP_TIME + (page - ACTIVITY_PAGE_STEP));
|
|
compo_textbox_set_location(txt_time, 82, start_pos_y + 18, 130, 30);
|
|
}
|
|
}
|
|
|
|
/* 更新图标数据 */
|
|
static void func_activity_chart_data_update(activity_page_e page)
|
|
{
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
|
|
if (page > ACTIVITY_PAGE_TIME || page < ACTIVITY_PAGE_STEP) return;
|
|
|
|
uint32_t cur_goal = 0;
|
|
widget_rect_t **cur_rect = NULL;
|
|
chart_data_get cur_chart_data = NULL;
|
|
|
|
/* 初始化图表初始数据 */
|
|
if (page == ACTIVITY_PAGE_STEP) {
|
|
cur_rect = f_activity->step_rect;
|
|
cur_goal = SysVariable.curSportRecord.goalPedo;
|
|
cur_chart_data = step_record_data_get;
|
|
} else if (page == ACTIVITY_PAGE_HEAT) {
|
|
cur_goal = SysVariable.curSportRecord.goalCalorie;
|
|
cur_rect = f_activity->heat_rect;
|
|
cur_chart_data = heat_record_data_get;
|
|
} else {
|
|
cur_goal = SysVariable.curSportRecord.goalTime;
|
|
cur_rect = f_activity->time_rect;
|
|
cur_chart_data = time_record_data_get;
|
|
}
|
|
|
|
/* 坐标参数 */
|
|
u16 chart_x, chart_y;
|
|
u16 chart_offser_x[ACTIVITY_CHART_COLUMN_MAX / 6] = { 0, 3, 6, 9};
|
|
|
|
/* 计算起始位置 */
|
|
int start_pos_y = GUI_SCREEN_HEIGHT * (page - ACTIVITY_PAGE_MAIN) + ACTIVITY_CHART_START_Y;
|
|
|
|
for (u8 i = 0; i < ACTIVITY_CHART_COLUMN_MAX; i++)
|
|
{
|
|
if (cur_rect[i] == NULL) {
|
|
return;
|
|
}
|
|
|
|
/* 计算当前小时所占百分比: (当前小时步数 * 百分百) / (总目标数 / 24小时) */
|
|
int bar_hei_percent = (cur_chart_data(i) * 100) / (cur_goal / ACTIVITY_CHART_COLUMN_MAX);
|
|
if (bar_hei_percent >= 100) {
|
|
bar_hei_percent = 100;
|
|
}
|
|
|
|
u16 height = ACTIVITY_CHART_BAR_HEIGHT * bar_hei_percent / 100;
|
|
if (height <= 0) {
|
|
height = 1;
|
|
}
|
|
|
|
chart_x = (ACTIVITY_CHART_START_X + chart_offser_x[i / 6]) + (i * 8);
|
|
chart_y = start_pos_y + (ACTIVITY_CHART_BAR_HEIGHT - height);
|
|
widget_set_location(cur_rect[i], chart_x, chart_y, ACTIVITY_CHART_BAR_WIDTH, height);
|
|
}
|
|
}
|
|
|
|
/* 创建图表 */
|
|
static void func_activity_chart_create(compo_form_t *frm, activity_page_e page)
|
|
{
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
|
|
if (f_activity->step_rect == NULL || f_activity->heat_rect == NULL || f_activity->time_rect == NULL) {
|
|
return;
|
|
}
|
|
|
|
u16 color;
|
|
widget_rect_t **save_rect = NULL;
|
|
|
|
/* 各类型图表数据样式初始化 */
|
|
if (page == ACTIVITY_PAGE_STEP) {
|
|
color = make_color(250, 17, 79);
|
|
save_rect = f_activity->step_rect;
|
|
} else if (page == ACTIVITY_PAGE_HEAT) {
|
|
color = make_color(134, 242, 6);
|
|
save_rect = f_activity->heat_rect;
|
|
} else {
|
|
color = make_color(16, 255, 230);
|
|
save_rect = f_activity->time_rect;
|
|
}
|
|
|
|
/* 绘制图表 */
|
|
for (u8 i = 0; i < ACTIVITY_CHART_COLUMN_MAX; i++)
|
|
{
|
|
widget_rect_t *rect = widget_rect_create(frm->page_body);
|
|
widget_rect_set_color(rect, color);
|
|
widget_rect_set_radius(rect, ACTIVITY_CHART_RADIUS);
|
|
widget_set_align_center(rect, false);
|
|
|
|
save_rect[i] = rect;
|
|
}
|
|
}
|
|
|
|
static void func_activity_total_data_show(compo_form_t *frm)
|
|
{
|
|
/* 背景 */
|
|
compo_shape_t *shape_bg = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE, 57);
|
|
compo_shape_set_color(shape_bg, COLOR_BLACK);
|
|
compo_shape_set_location(shape_bg, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y, GUI_SCREEN_WIDTH, GUI_SCREEN_HEIGHT);
|
|
|
|
/* 创建标题栏信息 */
|
|
func_activity_title_create(frm, ACTIVITY_PAGE_MAIN);
|
|
|
|
/* 步数进度 */
|
|
compo_arc_t *arc = compo_arc_create(frm);
|
|
compo_setid(arc, COMPO_ID_ARC_STEP);
|
|
compo_arc_set_color(arc, make_color(252, 40, 40), make_color(92, 19, 19));
|
|
compo_arc_set_width(arc, ACTIVITY_ARC_WIDTH);
|
|
compo_arc_set_location(arc, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y + 10, ACTIVITY_ARC_STEP_SIZE, ACTIVITY_ARC_STEP_SIZE);
|
|
|
|
compo_arc_set_angles(arc, 0, 3600);
|
|
compo_arc_set_rotation(arc, 0);
|
|
compo_arc_set_edge_circle(arc, false, false);
|
|
compo_arc_set_value(arc, 0);
|
|
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_ICON_STEP_BIN, GUI_SCREEN_CENTER_X - 1, GUI_SCREEN_CENTER_Y - 79);
|
|
|
|
/* 热量进度 */
|
|
arc = compo_arc_create(frm);
|
|
compo_setid(arc, COMPO_ID_ARC_HEAT);
|
|
compo_arc_set_color(arc, make_color(108, 248, 0), make_color(60, 103, 26));
|
|
compo_arc_set_width(arc, ACTIVITY_ARC_WIDTH);
|
|
compo_arc_set_location(arc, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y + 10, ACTIVITY_ARC_HEAT_SIZE, ACTIVITY_ARC_HEAT_SIZE);
|
|
|
|
compo_arc_set_angles(arc, 0, 3600);
|
|
compo_arc_set_rotation(arc, 0);
|
|
compo_arc_set_edge_circle(arc, false, false);
|
|
compo_arc_set_value(arc, 0);
|
|
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_ICON_HEAT_BIN, GUI_SCREEN_CENTER_X - 1, GUI_SCREEN_CENTER_Y - 51);
|
|
|
|
/* 热量进度 */
|
|
arc = compo_arc_create(frm);
|
|
compo_setid(arc, COMPO_ID_ARC_TIME);
|
|
compo_arc_set_color(arc, make_color(16, 230, 233), make_color(35, 101, 105));
|
|
compo_arc_set_width(arc, ACTIVITY_ARC_WIDTH);
|
|
compo_arc_set_location(arc, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y + 10, ACTIVITY_ARC_TIME_SIZE, ACTIVITY_ARC_TIME_SIZE);
|
|
|
|
compo_arc_set_angles(arc, 0, 3600);
|
|
compo_arc_set_rotation(arc, 0);
|
|
compo_arc_set_edge_circle(arc, false, false);
|
|
compo_arc_set_value(arc, 0);
|
|
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_ICON_TIME_BIN, GUI_SCREEN_CENTER_X - 1, GUI_SCREEN_CENTER_Y - 23);
|
|
|
|
/* 下滑指示图标 */
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_ICON_MORE_BIN, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y + 134);
|
|
}
|
|
|
|
static void func_activity_step_data_show(compo_form_t *frm)
|
|
{
|
|
int start_pos_y = GUI_SCREEN_HEIGHT;
|
|
|
|
/* 背景 */
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_STEP_BG_BIN, GUI_SCREEN_CENTER_X, start_pos_y + GUI_SCREEN_CENTER_Y);
|
|
|
|
/* 创建标题栏信息 */
|
|
func_activity_title_create(frm, ACTIVITY_PAGE_STEP);
|
|
|
|
/* 表格背景 */
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_STEP_BIN, GUI_SCREEN_CENTER_X, start_pos_y + GUI_SCREEN_CENTER_Y + 4);
|
|
|
|
/* 表格内容 */
|
|
func_activity_chart_create(frm, ACTIVITY_PAGE_STEP);
|
|
|
|
/* 数据文本 */
|
|
compo_textbox_t *txt_step = compo_textbox_create(frm, 10);
|
|
compo_setid(txt_step, COMPO_ID_TXT_STEP);
|
|
compo_textbox_set_pos(txt_step, 19, start_pos_y + 229);
|
|
compo_textbox_set_font(txt_step, UI_BUF_0FONT_FONT_NUM_38_BIN);
|
|
compo_textbox_set_forecolor(txt_step, make_color(248, 21, 78));
|
|
compo_textbox_set_align_center(txt_step, false);
|
|
|
|
txt_step = compo_textbox_create(frm, 10);
|
|
compo_textbox_set_pos(txt_step, 150, start_pos_y + 252);
|
|
compo_textbox_set_forecolor(txt_step, make_color(248, 21, 78));
|
|
compo_textbox_set_align_center(txt_step, false);
|
|
#if defined(__LANGUAGE_SM_CHINESE__)
|
|
if (tjd_Get_Language_Current_Index() == LANGUAGE_TYPE_Chinese)
|
|
compo_textbox_set(txt_step, "步数");
|
|
else
|
|
#endif
|
|
compo_textbox_set(txt_step, "STEPS");
|
|
}
|
|
|
|
static void func_activity_heat_data_show(compo_form_t *frm)
|
|
{
|
|
int start_pos_y = GUI_SCREEN_HEIGHT * 2;
|
|
|
|
/* 背景 */
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_HEAT_BG_BIN, GUI_SCREEN_CENTER_X, start_pos_y + GUI_SCREEN_CENTER_Y);
|
|
|
|
/* 创建标题栏信息 */
|
|
func_activity_title_create(frm, ACTIVITY_PAGE_HEAT);
|
|
|
|
/* 表格背景 */
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_HEAT_BIN, GUI_SCREEN_CENTER_X, start_pos_y + GUI_SCREEN_CENTER_Y + 4);
|
|
|
|
/* 表格内容 */
|
|
func_activity_chart_create(frm, ACTIVITY_PAGE_HEAT);
|
|
|
|
/* 数据文本 */
|
|
compo_textbox_t *txt_heat = compo_textbox_create(frm, 10);
|
|
compo_setid(txt_heat, COMPO_ID_TXT_HEAT);
|
|
compo_textbox_set_pos(txt_heat, 19, start_pos_y + 229);
|
|
compo_textbox_set_font(txt_heat, UI_BUF_0FONT_FONT_NUM_38_BIN);
|
|
compo_textbox_set_forecolor(txt_heat, make_color(134, 242, 6));
|
|
compo_textbox_set_align_center(txt_heat, false);
|
|
|
|
txt_heat = compo_textbox_create(frm, 10);
|
|
compo_textbox_set_pos(txt_heat, 125, start_pos_y + 252);
|
|
compo_textbox_set_forecolor(txt_heat, make_color(134, 242, 6));
|
|
compo_textbox_set_align_center(txt_heat, false);
|
|
#if defined(__LANGUAGE_SM_CHINESE__)
|
|
if (tjd_Get_Language_Current_Index() == LANGUAGE_TYPE_Chinese)
|
|
compo_textbox_set(txt_heat, "千卡");
|
|
else
|
|
#endif
|
|
compo_textbox_set(txt_heat, "KCAL");
|
|
}
|
|
|
|
static void func_activity_time_data_show(compo_form_t *frm)
|
|
{
|
|
int start_pos_y = GUI_SCREEN_HEIGHT * 3;
|
|
|
|
/* 背景 */
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_TIME_BG_BIN, GUI_SCREEN_CENTER_X, start_pos_y + GUI_SCREEN_CENTER_Y);
|
|
|
|
/* 创建标题栏信息 */
|
|
func_activity_title_create(frm, ACTIVITY_PAGE_TIME);
|
|
|
|
/* 表格背景 */
|
|
compo_form_add_image(frm, UI_BUF_ACTIVITY_TIME_BIN, GUI_SCREEN_CENTER_X, start_pos_y + GUI_SCREEN_CENTER_Y + 4);
|
|
|
|
/* 表格内容 */
|
|
func_activity_chart_create(frm, ACTIVITY_PAGE_TIME);
|
|
|
|
/* 数据文本 */
|
|
compo_textbox_t *txt_time = compo_textbox_create(frm, 10);
|
|
compo_setid(txt_time, COMPO_ID_TXT_TIME);
|
|
compo_textbox_set_pos(txt_time, 19, start_pos_y + 229);
|
|
compo_textbox_set_font(txt_time, UI_BUF_0FONT_FONT_NUM_38_BIN);
|
|
compo_textbox_set_forecolor(txt_time, make_color(16, 255, 230));
|
|
compo_textbox_set_align_center(txt_time, false);
|
|
compo_textbox_set(txt_time, "00");
|
|
|
|
area_t text_area = widget_text_get_area(txt_time->txt);
|
|
txt_time = compo_textbox_create(frm, 10);
|
|
compo_setid(txt_time, COMPO_ID_TXT_TIME_UNIT);
|
|
compo_textbox_set_pos(txt_time, text_area.wid + TIME_UNIT_TXT_X, TIME_UNIT_TXT_Y);
|
|
compo_textbox_set_forecolor(txt_time, make_color(16, 255, 230));
|
|
compo_textbox_set_align_center(txt_time, false);
|
|
#if defined(__LANGUAGE_SM_CHINESE__)
|
|
if (tjd_Get_Language_Current_Index() == LANGUAGE_TYPE_Chinese)
|
|
compo_textbox_set(txt_time, "分钟");
|
|
else
|
|
#endif
|
|
compo_textbox_set(txt_time, "MINUTE");
|
|
}
|
|
|
|
static void func_activity_detail_create(compo_form_t *frm)
|
|
{
|
|
/* 步数界面 */
|
|
func_activity_step_data_show(frm);
|
|
|
|
/* 热量界面 */
|
|
func_activity_heat_data_show(frm);
|
|
|
|
/* 运动时间界面 */
|
|
func_activity_time_data_show(frm);
|
|
|
|
/* 显示页面指示器 */
|
|
func_activity_indicator_create(frm);
|
|
}
|
|
|
|
/* 创建每日数据窗体 */
|
|
compo_form_t *func_activity_form_create(void)
|
|
{
|
|
/* 创建窗体 */
|
|
compo_form_t *frm = compo_form_create(true);
|
|
|
|
/* 运动汇总界面 */
|
|
func_activity_total_data_show(frm);
|
|
|
|
return frm;
|
|
}
|
|
|
|
/* 刷新每日数据 */
|
|
static void func_activity_refresh(void)
|
|
{
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
|
|
char text_buf[TEXTBOX_TEXT_BUF_LEN] = {0};
|
|
|
|
/* 10ms进场动画刷新 */
|
|
if (tick_check_expire(f_activity->anim_loading_tick, 10) && f_activity->anim_loading_state != ACTIVITY_ARC_ANIM_LOADING_COMPLETE)
|
|
{
|
|
f_activity->anim_loading_tick = tick_get();
|
|
|
|
compo_arc_t *step_arc = compo_getobj_byid(COMPO_ID_ARC_STEP);
|
|
compo_arc_t *heat_arc = compo_getobj_byid(COMPO_ID_ARC_HEAT);
|
|
compo_arc_t *time_arc = compo_getobj_byid(COMPO_ID_ARC_TIME);
|
|
|
|
f_activity->anim_loading_cnt++;
|
|
if (f_activity->anim_loading_cnt <= activity_step_percent_data_get()) {
|
|
compo_arc_set_edge_circle(step_arc, true, true);
|
|
compo_arc_set_value(step_arc, f_activity->anim_loading_cnt * 10);
|
|
} else {
|
|
f_activity->anim_loading_state |= ACTIVITY_ARC_ANIM_LOADING_STEP;
|
|
}
|
|
|
|
if (f_activity->anim_loading_cnt <= activity_heat_percent_data_get()) {
|
|
compo_arc_set_edge_circle(heat_arc, true, true);
|
|
compo_arc_set_value(heat_arc, f_activity->anim_loading_cnt * 10);
|
|
} else {
|
|
f_activity->anim_loading_state |= ACTIVITY_ARC_ANIM_LOADING_HEAT;
|
|
}
|
|
|
|
if (f_activity->anim_loading_cnt <= activity_time_percent_data_get()) {
|
|
compo_arc_set_edge_circle(time_arc, true, true);
|
|
compo_arc_set_value(time_arc, f_activity->anim_loading_cnt * 10);
|
|
} else {
|
|
f_activity->anim_loading_state |= ACTIVITY_ARC_ANIM_LOADING_TIME;
|
|
}
|
|
}
|
|
|
|
/* 500ms刷新事件 */
|
|
if (tick_check_expire(f_activity->data_refresh_tick, 500))
|
|
{
|
|
f_activity->data_refresh_tick = tick_get();
|
|
|
|
compo_arc_t *step_arc = compo_getobj_byid(COMPO_ID_ARC_STEP);
|
|
compo_arc_t *heat_arc = compo_getobj_byid(COMPO_ID_ARC_HEAT);
|
|
compo_arc_t *time_arc = compo_getobj_byid(COMPO_ID_ARC_TIME);
|
|
|
|
compo_textbox_t *step_text = compo_getobj_byid(COMPO_ID_TXT_STEP);
|
|
compo_textbox_t *heat_text = compo_getobj_byid(COMPO_ID_TXT_HEAT);
|
|
compo_textbox_t *minu_text = compo_getobj_byid(COMPO_ID_TXT_TIME);
|
|
compo_textbox_t *unit_text = compo_getobj_byid(COMPO_ID_TXT_TIME_UNIT);
|
|
|
|
compo_textbox_t *time_text = compo_getobj_byid(COMPO_ID_TITLE_TIME);
|
|
compo_textbox_t *step_time_text = compo_getobj_byid(COMPO_ID_TITLE_STEP_TIME);
|
|
compo_textbox_t *heat_time_text = compo_getobj_byid(COMPO_ID_TITLE_HEAT_TIME);
|
|
compo_textbox_t *minu_time_text = compo_getobj_byid(COMPO_ID_TITLE_MINU_TIME);
|
|
|
|
/* 更新圆弧数据 */
|
|
if (f_activity->anim_loading_state == ACTIVITY_ARC_ANIM_LOADING_COMPLETE) {
|
|
if ((activity_step_percent_data_get() * 10)) {
|
|
compo_arc_set_edge_circle(step_arc, true, true);
|
|
compo_arc_set_value(step_arc, activity_step_percent_data_get() * 10);
|
|
} else {
|
|
compo_arc_set_edge_circle(step_arc, false, false);
|
|
compo_arc_set_value(step_arc, 0);
|
|
}
|
|
|
|
if ((activity_heat_percent_data_get() * 10)) {
|
|
compo_arc_set_edge_circle(heat_arc, true, true);
|
|
compo_arc_set_value(heat_arc, activity_heat_percent_data_get() * 10);
|
|
} else {
|
|
compo_arc_set_edge_circle(heat_arc, false, false);
|
|
compo_arc_set_value(heat_arc, 0);
|
|
}
|
|
|
|
if ((activity_time_percent_data_get() * 10)) {
|
|
compo_arc_set_edge_circle(time_arc, true, true);
|
|
compo_arc_set_value(time_arc, activity_time_percent_data_get() * 10);
|
|
} else {
|
|
compo_arc_set_edge_circle(time_arc, false, false);
|
|
compo_arc_set_value(time_arc, 0);
|
|
}
|
|
}
|
|
|
|
/* 更新时间数据 */
|
|
if (SysVariable.deviceInfo.timeType == TIME_TYPE_12_HOUR)
|
|
sprintf(text_buf, "%02d:%02d%s", get_autoformat_hour(SysVariable.Rtc.hour), SysVariable.Rtc.min, SysVariable.Rtc.hour >= 12 ? "PM" : "AM");
|
|
else
|
|
sprintf(text_buf, "%02d:%02d", SysVariable.Rtc.hour, SysVariable.Rtc.min);
|
|
compo_textbox_set(time_text, text_buf);
|
|
compo_textbox_set(step_time_text, text_buf);
|
|
compo_textbox_set(heat_time_text, text_buf);
|
|
compo_textbox_set(minu_time_text, text_buf);
|
|
|
|
/* 更新表格 */
|
|
func_activity_chart_data_update(ACTIVITY_PAGE_MAIN);
|
|
func_activity_chart_data_update(ACTIVITY_PAGE_STEP);
|
|
func_activity_chart_data_update(ACTIVITY_PAGE_HEAT);
|
|
func_activity_chart_data_update(ACTIVITY_PAGE_TIME);
|
|
|
|
/* 更新详细数据 */
|
|
memset(text_buf, 0, sizeof(text_buf));
|
|
sprintf(text_buf, "%05d", activity_step_data_get());
|
|
compo_textbox_set(step_text, text_buf);
|
|
|
|
memset(text_buf, 0, sizeof(text_buf));
|
|
sprintf(text_buf, "%04d", activity_heat_data_get());
|
|
compo_textbox_set(heat_text, text_buf);
|
|
|
|
memset(text_buf, 0, sizeof(text_buf));
|
|
sprintf(text_buf, "%02d", activity_time_data_get());
|
|
compo_textbox_set(minu_text, text_buf);
|
|
|
|
area_t text_area = widget_text_get_area(minu_text->txt);
|
|
compo_textbox_set_pos(unit_text, text_area.wid + TIME_UNIT_TXT_X, TIME_UNIT_TXT_Y);
|
|
}
|
|
|
|
/* 50ms刷新事件 */
|
|
if (tick_check_expire(f_activity->indicator_refresh_tick, 50))
|
|
{
|
|
f_activity->indicator_refresh_tick = tick_get();
|
|
|
|
/* 更新页面指示器 */
|
|
func_activity_indicator_update();
|
|
}
|
|
}
|
|
|
|
/* 每日数据功能事件处理 */
|
|
static void func_activity_process(void)
|
|
{
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
compo_page_move_process(f_activity->ptm);
|
|
|
|
func_activity_refresh();
|
|
func_process();
|
|
}
|
|
|
|
/* 每日数据功能消息处理 */
|
|
static void func_activity_message(size_msg_t msg)
|
|
{
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
|
|
switch (msg)
|
|
{
|
|
case MSG_CTP_TOUCH:
|
|
compo_page_move_touch_handler(f_activity->ptm);
|
|
break;
|
|
|
|
case MSG_CTP_CLICK:
|
|
case MSG_CTP_SHORT_UP:
|
|
case MSG_CTP_SHORT_DOWN:
|
|
case MSG_CTP_LONG:
|
|
break;
|
|
|
|
case MSG_QDEC_BACKWARD:
|
|
if (func_cb.flag_sort) { // 快捷应用状态下不滚动页面
|
|
func_message(msg);
|
|
} else {
|
|
compo_page_move_set_by_pages(f_activity->ptm, -1);
|
|
}
|
|
break;
|
|
|
|
case MSG_QDEC_FORWARD:
|
|
if (func_cb.flag_sort) {
|
|
func_message(msg);
|
|
} else {
|
|
compo_page_move_set_by_pages(f_activity->ptm, 1);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
func_message(msg);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* 进入每日数据功能 */
|
|
static void func_activity_enter(void)
|
|
{
|
|
func_cb.f_cb = func_zalloc(sizeof(f_activity_t));
|
|
func_cb.frm_main = func_activity_form_create();
|
|
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
f_activity->ptm = (page_tp_move_t *)func_zalloc(sizeof(page_tp_move_t));
|
|
|
|
page_move_info_t info = {
|
|
.title_used = false,
|
|
.page_size = GUI_SCREEN_HEIGHT,
|
|
.page_count = ACTIVITY_PAGE_TOTAL_NUM,
|
|
.jump_perc = 1,
|
|
.quick_jump_perc = 0,
|
|
.up_over_perc = 0,
|
|
.down_over_perc = 0,
|
|
};
|
|
compo_page_move_init(f_activity->ptm, func_cb.frm_main->page_body, &info);
|
|
|
|
/* 进入界面后再创建详细界面,减少切换动画负担得以快速进入 */
|
|
func_activity_detail_create(func_cb.frm_main);
|
|
}
|
|
|
|
/* 退出每日数据功能 */
|
|
static void func_activity_exit(void)
|
|
{
|
|
f_activity_t *f_activity = (f_activity_t *)func_cb.f_cb;
|
|
if (f_activity->ptm) {
|
|
func_free(f_activity->ptm);
|
|
}
|
|
}
|
|
|
|
/* 每日数据功能 */
|
|
void func_activity(void)
|
|
{
|
|
func_activity_enter();
|
|
while (func_cb.sta == FUNC_ACTIVITY) {
|
|
func_activity_process();
|
|
func_activity_message(msg_dequeue());
|
|
}
|
|
func_activity_exit();
|
|
}
|