- UID
- 1798
- 麦力
- 476
- 注册时间
- 2016-11-22
- 最后登录
- 2017-4-25
- 精华
- 0
- 阅读权限
- 30
- 在线时间
- 12 小时
|
本来以为升级系统后,界面无法刷新的问题解决了。可是第二天早上一看又不刷新了,真是无语了。然后重启了下,又好了。把代码贴出来,大家帮我看看有没有问题,真心希望明天早上能看到一个正常刷新的界面。
代码太长 完整代码放到附件里了
#include <stdlib.h>#include <stdio.h>#include <string.h>
#include "./SDK/maibu_sdk.h"#include "maibu_res.h"
/*窗口ID, 通过该窗口ID获取窗口句柄*/static int8_t g_MainWindow_ID = -1;
//时间日期图层static int8_t g_DateTime_ID = -1;//限号图层static int8_t g_LimitNums_ID = -1;//文本图层static int8_t g_Text_ID = -1;//城市static int8_t g_City_ID = -1;
static void myapp_update_data(){
P_Window p_window = (P_Window)app_window_stack_get_window_by_id(g_MainWindow_ID); if (NULL == p_window) { return ; }
P_Layer p_datetime_layer = app_window_get_layer_by_id(p_window, g_DateTime_ID); if (NULL == p_datetime_layer) { return; }
P_Layer p_text_layer = app_window_get_layer_by_id(p_window, g_Text_ID); if (NULL == p_text_layer) { return; }
P_Layer p_limitnum_layer = app_window_get_layer_by_id(p_window, g_LimitNums_ID); if (NULL == p_limitnum_layer) { return; }
char weekday[7][4 = { {"日"}, {"一"}, {"二"}, {"三"}, {"四"}, {"五"}, {"六"} };
struct date_time datetime; app_service_get_datetime(&datetime); int today = datetime.wday;
char str[18 = ""; sprintf(str, "%02d:%02d 周%s %02d-%02d", datetime.hour, datetime.min, weekday[today], datetime.mon, datetime.mday); app_layer_set_text_text(p_datetime_layer, str); //maibu_print_log(str);
//周末不限行 if(today == 6 || today == 0) { unsigned char buf[18 = ""; memcpy(buf, "周末不限行", 18); app_layer_set_text_text(p_text_layer, buf); } else { unsigned char buf[20 = ""; memcpy(buf, "今日限行尾号", 20); app_layer_set_text_text(p_text_layer, buf);
int flag = 0; if(datetime.year == 2016 || ( datetime.mon == 1 && datetime.mday <= 8 )) flag = 1; else flag = -3;
char limitNum1 = (today - flag)%5;
char str[20 = ""; sprintf(str, "%d %d", limitNum1, limitNum1+5); app_layer_set_text_text(p_limitnum_layer, str);
}
app_window_update(p_window);
}static void app_mwd_watch_time_change(enum SysEventType type, void *context){ /*如果系统事件是时间更改*/ if (type == SysEventTypeTimeChange) { myapp_update_data(); }}
|
|