#include "include.h" #include "func.h" #include "app_variable.h" #if TRACE_EN #define TRACE(...) printf(__VA_ARGS__) #else #define TRACE(...) #endif #define OFFSET(x) ((x)<127?(x):(x-256) ) typedef struct f_weather_t_ { bool sta; s16 cur_temp; s16 n1day_temp; s16 n2day_temp; s16 cur_temp_low; s16 cur_temp_hig; page_tp_move_t *ptm; } f_weather_t; enum{ //文字 COMPO_ID_TXT_CUR_TEMP = 1, COMPO_ID_TXT_TIME, COMPO_ID_PIC_BIG, COMPO_ID_PIC_SMALL_LEF, COMPO_ID_PIC_SMALL_CEN, COMPO_ID_PIC_SMALL_RIG, COMPO_ID_TXT_TODAY_TEMP_BIG, COMPO_ID_TXT_GET_WEATHER_TIME, COMPO_ID_TXT_TODAY_TEMP_SMALL, COMPO_ID_TXT_TOMORROW_TEMP, COMPO_ID_TXT_3THDAY_TEMP, COMPO_ID_TXT_WEEK_1, /* 获取失败重试按钮 */ COMPO_ID_BTN_FAIL_RETRY = 0x40, }; //连上了蓝牙 static void func_weather_show_connect_ble_detail(compo_form_t *frm){ //设置标题栏 // compo_form_set_mode(frm, COMPO_FORM_MODE_SHOW_TITLE | COMPO_FORM_MODE_SHOW_TIME); // compo_form_set_title(frm, i18n[STR_WEATHER]); char week_en_text[][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; char week_ch_text[][12] = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"}; //创建蓝色矩形框 背景1 compo_shape_t *blue_btn_bg ; blue_btn_bg = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,GUI_SCREEN_CENTER_X + 50); compo_shape_set_color(blue_btn_bg, make_color(59, 138, 255)); compo_shape_set_location(blue_btn_bg, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y + 20, GUI_SCREEN_WIDTH + 100, GUI_SCREEN_HEIGHT+ 100); //创建白色矩形框 compo_shape_t *white_btn_big ; white_btn_big = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,45); compo_shape_set_color(white_btn_big, COLOR_WHITE); compo_shape_set_location(white_btn_big, GUI_SCREEN_CENTER_X, 77 , 208, 90); compo_shape_set_alpha(white_btn_big, 165); compo_shape_t *white_btn_lef ; white_btn_lef = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,26); compo_shape_set_color(white_btn_lef, COLOR_WHITE); compo_shape_set_location(white_btn_lef, GUI_SCREEN_CENTER_X - 78, 187 , 56, 106); compo_shape_set_alpha(white_btn_lef, 165); compo_shape_t *white_btn_cen ; white_btn_cen = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,26); compo_shape_set_color(white_btn_cen, COLOR_WHITE); compo_shape_set_location(white_btn_cen, GUI_SCREEN_CENTER_X, 187 , 56, 106); compo_shape_set_alpha(white_btn_cen, 165); compo_shape_t *white_btn_rig ; white_btn_rig = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,26); compo_shape_set_color(white_btn_rig, COLOR_WHITE); compo_shape_set_location(white_btn_rig, GUI_SCREEN_CENTER_X + 78, 187 , 56, 106); compo_shape_set_alpha(white_btn_rig, 165); // //创建 左边标题文本框 // compo_textbox_t *txt_sex = compo_textbox_create(frm, 50); // compo_textbox_set_align_center(txt_sex,FALSE); // compo_textbox_set_location(txt_sex, 32, 9, GUI_SCREEN_CENTER_X, 30); // compo_textbox_set_autoroll_mode(txt_sex, TEXT_AUTOROLL_MODE_SROLL_CIRC); // compo_textbox_set(txt_sex, i18n[STR_WEATHER]); // //右上角时间 // char buf_time[10] = {0}; // if (SysVariable.deviceInfo.timeType == TIME_TYPE_12_HOUR) // sprintf(buf_time, "%02d:%02d%s", get_autoformat_hour(SysVariable.Rtc.hour), SysVariable.Rtc.min, SysVariable.Rtc.hour >= 12 ? "PM" : "AM"); // else // sprintf(buf_time, "%02d:%02d", SysVariable.Rtc.hour, SysVariable.Rtc.min); // compo_textbox_t *txt_time = compo_textbox_create(frm, 8); // compo_setid(txt_time, COMPO_ID_TXT_TIME); // compo_textbox_set_location(txt_time, 180, 16, 0, 0); // compo_textbox_set_autosize(txt_time, true); // compo_textbox_set(txt_time, buf_time); // compo_textbox_set_visible(txt_time, true); //创建天气图片 compo_picturebox_t *pic = compo_picturebox_create(frm, UI_BUF_WEATHER_LIST_BIN); compo_setid(pic,COMPO_ID_PIC_BIG); compo_picturebox_cut(pic, SysVariable.weather.type, WEATHER_CNT); compo_picturebox_set_pos(pic, 30+24, 51+20); // compo_bonddata(pic, COMPO_BOND_WEATHER); compo_picturebox_t *pic_lef = compo_picturebox_create(frm, UI_BUF_WEATHER_LIST_BIN); compo_setid(pic_lef,COMPO_ID_PIC_SMALL_LEF); compo_picturebox_cut(pic_lef, SysVariable.weather.type, WEATHER_CNT); compo_picturebox_set_size(pic_lef,28,30); compo_picturebox_set_pos(pic_lef, GUI_SCREEN_CENTER_X - 78, 141 + 12); // compo_bonddata(pic_lef, COMPO_BOND_WEATHER); compo_picturebox_t *pic_cen = compo_picturebox_create(frm, UI_BUF_WEATHER_LIST_BIN); compo_setid(pic_cen,COMPO_ID_PIC_SMALL_CEN); compo_picturebox_cut(pic_cen, SysVariable.weather.n1day_type, WEATHER_CNT); compo_picturebox_set_size(pic_cen,28,30); compo_picturebox_set_pos(pic_cen, GUI_SCREEN_CENTER_X, 141 + 12); // compo_bonddata(pic_cen, COMPO_BOND_WEATHER); compo_picturebox_t *pic_rig = compo_picturebox_create(frm, UI_BUF_WEATHER_LIST_BIN); compo_setid(pic_rig,COMPO_ID_PIC_SMALL_RIG); compo_picturebox_cut(pic_rig, SysVariable.weather.n2day_type, WEATHER_CNT); compo_picturebox_set_size(pic_rig,28,30); compo_picturebox_set_pos(pic_rig, GUI_SCREEN_CENTER_X + 78, 141 + 12); // compo_bonddata(pic_rig, COMPO_BOND_WEATHER); //创建天气 当前温度 数字 compo_textbox_t *txt_cur_temp = compo_textbox_create(frm, 6); compo_textbox_set_font(txt_cur_temp,UI_BUF_0FONT_FONT_NUM_24_BIN); compo_setid(txt_cur_temp,COMPO_ID_TXT_CUR_TEMP); // compo_textbox_set_align_center(txt_cur_temp,FALSE); compo_textbox_set_pos(txt_cur_temp, 123, 62); // compo_textbox_set(txt_cur_temp, "30℃"); // compo_bonddata(txt_cur_temp, COMPO_BOND_TEMPERATURE); // compo_textbox_set(txt_height, i18n[STR_PER_HEIGHT]); //创建天气 当天温度范围 数字 compo_textbox_t *txt_today_temp_big = compo_textbox_create(frm, 12); compo_textbox_set_font(txt_today_temp_big,UI_BUF_0FONT_FONT_WEATHER_BIN); compo_setid(txt_today_temp_big,COMPO_ID_TXT_TODAY_TEMP_BIG); compo_textbox_set_location(txt_today_temp_big, 142, 98,180,40); //新建图片 获取时间图标 // compo_form_add_image(frm, UI_BUF_WEATHER_ICON_REFRESH_BIN, 142, 112); //创建天气 获取时间 数字 // compo_textbox_t *txt_get_time = compo_textbox_create(frm, 7); // compo_textbox_set_align_center(txt_get_time,FALSE); // compo_setid(txt_get_time,COMPO_ID_TXT_GET_WEATHER_TIME); // compo_textbox_set_pos(txt_get_time, 153, 105); // compo_textbox_set(txt_get_time, "20:36pm"); // 获取 当天天气 温度范围 【当天温度】 compo_textbox_t *txt_today_temp_small = compo_textbox_create(frm, 11); compo_textbox_set_font(txt_today_temp_small,UI_BUF_0FONT_FONT_WEATHER_BIN); compo_setid(txt_today_temp_small,COMPO_ID_TXT_TODAY_TEMP_SMALL); compo_textbox_set_autoroll_mode(txt_today_temp_small, TEXT_AUTOROLL_MODE_SROLL_CIRC); // compo_textbox_set_multiline(txt_today_temp_small,true); compo_textbox_set_location(txt_today_temp_small, GUI_SCREEN_CENTER_X - 78, 187,50,30); //获取 明天天气 温度范围 compo_textbox_t *txt_tomorrow_temp = compo_textbox_create(frm, 11); compo_textbox_set_font(txt_tomorrow_temp,UI_BUF_0FONT_FONT_WEATHER_BIN); compo_setid(txt_tomorrow_temp,COMPO_ID_TXT_TOMORROW_TEMP); compo_textbox_set_autoroll_mode(txt_tomorrow_temp, TEXT_AUTOROLL_MODE_SROLL_CIRC); // compo_textbox_set_multiline(txt_tomorrow_temp,true); compo_textbox_set_location(txt_tomorrow_temp, GUI_SCREEN_CENTER_X, 187,50,30); //获取 后天天气 温度范围 compo_textbox_t *txt_thrday_temp = compo_textbox_create(frm, 11); compo_textbox_set_font(txt_thrday_temp,UI_BUF_0FONT_FONT_WEATHER_BIN); compo_setid(txt_thrday_temp,COMPO_ID_TXT_3THDAY_TEMP); compo_textbox_set_autoroll_mode(txt_tomorrow_temp, TEXT_AUTOROLL_MODE_SROLL_CIRC); // compo_textbox_set_multiline(txt_thrday_temp,true); compo_textbox_set_location(txt_thrday_temp, GUI_SCREEN_CENTER_X + 78, 187,50,30); //星期 compo_textbox_t *txt_today = compo_textbox_create(frm, 4); compo_textbox_set_font(txt_today,UI_BUF_0FONT_FONT_BIN); compo_textbox_set_location(txt_today, GUI_SCREEN_CENTER_X-78, 254 - 31, 44, 30); compo_textbox_set_autoroll_mode(txt_today, TEXT_AUTOROLL_MODE_SROLL_CIRC); if (SysVariable.deviceInfo.language == LANGUAGE_TYPE_Chinese) compo_textbox_set(txt_today, week_ch_text[SysVariable.Rtc.weekday]); else compo_textbox_set(txt_today, week_en_text[SysVariable.Rtc.weekday]); compo_textbox_t *txt_week2 = compo_textbox_create(frm, 4); compo_textbox_set_font(txt_week2, UI_BUF_0FONT_FONT_BIN); compo_textbox_set_location(txt_week2, GUI_SCREEN_CENTER_X, 254 - 31, 44, 30); compo_textbox_set_autoroll_mode(txt_week2, TEXT_AUTOROLL_MODE_SROLL_CIRC); if (SysVariable.deviceInfo.language == LANGUAGE_TYPE_Chinese) compo_textbox_set(txt_week2, week_ch_text[(SysVariable.Rtc.weekday + 1) % 7]); else compo_textbox_set(txt_week2, week_en_text[(SysVariable.Rtc.weekday + 1) % 7]); compo_textbox_t *txt_week3 = compo_textbox_create(frm, 4); compo_textbox_set_font(txt_week3, UI_BUF_0FONT_FONT_BIN); compo_textbox_set_location(txt_week3, GUI_SCREEN_CENTER_X + 78, 254 - 31, 44, 30); compo_textbox_set_autoroll_mode(txt_week3, TEXT_AUTOROLL_MODE_SROLL_CIRC); if (SysVariable.deviceInfo.language == LANGUAGE_TYPE_Chinese) compo_textbox_set(txt_week3, week_ch_text[(SysVariable.Rtc.weekday + 2) % 7]); else compo_textbox_set(txt_week3, week_en_text[(SysVariable.Rtc.weekday + 2) % 7]); } //未连接蓝牙或者未获取天气 static void func_weather_show_disconnect_ble_detail(compo_form_t *frm) { // //设置标题栏 // compo_form_set_mode(frm, COMPO_FORM_MODE_SHOW_TITLE | COMPO_FORM_MODE_SHOW_TIME); // compo_form_set_title(frm, i18n[STR_WEATHER]); //新建图片 大背景 // compo_form_add_image(frm, UI_BUF_REMIND_CONNECT_APP_BIN, GUI_SCREEN_CENTER_X, 100); //提示语 compo_textbox_t *txt_remind = compo_textbox_create(frm, 150); // compo_textbox_set_align_center(txt_today,FALSE); compo_textbox_set_multiline(txt_remind,true); compo_textbox_set_location(txt_remind, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y, GUI_SCREEN_WIDTH - 60, 60); compo_textbox_set_autosize(txt_remind, true); // compo_textbox_set_forecolor(txt_remind,make_color(60,134,244)); compo_textbox_set_autoroll_mode(txt_remind, TEXT_AUTOROLL_MODE_SROLL_CIRC); compo_textbox_set(txt_remind, i18n[STR_CONNECT_APP]); } /* 未成功获取到天气 */ static void func_weather_show_fail(compo_form_t *frm) { // compo_picturebox_t *pic = compo_picturebox_create(frm, UI_BUF_COMMON_ICON_FAIL_BIN); // compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y - 79); compo_textbox_t *acquiring_txt = compo_textbox_create(frm, 120); compo_textbox_set_location(acquiring_txt, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y, GUI_SCREEN_WIDTH/6*5, 80); compo_textbox_set_multiline(acquiring_txt, true); compo_textbox_set(acquiring_txt, i18n[STR_GET_DATA_FAIL]); /* 重试按钮 */ compo_shape_t *btn_shape = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE, 30); compo_shape_set_color(btn_shape, make_color(19, 126, 250)); compo_shape_set_location(btn_shape, GUI_SCREEN_CENTER_X, GUI_SCREEN_HEIGHT/4*3, GUI_SCREEN_WIDTH-60, 60); compo_button_t *btn = compo_button_create(frm); compo_setid(btn, COMPO_ID_BTN_FAIL_RETRY); compo_button_set_location(btn, GUI_SCREEN_CENTER_X, GUI_SCREEN_HEIGHT/4*3, GUI_SCREEN_WIDTH-60, 60); compo_textbox_t *txt_retry = compo_textbox_create(frm, 20); compo_textbox_set_pos(txt_retry, GUI_SCREEN_CENTER_X, GUI_SCREEN_HEIGHT/4*3); compo_textbox_set(txt_retry, i18n[STR_RETRY]); } //创建天气窗体,创建窗体中不要使用功能结构体 func_cb.f_cb compo_form_t *func_weather_form_create(void) { //新建窗体和背景 compo_form_t *frm = compo_form_create(true); if (SysVariable.weather.getFlag == true) { /* 获取过天气数据,显示天气列表 */ func_weather_show_connect_ble_detail(frm); } else { if (!ble_is_connected()) { /* 显示未连接APP提示 */ func_weather_show_disconnect_ble_detail(frm); } else { /* 显示获取失败提示 */ func_weather_show_fail(frm); } } return frm; } //天气界面刷新 static void func_weather_refresh(void) { compo_picturebox_t *pic = NULL; compo_textbox_t *txt = NULL; f_weather_t *f_weather = (f_weather_t *)func_cb.f_cb; f_weather->cur_temp = SysVariable.weather.temperature; f_weather->cur_temp_low = SysVariable.weather.minTemp; f_weather->cur_temp_hig = SysVariable.weather.maxTemp; f_weather->n1day_temp = SysVariable.weather.n1day_temperature; f_weather->n2day_temp = SysVariable.weather.n2day_temperature; f_weather->cur_temp = weather_temperature_transform(OFFSET(f_weather->cur_temp))/100; f_weather->cur_temp_low = weather_temperature_transform(OFFSET(f_weather->cur_temp_low))/100; f_weather->cur_temp_hig = weather_temperature_transform(OFFSET(f_weather->cur_temp_hig))/100; f_weather->n1day_temp = weather_temperature_transform(OFFSET(f_weather->n1day_temp))/100; f_weather->n2day_temp = weather_temperature_transform(OFFSET(f_weather->n2day_temp))/100; char buf[16]; memset(buf, 0, sizeof(buf)); if(SysVariable.weather.getFlag==true) { pic = (compo_picturebox_t *)compo_getobj_byid(COMPO_ID_PIC_BIG); if (pic) { compo_picturebox_cut(pic, SysVariable.weather.type, WEATHER_CNT); } pic = (compo_picturebox_t *)compo_getobj_byid(COMPO_ID_PIC_SMALL_LEF); if (pic) { compo_picturebox_cut(pic, SysVariable.weather.type, WEATHER_CNT); compo_picturebox_set_size(pic, 28, 30); } pic = (compo_picturebox_t *)compo_getobj_byid(COMPO_ID_PIC_SMALL_CEN); if (pic) { compo_picturebox_cut(pic, SysVariable.weather.n1day_type, WEATHER_CNT); compo_picturebox_set_size(pic, 28, 30); } pic = (compo_picturebox_t *)compo_getobj_byid(COMPO_ID_PIC_SMALL_RIG); if (pic) { compo_picturebox_cut(pic, SysVariable.weather.n2day_type, WEATHER_CNT); compo_picturebox_set_size(pic, 28, 30); } //获取时的当前天气温度 txt = (compo_textbox_t *)compo_getobj_byid(COMPO_ID_TXT_CUR_TEMP); if(SysVariable.deviceInfo.distanceUnit == UNIT_TYPE_INCH){ snprintf(buf, sizeof(buf), "%d℉", f_weather->cur_temp); } else{ snprintf(buf, sizeof(buf), "%d℃", f_weather->cur_temp); } if(txt) { compo_textbox_set(txt, buf); } //获取时的时间 // txt = (compo_textbox_t *)compo_getobj_byid(COMPO_ID_TXT_GET_WEATHER_TIME); // snprintf(buf, sizeof(buf), "%d℉", (SysVariable.weather.temperature*9/5+ 32)); // compo_textbox_set(txt, buf); //获取当天 天气温度范围 txt = (compo_textbox_t *)compo_getobj_byid(COMPO_ID_TXT_TODAY_TEMP_BIG); if(SysVariable.deviceInfo.distanceUnit == UNIT_TYPE_INCH){ snprintf(buf, sizeof(buf), "%d℉/%d℉", f_weather->cur_temp_low,f_weather->cur_temp_hig); } else{ snprintf(buf, sizeof(buf), "%d℃/%d℃", f_weather->cur_temp_low,f_weather->cur_temp_hig); } if(txt) { compo_textbox_set(txt, buf); } //获取当天 天气温度范围 txt = (compo_textbox_t *)compo_getobj_byid(COMPO_ID_TXT_TODAY_TEMP_SMALL); if(SysVariable.deviceInfo.distanceUnit == UNIT_TYPE_INCH){ // snprintf(buf, sizeof(buf), "%d~%d℉", (SysVariable.weather.minTemp*9/5+ 32),(SysVariable.weather.maxTemp*9/5+ 32)); snprintf(buf, sizeof(buf), "%d℉", f_weather->cur_temp); } else{ // snprintf(buf, sizeof(buf), "%d~%d℃", SysVariable.weather.minTemp,SysVariable.weather.maxTemp); snprintf(buf, sizeof(buf), "%d℃", f_weather->cur_temp); } if(txt) { compo_textbox_set(txt, buf); } //获取明天 天气温度范围 txt = (compo_textbox_t *)compo_getobj_byid(COMPO_ID_TXT_TOMORROW_TEMP); if(SysVariable.deviceInfo.distanceUnit == UNIT_TYPE_INCH){ // snprintf(buf, sizeof(buf), "%d~%d℉", (SysVariable.weather.n1day_minTemp*9/5+ 32),(SysVariable.weather.n1day_maxTemp*9/5+ 32)); snprintf(buf, sizeof(buf), "%d℉", f_weather->n1day_temp); } else{ // snprintf(buf, sizeof(buf), "%d~%d℃", SysVariable.weather.n1day_minTemp,SysVariable.weather.n1day_maxTemp); snprintf(buf, sizeof(buf), "%d℃", f_weather->n1day_temp); } if(txt) compo_textbox_set(txt, buf); //获取后天 天气温度范围 txt = (compo_textbox_t *)compo_getobj_byid(COMPO_ID_TXT_3THDAY_TEMP); if(SysVariable.deviceInfo.distanceUnit == UNIT_TYPE_INCH){ // snprintf(buf, sizeof(buf), "%d~%d℉", (SysVariable.weather.n2day_minTemp*9/5+ 32),(SysVariable.weather.n2day_maxTemp*9/5+ 32)); snprintf(buf, sizeof(buf), "%d℉", f_weather->n2day_temp); } else{ // snprintf(buf, sizeof(buf), "%d~%d℃", SysVariable.weather.n2day_minTemp,SysVariable.weather.n2day_maxTemp); snprintf(buf, sizeof(buf), "%d℃", f_weather->n2day_temp); } if(txt) compo_textbox_set(txt, buf); } else{ SysVariable.weather.n1day_type = 0; SysVariable.weather.n2day_type = 0; } } static void func_weather_interface(void) { f_weather_t *f_weather = (f_weather_t *)func_cb.f_cb; if ((SysVariable.weather.getFlag == true) &&(f_weather->sta == false)) { //销毁窗体 if (func_cb.frm_main != NULL) { compo_form_destroy(func_cb.frm_main); } func_cb.frm_main = func_weather_form_create(); f_weather->sta = true; } } //天气功能事件处理 static void func_weather_process(void) { f_weather_t *f_weather = (f_weather_t *)func_cb.f_cb; /* 界面刷新检查 */ func_weather_interface(); compo_page_move_process(f_weather->ptm); compo_textbox_t *txt_time = (compo_textbox_t *)compo_getobj_byid(COMPO_ID_TXT_TIME); char buf_time[10] = {0}; static u32 tick = 0; if (tick_check_expire(tick, 500)) { if(txt_time){ tick = tick_get(); if (SysVariable.deviceInfo.timeType == TIME_TYPE_12_HOUR) sprintf(buf_time, "%02d:%02d%s", get_autoformat_hour(SysVariable.Rtc.hour), SysVariable.Rtc.min, SysVariable.Rtc.hour >= 12 ? "PM" : "AM"); else sprintf(buf_time, "%02d:%02d", SysVariable.Rtc.hour, SysVariable.Rtc.min); compo_textbox_set(txt_time, buf_time); } } if(SysVariable.weather.getFlag == true) { func_weather_refresh(); } if((SysVariable.weather.getFlag == true)&&(f_weather->sta == false)) { f_weather->ptm = (page_tp_move_t *)func_zalloc(sizeof(page_tp_move_t)); page_move_info_t info = { .title_used = false, .page_size = 290, //除标题外页面总长度 .page_count = 1, .up_over_perc = 10, .down_over_perc = 10, }; compo_page_move_init(f_weather->ptm, func_cb.frm_main->page_body, &info); } func_process(); } // 天气按钮点击处理 static void func_weather_click_handler(void) { static u32 retry_tick = 0; f_weather_t *f_weather = (f_weather_t *)func_cb.f_cb; u8 id = compo_get_button_id(); switch (id) { case COMPO_ID_BTN_FAIL_RETRY: if (ble_is_connected() && tick_check_expire(retry_tick, 1000)) { /* 数据获取异常 - 手动请求重新下发 */ printf("[%s %d][Send_Protocol_Get_Weather]\n", __func__, __LINE__); retry_tick = tick_get(); Send_Protocol_Get_Weather(); f_weather->sta = FALSE; // 重新获取天气 } else { /* 销毁窗体 - 切换到未连接页面 */ if (func_cb.frm_main != NULL) { compo_form_destroy(func_cb.frm_main); } func_cb.frm_main = func_weather_form_create(); } break; default: break; } } //天气功能消息处理 static void func_weather_message(size_msg_t msg) { f_weather_t *f_weather = (f_weather_t *)func_cb.f_cb; switch (msg) { if(SysVariable.weather.getFlag == TRUE) { case MSG_CTP_TOUCH: compo_page_move_touch_handler(f_weather->ptm); break; case MSG_QDEC_BACKWARD: if (func_cb.flag_sort) { //快捷应用状态下不滚动页面 func_message(msg); } else { compo_page_move_set_by_pages(f_weather->ptm, -1); } break; case MSG_QDEC_FORWARD: if (func_cb.flag_sort) { func_message(msg); } else { compo_page_move_set_by_pages(f_weather->ptm, 1); } break; } case MSG_CTP_CLICK: func_weather_click_handler(); // sys_cb.weather_idx = (sys_cb.weather_idx + 1) % WEATHER_CNT; //test // printf("sys_cb.weather_idx=%d\n", sys_cb.weather_idx); break; case MSG_CTP_SHORT_UP: break; case MSG_CTP_SHORT_DOWN: break; case MSG_CTP_LONG: break; default: func_message(msg); break; } } //进入天气功能 static void func_weather_enter(void) { func_cb.f_cb = func_zalloc(sizeof(f_weather_t)); func_cb.frm_main = func_weather_form_create(); f_weather_t *f_weather = (f_weather_t *)func_cb.f_cb; f_weather->sta = SysVariable.weather.getFlag; if(SysVariable.weather.getFlag == TRUE) { f_weather->ptm = (page_tp_move_t *)func_zalloc(sizeof(page_tp_move_t)); page_move_info_t info = { .title_used = false, .page_size = 290 , //除标题外页面总长度 .page_count = 1, .up_over_perc = 10, .down_over_perc = 10, }; compo_page_move_init(f_weather->ptm, func_cb.frm_main->page_body, &info); } func_weather_refresh(); } //退出天气功能 static void func_weather_exit(void) { f_weather_t *f_weather = (f_weather_t *)func_cb.f_cb; if (f_weather->ptm) { func_free(f_weather->ptm); } func_cb.last = FUNC_WEATHER; } //天气功能 void func_weather(void) { printf("%s\n", __func__); func_weather_enter(); while (func_cb.sta == FUNC_WEATHER) { func_weather_process(); func_weather_message(msg_dequeue()); } func_weather_exit(); }