CARPLAY版本整理
This commit is contained in:
@ -0,0 +1,92 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
#include "../common/data_port.h"
|
||||
#include "../common/universal.h"
|
||||
|
||||
extern uint8_t winflag;
|
||||
|
||||
static ret_t on_ToolTip_box_key_down(void* ctx, event_t* e) {
|
||||
key_event_t* evt = key_event_cast(e);
|
||||
// TODO: 在此添加控件事件处理程序代码
|
||||
widget_t* win = window_manager();
|
||||
widget_t* child = NULL;
|
||||
widget_t* widget = NULL;
|
||||
uint8_t count=0;
|
||||
uint8_t child_count=0;
|
||||
|
||||
widget = window_manager_get_top_main_window(win);
|
||||
if(evt->key == TK_KEY_q){
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
count = widget_index_of(child);
|
||||
|
||||
child_count = widget_count_children(child->parent);
|
||||
if(child_count == 1)
|
||||
return RET_OK;
|
||||
|
||||
widget_set_focused(child,FALSE);
|
||||
count++;
|
||||
if(count>=child_count)
|
||||
count = 0;
|
||||
widget = widget_get_child(child->parent,count);
|
||||
|
||||
widget_set_focused(widget,TRUE);
|
||||
widget_set_prop_bool(widget, WIDGET_PROP_FOCUSED, TRUE);
|
||||
widget_set_value(widget,1);
|
||||
|
||||
}else if(evt->key == TK_KEY_w){
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
count = widget_index_of(child);
|
||||
// printf("$$$$$$$child = %s,child->parent = %s,count = %d \r\n",child->name,child->parent->name,count);
|
||||
switch(count){
|
||||
case 0:
|
||||
Set_sys_maintenance_mileage(0);
|
||||
Set_sys_warning_maintenance(0);
|
||||
newA27_return_theme();
|
||||
break;
|
||||
// case 1:
|
||||
// newA27_return_theme();
|
||||
// break;
|
||||
default:
|
||||
newA27_return_theme();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
if (tk_str_eq(name, "ToolTip_box")) {
|
||||
widget_on(widget, EVT_KEY_DOWN, on_ToolTip_box_key_down, win);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t ToolTip_box_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
widget_t* btn_view = widget_lookup(win,"btn_view",TRUE);
|
||||
widget_t* child = widget_get_child(btn_view,0);
|
||||
// widget_set_prop_bool(child, WIDGET_PROP_FOCUSED, TRUE);
|
||||
widget_set_focused(child,TRUE);
|
||||
|
||||
winflag = 5;
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
//widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t call_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,827 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
#include "../common/data_port.h"
|
||||
#include "../common/universal.h"
|
||||
#include "../common/moto_config.h"
|
||||
#include "tkc/object_date_time.h"
|
||||
|
||||
static uint8_t inited = 0;
|
||||
uint8_t refresh_flag = 0;
|
||||
extern uint8_t speed_flag;
|
||||
|
||||
extern void NEW_ui_data_refreshes(widget_t* win);
|
||||
extern void tire_pressure_init(widget_t*win);
|
||||
|
||||
extern uint8_t winflag;
|
||||
|
||||
static void removeNonNumeric(char *str) {
|
||||
int j = 0;
|
||||
for (int i = 0; str[i] != '\0'; i++) {
|
||||
if (isdigit(str[i]) || str[i] == '-') {
|
||||
str[j++] = str[i];
|
||||
} else {
|
||||
break; // 遇到非数字和"-"字符,结束循环
|
||||
}
|
||||
}
|
||||
str[j] = '\0';
|
||||
}
|
||||
|
||||
|
||||
static void new_call_refresh(void){
|
||||
widget_t* win = window_manager();
|
||||
widget_t* call_number = widget_lookup(win, "call_number", TRUE);
|
||||
widget_t* call_img = widget_lookup(win, "call_img", TRUE);
|
||||
widget_t* call_label = widget_lookup(win, "call_label", TRUE);
|
||||
char tmpStr[30] = {0};
|
||||
char color[15] = {0};
|
||||
|
||||
|
||||
if(Get_sys_theme_state() == 0){
|
||||
tk_snprintf(color, sizeof(color), COLOR_USER_BLUE2);
|
||||
}else if(Get_sys_theme_state() == 1){
|
||||
tk_snprintf(color, sizeof(color), COLOR_USER_BLUE);
|
||||
}else{
|
||||
if(Get_sys_display_theme())
|
||||
tk_snprintf(color, sizeof(color), COLOR_USER_BLUE);
|
||||
else
|
||||
tk_snprintf(color, sizeof(color), COLOR_USER_BLUE2);
|
||||
}
|
||||
|
||||
if(Get_sys_call_state()==1){//来电状态 字体正常 不显示通话中和通话时间
|
||||
widget_set_visible(call_label,FALSE);
|
||||
widget_set_visible(call_number,TRUE);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%s",custom_data.call.number);
|
||||
removeNonNumeric(tmpStr);//号码保护
|
||||
widget_set_text_utf8(call_number,tmpStr);
|
||||
// widget_set_text_utf8(call_number,"12345678987");
|
||||
}else if(Get_sys_call_state()==2){//接听状态 字体变小 显示通话时间
|
||||
widget_set_visible(call_number,FALSE);
|
||||
widget_set_visible(call_label,TRUE);
|
||||
|
||||
}else if(Get_sys_call_state()==3){//电话2来电 字体回归 显示电话2
|
||||
widget_set_visible(call_label,FALSE);
|
||||
widget_set_visible(call_number,TRUE);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%s",custom_data.call.renumber);
|
||||
removeNonNumeric(tmpStr);//号码保护
|
||||
widget_set_text_utf8(call_number,tmpStr);
|
||||
// widget_set_text_utf8(call_number,"12345678987");
|
||||
}else if(Get_sys_call_state()==4){//电话1挂断电话2接听 字体回归 显示通话时间
|
||||
widget_set_visible(call_number,FALSE);
|
||||
widget_set_visible(call_label,TRUE);
|
||||
}
|
||||
|
||||
widget_set_style_color(call_number, "normal:text_color", OUTPUT_COLOR(color));
|
||||
widget_set_style_color(call_label, "normal:text_color", OUTPUT_COLOR(color));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void tire_pressure_init(widget_t*win){
|
||||
static widget_t* tire_pressure_view = NULL;
|
||||
static widget_t* tire = NULL;
|
||||
static widget_t* f_view = NULL;
|
||||
static widget_t* r_view = NULL;
|
||||
static widget_t* f_data = NULL;
|
||||
static widget_t* r_data = NULL;
|
||||
static widget_t* moto_bg = NULL;
|
||||
static widget_t* bg_button1 = NULL;
|
||||
static widget_t* bg_button2 = NULL;
|
||||
static widget_t* btn = NULL;
|
||||
if (!inited)
|
||||
{
|
||||
tire_pressure_view = widget_lookup(win, "tire_pressure_view", TRUE);//容器
|
||||
tire = widget_lookup(win, "tire", TRUE);//图标
|
||||
f_view = widget_lookup(win, "f_view", TRUE);////前胎压视图
|
||||
r_view = widget_lookup(win, "r_view", TRUE);////后胎压视图
|
||||
f_data = widget_lookup(win, "f_data", TRUE);////前胎压数据
|
||||
r_data = widget_lookup(win, "r_data", TRUE);////后胎压数据
|
||||
moto_bg = widget_lookup(win, "moto_bg", TRUE);////胎压图标
|
||||
bg_button1 = widget_lookup(win, "bg_button1", TRUE);////前胎压背景
|
||||
bg_button2 = widget_lookup(win, "bg_button2", TRUE);////后胎压背景
|
||||
}
|
||||
|
||||
if(Get_sys_power_on_self_test()!=100)
|
||||
return;
|
||||
|
||||
//来电
|
||||
if(Get_sys_call_state()){
|
||||
widget_set_visible(tire_pressure_view,FALSE);
|
||||
if(Get_sys_call_display()==0){
|
||||
if(navigator_to("call") == RET_OK){
|
||||
new_call_refresh();
|
||||
Set_sys_call_display(1);
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
new_call_refresh();
|
||||
}
|
||||
return;
|
||||
}else if(Get_sys_call_display()){
|
||||
if(navigator_close("call") == RET_OK){
|
||||
Set_sys_call_display(0);
|
||||
}
|
||||
}
|
||||
|
||||
double buf =0;
|
||||
uint8_t count =0;
|
||||
char tmpStr[20] = {0};
|
||||
|
||||
#if UI_VIEW_TIRE_PRESSURE
|
||||
//胎压数据刷新函数
|
||||
count = Get_device_ability();//支持功能
|
||||
if(JUDGE_BIN_4(count)){//为1支持胎压
|
||||
|
||||
widget_set_visible(tire_pressure_view,TRUE);
|
||||
|
||||
Pressure_t ago_pressure = Get_sys_front_pressure();
|
||||
Pressure_t after_pressure = Get_sys_rear_pressure();
|
||||
|
||||
if(mac_address_normal(ago_pressure.mac_address,6) == 0){//mac是否正常
|
||||
widget_set_visible(f_view,FALSE);
|
||||
}else{
|
||||
widget_set_visible(f_view,TRUE);
|
||||
|
||||
buf = (ago_pressure.psi-146);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.02f",(buf*0.0069));
|
||||
if(ago_pressure.psi< 1){
|
||||
widget_set_text_utf8(f_data,"--");
|
||||
}else{
|
||||
widget_set_text_utf8(f_data,tmpStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(mac_address_normal(after_pressure.mac_address,6) == 0){//mac是否正常
|
||||
widget_set_visible(r_view,FALSE);
|
||||
}else{
|
||||
widget_set_visible(r_view,TRUE);
|
||||
buf = (after_pressure.psi-146);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.02f",(buf*0.0069));
|
||||
if(after_pressure.psi< 1 || after_pressure.temp< 1 )
|
||||
widget_set_text_utf8(r_data,"--");
|
||||
else
|
||||
widget_set_text_utf8(r_data,tmpStr);
|
||||
|
||||
}
|
||||
//胎压警告图标
|
||||
if((mac_address_normal(after_pressure.mac_address,6) == 1) || (mac_address_normal(ago_pressure.mac_address,6) == 1))
|
||||
Universal_widget_display(tire,Get_sys_warning_tire());
|
||||
else
|
||||
widget_set_visible(tire,FALSE);
|
||||
|
||||
count = widget_count_children(f_view);//获取子类个数
|
||||
if(Get_sys_theme_state() == 1){//白色
|
||||
widget_use_style(moto_bg, "demo_moto_wt");
|
||||
widget_use_style(bg_button1, "bg_btn_wt");
|
||||
widget_use_style(bg_button2, "bg_btn_wt");
|
||||
for(uint8_t i=1;i<count;i++){
|
||||
btn = widget_get_child(f_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_USER_BLUE);
|
||||
btn = widget_get_child(r_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_USER_BLUE);
|
||||
}
|
||||
}else if(Get_sys_theme_state() == 2){//白色
|
||||
if(Get_sys_display_theme()){
|
||||
widget_use_style(moto_bg, "demo_moto_wt");
|
||||
widget_use_style(bg_button1, "bg_btn_wt");
|
||||
widget_use_style(bg_button2, "bg_btn_wt");
|
||||
for(uint8_t i=1;i<count;i++){
|
||||
btn = widget_get_child(f_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_USER_BLUE);
|
||||
btn = widget_get_child(r_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_USER_BLUE);
|
||||
}
|
||||
}else{
|
||||
widget_use_style(moto_bg, "demo_moto_bk");
|
||||
widget_use_style(bg_button1, "bg_btn_bk");
|
||||
widget_use_style(bg_button2, "bg_btn_bk");
|
||||
for(uint8_t i=1;i<count;i++){
|
||||
btn = widget_get_child(f_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
btn = widget_get_child(r_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
widget_use_style(moto_bg, "demo_moto_bk");
|
||||
widget_use_style(bg_button1, "bg_btn_bk");
|
||||
widget_use_style(bg_button2, "bg_btn_bk");
|
||||
for(uint8_t i=1;i<count;i++){
|
||||
btn = widget_get_child(f_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
btn = widget_get_child(r_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}else{//不支持胎压
|
||||
tire_pressure_view = widget_lookup(win, "tire_pressure_view", TRUE);
|
||||
if(tire_pressure_view!=NULL)
|
||||
widget_set_visible(tire_pressure_view,FALSE);
|
||||
tire = widget_lookup(win, "tire", TRUE);
|
||||
if(tire!=NULL)
|
||||
widget_set_visible(tire,FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void NEW_ui_data_refreshes(widget_t* win){
|
||||
static widget_t* ui_bg = NULL; //转速ui_img
|
||||
static widget_t* arc_bg = NULL; //转速ui_img
|
||||
static widget_t* progress_circle = NULL; //转速ui变化
|
||||
static widget_t* odo_data = NULL;
|
||||
static widget_t* trip_data = NULL;
|
||||
static widget_t* speed_num1 = NULL;
|
||||
static widget_t* speed_num2 = NULL;
|
||||
static widget_t* speed_num3 = NULL;
|
||||
static widget_t* grade = NULL;
|
||||
static widget_t* grade_bg = NULL;
|
||||
static widget_t* oil_bar = NULL;
|
||||
static widget_t* oil = NULL;
|
||||
static widget_t* oil_view = NULL;
|
||||
static widget_t* temp_bar = NULL;
|
||||
static widget_t* temp = NULL;
|
||||
static widget_t* temp_view = NULL;
|
||||
static widget_t* clock_hour1 = NULL;
|
||||
static widget_t* clock_hour2 = NULL;
|
||||
static widget_t* clock_colon = NULL;
|
||||
static widget_t* clock_min1 = NULL;
|
||||
static widget_t* clock_min2 = NULL;
|
||||
static widget_t* cell = NULL;
|
||||
static widget_t* cell_data = NULL;
|
||||
static widget_t* speed_unit = NULL;
|
||||
static widget_t* text_view = NULL;
|
||||
static widget_t* temp_C = NULL;
|
||||
static widget_t* oil_F = NULL;
|
||||
static widget_t* service = NULL;
|
||||
// static widget_t* veer = NULL;
|
||||
static widget_t* eng_wrn = NULL;
|
||||
static widget_t* abs = NULL;
|
||||
static widget_t* light = NULL;
|
||||
static widget_t* wifi = NULL;
|
||||
static widget_t* bt = NULL;
|
||||
static widget_t* fan = NULL;
|
||||
static widget_t* eng = NULL;
|
||||
static widget_t* tcs = NULL;
|
||||
static widget_t* kp_icon = NULL;
|
||||
|
||||
static widget_t* trip_unit = NULL;
|
||||
static widget_t* odo_unit = NULL;
|
||||
uint32_t count =0;
|
||||
uint8_t value =0;
|
||||
uint8_t value1 =0;
|
||||
uint8_t value2 =0;
|
||||
uint8_t value3 =0;
|
||||
uint8_t value4 =0;
|
||||
char tmpStr[20] = {0};
|
||||
widget_t* child = NULL;
|
||||
double buf =0;
|
||||
|
||||
uint8_t theme_Offset = 0;
|
||||
uint8_t display_unit = 0;
|
||||
switch(Get_sys_theme_state()){
|
||||
case 1:
|
||||
theme_Offset = RESOURCE_UI_WHITE;
|
||||
break;
|
||||
case 2:
|
||||
if(Get_sys_display_theme())
|
||||
theme_Offset = RESOURCE_UI_WHITE;
|
||||
else
|
||||
theme_Offset = RESOURCE_UI_BLACK;
|
||||
break;
|
||||
default:
|
||||
theme_Offset = RESOURCE_UI_BLACK;
|
||||
break;
|
||||
}
|
||||
display_unit = Get_sys_unit();
|
||||
uint8_t light_flag = 0;
|
||||
static uint8_t oil_light_flag = 0;
|
||||
static uint8_t temp_light_flag = 0;
|
||||
#ifdef AMT630HV100
|
||||
if(xTaskGetTickCount()%1000>500){
|
||||
light_flag = 1;
|
||||
}
|
||||
#endif
|
||||
if (!inited)
|
||||
{
|
||||
ui_bg = widget_lookup(win, "ui_bg", TRUE); //转速ui_img
|
||||
arc_bg = widget_lookup(win, "arc_bg", TRUE); //转速ui_img
|
||||
progress_circle = widget_lookup(win, "progress_circle", TRUE); //转速ui变化
|
||||
odo_data = widget_lookup(win, "odo_data", TRUE);
|
||||
trip_data = widget_lookup(win, "trip_data", TRUE);
|
||||
speed_num1 = widget_lookup(win, "speed_num1", TRUE);
|
||||
speed_num2 = widget_lookup(win, "speed_num2", TRUE);
|
||||
speed_num3 = widget_lookup(win, "speed_num3", TRUE);
|
||||
grade = widget_lookup(win, "grade", TRUE);
|
||||
grade_bg = widget_lookup(win, "grade_bg", TRUE);
|
||||
oil_bar = widget_lookup(win, "oil_bar", TRUE);
|
||||
oil = widget_lookup(win, "oil", TRUE);
|
||||
oil_view = widget_lookup(win, "oil_view", TRUE);
|
||||
temp_bar = widget_lookup(win, "temp_bar", TRUE);
|
||||
temp = widget_lookup(win, "temp", TRUE);
|
||||
temp_view = widget_lookup(win, "temp_view", TRUE);
|
||||
clock_hour1 = widget_lookup(win, "clock_hour1", TRUE);
|
||||
clock_hour2 = widget_lookup(win, "clock_hour2", TRUE);
|
||||
clock_colon = widget_lookup(win, "clock_colon", TRUE);
|
||||
clock_min1 = widget_lookup(win, "clock_min1", TRUE);
|
||||
clock_min2 = widget_lookup(win, "clock_min2", TRUE);
|
||||
cell = widget_lookup(win, "cell", TRUE);
|
||||
cell_data = widget_lookup(win, "cell_data", TRUE);
|
||||
speed_unit = widget_lookup(win, "speed_unit", TRUE);
|
||||
text_view = widget_lookup(win, "text_view", TRUE);
|
||||
temp_C = widget_lookup(win, "temp_C", TRUE);
|
||||
oil_F = widget_lookup(win, "oil_F", TRUE);
|
||||
service = widget_lookup(win, "service", TRUE);
|
||||
// veer = widget_lookup(win, "veer", TRUE);//转向
|
||||
eng_wrn = widget_lookup(win, "eng_wrn", TRUE);
|
||||
abs = widget_lookup(win, "abs", TRUE);
|
||||
light = widget_lookup(win, "light", TRUE);
|
||||
bt = widget_lookup(win, "bt", TRUE);
|
||||
wifi = widget_lookup(win, "wifi", TRUE);
|
||||
fan = widget_lookup(win, "fan", TRUE);
|
||||
eng = widget_lookup(win, "eng", TRUE);
|
||||
tcs = widget_lookup(win, "tcs", TRUE);
|
||||
kp_icon = widget_lookup(win, "kp_icon", TRUE);
|
||||
trip_unit = widget_lookup(win, "trip_unit", TRUE);
|
||||
odo_unit = widget_lookup(win, "odo_unit", TRUE);
|
||||
// left = widget_lookup(win, "left", TRUE);
|
||||
// right = widget_lookup(win, "right", TRUE);
|
||||
}
|
||||
|
||||
if(Get_sys_power_on_self_test()==100){
|
||||
widget_use_style(service, resource_style[RESOURCE_OFFSET_SERVICE+theme_Offset]);
|
||||
//图标刷新
|
||||
Universal_widget_display(light,Get_sys_lamplight());
|
||||
Universal_widget_display(abs,Get_sys_warning_abs());
|
||||
Universal_widget_display(tcs,Get_sys_warning_tcs());
|
||||
if(Get_sys_bt_on_off())
|
||||
Universal_widget_display(bt,Get_sys_bt_connect_state());
|
||||
else
|
||||
widget_set_visible(bt,FALSE);
|
||||
Universal_widget_display(wifi,Get_sys_wifi_state());
|
||||
|
||||
Universal_widget_display(fan,Get_sys_warning_fan());
|
||||
Universal_widget_display(eng,Get_sys_warning_engine());
|
||||
Universal_widget_display(eng_wrn,Get_sys_warning_machine_oil());
|
||||
Universal_widget_display(service,Get_sys_warning_maintenance());
|
||||
#ifdef UI_VIEW_QUICKLY_ARRANGE
|
||||
Universal_widget_display(kp_icon,Get_sys_quickly_arrange_state());
|
||||
#else
|
||||
widget_set_visible(kp_icon,FALSE);
|
||||
#endif
|
||||
|
||||
//速度
|
||||
value = Get_sys_display_velocity();
|
||||
if(display_unit){
|
||||
value = (int)(value*0.6);
|
||||
}
|
||||
if(value<10){
|
||||
widget_set_visible(speed_num1,FALSE);
|
||||
widget_set_visible(speed_num3,FALSE);
|
||||
widget_set_visible(speed_num2,TRUE);
|
||||
value3 = (value%10);
|
||||
widget_use_style(speed_num2, resource_style[value3+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
|
||||
}else if(value<100){
|
||||
widget_set_visible(speed_num1,FALSE);
|
||||
widget_set_visible(speed_num2,TRUE);
|
||||
widget_set_visible(speed_num3,TRUE);
|
||||
|
||||
value2 = (value/10%10);
|
||||
value3 = (value%10);
|
||||
|
||||
widget_use_style(speed_num2, resource_style[value2+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
widget_use_style(speed_num3, resource_style[value3+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
}else{
|
||||
widget_set_visible(speed_num1,TRUE);
|
||||
widget_set_visible(speed_num2,TRUE);
|
||||
widget_set_visible(speed_num3,TRUE);
|
||||
value1 = (value/100%10);
|
||||
value2 = (value/10%10);
|
||||
value3 = (value%10);
|
||||
widget_use_style(speed_num1, resource_style[value1+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
widget_use_style(speed_num2, resource_style[value2+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
widget_use_style(speed_num3, resource_style[value3+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
}
|
||||
|
||||
|
||||
widget_use_style(win, resource_style[RESOURCE_OFFSET_UI_BG_COLOR+theme_Offset]);
|
||||
widget_use_style(arc_bg, resource_style[RESOURCE_OFFSET_VEER_VELOCITY_ARC_IMG+theme_Offset]);
|
||||
widget_use_style(ui_bg, resource_style[RESOURCE_OFFSET_UI_BG+theme_Offset]);
|
||||
//转速
|
||||
count = (int)(Get_sys_veer_velocity()/100);
|
||||
if(count<18 && count>12)
|
||||
count = 15;
|
||||
|
||||
if(count>=120)
|
||||
count = 0;
|
||||
else
|
||||
count = (120-count);
|
||||
widget_use_style(progress_circle, resource_style[RESOURCE_OFFSET_VEER_VELOCITY+theme_Offset]);
|
||||
if(count)
|
||||
widget_animate_value_to(progress_circle, count,ANIMATE_SPEED);
|
||||
else
|
||||
widget_set_value_int(progress_circle,count);
|
||||
// widget_set_value(progress_circle, count);
|
||||
|
||||
//档位
|
||||
value = Get_sys_grade();
|
||||
if(value == GRADE_NULL){
|
||||
widget_use_style(grade_bg, resource_style[GRADE_BG_NULL+RESOURCE_OFFSET_GRADE_BG+theme_Offset]);
|
||||
}else{
|
||||
widget_use_style(grade_bg, resource_style[GRADE_BG_NUAMAL+RESOURCE_OFFSET_GRADE_BG+theme_Offset]);
|
||||
}
|
||||
|
||||
widget_use_style(grade, resource_style[value+RESOURCE_OFFSET_GRADE+theme_Offset]);
|
||||
|
||||
//油量
|
||||
value = Get_sys_gas(); //得到的是百分比
|
||||
if(value <=UI_TORAL6_GRIDS_OIL_1)
|
||||
widget_use_style(oil, resource_style[RESOURCE_IMG_ERROR+RESOURCE_OFFSET_OIL_BG+theme_Offset]);
|
||||
else
|
||||
widget_use_style(oil, resource_style[RESOURCE_IMG_NORMAL+RESOURCE_OFFSET_OIL_BG+theme_Offset]);
|
||||
if(refresh_flag%20 == 0){
|
||||
if( value <=UI_TORAL6_GRIDS_OIL_WARNING)
|
||||
value1 = 0;
|
||||
else if( value <=UI_TORAL6_GRIDS_OIL_1)
|
||||
value1 = 1;
|
||||
else if( value <=UI_TORAL6_GRIDS_OIL_2)
|
||||
value1 = 2;
|
||||
else if( value <=UI_TORAL6_GRIDS_OIL_3)
|
||||
value1 = 3;
|
||||
else if( value <=UI_TORAL6_GRIDS_OIL_4)
|
||||
value1 = 4;
|
||||
else if( value <=UI_TORAL6_GRIDS_OIL_5)
|
||||
value1 = 5;
|
||||
else
|
||||
value1 = 6;
|
||||
if(value1==0)
|
||||
oil_light_flag = 1;
|
||||
else
|
||||
oil_light_flag = 0;
|
||||
widget_use_style(oil_bar, resource_style[value1+RESOURCE_OFFSET_OIL+theme_Offset]);
|
||||
}
|
||||
//油量闪烁刷新
|
||||
if(oil_light_flag){
|
||||
if(light_flag)
|
||||
widget_set_visible(oil_view,FALSE);
|
||||
else
|
||||
widget_set_visible(oil_view,TRUE);
|
||||
|
||||
}else{
|
||||
widget_set_visible(oil_view,TRUE);
|
||||
}
|
||||
|
||||
//温度 6格显示
|
||||
value = Get_sys_temp(); //值为60-120
|
||||
if(speed_flag){
|
||||
buf = (double)Get_sys_can_temp(); //值为60-120
|
||||
if(buf>5280)
|
||||
buf = 255;
|
||||
else if(buf>2730)
|
||||
buf = ((buf*0.1)-273);
|
||||
else
|
||||
buf = 0;
|
||||
value = (int)buf;
|
||||
// printf("temp value = %d .\r\n",value);
|
||||
if(refresh_flag%20 == 0){
|
||||
if(value < UI_CAN_TORAL6_GRIDS_TEMP_0)
|
||||
value1 = 0;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_1)
|
||||
value1 = 1;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_2)
|
||||
value1 = 2;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_3)
|
||||
value1 = 3;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_4)
|
||||
value1 = 4;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_5)
|
||||
value1 = 5;
|
||||
else
|
||||
value1 = 6;
|
||||
if(value1==6)
|
||||
temp_light_flag = 1;
|
||||
else
|
||||
temp_light_flag = 0;
|
||||
widget_use_style(temp_bar, resource_style[value1+RESOURCE_OFFSET_TEMP+theme_Offset]);
|
||||
|
||||
if(value < UI_CAN_TORAL6_GRIDS_TEMP_0){
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
widget_use_style(temp, resource_style[RESOURCE_IMG_NULL+RESOURCE_OFFSET_TEMP_BG+theme_Offset]);
|
||||
}else if(value >=UI_CAN_TORAL6_GRIDS_TEMP_5){
|
||||
widget_use_style(temp, resource_style[RESOURCE_IMG_ERROR+RESOURCE_OFFSET_TEMP_BG+theme_Offset]);
|
||||
}else{
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
widget_use_style(temp, resource_style[RESOURCE_IMG_NORMAL+RESOURCE_OFFSET_TEMP_BG+theme_Offset]);
|
||||
}
|
||||
}
|
||||
|
||||
//温度闪烁刷新
|
||||
if(temp_light_flag){
|
||||
if(light_flag)
|
||||
widget_set_visible(temp_view,FALSE);
|
||||
else
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
}else{
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
value = Get_sys_temp(); //值为60-120
|
||||
|
||||
if(refresh_flag%20 == 0){
|
||||
if(value < UI_TORAL6_GRIDS_TEMP_0)
|
||||
value1 = 0;
|
||||
else if(value < UI_TORAL6_GRIDS_TEMP_1)
|
||||
value1 = 1;
|
||||
else if(value < UI_TORAL6_GRIDS_TEMP_2)
|
||||
value1 = 2;
|
||||
else if(value < UI_TORAL6_GRIDS_TEMP_3)
|
||||
value1 = 3;
|
||||
else if(value < UI_TORAL6_GRIDS_TEMP_4)
|
||||
value1 = 4;
|
||||
else if(value < UI_TORAL6_GRIDS_TEMP_5)
|
||||
value1 = 5;
|
||||
else
|
||||
value1 = 6;
|
||||
if(value1==6)
|
||||
temp_light_flag = 1;
|
||||
else
|
||||
temp_light_flag = 0;
|
||||
widget_use_style(temp_bar, resource_style[value1+RESOURCE_OFFSET_TEMP+theme_Offset]);
|
||||
|
||||
if(value < UI_TORAL6_GRIDS_TEMP_0){
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
widget_use_style(temp, resource_style[RESOURCE_IMG_NULL+RESOURCE_OFFSET_TEMP_BG+theme_Offset]);
|
||||
}else if(value >=UI_TORAL6_GRIDS_TEMP_5){
|
||||
widget_use_style(temp, resource_style[RESOURCE_IMG_ERROR+RESOURCE_OFFSET_TEMP_BG+theme_Offset]);
|
||||
}else{
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
widget_use_style(temp, resource_style[RESOURCE_IMG_NORMAL+RESOURCE_OFFSET_TEMP_BG+theme_Offset]);
|
||||
}
|
||||
}
|
||||
|
||||
//温度闪烁刷新
|
||||
if(temp_light_flag){
|
||||
if(light_flag)
|
||||
widget_set_visible(temp_view,FALSE);
|
||||
else
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
}else{
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//电压
|
||||
if(Get_sys_voltage()<11.75 || Get_sys_voltage()>=15.45){//变红
|
||||
widget_use_style(cell, resource_style[RESOURCE_IMG_ERROR+RESOURCE_OFFSET_CELL+theme_Offset]);
|
||||
widget_set_style_color(cell_data, "normal:text_color", OUTPUT_COLOR_RED);
|
||||
}else{
|
||||
widget_use_style(cell, resource_style[RESOURCE_IMG_NORMAL+RESOURCE_OFFSET_CELL+theme_Offset]);
|
||||
//widget_set_style_color(cell_data, "normal:text_color", OUTPUT_COLOR(tmpStr));
|
||||
widget_set_style_color(cell_data, "normal:text_color", OUTPUT_COLOR_GREEN);
|
||||
}
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.1fV",Get_sys_voltage());
|
||||
widget_set_text_utf8(cell_data,tmpStr);
|
||||
|
||||
//时间
|
||||
date_time_t dt;
|
||||
date_time_init(&dt);
|
||||
value1 = dt.hour/10%10;
|
||||
value2 = dt.hour%10;
|
||||
value3 = dt.minute/10%10;
|
||||
value4 = dt.minute%10;
|
||||
widget_use_style(clock_hour1, resource_style[value1+RESOURCE_OFFSET_CLOCK+theme_Offset]);
|
||||
widget_use_style(clock_hour2, resource_style[value2+RESOURCE_OFFSET_CLOCK+theme_Offset]);
|
||||
widget_use_style(clock_colon, resource_style[RESOURCE_OFFSET_CLOCK_COLON+theme_Offset]);
|
||||
|
||||
widget_use_style(clock_min1, resource_style[value3+RESOURCE_OFFSET_CLOCK+theme_Offset]);
|
||||
widget_use_style(clock_min2, resource_style[value4+RESOURCE_OFFSET_CLOCK+theme_Offset]);
|
||||
|
||||
|
||||
//部分文本颜色
|
||||
for(uint8_t i =0;i<4;i++){
|
||||
child = widget_get_child(text_view,i);
|
||||
widget_use_style(child,resource_style[RESOURCE_OFFSET_TEXT_COLOR+theme_Offset]);
|
||||
}
|
||||
widget_use_style(temp_C,resource_style[RESOURCE_OFFSET_TEXT_COLOR+theme_Offset]);
|
||||
widget_use_style(oil_F,resource_style[RESOURCE_OFFSET_TEXT_COLOR+theme_Offset]);
|
||||
|
||||
//速度单位
|
||||
if(display_unit){
|
||||
widget_use_style(speed_unit,resource_style[RESOURCE_SPEED_UNIT_MPH+RESOURCE_OFFSET_SPEED_UNIT+theme_Offset]);
|
||||
count = (int)(Get_sys_total_mileage()/1000*0.6);//总计里程
|
||||
buf = (int)(Get_sys_trip_mileage()/100);//小计里程
|
||||
buf = buf/10;
|
||||
buf = buf*0.6;
|
||||
widget_set_text_utf8(trip_unit,"mile");
|
||||
widget_set_text_utf8(odo_unit,"mile");
|
||||
}else{
|
||||
widget_use_style(speed_unit,resource_style[RESOURCE_SPEED_UNIT_KM+RESOURCE_OFFSET_SPEED_UNIT+theme_Offset]);
|
||||
count = Get_sys_total_mileage()/1000;//总计里程
|
||||
buf = (int)(Get_sys_trip_mileage()/100);//小计里程
|
||||
buf = buf/10;
|
||||
widget_set_text_utf8(trip_unit,"km");
|
||||
widget_set_text_utf8(odo_unit,"km");
|
||||
}
|
||||
|
||||
//总计里程数刷新
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%d",count);
|
||||
widget_set_text_utf8(odo_data,tmpStr);
|
||||
// //小计里程刷新
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.1lf",buf);
|
||||
widget_set_text_utf8(trip_data,tmpStr);
|
||||
|
||||
refresh_flag++;
|
||||
if(refresh_flag>=21)
|
||||
refresh_flag = 1;
|
||||
}else if(Get_sys_power_on_self_test()==75){
|
||||
widget_use_style(win, resource_style[RESOURCE_OFFSET_UI_BG_COLOR+theme_Offset]);
|
||||
widget_use_style(arc_bg, resource_style[RESOURCE_OFFSET_VEER_VELOCITY_ARC_IMG+theme_Offset]);
|
||||
widget_use_style(ui_bg, resource_style[RESOURCE_OFFSET_UI_BG+theme_Offset]);
|
||||
|
||||
count =widget_get_value_int(progress_circle);
|
||||
// DEBUG_PRINT("animo count = %d .\r\n",count);
|
||||
|
||||
// 速度
|
||||
// value = Get_sys_velocity();
|
||||
value = (255-(int)(count*2.125));
|
||||
if(value<10){
|
||||
widget_set_visible(speed_num1,FALSE);
|
||||
widget_set_visible(speed_num3,FALSE);
|
||||
widget_set_visible(speed_num2,TRUE);
|
||||
value3 = (value%10);
|
||||
if(value3<5)
|
||||
value3 = 0;
|
||||
widget_use_style(speed_num2, resource_style[value3+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
|
||||
}else if(value<100){
|
||||
widget_set_visible(speed_num1,FALSE);
|
||||
widget_set_visible(speed_num2,TRUE);
|
||||
widget_set_visible(speed_num3,TRUE);
|
||||
|
||||
value2 = (value/10%10);
|
||||
value3 = (value%10);
|
||||
|
||||
widget_use_style(speed_num2, resource_style[value2+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
widget_use_style(speed_num3, resource_style[value3+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
}else{
|
||||
widget_set_visible(speed_num1,TRUE);
|
||||
widget_set_visible(speed_num2,TRUE);
|
||||
widget_set_visible(speed_num3,TRUE);
|
||||
value1 = (value/100%10);
|
||||
value2 = (value/10%10);
|
||||
value3 = (value%10);
|
||||
widget_use_style(speed_num1, resource_style[value1+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
widget_use_style(speed_num2, resource_style[value2+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
widget_use_style(speed_num3, resource_style[value3+RESOURCE_OFFSET_SPEED+theme_Offset]);
|
||||
}
|
||||
//档位
|
||||
// value = Get_sys_grade();
|
||||
value = (7-(int)(count/16));
|
||||
if(value == GRADE_NULL){
|
||||
widget_use_style(grade_bg, resource_style[GRADE_BG_NULL+RESOURCE_OFFSET_GRADE_BG+theme_Offset]);
|
||||
}else{
|
||||
widget_use_style(grade_bg, resource_style[GRADE_BG_NUAMAL+RESOURCE_OFFSET_GRADE_BG+theme_Offset]);
|
||||
}
|
||||
widget_use_style(grade, resource_style[value+RESOURCE_OFFSET_GRADE+theme_Offset]);
|
||||
if(value == 7){
|
||||
value=6;
|
||||
}
|
||||
//油量
|
||||
widget_use_style(oil_bar, resource_style[value+RESOURCE_OFFSET_OIL+theme_Offset]);
|
||||
//温度
|
||||
widget_use_style(temp_bar, resource_style[value+RESOURCE_OFFSET_TEMP+theme_Offset]);
|
||||
|
||||
//时间
|
||||
value = (9-(int)(count/12.5));
|
||||
widget_use_style(clock_hour1, resource_style[value+RESOURCE_OFFSET_CLOCK+theme_Offset]);
|
||||
widget_use_style(clock_hour2, resource_style[value+RESOURCE_OFFSET_CLOCK+theme_Offset]);
|
||||
widget_use_style(clock_colon, resource_style[RESOURCE_OFFSET_CLOCK_COLON+theme_Offset]);
|
||||
widget_use_style(clock_min1, resource_style[value+RESOURCE_OFFSET_CLOCK+theme_Offset]);
|
||||
widget_use_style(clock_min2, resource_style[value+RESOURCE_OFFSET_CLOCK+theme_Offset]);
|
||||
|
||||
//小计 总计
|
||||
count = value*11111111;
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%d",count);
|
||||
widget_set_text_utf8(odo_data,tmpStr);
|
||||
|
||||
buf = value*111111.1;
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.1lf",buf);
|
||||
widget_set_text_utf8(trip_data,tmpStr);
|
||||
|
||||
//电压
|
||||
buf = value*11.1;
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.1lf",buf);
|
||||
widget_set_text_utf8(cell_data,tmpStr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void A270F_ui_refresh(widget_t* win){
|
||||
NEW_ui_data_refreshes(win);
|
||||
tire_pressure_init(win);
|
||||
inited = 1;
|
||||
}
|
||||
/*
|
||||
static ret_t ui_refresh(const timer_info_t* timer){
|
||||
widget_t*win = WIDGET(timer->ctx);//home_page
|
||||
// if(Get_sys_power_on_self_test()==100){
|
||||
NEW_ui_data_refreshes(win);
|
||||
tire_pressure_init(win);
|
||||
// }
|
||||
inited = 1;
|
||||
|
||||
return RET_REPEAT;
|
||||
}*/
|
||||
|
||||
#if 1
|
||||
static ret_t on_home_page_key_down(void* ctx, event_t* e) {
|
||||
key_event_t* evt = key_event_cast(e);
|
||||
if(Get_sys_power_on_self_test()!=100)
|
||||
return RET_OK;
|
||||
|
||||
if(Get_sys_call_state() == 0){
|
||||
if(evt->key == TK_KEY_w){
|
||||
if(Get_sys_velocity() == 0){//有速度的情况下不允许进入设置界面
|
||||
inited = 0;
|
||||
navigator_replace("set_list");
|
||||
}
|
||||
}else if(evt->key == TK_KEY_q){
|
||||
inited = 0;
|
||||
navigator_to("new");
|
||||
}else if(evt->key == TK_KEY_z){
|
||||
if(Get_sys_velocity() == 0 && Get_sys_maintenance_mileage()){//有速度的情况下不允许进入设置界面
|
||||
inited = 0;
|
||||
navigator_to("ToolTip_box");
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
if(evt->key == TK_KEY_w){//接听
|
||||
Set_sys_call_key_state(1);
|
||||
}else if(evt->key == TK_KEY_q){//挂断
|
||||
Set_sys_call_key_state(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern ret_t on_key_set_data(void* ctx, event_t* e);
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
if (tk_str_eq(name, "home_page")) {
|
||||
widget_on(widget, EVT_KEY_DOWN, on_home_page_key_down, win);
|
||||
#ifndef AMT630HV100
|
||||
widget_on(widget, EVT_KEY_DOWN, on_key_set_data, win);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t home_page_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
inited = 0;
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
Update_theme_init();
|
||||
// NEW_ui_data_refreshes(win);
|
||||
if(Get_sys_power_on_self_test()==100 && winflag != 5){
|
||||
refresh_flag = 20;
|
||||
NEW_ui_data_refreshes(win);
|
||||
light_refresh(win);
|
||||
tire_pressure_init(win);
|
||||
}
|
||||
printf("home_page_init--------------------\r\n");
|
||||
// widget_add_timer(win, ui_refresh, 100);//进度条颜色刷新
|
||||
extern uint8_t button_flag;
|
||||
if(button_flag==0)
|
||||
button_flag = 1;
|
||||
winflag = 0;
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,738 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/data_port.h"
|
||||
#include "../common/navigator.h"
|
||||
#include "../common/universal.h"
|
||||
#include "../common/user_data.h"
|
||||
#include "../common/moto_config.h"
|
||||
|
||||
static uint8_t qr_flag = 0;
|
||||
|
||||
static uint8_t tp_inited = 0;
|
||||
static uint8_t qr = 0;
|
||||
static uint8_t qr_imgdisplay_flag = 0;
|
||||
|
||||
extern char strQrText[200];
|
||||
extern char UI_uuid[32];
|
||||
extern uint8_t refresh500ms_flag;
|
||||
|
||||
extern void Return_demo_win(void);
|
||||
extern ret_t on_key_set_data(void *ctx, event_t *e);
|
||||
extern widget_t *qr_create(widget_t *parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
extern char bt121_name[50];
|
||||
|
||||
char *temp_resource_icon[6] = {
|
||||
"temp_bk_normal",
|
||||
"temp_bk_normal",
|
||||
"temp_bk_error",
|
||||
"temp_bk_error",
|
||||
"temp_bk_error",
|
||||
"temp_bk_error",
|
||||
};
|
||||
|
||||
char *fuel_resource_icon[3] = {
|
||||
"oil_bk_normal",
|
||||
"oil_bk_normal",
|
||||
"oil_bk_error",
|
||||
};
|
||||
|
||||
|
||||
//取字符串最后n位字符
|
||||
void getLastNChars(char *strQrText, int n, char *text) {
|
||||
int len = strlen(strQrText);
|
||||
|
||||
if (len <= n) {
|
||||
strcpy(text, strQrText); // 如果字符串长度小于等于 n,则直接复制整个字符串
|
||||
} else {
|
||||
strcpy(text, strQrText + len - n); // 复制最后 n 个字符到 text 中
|
||||
}
|
||||
}
|
||||
//取字符串最后一个=后的n位字符
|
||||
void getTextAfterLastEqual(char *strQrText, char *text) {
|
||||
int len = strlen(strQrText);
|
||||
int i;
|
||||
int lastEqualIndex = -1;
|
||||
|
||||
// 找到最后一个等号符号的位置
|
||||
for (i = len - 1; i >= 0; i--) {
|
||||
if (strQrText[i] == '=') {
|
||||
lastEqualIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastEqualIndex != -1) {
|
||||
strcpy(text, strQrText + lastEqualIndex + 1); // 复制等号符号后的所有字符到 text 中
|
||||
} else {
|
||||
strcpy(text, strQrText); // 如果没有找到等号符号,则复制整个字符串
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void tp_init(widget_t *win) {
|
||||
// 加载二维码部分初始化
|
||||
char tmpStr[200] = {0};
|
||||
char tmpStr_text[100] = {0};
|
||||
|
||||
widget_t *qr_view = widget_lookup(win, "qr_view", TRUE);
|
||||
widget_set_style_color(qr_view, "normal:bg_color", 0xff000000);
|
||||
|
||||
// 三个提示界面 UI初始为隐藏属性
|
||||
widget_t *p2p_view = widget_lookup(win, "p2p_view", TRUE);
|
||||
widget_t *carplay_view = widget_lookup(win, "carplay_view", TRUE);
|
||||
widget_t *android_view = widget_lookup(win, "android_view", TRUE);
|
||||
|
||||
widget_t *tp_switch = widget_lookup(win, "tp_switch", TRUE);
|
||||
widget_t *Tab = widget_lookup(win, "Tab", TRUE);
|
||||
|
||||
widget_t *select_tab = NULL;
|
||||
switch (Get_sys_tp_state()) {
|
||||
case 0:
|
||||
select_tab = widget_lookup(win, "cp_tab", TRUE);
|
||||
break;
|
||||
case 1:
|
||||
select_tab = widget_lookup(win, "aa_tab", TRUE);
|
||||
break;
|
||||
case 2:
|
||||
select_tab = widget_lookup(win, "ec_tab", TRUE);
|
||||
break;
|
||||
default: // 投屏保护
|
||||
Set_sys_tp_state(0);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef UI_ABS_CLOSE
|
||||
widget_t *warn_abs_icon = widget_lookup(win, "warn_abs_icon", TRUE);
|
||||
widget_set_visible(warn_abs_icon,FALSE);
|
||||
#endif
|
||||
#ifdef UI_TCS_CLOSE
|
||||
widget_t *tcs_icon = widget_lookup(win, "tcs_icon", TRUE);
|
||||
widget_set_visible(tcs_icon,FALSE);
|
||||
#endif
|
||||
#ifdef UI_ENG_CLOSE
|
||||
widget_t *warn_engine_icon = widget_lookup(win, "warn_engine_icon", TRUE);
|
||||
widget_set_visible(warn_engine_icon,FALSE);
|
||||
#endif
|
||||
#ifdef UI_TEMP_CLOSE
|
||||
widget_t *temp_view = widget_lookup(win, "temp_view", TRUE);
|
||||
widget_set_visible(temp_view,FALSE);
|
||||
#endif
|
||||
|
||||
|
||||
#if (MOTO_WARE_HOSE == MOTO_ICMX_A580A || (MOTO_WARE_HOSE == MOTO_ICMX_GB518_A270S))
|
||||
// 关闭对应按钮
|
||||
widget_t *dis_tab = widget_lookup(win, "ec_tab", TRUE);
|
||||
widget_set_visible(dis_tab, FALSE);
|
||||
|
||||
if (!Get_sys_tp_state()) { // carplay
|
||||
widget_set_visible(carplay_view, TRUE);
|
||||
widget_set_visible(android_view, FALSE);
|
||||
|
||||
} else { // android
|
||||
widget_set_visible(android_view, TRUE);
|
||||
widget_set_visible(carplay_view, FALSE);
|
||||
}
|
||||
widget_set_visible(p2p_view, FALSE);
|
||||
#elif (MOTO_WARE_HOSE == MOTO_ICMX_A590A)
|
||||
// 关闭对应按钮
|
||||
widget_t *dis_tab = widget_lookup(win, "aa_tab", TRUE);
|
||||
widget_set_visible(dis_tab, FALSE);
|
||||
|
||||
if (!Get_sys_tp_state()) { // carplay
|
||||
widget_set_visible(carplay_view, TRUE);
|
||||
widget_set_visible(p2p_view, FALSE);
|
||||
} else { // 亿连
|
||||
widget_set_visible(p2p_view, TRUE);
|
||||
widget_set_visible(carplay_view, FALSE);
|
||||
|
||||
widget_t *bt_name = widget_lookup(win, "bt_name", TRUE);
|
||||
printf("strQrText=%s.\r\n",strQrText);
|
||||
widget_t *qr1 = qr_create(qr_view, 40, 81, 200, 200);
|
||||
// printf("qr1 >>option>> %d.\r\n",widget_index_of(qr1));
|
||||
qr_set_value(qr1, strQrText);
|
||||
// getLastNChars(strQrText, 22, tmpStr);
|
||||
getTextAfterLastEqual(strQrText, tmpStr);
|
||||
widget_set_text_utf8(bt_name, tmpStr);
|
||||
widget_t *uuid = widget_lookup(win, "uuid", TRUE);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "uuid:%s", UI_uuid);
|
||||
// printf("UI_uuid > %s .\r\n",UI_uuid);
|
||||
widget_set_text_utf8(uuid, tmpStr);
|
||||
// printf("tmpStr>%s.\r\n",tmpStr);
|
||||
ap_get_ssid(strQrText, tmpStr);
|
||||
printf("wifi_name>%s.\r\n",tmpStr);
|
||||
ap_get_pwd(strQrText, tmpStr);
|
||||
printf("wifi_pwd>%s.\r\n",tmpStr);
|
||||
|
||||
qr_flag = 1;
|
||||
}
|
||||
|
||||
#elif (MOTO_WARE_HOSE == MOTO_ICMX_A591F)
|
||||
// 关闭对应按钮
|
||||
widget_t *dis_tab = widget_lookup(win, "aa_tab", TRUE);
|
||||
widget_set_visible(dis_tab, FALSE);
|
||||
widget_t *ec_tab = widget_lookup(win, "ec_tab", TRUE);
|
||||
widget_set_visible(ec_tab, FALSE);
|
||||
widget_set_visible(carplay_view, TRUE);
|
||||
widget_set_visible(p2p_view, FALSE);
|
||||
|
||||
/*
|
||||
if (!Get_sys_tp_state()) { // carplay
|
||||
widget_set_visible(carplay_view, TRUE);
|
||||
widget_set_visible(p2p_view, FALSE);
|
||||
} else { // 亿连
|
||||
widget_set_visible(p2p_view, TRUE);
|
||||
widget_set_visible(carplay_view, FALSE);
|
||||
|
||||
widget_t *bt_name = widget_lookup(win, "bt_name", TRUE);
|
||||
printf("strQrText=%s.\r\n",strQrText);
|
||||
widget_t *qr1 = qr_create(qr_view, 40, 81, 200, 200);
|
||||
qr_set_value(qr1, strQrText);
|
||||
getTextAfterLastEqual(strQrText, tmpStr);
|
||||
widget_set_text_utf8(bt_name, tmpStr);
|
||||
widget_t *uuid = widget_lookup(win, "uuid", TRUE);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "uuid:%s", UI_uuid);
|
||||
widget_set_text_utf8(uuid, tmpStr);
|
||||
ap_get_ssid(strQrText, tmpStr);
|
||||
printf("wifi_name>%s.\r\n",tmpStr);
|
||||
ap_get_pwd(strQrText, tmpStr);
|
||||
printf("wifi_pwd>%s.\r\n",tmpStr);
|
||||
|
||||
qr_flag = 1;
|
||||
}*/
|
||||
|
||||
select_tab = widget_lookup(win, "cp_tab", TRUE);
|
||||
|
||||
#endif
|
||||
|
||||
// 加载二维码部分初始化
|
||||
widget_t *uuid_text = widget_lookup(win, "uuid_text", TRUE);
|
||||
printf("bt121_name>>>%s.\r\n",bt121_name);
|
||||
if (strlen(bt121_name) != 0) {
|
||||
widget_set_visible(uuid_text, TRUE);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "BT:%s", bt121_name);
|
||||
widget_set_text_utf8(uuid_text, tmpStr);
|
||||
} else {
|
||||
widget_set_visible(uuid_text, FALSE);
|
||||
}
|
||||
|
||||
widget_t *bt_hint = widget_lookup(win, "bt_hint", TRUE);
|
||||
if(Get_sys_bt_on_off())
|
||||
widget_set_visible(bt_hint, FALSE);
|
||||
else
|
||||
widget_set_visible(bt_hint, TRUE);
|
||||
|
||||
|
||||
if (select_tab != NULL)
|
||||
widget_set_value(select_tab, TRUE);
|
||||
|
||||
// 投屏初始化
|
||||
if (Get_sys_wifi_state()) // 若当前连接投屏 则隐藏二维码部分
|
||||
widget_set_opacity(qr_view, 0);
|
||||
}
|
||||
|
||||
static void uuid_UI_refresh(widget_t *win) {
|
||||
static widget_t *uuid = NULL;
|
||||
if (!tp_inited) {
|
||||
uuid = widget_lookup(win, "uuid", TRUE);
|
||||
}
|
||||
if (Get_sys_uuid_state()) { // 已激活授权
|
||||
widget_set_style_str(uuid, "normal.text_color", "#00FF00");
|
||||
} else {
|
||||
widget_set_style_str(uuid, "normal.text_color", "#FF0000");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 图标刷新
|
||||
*
|
||||
* @param win
|
||||
*/
|
||||
static void tp_ui_refresh_icons(widget_t *win) {
|
||||
static widget_t *func_bt_icon = NULL;
|
||||
static widget_t *light = NULL;
|
||||
static widget_t *wifi = NULL;
|
||||
#ifndef UI_ABS_CLOSE
|
||||
static widget_t *warn_abs_icon = NULL;
|
||||
#endif
|
||||
#ifndef UI_TCS_CLOSE
|
||||
static widget_t *tcs_icon = NULL;
|
||||
#endif
|
||||
#ifndef UI_ENG_CLOSE
|
||||
static widget_t *warn_engine_icon = NULL;
|
||||
#endif
|
||||
|
||||
if (!tp_inited) {
|
||||
func_bt_icon = widget_lookup(win, "func_bt_icon", TRUE);
|
||||
light = widget_lookup(win, "light", TRUE); // 示宽灯
|
||||
wifi = widget_lookup(win, "wifi", TRUE); // wifi
|
||||
#ifndef UI_ABS_CLOSE
|
||||
warn_abs_icon = widget_lookup(win, "warn_abs_icon", TRUE); // abs
|
||||
#endif
|
||||
#ifndef UI_TCS_CLOSE
|
||||
tcs_icon = widget_lookup(win, "tcs_icon", TRUE);
|
||||
#endif
|
||||
#ifndef UI_ENG_CLOSE
|
||||
warn_engine_icon = widget_lookup(win, "warn_engine_icon", TRUE); // abs
|
||||
#endif
|
||||
}
|
||||
Universal_widget_display(func_bt_icon, Get_sys_bt_connect_state());
|
||||
Universal_widget_display(light, Get_sys_lamplight());
|
||||
Universal_widget_display(wifi, Get_sys_wifi_state());
|
||||
|
||||
#ifndef UI_ABS_CLOSE
|
||||
Universal_widget_display(warn_abs_icon, Get_sys_warning_abs());
|
||||
#endif
|
||||
#ifndef UI_TCS_CLOSE
|
||||
Universal_widget_display(tcs_icon, Get_sys_warning_tcs());
|
||||
#endif
|
||||
#ifndef UI_ENG_CLOSE
|
||||
Universal_widget_display(warn_engine_icon, Get_sys_warning_engine());
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 转速刷新
|
||||
*
|
||||
* @param win
|
||||
* @param value 转速值 r/min
|
||||
*/
|
||||
static void tp_ui_refresh_rmp(widget_t *win, uint16_t value) {
|
||||
static widget_t *dh_veer_velocity = NULL; // 转速
|
||||
if (!tp_inited) {
|
||||
dh_veer_velocity = widget_lookup(win, "dh_veer_velocity", TRUE);
|
||||
}
|
||||
char tmpStr[20] = {0};
|
||||
static int16_t _value = 0;
|
||||
double rpm = 0;
|
||||
value /= 100;
|
||||
int16_t diff = (int16_t)_value - (int16_t)value;
|
||||
|
||||
if (diff > 2 || diff < -2 || !tp_inited) {
|
||||
if (value >= 14 && value <= 16)
|
||||
value = 15;
|
||||
else if (value > 163)
|
||||
value = 163;
|
||||
else if (value <= 3)
|
||||
value = 0;
|
||||
_value = value;
|
||||
// if(value>=100)
|
||||
// tk_snprintf(tmpStr, sizeof(tmpStr), "%d",(value/10));
|
||||
// else{
|
||||
rpm = value;
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.1f", (double)(rpm / 10));
|
||||
// }
|
||||
widget_set_text_utf8(dh_veer_velocity, tmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 速度刷新
|
||||
*
|
||||
* @param win
|
||||
* @param value 速度值 km/h
|
||||
*/
|
||||
static void tp_ui_refresh_speed(widget_t *win, uint16_t value) {
|
||||
static widget_t *speed = NULL; // 速度
|
||||
static widget_t *speed_unit = NULL; // 速度单位
|
||||
if (!tp_inited) {
|
||||
speed = widget_lookup(win, "dh_speed", TRUE);
|
||||
speed_unit = widget_lookup(win, "dh_speed_uint", TRUE);
|
||||
}
|
||||
|
||||
if (Get_sys_unit()) {
|
||||
value *= 0.6;
|
||||
widget_set_text_utf8(speed_unit, "mph");
|
||||
} else
|
||||
widget_set_text_utf8(speed_unit, "km/h");
|
||||
char tmpStr[20] = {0};
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%d", value);
|
||||
// widget_set_value(speed,value);
|
||||
widget_set_text_utf8(speed, tmpStr);
|
||||
}
|
||||
|
||||
// 挡位
|
||||
static void tp_ui_refresh_gear(widget_t *win, uint16_t value) {
|
||||
static widget_t *gear = NULL; // 挡位
|
||||
if (!tp_inited) {
|
||||
gear = widget_lookup(win, "dh_grade", TRUE);
|
||||
}
|
||||
char tmpStr[20] = {0};
|
||||
if (value == 0) {
|
||||
tmpStr[0] = 'N';
|
||||
widget_set_style_color(gear, "text_color", 0xff00ff00);
|
||||
} else if (value > 6) {
|
||||
tmpStr[0] = '-';
|
||||
widget_set_style_color(gear, "text_color", 0xffffffff);
|
||||
} else {
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%d", value);
|
||||
widget_set_style_color(gear, "text_color", 0xffffffff);
|
||||
}
|
||||
widget_set_text_utf8(gear, tmpStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 油量刷新
|
||||
*
|
||||
* @param win
|
||||
* @param value 油量值 0-100
|
||||
*/
|
||||
extern uint8_t temp_state;
|
||||
static void tp_ui_refresh_oil(widget_t *win, uint16_t value) {
|
||||
static widget_t *fuel_icon = NULL; // 油量图标
|
||||
static widget_t *fuel_bar = NULL; // 油量
|
||||
static widget_t *fuel_view = NULL; // 油量
|
||||
if (!tp_inited) {
|
||||
fuel_icon = widget_lookup(win, "oil", TRUE); // 油量图标
|
||||
fuel_bar = widget_lookup(win, "oil_bar", TRUE); // 油量
|
||||
fuel_view = widget_lookup(win, "fuel_view", TRUE); // 油量
|
||||
}
|
||||
// uint16_t fuel_list[7] = {10, 20, 32, 44, 56, 68, 80};
|
||||
uint16_t fuel_list[6] = {UI_TORAL6_GRIDS_OIL_1, UI_TORAL6_GRIDS_OIL_1,
|
||||
UI_TORAL6_GRIDS_OIL_2, UI_TORAL6_GRIDS_OIL_3,
|
||||
UI_TORAL6_GRIDS_OIL_4, UI_TORAL6_GRIDS_OIL_5,};
|
||||
uint8_t fuel_value[6] = {0, 20, 40, 60, 80, 100};
|
||||
uint8_t index = 0;
|
||||
for (size_t i = 0; i < 6; i++) {
|
||||
if (value <= fuel_list[i]) {
|
||||
break;
|
||||
}
|
||||
index = i;
|
||||
}
|
||||
|
||||
if(!index){
|
||||
widget_use_style(fuel_icon, fuel_resource_icon[2]); // 油量图标
|
||||
widget_set_visible(fuel_view,refresh500ms_flag);
|
||||
} else {
|
||||
widget_use_style(fuel_icon, fuel_resource_icon[0]);
|
||||
widget_set_visible(fuel_view,TRUE);
|
||||
}
|
||||
widget_set_value(fuel_bar, (index * 20));
|
||||
// widget_animate_value_to(fuel_bar, fuel_value[index],ANIMATE_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 水温刷新 7格显示
|
||||
*
|
||||
* @param win
|
||||
* @param value 温度值 60-120
|
||||
*/
|
||||
extern uint8_t speed_flag;
|
||||
|
||||
|
||||
static void tp_ui_refresh_temp(widget_t *win, uint16_t value) {
|
||||
static widget_t *temp_icon = NULL; // 水温图标
|
||||
static widget_t *temp_bar = NULL; // 水温
|
||||
static widget_t *temp_view = NULL; // 水温
|
||||
|
||||
|
||||
if (!tp_inited) {
|
||||
temp_icon = widget_lookup(win, "temp_icon", TRUE);
|
||||
temp_bar = widget_lookup(win, "temp_bar", TRUE);
|
||||
temp_view = widget_lookup(win, "temp_view", TRUE);
|
||||
}
|
||||
uint8_t index = 0;
|
||||
uint8_t temp_icon_state; // 0为正常 1为高温红色 2为低温蓝色 3为黄色
|
||||
|
||||
if (speed_flag){
|
||||
if(value < UI_CAN_TORAL6_GRIDS_TEMP_0)
|
||||
index = 0;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_1)
|
||||
index = 1;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_2)
|
||||
index = 2;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_3)
|
||||
index = 3;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_4)
|
||||
index = 4;
|
||||
else if(value < UI_CAN_TORAL6_GRIDS_TEMP_5)
|
||||
index = 5;
|
||||
else
|
||||
index = 6;
|
||||
}else{
|
||||
if (value < UI_TORAL6_GRIDS_TEMP_0)
|
||||
index = 0;
|
||||
else if (value < UI_TORAL6_GRIDS_TEMP_1)
|
||||
index = 1;
|
||||
else if (value < UI_TORAL6_GRIDS_TEMP_2)
|
||||
index = 2;
|
||||
else if (value < UI_TORAL6_GRIDS_TEMP_3)
|
||||
index = 3;
|
||||
else if (value < UI_TORAL6_GRIDS_TEMP_4)
|
||||
index = 4;
|
||||
else if (value < UI_TORAL6_GRIDS_TEMP_5)
|
||||
index = 5;
|
||||
else
|
||||
index = 6;
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
widget_use_style(temp_icon, temp_resource_icon[0]);
|
||||
widget_set_style_color(temp_bar, "normal:fg_color", 0xffffffff);
|
||||
widget_set_visible(temp_view,TRUE);
|
||||
break;
|
||||
default:
|
||||
widget_use_style(temp_icon, temp_resource_icon[2]);
|
||||
widget_set_style_color(temp_bar, "normal:fg_color", 0xff0000ff);
|
||||
widget_set_visible(temp_view,refresh500ms_flag);
|
||||
break;
|
||||
}
|
||||
|
||||
widget_set_value(temp_bar, (index * 20));
|
||||
}
|
||||
|
||||
|
||||
static void uuid_BT_switch_refresh(widget_t *win, uint8_t value) {
|
||||
static widget_t *bt_hint = NULL;
|
||||
if (!tp_inited) {
|
||||
bt_hint = widget_lookup(win, "bt_hint", TRUE); // 蓝牙提示窗口
|
||||
}
|
||||
widget_set_visible(bt_hint, value?FALSE:TRUE);
|
||||
|
||||
}
|
||||
|
||||
static void tp_ui_refresh(widget_t *win) {
|
||||
uint8_t state = Get_sys_wifi_state();
|
||||
|
||||
widget_t *qr_view = widget_lookup(win, "qr_view", TRUE);
|
||||
light_refresh(win);
|
||||
// 档位刷新
|
||||
tp_ui_refresh_gear(win, Get_sys_grade());
|
||||
// 转速
|
||||
tp_ui_refresh_rmp(win, Get_sys_veer_velocity());
|
||||
// 速度
|
||||
tp_ui_refresh_speed(win, Get_sys_velocity());
|
||||
// 油量
|
||||
tp_ui_refresh_oil(win, Get_sys_gas()); // 得到的是百分比
|
||||
#ifndef UI_TEMP_CLOSE
|
||||
// 水温
|
||||
#if (MOTO_WARE_HOSE == MOTO_ICMX_A580A)
|
||||
tp_ui_refresh_temp(win, Get_sys_can_temp()); // 值为60-120
|
||||
#else
|
||||
if (speed_flag)
|
||||
tp_ui_refresh_temp(win, Get_sys_can_temp()); // 值为60-120
|
||||
else
|
||||
tp_ui_refresh_temp(win, Get_sys_temp()); // 值为60-120
|
||||
#endif
|
||||
#endif
|
||||
// 图标刷新
|
||||
tp_ui_refresh_icons(win);
|
||||
|
||||
// UUID刷新
|
||||
uuid_UI_refresh(win);
|
||||
//蓝牙提示窗口刷新
|
||||
uuid_BT_switch_refresh(win,Get_sys_bt_on_off());
|
||||
|
||||
// wifi图标
|
||||
if (state == 1) {
|
||||
if (qr == 1) {
|
||||
widget_set_opacity(qr_view, 0);
|
||||
qr = 0;
|
||||
}
|
||||
} else {
|
||||
if (qr == 0) {
|
||||
widget_set_opacity(qr_view, 255);
|
||||
qr = 1;
|
||||
}
|
||||
}
|
||||
|
||||
tp_inited = 1;
|
||||
}
|
||||
|
||||
static ret_t on_new_key_down(void *ctx, event_t *e) {
|
||||
key_event_t *evt = key_event_cast(e);
|
||||
widget_t *win = e->target;
|
||||
|
||||
if (Get_sys_call_state()) {
|
||||
if (evt->key == TK_KEY_w) { // 接听
|
||||
if (Get_sys_call_state() != 2)
|
||||
console_send_atcmd("AT+HFPANSW\r\n", strlen("AT+HFPANSW\r\n")); // 接听
|
||||
} else if (evt->key == TK_KEY_q) { // 挂断
|
||||
// printf("q-----------------------\r\n");
|
||||
console_send_atcmd("AT+HFPCHUP\r\n", strlen("AT+HFPCHUP\r\n")); // 拒接
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
if (evt->key == TK_KEY_w) {
|
||||
#if (MOTO_WARE_HOSE == MOTO_ICMX_A591F)
|
||||
return_demo();
|
||||
#else
|
||||
if(Get_sys_wifi_state())//连接上不允许切换
|
||||
return RET_OK;
|
||||
widget_t *qr_view = widget_lookup(win, "qr_view", TRUE);
|
||||
widget_t *Tab = widget_lookup(win, "Tab", TRUE); // 选择器
|
||||
widget_t *child = NULL;
|
||||
uint8_t i;
|
||||
// 查找当前选中对象
|
||||
for (i = 0; i < 3; i++) {
|
||||
child = widget_get_child(Tab, i);
|
||||
if (!widget_get_visible(child))
|
||||
continue;
|
||||
if (widget_get_value(child))
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
if (i > 2)
|
||||
i = 0;
|
||||
child = widget_get_child(Tab, i);
|
||||
// 判断目标是否被隐藏 若隐藏 则切换下一个
|
||||
while (!widget_get_visible(child)) {
|
||||
i++;
|
||||
if (i > 2)
|
||||
i = 0;
|
||||
child = widget_get_child(Tab, i);
|
||||
}
|
||||
// 设置目标被选中
|
||||
widget_set_value(child, TRUE);
|
||||
|
||||
// 提示界面刷新
|
||||
widget_t *carplay_view = widget_lookup(win, "carplay_view", TRUE);
|
||||
widget_t *android_view = widget_lookup(win, "android_view", TRUE);
|
||||
widget_t *p2p_view = widget_lookup(win, "p2p_view", TRUE);
|
||||
switch (i) {
|
||||
case 0: // carplay
|
||||
|
||||
widget_set_visible(carplay_view, TRUE);
|
||||
widget_set_visible(android_view, FALSE);
|
||||
widget_set_visible(p2p_view, FALSE);
|
||||
carlink_cp_enable(1);
|
||||
carlink_aa_enable(0);
|
||||
carlink_ec_enable(0);
|
||||
Set_sys_tp_state(0);
|
||||
if (qr_flag) {
|
||||
widget_t *qr1 = widget_get_child(qr_view, 1);
|
||||
widget_set_visible(qr1, FALSE);
|
||||
}
|
||||
printf("now>>>carplay .\r\n");
|
||||
break;
|
||||
case 1: // android
|
||||
widget_set_visible(carplay_view, FALSE);
|
||||
widget_set_visible(android_view, TRUE);
|
||||
widget_set_visible(p2p_view, FALSE);
|
||||
carlink_cp_enable(0);
|
||||
carlink_aa_enable(1);
|
||||
carlink_ec_enable(0);
|
||||
Set_sys_tp_state(1);
|
||||
if (qr_flag) {
|
||||
widget_t *qr1 = widget_get_child(qr_view, 1);
|
||||
widget_set_visible(qr1, FALSE);
|
||||
}
|
||||
printf("now>>>android .\r\n");
|
||||
break;
|
||||
default: // ec
|
||||
if (!qr_flag) {
|
||||
char tmpStr[100] = {0};
|
||||
widget_t *bt_name = widget_lookup(win, "bt_name", TRUE);
|
||||
printf("strQrText=%s.\r\n",strQrText);
|
||||
widget_t *qr1 = qr_create(qr_view, 40, 81, 200, 200);
|
||||
qr_set_value(qr1, strQrText);
|
||||
getTextAfterLastEqual(strQrText, tmpStr);
|
||||
|
||||
widget_set_text_utf8(bt_name, tmpStr);
|
||||
widget_t *uuid = widget_lookup(win, "uuid", TRUE);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "uuid:%s", UI_uuid);
|
||||
// printf("UI_uuid > %s .\r\n",UI_uuid);
|
||||
widget_set_text_utf8(uuid, tmpStr);
|
||||
ap_get_ssid(strQrText, tmpStr);
|
||||
printf("wifi_name>%s.\r\n",tmpStr);
|
||||
ap_get_pwd(strQrText, tmpStr);
|
||||
printf("wifi_pwd>%s.\r\n",tmpStr);
|
||||
qr_flag = 1;
|
||||
} else {
|
||||
widget_t *qr1 = widget_get_child(qr_view, 1);
|
||||
widget_set_visible(qr1, TRUE);
|
||||
}
|
||||
widget_set_visible(carplay_view, FALSE);
|
||||
widget_set_visible(android_view, FALSE);
|
||||
widget_set_visible(p2p_view, TRUE);
|
||||
carlink_cp_enable(0);
|
||||
carlink_aa_enable(0);
|
||||
carlink_ec_enable(1);
|
||||
Set_sys_tp_state(2);
|
||||
printf("now>>> ec .\r\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
} else if (evt->key == TK_KEY_q) { // 灯光开关
|
||||
return_demo();
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
// ui刷新
|
||||
static ret_t ui_update(const timer_info_t *timer) {
|
||||
// static uint8_t test_flag = 0;
|
||||
widget_t *win = WIDGET(timer->ctx); // home_page
|
||||
tp_ui_refresh(win);
|
||||
|
||||
if (Get_sys_call_state() && !Get_sys_wifi_state()) {
|
||||
return_demo();
|
||||
}
|
||||
|
||||
|
||||
return RET_REPEAT;
|
||||
}
|
||||
|
||||
#ifdef AMT630HV100
|
||||
extern void clear_rect(float x, float y, float w, float h, float a, float r,
|
||||
float g, float b);
|
||||
|
||||
ret_t onClearBg(void *ctx, event_t *e) {
|
||||
// printf("onClearBg=================================\r\n");
|
||||
clear_rect(0, 0, 800, 380, 0, 0, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static ret_t on_new_page_destroy(void *ctx, event_t *e) {
|
||||
tp_inited = 0;
|
||||
qr = 0;
|
||||
qr_flag = 0;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void *ctx, const void *iter) {
|
||||
widget_t *win = WIDGET(ctx);
|
||||
widget_t *widget = WIDGET(iter);
|
||||
const char *name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
if (tk_str_eq(name, "new")) {
|
||||
widget_on(widget, EVT_KEY_DOWN, on_new_key_down, win);
|
||||
widget_on(widget, EVT_DESTROY, on_new_page_destroy, win);
|
||||
#ifdef AMT630HV100
|
||||
widget_on(widget, EVT_BEFORE_PAINT, onClearBg, widget);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t new_init(widget_t *win, void *ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
|
||||
tp_init(win);
|
||||
uuid_UI_refresh(win);
|
||||
tp_ui_refresh(win);
|
||||
|
||||
widget_add_timer(win, ui_update, 100);
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
//widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t new1_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
#include "../common/data_port.h"
|
||||
#include "../common/universal.h"
|
||||
|
||||
static ret_t prompt_refresh(const timer_info_t* timer){ //demo Progress bar Color change
|
||||
widget_t*win = WIDGET(timer->ctx);
|
||||
widget_t* plan_bar = widget_lookup(win, "plan_bar", TRUE);
|
||||
widget_t* point_text = widget_lookup(win, "point_text", TRUE);
|
||||
// widget_t* prompt_image = NULL;
|
||||
double buf =0;
|
||||
uint8_t count =0;
|
||||
double x,y;
|
||||
|
||||
widget_use_style(win,"ui_bg_color_bk");
|
||||
|
||||
if(Get_sys_plan()!=0){
|
||||
x=Get_sys_pace();
|
||||
y=Get_sys_plan();
|
||||
buf = x/y;
|
||||
buf *= 100;
|
||||
count = (int)buf;
|
||||
widget_set_value(plan_bar,count);
|
||||
if(Get_sys_upgrade()==1){
|
||||
widget_set_text_utf8(point_text,"升级拷贝中...");
|
||||
}else{
|
||||
widget_set_text_utf8(point_text,"升级中...");
|
||||
}
|
||||
}
|
||||
|
||||
return RET_REPEAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
//widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t prompt_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
|
||||
// widget_t* prompt_image = widget_lookup(win, "prompt_image", TRUE);
|
||||
// widget_use_style(prompt_image,"bg_blk");
|
||||
|
||||
widget_add_timer(win, prompt_refresh, 100);//进度条提示
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,368 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
#include "tkc/object_date_time.h"
|
||||
#include "../common/universal.h"
|
||||
#include "../common/data_port.h"
|
||||
|
||||
extern uint8_t winflag;
|
||||
extern void BT2_Switch(int type);
|
||||
extern void list_theme_init(widget_t* set_list);
|
||||
|
||||
static void set_list_key_event_handing(widget_t* child){
|
||||
widget_t* win = window_manager();
|
||||
uint8_t count = widget_index_of(child);
|
||||
uint8_t child_count=0;
|
||||
char tmpStr[20] = {0};
|
||||
|
||||
|
||||
uint8_t value = 0;
|
||||
widget_t* btn = NULL;
|
||||
widget_t* widget = NULL;
|
||||
|
||||
switch(count){
|
||||
case 0://设置界面
|
||||
widget_set_focused(child,FALSE);
|
||||
widget = widget_lookup(win, "set_view", TRUE);
|
||||
child = widget_get_child(widget,0);
|
||||
widget_set_focused(child,TRUE);
|
||||
break;
|
||||
case 1://信息界面
|
||||
|
||||
break;
|
||||
case 2://主题界面
|
||||
widget_set_focused(child,FALSE);
|
||||
widget = widget_lookup(win, "theme_view", TRUE);
|
||||
child_count = Get_sys_theme_state();
|
||||
// printf("child_count ================= %d Get_sys_theme_state =%d .\r\n",child_count,Get_sys_theme_state());
|
||||
if(child_count>2)
|
||||
child_count = 0;
|
||||
child = widget_get_child(widget,child_count);
|
||||
widget_set_focused(child,TRUE);
|
||||
btn = widget_get_child(child,0);
|
||||
widget_set_visible(btn,FALSE);
|
||||
|
||||
break;
|
||||
case 3://亮度界面
|
||||
widget_set_focused(child,FALSE);
|
||||
widget = widget_lookup(win, "light_view", TRUE);
|
||||
child = widget_get_child(widget,0);
|
||||
widget_set_visible(child,TRUE);
|
||||
count = Get_sys_light_value();
|
||||
if(count == 6){
|
||||
const char* language = locale_info()->language;
|
||||
if (tk_str_eq(language, "en")) //英文
|
||||
widget_set_text_utf8(child, "AUTO");
|
||||
else
|
||||
widget_set_text_utf8(child, "自动");
|
||||
}else{
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%d",(count));
|
||||
widget_set_text_utf8(child,tmpStr);
|
||||
}
|
||||
widget_set_focused(child,TRUE);
|
||||
widget = widget_lookup(win, "light_bar", TRUE);
|
||||
value = count*20;
|
||||
if(count == 6)
|
||||
value = 20;
|
||||
widget_set_value(widget,value);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
extern uint8_t button_flag;
|
||||
static void set_key_event_handing(widget_t* child){
|
||||
widget_t* win = window_manager();
|
||||
widget_t* widget = NULL;
|
||||
uint8_t count = widget_index_of(child);
|
||||
const char* language = locale_info()->language;
|
||||
// printf("set_key >>>>>>>>>>>>>count = %d .\r\n",count);
|
||||
switch(count){
|
||||
case 0://时钟
|
||||
navigator_to("set_time");
|
||||
break;
|
||||
case 1://语言
|
||||
widget = widget_get_child(child,0);
|
||||
if (tk_str_eq(language, "en")) {
|
||||
change_locale("zh_CN");
|
||||
Set_sys_language(0);
|
||||
widget_set_text_utf8(widget,"[中文]");
|
||||
} else {
|
||||
change_locale("en_US");
|
||||
Set_sys_language(1);
|
||||
widget_set_text_utf8(widget,"[EN]");
|
||||
}
|
||||
button_flag = 1;
|
||||
break;
|
||||
case 2://单位
|
||||
widget = widget_get_child(child,0);
|
||||
if (tk_str_eq(language, "en")) {//英文切换
|
||||
if(Get_sys_unit()==0){
|
||||
Set_sys_unit(1);
|
||||
widget_set_text_utf8(widget,"[Inch]");//公制
|
||||
}else{
|
||||
Set_sys_unit(0);
|
||||
widget_set_text_utf8(widget,"[Metric]");
|
||||
}
|
||||
}else{//中文切换
|
||||
if(Get_sys_unit()==0){
|
||||
Set_sys_unit(1);
|
||||
widget_set_text_utf8(widget,"[英制]");
|
||||
}else{
|
||||
Set_sys_unit(0);
|
||||
widget_set_text_utf8(widget,"[公制]");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3://保养里程
|
||||
navigator_to("set_mile");
|
||||
break;
|
||||
case 4://胎压
|
||||
navigator_to("set_tire_pressure");
|
||||
break;
|
||||
case 5://蓝牙
|
||||
#if (CALL_BW121_KEY)
|
||||
if(Get_sys_bt_on_off()){
|
||||
BW_121_Switch(0);
|
||||
}else{
|
||||
BW_121_Switch(1);
|
||||
}
|
||||
#else
|
||||
if(Get_sys_bt_on_off()){
|
||||
BT2_Switch(0);
|
||||
}else{
|
||||
BT2_Switch(1);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 6://快排
|
||||
widget = widget_lookup(win, "kp_switch", TRUE);
|
||||
if(Get_sys_quickly_arrange()){
|
||||
Set_sys_quickly_arrange(0);
|
||||
widget_set_value(widget,0);
|
||||
}else{
|
||||
Set_sys_quickly_arrange(1);
|
||||
widget_set_value(widget,1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void set_theme_key_event_handing(widget_t* child){
|
||||
widget_t* win = window_manager();
|
||||
uint8_t count = widget_index_of(child);
|
||||
|
||||
switch(count){
|
||||
case 0:
|
||||
if(Get_sys_theme_state()!=0)
|
||||
Set_sys_theme_state(0);
|
||||
newA27_return_theme();
|
||||
break;
|
||||
case 1:
|
||||
if(Get_sys_theme_state()!=1)
|
||||
Set_sys_theme_state(1);
|
||||
newA27_return_theme();
|
||||
break;
|
||||
case 2:
|
||||
if(Get_sys_theme_state()!=2)
|
||||
Set_sys_theme_state(2);
|
||||
newA27_return_theme();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void set_light_key_event_handing(widget_t* child){
|
||||
widget_t* win = window_manager();
|
||||
char tmpStr[20] = {0};
|
||||
|
||||
uint8_t count = Get_sys_light_value();
|
||||
if(count == 5){
|
||||
const char* language = locale_info()->language;
|
||||
if (tk_str_eq(language, "en")) //英文
|
||||
widget_set_text_utf8(child, "AUTO");
|
||||
else
|
||||
widget_set_text_utf8(child, "自动");
|
||||
Set_sys_light_value(count+1);
|
||||
}else if(count == 6){
|
||||
widget_set_text_utf8(child, "1");
|
||||
Set_sys_light_value(1);
|
||||
}else{
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%d",(count+1));
|
||||
widget_set_text_utf8(child,tmpStr);
|
||||
Set_sys_light_value(count+1);
|
||||
}
|
||||
|
||||
count = Get_sys_light_value();
|
||||
if(count<6){
|
||||
Unified_brightness_processing(count,0);
|
||||
}else{
|
||||
count = Get_sys_light_perception_value();
|
||||
printf("light_perception_value = %d ...............\r\n",count);
|
||||
if(count<=30)
|
||||
count = 30;
|
||||
if(Get_sys_veer_velocity()<1000)
|
||||
count = count/LOW_BRIGHTNESS_MODE;
|
||||
Unified_brightness_processing(count,1);
|
||||
}
|
||||
widget_t* widget = widget_lookup(child->parent->parent, "light_bar", TRUE);
|
||||
uint8_t value = count*20;
|
||||
if(count == 6)
|
||||
value = 20;
|
||||
widget_set_value(widget,value);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static ret_t on_set_list_key_down(void* ctx, event_t* e) {
|
||||
key_event_t* evt = key_event_cast(e);
|
||||
// TODO: 在此添加控件事件处理程序代码
|
||||
widget_t* win = window_manager();
|
||||
widget_t* child = NULL;
|
||||
widget_t* widget = NULL;
|
||||
uint8_t count=0;
|
||||
uint8_t child_count=0;
|
||||
|
||||
// printf("on_set_list_key_down ===> key =%d\r\n",evt->key);
|
||||
widget = window_manager_get_top_main_window(win);
|
||||
if(evt->key == TK_KEY_q){
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
count = widget_index_of(child);
|
||||
|
||||
child_count = widget_count_children(child->parent);
|
||||
if(child_count == 1)
|
||||
return RET_OK;
|
||||
|
||||
widget_set_focused(child,FALSE);
|
||||
|
||||
count++;
|
||||
if(count>=child_count)
|
||||
count = 0;
|
||||
widget = widget_get_child(child->parent,count);
|
||||
if(widget_get_visible(widget)==0)
|
||||
count++;
|
||||
if(count>=child_count)
|
||||
count = 0;
|
||||
|
||||
widget = widget_get_child(child->parent,count);
|
||||
// printf("-->>%s ,%s , %d",widget->name,widget->parent->name,count);
|
||||
|
||||
widget_set_focused(widget,TRUE);
|
||||
widget_set_prop_bool(widget, WIDGET_PROP_FOCUSED, TRUE);
|
||||
widget_set_value(widget,1);
|
||||
if(strcmp(widget->parent->name,"list_view")==0){
|
||||
widget_t* list_title = widget_lookup(win,"list_title",TRUE);
|
||||
const char* language = locale_info()->language;
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
if(count ==LIST_NUMBER_OF_OPTION)
|
||||
widget_set_text_utf8(list_title,set_en_label[0]);
|
||||
else
|
||||
widget_set_text_utf8(list_title,set_en_label[count]);
|
||||
}else{
|
||||
if(count ==LIST_NUMBER_OF_OPTION)
|
||||
widget_set_text_utf8(list_title,set_label[0]);
|
||||
else
|
||||
widget_set_text_utf8(list_title,set_label[count]);
|
||||
}
|
||||
// }else if(strcmp(widget->parent->name,"theme_view")==0){
|
||||
// // count = widget_index_of(widget);
|
||||
// printf("theme btn >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> count =%d ,win =%s\r\n",count,win->name);
|
||||
// Set_sys_theme_state(count);
|
||||
// widget_t* set_list = widget_lookup(win, "set_list", TRUE);
|
||||
// list_theme_init(set_list);
|
||||
|
||||
}
|
||||
if(strcmp(widget->name,"tab_button2")==0){
|
||||
list_theme_button2_init();
|
||||
}else if(strcmp(widget->name,"tab_button3")==0){
|
||||
theme_win_init(win);
|
||||
}else if(strcmp(widget->name,"tab_button4")==0){
|
||||
list_theme_button4_init();
|
||||
}
|
||||
|
||||
}else if(evt->key == TK_KEY_w){
|
||||
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
// printf("$$$$$$$child = %s,child->parent = %s\r\n",child->name,child->parent->name);
|
||||
|
||||
if(child != NULL && strcmp(child->parent->name,"list_view")==0){
|
||||
set_list_key_event_handing(child);
|
||||
}else if(child != NULL && strcmp(child->parent->name,"set_view")==0){
|
||||
set_key_event_handing(child);
|
||||
}else if(child != NULL && strcmp(child->parent->name,"theme_view")==0){
|
||||
set_theme_key_event_handing(child);
|
||||
}else if(child != NULL && strcmp(child->parent->name,"light_view")==0){
|
||||
set_light_key_event_handing(child);
|
||||
}
|
||||
}else if(evt->key == TK_KEY_e){
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
// printf("$$$$$$$child = %s,child->parent = %s\r\n",child->name,child->parent->name);
|
||||
|
||||
if(child != NULL && strcmp(child->parent->name,"list_view")==0){
|
||||
newA27_return_theme();
|
||||
}else if(child != NULL && strcmp(child->parent->name,"set_view")==0){
|
||||
widget_set_focused(child,FALSE);
|
||||
widget = widget_lookup(win, "list_view", TRUE);
|
||||
child = widget_get_child(widget,0);
|
||||
widget_set_focused(child,TRUE);
|
||||
}else if(child != NULL && strcmp(child->parent->name,"theme_view")==0){
|
||||
widget_set_focused(child,FALSE);
|
||||
widget = widget_lookup(win, "list_view", TRUE);
|
||||
child = widget_get_child(widget,2);
|
||||
widget_set_focused(child,TRUE);
|
||||
theme_win_init(win);
|
||||
// list_theme_init(win);
|
||||
}else if(child != NULL && strcmp(child->parent->name,"light_view")==0){
|
||||
widget_set_focused(child,FALSE);
|
||||
widget_set_visible(child,FALSE);
|
||||
widget = widget_lookup(win, "list_view", TRUE);
|
||||
child = widget_get_child(widget,3);
|
||||
widget_set_focused(child,TRUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
if (tk_str_eq(name, "set_list")) {
|
||||
widget_on(widget, EVT_KEY_DOWN, on_set_list_key_down, win);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t set_list_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
|
||||
widget_t* list_view = widget_lookup(win,"list_view",TRUE);
|
||||
widget_t* child = widget_get_child(list_view,0);
|
||||
widget_set_prop_bool(child, WIDGET_PROP_FOCUSED, TRUE);
|
||||
// widget_set_focused(child,TRUE);
|
||||
list_theme_init(win);
|
||||
winflag = 1;
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
#include "../common/universal.h"
|
||||
#include "../common/data_port.h"
|
||||
|
||||
extern uint8_t winflag;
|
||||
|
||||
static void mile_event_handling(widget_t* child){
|
||||
uint8_t count = 0;
|
||||
uint8_t num = 0;
|
||||
count = text_selector_count_options(child);
|
||||
num = text_selector_get_value(child);
|
||||
if(num<count-1){
|
||||
num++;
|
||||
}else if(num == count-1){
|
||||
num=0;
|
||||
}
|
||||
text_selector_set_value(child,num);
|
||||
}
|
||||
|
||||
static ret_t on_set_time_key_down(void* ctx, event_t* e) {
|
||||
key_event_t* evt = key_event_cast(e);
|
||||
// TODO: 在此添加控件事件处理程序代码
|
||||
widget_t* win = window_manager();
|
||||
widget_t* child = NULL;
|
||||
widget_t* widget = NULL;
|
||||
uint8_t count=0;
|
||||
uint8_t child_count=0;
|
||||
widget = window_manager_get_top_window(win);
|
||||
//printf("################--------- evt->key =%d ----%s \r\n",evt->key,widget->name);
|
||||
|
||||
if(evt->key == TK_KEY_q){
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
count = widget_index_of(child);
|
||||
widget_set_visible(child,TRUE);
|
||||
|
||||
// time_scope_limitation(child);
|
||||
widget_set_focused(child,FALSE);//取消聚焦
|
||||
child_count = widget_count_children(child->parent);//获取父类子类个数
|
||||
count++;
|
||||
if(count>=child_count)
|
||||
count = 0;
|
||||
widget = widget_get_child(child->parent,count);
|
||||
widget_set_focused(widget,TRUE);
|
||||
//printf("time -->>%s ,%s,%d \r\n",child->name,child->parent->name,count);
|
||||
}else if(evt->key == TK_KEY_w){
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
mile_event_handling(child);
|
||||
}else if(evt->key == TK_KEY_e){
|
||||
widget_t* mile1 = widget_lookup(win, "mile1", TRUE);
|
||||
widget_t* mile2 = widget_lookup(win, "mile2", TRUE);
|
||||
widget_t* mile3 = widget_lookup(win, "mile3", TRUE);
|
||||
widget_t* mile4 = widget_lookup(win, "mile4", TRUE);
|
||||
widget_t* mile5 = widget_lookup(win, "mile5", TRUE);
|
||||
uint32_t value = 0;
|
||||
uint8_t value1 = widget_get_value_int(mile1)*10 + widget_get_value_int(mile2);
|
||||
uint8_t value2 = widget_get_value_int(mile3)*10 + widget_get_value_int(mile4);
|
||||
uint8_t value3 = widget_get_value_int(mile5);
|
||||
value = value3+(value2*10)+(value1*1000);
|
||||
printf("mile value %d .\r\n",value);
|
||||
if(value != Get_sys_maintenance_mileage()){
|
||||
Set_sys_maintenance_mileage(value);
|
||||
Set_sys_warning_maintenance(0);
|
||||
}else
|
||||
printf("maintenance mile data == flash mile data.\r\n");
|
||||
|
||||
printf("now mile value , %d, %d .\r\n",Get_sys_maintenance_mileage(),Get_sys_start_mileage());
|
||||
printf("now total mile=%d ,trip = %d .\r\n",Get_sys_total_mileage(),Get_sys_trip_mileage());
|
||||
return navigator_back();
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static void set_mile_theme_init(widget_t* win){
|
||||
widget_t* view = widget_lookup(win, "view", TRUE);
|
||||
widget_t* mile1 = widget_lookup(win, "mile1", TRUE);
|
||||
widget_t* mile2 = widget_lookup(win, "mile2", TRUE);
|
||||
widget_t* mile3 = widget_lookup(win, "mile3", TRUE);
|
||||
widget_t* mile4 = widget_lookup(win, "mile4", TRUE);
|
||||
widget_t* mile5 = widget_lookup(win, "mile5", TRUE);
|
||||
widget_t* label = widget_lookup(win, "label", TRUE);
|
||||
widget_t* page_label = widget_lookup(win, "page_label", TRUE);
|
||||
widget_t* top_bg = widget_lookup(win, "top_bg", TRUE);
|
||||
widget_t* time_view = widget_lookup(win, "time_view", TRUE);
|
||||
widget_set_focused(mile1,TRUE);
|
||||
uint8_t count = widget_count_children(time_view);//获取子类个数
|
||||
|
||||
uint32_t value = Get_sys_maintenance_mileage();
|
||||
//printf("value = %d .\r\n",Get_sys_maintenance_mileage(),);
|
||||
printf("now >>>>>>>>>>>>>>>>>>>>>> %d ,%d .\r\n", Get_sys_maintenance_mileage(), Get_sys_start_mileage());
|
||||
widget_set_value_int(mile1,(value/10000%10));
|
||||
widget_set_value_int(mile2,(value/1000%10));
|
||||
widget_set_value_int(mile3,(value/100%10));
|
||||
widget_set_value_int(mile4,(value/10%10));
|
||||
widget_set_value_int(mile5,(value%10));
|
||||
|
||||
if(Get_sys_theme_state()){
|
||||
widget_use_style(view, "page_view_bg_wt");
|
||||
widget_use_style(top_bg, "top_bg_wt");
|
||||
|
||||
widget_set_style_color(label, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(page_label, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
|
||||
for(uint8_t i=0;i<count;i++){
|
||||
widget_t* btn = widget_get_child(time_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
}
|
||||
}else{
|
||||
widget_use_style(view, "page_view_bg_bk");
|
||||
widget_use_style(top_bg, "top_bg_bk");
|
||||
|
||||
widget_set_style_color(label, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(page_label, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
for(uint8_t i=0;i<count;i++){
|
||||
widget_t* btn = widget_get_child(time_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
if (tk_str_eq(name, "set_mile")) {
|
||||
widget_on(widget, EVT_KEY_DOWN, on_set_time_key_down, win);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t set_mile_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
set_mile_theme_init(win);
|
||||
winflag = 3;
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,349 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
#include "tkc/object_date_time.h"
|
||||
#include "../common/user_data.h"
|
||||
#include "../common/universal.h"
|
||||
#include "../common/data_port.h"
|
||||
|
||||
extern uint8_t winflag;
|
||||
|
||||
extern void Set_sys_ttrb_time(uint8_t value);
|
||||
#if 0
|
||||
// 时间戳
|
||||
// const uint16_t month_day_table[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
|
||||
// 判断是否为闰年 1为是 0为不是
|
||||
uint16_t fml_leap_year(uint16_t year){
|
||||
return ((year%4 == 0)&&(year%100!=0) ) || (year%400 ==0);
|
||||
}
|
||||
|
||||
uint32_t fml_time_to_stamp(int time[]){
|
||||
static uint32_t dax = 0;
|
||||
static uint32_t day_count = 0;
|
||||
uint16_t leap_year_count = 0;
|
||||
uint16_t i;
|
||||
|
||||
//计算闰年
|
||||
for(i = 1970;i<time[0];i++){
|
||||
if(fml_leap_year(i))
|
||||
leap_year_count ++;
|
||||
}
|
||||
//计算年总天数
|
||||
day_count = leap_year_count * 366 + (time[0] - 1970 -leap_year_count)*365;
|
||||
|
||||
for(i=1;i<time[1];i++){
|
||||
if((2==i)&& (fml_leap_year(time[0]))){
|
||||
day_count += 29;
|
||||
}else{
|
||||
day_count += month_day_table[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//累加计算当月天数
|
||||
day_count += (time[2] -1);
|
||||
dax= (uint32_t)(day_count *86400) + (uint32_t)((uint32_t)time[3] *3600) + (uint32_t)((uint32_t)time[4] * 60) + (uint32_t)time[5];
|
||||
|
||||
//北京时间补偿
|
||||
dax = dax - 8*60*60;
|
||||
|
||||
printf("dax ==================== %d \n",dax);
|
||||
return dax;
|
||||
|
||||
}
|
||||
|
||||
uint32_t fml_stamp_to_time(uint32_t timep , int time[]){
|
||||
uint32_t days = 0;
|
||||
uint32_t rem = 0;
|
||||
|
||||
//北京时间补偿
|
||||
timep = timep + 8*60*60;
|
||||
|
||||
days = (uint32_t)(timep/86400);
|
||||
rem = (uint32_t)(timep%86400);
|
||||
|
||||
uint16_t year;
|
||||
for(year = 1970; ; ++year){
|
||||
uint16_t leap = ((year%4 == 0)&&(year%100!=0) ) || (year%400 ==0);
|
||||
uint16_t ydays = leap ? 366:365;
|
||||
if(days < ydays){
|
||||
break;
|
||||
}
|
||||
days -= ydays;
|
||||
|
||||
}
|
||||
time[0] = year;
|
||||
|
||||
static const uint16_t days_in_month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
|
||||
uint16_t month;
|
||||
for(month = 0;month<12 ; month++){
|
||||
uint16_t mdays = days_in_month[month];
|
||||
if(month == 1 && ((year%4 == 0)&&(year%100!=0) ) || (year%400 ==0)){
|
||||
mdays = 29;
|
||||
}
|
||||
if(days < mdays){
|
||||
break;
|
||||
}
|
||||
days -= mdays;
|
||||
}
|
||||
time[1] =month;
|
||||
time[1] +=1;
|
||||
|
||||
time[2] =days+1;
|
||||
|
||||
time[3] = rem /3600;
|
||||
rem %= 3600;
|
||||
time[4] = rem/60;
|
||||
time[5] = rem%60;
|
||||
|
||||
printf("date = %04d-%02d-%02d %02d:%02d:%02d \n",time[0],time[1],time[2],time[3],time[4],time[5]);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void time_scope_limitation(widget_t* child){//hour时间 条件限制
|
||||
widget_t*win = window_manager();
|
||||
uint8_t num =0;
|
||||
widget_t* widget = NULL;
|
||||
if(child != NULL && strcmp(child->name,"hour1")==0){
|
||||
num = widget_get_value_int(child);
|
||||
if( num==2 ){
|
||||
widget = widget_lookup(win, "hour2", TRUE);
|
||||
text_selector_set_options(widget,"0-3");
|
||||
}else{
|
||||
widget = widget_lookup(win, "hour2", TRUE);
|
||||
text_selector_set_options(widget,"0-9");
|
||||
}
|
||||
}else if(child != NULL && strcmp(child->name,"hour2")==0){
|
||||
num = widget_get_value_int(child);
|
||||
if( num>3 ){
|
||||
widget = widget_lookup(win, "hour1", TRUE);
|
||||
text_selector_set_options(widget,"0-1");
|
||||
}else{
|
||||
widget = widget_lookup(win, "hour1", TRUE);
|
||||
text_selector_set_options(widget,"0-2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void time_event_handling(widget_t* child){
|
||||
uint8_t count = 0;
|
||||
uint8_t num = 0;
|
||||
count = text_selector_count_options(child);
|
||||
num = text_selector_get_value(child);
|
||||
//printf("=============================>>>>now num = %d ,",num);
|
||||
if(num<count-1){
|
||||
num++;
|
||||
}else if(num == count-1){
|
||||
num=0;
|
||||
}
|
||||
//printf("set num = %d ,",num);
|
||||
text_selector_set_value(child,num);
|
||||
//printf("result num = %d \n",text_selector_get_value(child));
|
||||
}
|
||||
|
||||
static ret_t on_set_time_key_down(void* ctx, event_t* e) {
|
||||
key_event_t* evt = key_event_cast(e);
|
||||
// TODO: 在此添加控件事件处理程序代码
|
||||
widget_t* win = window_manager();
|
||||
widget_t* child = NULL;
|
||||
widget_t* widget = NULL;
|
||||
uint8_t count=0;
|
||||
uint8_t child_count=0;
|
||||
widget = window_manager_get_top_window(win);
|
||||
//printf("################--------- evt->key =%d ----%s \r\n",evt->key,widget->name);
|
||||
|
||||
if(evt->key == TK_KEY_q){
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
count = widget_index_of(child);
|
||||
widget_set_visible(child,TRUE);
|
||||
|
||||
time_scope_limitation(child);
|
||||
widget_set_focused(child,FALSE);//取消聚焦
|
||||
child_count = widget_count_children(child->parent);//获取父类子类个数
|
||||
count++;
|
||||
if(count>=child_count)
|
||||
count = 0;
|
||||
widget = widget_get_child(child->parent,count);
|
||||
widget_set_focused(widget,TRUE);
|
||||
//printf("time -->>%s ,%s,%d \r\n",child->name,child->parent->name,count);
|
||||
}else if(evt->key == TK_KEY_w){
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
time_event_handling(child);
|
||||
// if(child != NULL && strcmp(child->name,"hour1")==0){ //0 1 2 coun = 3 0 1 count =2
|
||||
// time_event_handling(child);
|
||||
// }else if(child != NULL && strcmp(child->name,"hour2")==0){
|
||||
// time_event_handling(child);
|
||||
// }else if(child != NULL && strcmp(child->name,"min1")==0){
|
||||
// time_event_handling(child);
|
||||
// }else if(child != NULL && strcmp(child->name,"min2")==0){
|
||||
// time_event_handling(child);
|
||||
// }
|
||||
}else if(evt->key == TK_KEY_e){
|
||||
|
||||
widget_t* hour1 = widget_lookup(win, "hour1", TRUE);
|
||||
widget_t* hour2 = widget_lookup(win, "hour2", TRUE);
|
||||
widget_t* min1 = widget_lookup(win, "min1", TRUE);
|
||||
widget_t* min2 = widget_lookup(win, "min2", TRUE);
|
||||
|
||||
date_time_t dt;
|
||||
date_time_init(&dt);
|
||||
uint32_t sum,sum1,sum2,sum3,sum4;;
|
||||
|
||||
int32_t hour_num = widget_get_value_int(hour1);
|
||||
hour_num = hour_num*10 + widget_get_value_int(hour2);
|
||||
int32_t min_num = widget_get_value_int(min1);
|
||||
min_num = min_num*10 + widget_get_value_int(min2);
|
||||
|
||||
printf("set_time >>>>>>>>> %d:%d \n",hour_num,min_num);
|
||||
dt.hour = hour_num;
|
||||
dt.minute = min_num;
|
||||
dt.second = 0;
|
||||
date_time_set(&dt);
|
||||
|
||||
int check_buffer[6];
|
||||
check_buffer[0] = dt.year;
|
||||
check_buffer[1] = dt.month;
|
||||
check_buffer[2] = dt.day;
|
||||
check_buffer[3] = dt.hour;
|
||||
check_buffer[4] = dt.minute;
|
||||
check_buffer[5] = dt.second;
|
||||
|
||||
printf("%04d/%02d/%02d %02d:%02d:%02d",check_buffer[0], check_buffer[1], check_buffer[2], check_buffer[3],
|
||||
check_buffer[4],check_buffer[5]);
|
||||
|
||||
sum = fml_time_to_stamp(check_buffer);
|
||||
Send_list_set_time(sum);
|
||||
|
||||
navigator_back();
|
||||
return image_manager_unload_unused(image_manager(), 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
static void set_time_theme_init(widget_t* win){
|
||||
widget_t* view = widget_lookup(win, "view", TRUE);
|
||||
widget_t* label = widget_lookup(win, "label", TRUE);
|
||||
widget_t* page_label = widget_lookup(win, "page_label", TRUE);
|
||||
widget_t* top_bg = widget_lookup(win, "top_bg", TRUE);
|
||||
|
||||
widget_t* hour1 = widget_lookup(win, "hour1", TRUE);
|
||||
widget_t* hour2 = widget_lookup(win, "hour2", TRUE);
|
||||
widget_t* min1 = widget_lookup(win, "min1", TRUE);
|
||||
widget_t* min2 = widget_lookup(win, "min2", TRUE);
|
||||
|
||||
|
||||
date_time_t dt;
|
||||
date_time_init(&dt);
|
||||
printf("set_time_theme_init %04d/%02d/%02d %02d:%02d:%02d", dt.year, dt.month, dt.day, dt.hour,
|
||||
dt.minute, dt.second);
|
||||
|
||||
widget_set_focused(hour1,TRUE);
|
||||
time_scope_limitation(hour1);
|
||||
widget_set_value_int(hour1,(dt.hour/10));
|
||||
|
||||
|
||||
widget_set_value_int(hour2,(dt.hour%10));
|
||||
time_scope_limitation(hour2);
|
||||
|
||||
widget_set_value_int(min1,(dt.minute/10));
|
||||
widget_set_value_int(min2,(dt.minute%10));
|
||||
|
||||
|
||||
if(Get_sys_theme_state()){
|
||||
widget_use_style(view, "page_view_bg_wt");
|
||||
widget_use_style(top_bg, "top_bg_wt");
|
||||
|
||||
widget_set_style_color(label, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(page_label, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(hour1, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(hour2, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(min1, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(min2, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
}else{
|
||||
widget_use_style(view, "page_view_bg_bk");
|
||||
widget_use_style(top_bg, "top_bg_bk");
|
||||
|
||||
widget_set_style_color(label, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(page_label, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(hour1, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(hour2, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(min1, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(min2, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时器事件
|
||||
*/
|
||||
/*选中对象闪烁
|
||||
static ret_t time_flicker(const timer_info_t* timer){
|
||||
widget_t*win = WIDGET(timer->ctx);
|
||||
widget_t*widget = NULL;
|
||||
uint8_t count =0;
|
||||
uint8_t child_count =0;
|
||||
static uint8_t num=0;
|
||||
|
||||
widget = widget_get_focused_widget(win);//聚焦对象
|
||||
//printf("************** %s \r\n",widget->name);
|
||||
|
||||
if(widget != NULL && strcmp(widget->parent->name,"time_view")==0){
|
||||
count = widget_index_of(widget);
|
||||
child_count = widget_count_children(widget->parent);
|
||||
if(count != (child_count-1)){
|
||||
if (num==0) {
|
||||
num = 1;
|
||||
widget_set_visible(widget,FALSE);
|
||||
} else{
|
||||
num = 0;
|
||||
widget_set_visible(widget,TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return RET_REPEAT;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
if (tk_str_eq(name, "set_time")) {
|
||||
widget_on(widget, EVT_KEY_DOWN, on_set_time_key_down, win);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t set_time_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
|
||||
set_time_theme_init(win);
|
||||
winflag = 2;
|
||||
|
||||
|
||||
|
||||
|
||||
// widget_add_timer(win, time_flicker, 500);
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,797 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
#include "../common/universal.h"
|
||||
#include "../common/user_data.h"
|
||||
#include "../common/data_port.h"
|
||||
|
||||
#define LOADING_STATE_NORMAL 0
|
||||
#define LOADING_STATE_FRONT 1
|
||||
#define LOADING_STATE_REAR 1
|
||||
#define DETECTION_TIME 50
|
||||
|
||||
uint8_t front_loading_state = 0 ;
|
||||
uint8_t rear_loading_state = 0 ;
|
||||
uint32_t tire_id ;
|
||||
|
||||
extern uint8_t winflag;
|
||||
extern uint8_t power_on_flag;
|
||||
|
||||
extern void SaveDataToFlash(SfudData_t user_data);
|
||||
extern uint8_t tire_pressure_loading;
|
||||
extern uint8_t front_time;
|
||||
// extern void copy_tire_pressure_front(void);
|
||||
// extern void copy_tire_pressure_rear(void);
|
||||
|
||||
void copy_user_tire_pressure_front(void){
|
||||
Pressure_t pressure ={0};
|
||||
custom_data.front_pressure = pressure;
|
||||
strcpy(custom_data.front_pressure.mac_address,custom_data.user_data.f_mac_address);
|
||||
if(mac_address_normal(custom_data.front_pressure.mac_address,6) == 1){//判断mac是否正常
|
||||
custom_data.front_pressure.temp = custom_data.user_data.f_mac_address[6];
|
||||
custom_data.front_pressure.psi = custom_data.user_data.f_mac_address[7];
|
||||
custom_data.front_pressure.psi = custom_data.front_pressure.psi<<8 | custom_data.user_data.f_mac_address[8];
|
||||
custom_data.front_pressure.blow_by_state = 0;
|
||||
custom_data.front_pressure.voltage_state = 0;
|
||||
custom_data.front_pressure.temp_state = 0;
|
||||
custom_data.front_pressure.lose_flag = 0;
|
||||
}else{
|
||||
printf("front mac_address error.\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void copy_user_tire_pressure_rear(void){
|
||||
Pressure_t pressure ={0};
|
||||
custom_data.rear_pressure = pressure;
|
||||
strcpy(custom_data.rear_pressure.mac_address,custom_data.user_data.r_mac_address);
|
||||
if(mac_address_normal(custom_data.rear_pressure.mac_address,6) == 1){//判断mac是否正常
|
||||
custom_data.rear_pressure.temp = custom_data.user_data.r_mac_address[6];
|
||||
custom_data.rear_pressure.psi = custom_data.user_data.r_mac_address[7];
|
||||
custom_data.rear_pressure.psi = custom_data.rear_pressure.psi<<8 | custom_data.user_data.r_mac_address[8];
|
||||
custom_data.rear_pressure.blow_by_state = 0;
|
||||
custom_data.rear_pressure.voltage_state = 0;
|
||||
custom_data.rear_pressure.temp_state = 0;
|
||||
custom_data.rear_pressure.lose_flag = 0;
|
||||
}else{
|
||||
printf("rear mac_address error.\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
//前胎压按键学习
|
||||
void front_tire_pressure_loading(void){
|
||||
widget_t* win = window_manager();
|
||||
widget_t* child = NULL;
|
||||
widget_t* widget = NULL;
|
||||
//DEBUG_PRINT("win>name %s .\r\n",win->name);
|
||||
widget = window_manager_get_top_window(win);
|
||||
widget_t*front_temp = widget_lookup(win, "front_temp", TRUE);
|
||||
widget_t*front_bar = widget_lookup(win, "front_bar", TRUE);
|
||||
// widget_t*rear_temp = widget_lookup(win, "rear_temp", TRUE);
|
||||
// widget_t*rear_bar = widget_lookup(win, "rear_bar", TRUE);
|
||||
widget_t*front_tempuint = widget_lookup(win, "front_tempuint", TRUE);
|
||||
widget_t*front_psiuint = widget_lookup(win, "front_psiuint", TRUE);
|
||||
// widget_t*rear_tempuint = widget_lookup(win, "rear_tempuint", TRUE);
|
||||
// widget_t*rear_psiuint = widget_lookup(win, "rear_psiuint", TRUE);
|
||||
|
||||
widget_t*front_error1 = widget_lookup(win, "front_error1", TRUE);
|
||||
widget_t*front_error2 = widget_lookup(win, "front_error2", TRUE);
|
||||
widget_t*front_error3 = widget_lookup(win, "front_error3", TRUE);
|
||||
widget_t*front_error4 = widget_lookup(win, "front_error4", TRUE);
|
||||
|
||||
Pressure_t pressure ={0};
|
||||
Pressure_t ago_pressure = Get_sys_front_pressure();
|
||||
// Pressure_t after_pressure = Get_sys_rear_pressure();
|
||||
|
||||
const char* language = locale_info()->language;
|
||||
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
|
||||
custom_data.user_data.f_mac_address[6]=ago_pressure.temp&0xFF;
|
||||
custom_data.user_data.f_mac_address[7]=ago_pressure.psi>>8&0xFF;
|
||||
custom_data.user_data.f_mac_address[8]=ago_pressure.psi&0xFF;
|
||||
//前胎压清零
|
||||
Set_sys_front_pressure(pressure);
|
||||
Set_sys_warning_tire(0);
|
||||
|
||||
Send_tire_pressure_information();
|
||||
widget_set_state(child,WIDGET_STATE_PRESSED);
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
widget_set_text_utf8(child,"Learning");
|
||||
}else{
|
||||
widget_set_text_utf8(child,"学习中");
|
||||
}
|
||||
widget = widget_get_child(child,0);
|
||||
widget_use_style(widget,"F_loading");
|
||||
|
||||
widget_set_text_utf8(front_temp,"--");
|
||||
widget_set_text_utf8(front_bar,"--");
|
||||
|
||||
if(Get_sys_theme_state()){
|
||||
widget_set_style_color(front_temp, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(front_tempuint, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(front_bar, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(front_psiuint, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
}else{
|
||||
widget_set_style_color(front_temp, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(front_tempuint, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(front_bar, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(front_psiuint, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
|
||||
// widget_set_style_str(front_temp, "normal.text_color", "#ffffff");
|
||||
// widget_set_style_str(front_tempuint, "normal.text_color", "#ffffff");
|
||||
// widget_set_style_str(front_bar, "normal.text_color", "#ffffff");
|
||||
// widget_set_style_str(front_psiuint, "normal.text_color", "#ffffff");
|
||||
|
||||
//刷新警告信息
|
||||
widget_set_visible(front_error1,FALSE);
|
||||
//低电压
|
||||
widget_set_visible(front_error2,FALSE);
|
||||
//高温
|
||||
widget_set_visible(front_error3,FALSE);
|
||||
//丢失
|
||||
widget_set_visible(front_error4,FALSE);
|
||||
Set_sys_pressure_signal(1);
|
||||
|
||||
}
|
||||
//后胎压按键学习
|
||||
void rear_tire_pressure_loading(void){
|
||||
widget_t* win = window_manager();
|
||||
widget_t* child = NULL;
|
||||
widget_t* widget = NULL;
|
||||
//DEBUG_PRINT("win>name %s .\r\n",win->name);
|
||||
widget = window_manager_get_top_window(win);
|
||||
// widget_t*front_temp = widget_lookup(win, "front_temp", TRUE);
|
||||
// widget_t*front_bar = widget_lookup(win, "front_bar", TRUE);
|
||||
widget_t*rear_temp = widget_lookup(win, "rear_temp", TRUE);
|
||||
widget_t*rear_bar = widget_lookup(win, "rear_bar", TRUE);
|
||||
// widget_t*front_tempuint = widget_lookup(win, "front_tempuint", TRUE);
|
||||
// widget_t*front_psiuint = widget_lookup(win, "front_psiuint", TRUE);
|
||||
widget_t*rear_tempuint = widget_lookup(win, "rear_tempuint", TRUE);
|
||||
widget_t*rear_psiuint = widget_lookup(win, "rear_psiuint", TRUE);
|
||||
widget_t*rear_error1 = widget_lookup(win, "rear_error1", TRUE);
|
||||
widget_t*rear_error2 = widget_lookup(win, "rear_error2", TRUE);
|
||||
widget_t*rear_error3 = widget_lookup(win, "rear_error3", TRUE);
|
||||
widget_t*rear_error4 = widget_lookup(win, "rear_error4", TRUE);
|
||||
|
||||
Pressure_t pressure ={0};
|
||||
Pressure_t after_pressure = Get_sys_rear_pressure();
|
||||
const char* language = locale_info()->language;
|
||||
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
|
||||
custom_data.user_data.r_mac_address[6]=after_pressure.temp&0xFF;
|
||||
custom_data.user_data.r_mac_address[7]=after_pressure.psi>>8&0xFF;
|
||||
custom_data.user_data.r_mac_address[8]=after_pressure.psi&0xFF;
|
||||
//后胎压清零
|
||||
Set_sys_rear_pressure(pressure);
|
||||
Set_sys_warning_tire(0);
|
||||
|
||||
Send_tire_pressure_information();
|
||||
widget_set_state(child,WIDGET_STATE_PRESSED);
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
widget_set_text_utf8(child,"Learning");
|
||||
}else{
|
||||
widget_set_text_utf8(child,"学习中");
|
||||
}
|
||||
|
||||
widget = widget_get_child(child,0);
|
||||
widget_use_style(widget,"R_loading");
|
||||
|
||||
widget_set_text_utf8(rear_temp,"--");
|
||||
widget_set_text_utf8(rear_bar,"--");
|
||||
if(Get_sys_theme_state()){
|
||||
widget_set_style_color(rear_temp, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(rear_tempuint, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(rear_bar, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(rear_psiuint, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
}else{
|
||||
widget_set_style_color(rear_temp, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(rear_tempuint, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(rear_bar, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(rear_psiuint, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
|
||||
// widget_set_style_str(rear_temp, "normal.text_color", "#ffffff");
|
||||
// widget_set_style_str(rear_tempuint, "normal.text_color", "#ffffff");
|
||||
// widget_set_style_str(rear_bar, "normal.text_color", "#ffffff");
|
||||
// widget_set_style_str(rear_psiuint, "normal.text_color", "#ffffff");
|
||||
//刷新警告信息
|
||||
widget_set_visible(rear_error1,FALSE);
|
||||
//低电压
|
||||
widget_set_visible(rear_error2,FALSE);
|
||||
//高温
|
||||
widget_set_visible(rear_error3,FALSE);
|
||||
//报警
|
||||
widget_set_visible(rear_error4,FALSE);
|
||||
Set_sys_pressure_signal(2);
|
||||
}
|
||||
|
||||
//前胎压刷新
|
||||
void refresh_front_tire_oressure(widget_t* win){
|
||||
widget_t*front_temp = widget_lookup(win, "front_temp", TRUE);
|
||||
widget_t*front_bar = widget_lookup(win, "front_bar", TRUE);
|
||||
widget_t*front_tempuint = widget_lookup(win, "front_tempuint", TRUE);
|
||||
widget_t*front_psiuint = widget_lookup(win, "front_psiuint", TRUE);
|
||||
widget_t*Front = widget_lookup(win, "Front", TRUE);
|
||||
widget_t*front_error1 = widget_lookup(win, "front_error1", TRUE);
|
||||
widget_t*front_error2 = widget_lookup(win, "front_error2", TRUE);
|
||||
widget_t*front_error3 = widget_lookup(win, "front_error3", TRUE);
|
||||
widget_t*front_error4 = widget_lookup(win, "front_error4", TRUE);
|
||||
|
||||
|
||||
widget_t* widget = NULL;
|
||||
widget_set_state(Front,WIDGET_STATE_NORMAL);
|
||||
char tmpStr[20] = {0};
|
||||
double bar_num = 0;
|
||||
Pressure_t ago_pressure = Get_sys_front_pressure();
|
||||
const char* language = locale_info()->language;
|
||||
|
||||
if(mac_address_normal(ago_pressure.mac_address,6) == 1){
|
||||
char mac_str[13]; // 由于每个元素对应两个十六进制字符,所以字符串长度为 size * 2
|
||||
mac_str[12] = '\0'; // 字符串末尾添加结束符
|
||||
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
sprintf(mac_str + (i * 2), "%02X", ago_pressure.mac_address[5-i]); // 将每个元素转换为两个十六进制字符
|
||||
}
|
||||
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%s",mac_str);
|
||||
widget_set_text_utf8(Front,tmpStr);
|
||||
|
||||
widget = widget_get_child(Front,0);
|
||||
//前胎压范围130-250kpa 取130 250 转psi范围为188-362
|
||||
if(ago_pressure.blow_by_state || ago_pressure.voltage_state || ago_pressure.temp_state || ago_pressure.lose_flag){
|
||||
widget_use_style(widget,"F_error");
|
||||
}else if(ago_pressure.temp<70 && (ago_pressure.psi>=TIRE_PRESSURE_FRONT_LOWER && ago_pressure.psi<=TIRE_PRESSURE_FRONT_UPPER)){
|
||||
widget_use_style(widget,"F_normal");
|
||||
}else{
|
||||
widget_use_style(widget,"F_error");
|
||||
}
|
||||
|
||||
//刷新前胎压数据
|
||||
if(ago_pressure.temp==0)
|
||||
widget_set_text_utf8(front_temp,"0");
|
||||
else{
|
||||
if(ago_pressure.temp>127)
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "-%d",(ago_pressure.temp-128));
|
||||
else
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%d",ago_pressure.temp);
|
||||
widget_set_text_utf8(front_temp,tmpStr);
|
||||
|
||||
if(ago_pressure.temp>=70){
|
||||
widget_set_style_str(front_temp, "normal.text_color", "red");
|
||||
widget_set_style_str(front_tempuint, "normal.text_color", "red");
|
||||
}else{
|
||||
if(Get_sys_theme_state()){
|
||||
widget_set_style_color(front_temp, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(front_tempuint, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
}else{
|
||||
widget_set_style_color(front_temp, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(front_tempuint, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
// widget_set_style_str(front_temp, "normal.text_color", "#ffffff");
|
||||
// widget_set_style_str(front_tempuint, "normal.text_color", "#ffffff");
|
||||
}
|
||||
}
|
||||
|
||||
//刷新胎压数据
|
||||
if(ago_pressure.psi< 1)
|
||||
widget_set_text_utf8(front_bar,"--");
|
||||
else{
|
||||
bar_num = (ago_pressure.psi-146);
|
||||
//tk_snprintf(tmpStr, sizeof(tmpStr), "%.2f",(bar_num/145));
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.2f",(bar_num*0.0069));
|
||||
widget_set_text_utf8(front_bar,tmpStr);
|
||||
if(ago_pressure.psi<TIRE_PRESSURE_FRONT_LOWER || ago_pressure.psi>TIRE_PRESSURE_FRONT_UPPER){
|
||||
widget_set_style_str(front_bar, "normal.text_color", "red");
|
||||
widget_set_style_str(front_psiuint, "normal.text_color", "red");
|
||||
}else{
|
||||
if(Get_sys_theme_state()){
|
||||
widget_set_style_color(front_bar, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(front_psiuint, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
}else{
|
||||
widget_set_style_color(front_bar, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(front_psiuint, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
// widget_set_style_str(front_bar, "normal.text_color", "#ffffff");
|
||||
// widget_set_style_str(front_psiuint, "normal.text_color", "#ffffff");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//刷新警告信息
|
||||
//漏气
|
||||
if(ago_pressure.blow_by_state)
|
||||
widget_set_visible(front_error1,TRUE);
|
||||
else
|
||||
widget_set_visible(front_error1,FALSE);
|
||||
//低电压
|
||||
if(ago_pressure.voltage_state)
|
||||
widget_set_visible(front_error2,TRUE);
|
||||
else
|
||||
widget_set_visible(front_error2,FALSE);
|
||||
//高温
|
||||
if(ago_pressure.temp_state)
|
||||
widget_set_visible(front_error3,TRUE);
|
||||
else
|
||||
widget_set_visible(front_error3,FALSE);
|
||||
|
||||
if(ago_pressure.lose_flag)
|
||||
widget_set_visible(front_error4,TRUE);
|
||||
else
|
||||
widget_set_visible(front_error4,FALSE);
|
||||
|
||||
}else{
|
||||
widget_set_text_utf8(front_temp,"--");
|
||||
widget_set_text_utf8(front_bar,"--");
|
||||
widget_set_visible(front_error1,FALSE);
|
||||
widget_set_visible(front_error2,FALSE);
|
||||
widget_set_visible(front_error3,FALSE);
|
||||
widget_set_visible(front_error4,FALSE);
|
||||
widget = widget_get_child(Front,0);
|
||||
widget_use_style(widget,"F_error");
|
||||
|
||||
if(front_loading_state){
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
widget_set_text_utf8(Front,"Sensor loss");
|
||||
}else{
|
||||
widget_set_text_utf8(Front,"传感器丢失");
|
||||
}
|
||||
}else{
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
widget_set_text_utf8(Front,"Not learned");
|
||||
}else{
|
||||
widget_set_text_utf8(Front,"未学习");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//后胎压刷新
|
||||
void refresh_rear_tire_oressure(widget_t* win){
|
||||
widget_t*rear_temp = widget_lookup(win, "rear_temp", TRUE);
|
||||
widget_t*rear_bar = widget_lookup(win, "rear_bar", TRUE);
|
||||
widget_t*rear_tempuint = widget_lookup(win, "rear_tempuint", TRUE);
|
||||
widget_t*rear_psiuint = widget_lookup(win, "rear_psiuint", TRUE);
|
||||
widget_t*Rear = widget_lookup(win, "Rear", TRUE);
|
||||
widget_t*rear_error1 = widget_lookup(win, "rear_error1", TRUE);
|
||||
widget_t*rear_error2 = widget_lookup(win, "rear_error2", TRUE);
|
||||
widget_t*rear_error3 = widget_lookup(win, "rear_error3", TRUE);
|
||||
widget_t*rear_error4 = widget_lookup(win, "rear_error4", TRUE);
|
||||
|
||||
widget_t* widget = NULL;
|
||||
widget_set_state(Rear,WIDGET_STATE_NORMAL);
|
||||
|
||||
char tmpStr[20] = {0};
|
||||
double bar_num = 0;
|
||||
Pressure_t after_pressure = Get_sys_rear_pressure();
|
||||
const char* language = locale_info()->language;
|
||||
|
||||
if(mac_address_normal(after_pressure.mac_address,6) == 1){
|
||||
char mac_str[13]; // 由于每个元素对应两个十六进制字符,所以字符串长度为 size * 2
|
||||
mac_str[12] = '\0'; // 字符串末尾添加结束符
|
||||
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
sprintf(mac_str + (i * 2), "%02X", after_pressure.mac_address[5-i]); // 将每个元素转换为两个十六进制字符
|
||||
}
|
||||
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%s",mac_str);
|
||||
widget_set_text_utf8(Rear,tmpStr);
|
||||
widget = widget_get_child(Rear,0);
|
||||
//后胎压范围150-280kpa 取150 280 转psi范围为217-406
|
||||
if(after_pressure.blow_by_state || after_pressure.voltage_state || after_pressure.temp_state || after_pressure.lose_flag){
|
||||
widget_use_style(widget,"R_error");
|
||||
}else if(after_pressure.temp<70 && (after_pressure.psi>=TIRE_PRESSURE_REAR_LOWER && after_pressure.psi<=TIRE_PRESSURE_REAR_UPPER)){
|
||||
widget_use_style(widget,"R_normal");
|
||||
}else{
|
||||
widget_use_style(widget,"R_error");
|
||||
}
|
||||
|
||||
//刷新后胎压
|
||||
if(after_pressure.temp==0)
|
||||
widget_set_text_utf8(rear_temp,"0");
|
||||
else{
|
||||
if(after_pressure.temp>127)
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "-%d",(after_pressure.temp-128));
|
||||
else
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%d",after_pressure.temp);
|
||||
widget_set_text_utf8(rear_temp,tmpStr);
|
||||
if(after_pressure.temp>=70){
|
||||
widget_set_style_str(rear_temp, "normal.text_color", "red");
|
||||
widget_set_style_str(rear_tempuint, "normal.text_color", "red");
|
||||
}else{
|
||||
if(Get_sys_theme_state()){
|
||||
widget_set_style_color(rear_temp, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(rear_tempuint, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
}else{
|
||||
widget_set_style_color(rear_temp, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(rear_tempuint, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(after_pressure.psi< 1)
|
||||
widget_set_text_utf8(rear_bar,"--");
|
||||
else{
|
||||
bar_num = (after_pressure.psi-146);
|
||||
tk_snprintf(tmpStr, sizeof(tmpStr), "%.2f",(bar_num*0.0069));
|
||||
widget_set_text_utf8(rear_bar,tmpStr);
|
||||
if(after_pressure.psi<TIRE_PRESSURE_REAR_LOWER || after_pressure.psi>TIRE_PRESSURE_REAR_UPPER){
|
||||
widget_set_style_str(rear_bar, "normal.text_color", "red");
|
||||
widget_set_style_str(rear_psiuint, "normal.text_color", "red");
|
||||
}else{
|
||||
if(Get_sys_theme_state()){
|
||||
widget_set_style_color(rear_bar, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
widget_set_style_color(rear_psiuint, "normal.text_color", OUTPUT_COLOR_BLACK);
|
||||
}else{
|
||||
widget_set_style_color(rear_bar, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
widget_set_style_color(rear_psiuint, "normal.text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//刷新警告信息
|
||||
//漏气
|
||||
if(after_pressure.blow_by_state)
|
||||
widget_set_visible(rear_error1,TRUE);
|
||||
else
|
||||
widget_set_visible(rear_error1,FALSE);
|
||||
//低电压
|
||||
if(after_pressure.voltage_state)
|
||||
widget_set_visible(rear_error2,TRUE);
|
||||
else
|
||||
widget_set_visible(rear_error2,FALSE);
|
||||
//高温
|
||||
if(after_pressure.temp_state)
|
||||
widget_set_visible(rear_error3,TRUE);
|
||||
else
|
||||
widget_set_visible(rear_error3,FALSE);
|
||||
|
||||
if(after_pressure.lose_flag)
|
||||
widget_set_visible(rear_error4,TRUE);
|
||||
else
|
||||
widget_set_visible(rear_error4,FALSE);
|
||||
|
||||
}else{
|
||||
widget_set_text_utf8(rear_temp,"--");
|
||||
widget_set_text_utf8(rear_bar,"--");
|
||||
widget_set_visible(rear_error1,FALSE);
|
||||
widget_set_visible(rear_error2,FALSE);
|
||||
widget_set_visible(rear_error3,FALSE);
|
||||
widget_set_visible(rear_error4,FALSE);
|
||||
widget = widget_get_child(Rear,0);
|
||||
widget_use_style(widget,"R_error");
|
||||
if(rear_loading_state){
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
widget_set_text_utf8(Rear,"Sensor loss");
|
||||
}else{
|
||||
widget_set_text_utf8(Rear,"传感器丢失");
|
||||
}
|
||||
}else{
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
widget_set_text_utf8(Rear,"Not learned");
|
||||
}else{
|
||||
widget_set_text_utf8(Rear,"未学习");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//前胎压检测
|
||||
void front_tire_detection(widget_t* win){
|
||||
widget_t*Front = widget_lookup(win, "Front", TRUE);
|
||||
const char* language = locale_info()->language;
|
||||
Pressure_t ago_pressure = Get_sys_front_pressure();
|
||||
|
||||
if(mac_address_normal(ago_pressure.mac_address,6) == 0){
|
||||
front_time--;
|
||||
front_loading_state = LOADING_STATE_FRONT;
|
||||
if(front_time == 1){
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
widget_set_text_utf8(Front,"Sensor loss");
|
||||
}else{
|
||||
widget_set_text_utf8(Front,"传感器丢失");
|
||||
}
|
||||
//widget_set_state(Front,"normal");
|
||||
widget_set_state(Front,WIDGET_STATE_NORMAL);
|
||||
|
||||
widget_t* widget = widget_get_child(Front,0);
|
||||
widget_use_style(widget,"F_error");
|
||||
Set_sys_pressure_signal(0);
|
||||
front_time=DETECTION_TIME;
|
||||
//若学习失败 则去读取flash保存的数据
|
||||
copy_user_tire_pressure_front();
|
||||
Send_tire_pressure_information();
|
||||
power_on_flag = 1;
|
||||
}
|
||||
Set_sys_return_demo(2); //50为1s
|
||||
// }else{
|
||||
// front_time=DETECTION_TIME;
|
||||
// widget_set_state(Front,WIDGET_STATE_NORMAL);
|
||||
// Set_sys_pressure_signal(0);
|
||||
}
|
||||
}
|
||||
//后胎压检测
|
||||
void rear_tire_detection(widget_t* win){
|
||||
widget_t*Rear = widget_lookup(win, "Rear", TRUE);
|
||||
|
||||
Pressure_t after_pressure = Get_sys_rear_pressure();
|
||||
const char* language = locale_info()->language;
|
||||
|
||||
if(mac_address_normal(after_pressure.mac_address,6) == 0){
|
||||
front_time--;
|
||||
rear_loading_state = LOADING_STATE_REAR;
|
||||
if(front_time == 1){
|
||||
if (tk_str_eq(language, "en")) {//英文
|
||||
widget_set_text_utf8(Rear,"Sensor loss");
|
||||
}else{
|
||||
widget_set_text_utf8(Rear,"传感器丢失");
|
||||
}
|
||||
widget_set_state(Rear,WIDGET_STATE_NORMAL);
|
||||
|
||||
widget_t* widget = widget_get_child(Rear,0);
|
||||
widget_use_style(widget,"R_error");
|
||||
Set_sys_pressure_signal(0);
|
||||
front_time =DETECTION_TIME;
|
||||
//若学习失败 则去读取flash保存的数据
|
||||
copy_user_tire_pressure_rear();
|
||||
Send_tire_pressure_information();
|
||||
power_on_flag = 1;
|
||||
}
|
||||
Set_sys_return_demo(2); //50为1s
|
||||
// }else{
|
||||
// front_time =DETECTION_TIME;
|
||||
// widget_set_state(Rear,WIDGET_STATE_NORMAL);
|
||||
// Set_sys_pressure_signal(0);
|
||||
}
|
||||
}
|
||||
//按键事件
|
||||
static ret_t on_set_tire_pressure_key_down(void* ctx, event_t* e) {
|
||||
key_event_t* evt = key_event_cast(e);
|
||||
// TODO: 在此添加控件事件处理程序代码
|
||||
widget_t* win = window_manager();
|
||||
|
||||
widget_t* child = NULL;
|
||||
widget_t* widget = NULL;
|
||||
widget_t* btn = NULL;
|
||||
uint8_t count=0;
|
||||
uint8_t child_count=0;
|
||||
//widget_t* test_win = window_manager_get_top_main_window(win);
|
||||
widget = window_manager_get_top_window(win);
|
||||
|
||||
|
||||
child = widget_get_focused_widget(widget);//聚焦对象
|
||||
count = widget_index_of(child);
|
||||
|
||||
if(evt->key == TK_KEY_q){
|
||||
widget_set_visible(child,TRUE);
|
||||
widget_set_focused(child,FALSE);//取消聚焦
|
||||
if(count!=2){
|
||||
btn = widget_get_child(child,1);
|
||||
widget_set_visible(btn,FALSE);
|
||||
}
|
||||
|
||||
child_count = widget_count_children(child->parent);//获取父类子类个数
|
||||
count++;
|
||||
if(count>=child_count)
|
||||
count = 0;
|
||||
|
||||
widget = widget_get_child(child->parent,count);
|
||||
widget_set_focused(widget,TRUE);
|
||||
if(widget_count_children(widget)!=0){
|
||||
btn = widget_get_child(widget,1);
|
||||
widget_set_visible(btn,TRUE);
|
||||
}
|
||||
|
||||
}else if(evt->key == TK_KEY_w){
|
||||
uint8_t tire_state = Get_sys_pressure_signal();
|
||||
Pressure_t ago_pressure = Get_sys_front_pressure();
|
||||
Pressure_t after_pressure = Get_sys_rear_pressure();
|
||||
if(count==0){//学习前胎压
|
||||
|
||||
//front_tire_pressure_loading(win);
|
||||
if(tire_state==0 && mac_address_normal(ago_pressure.mac_address,6) == 0){//为0才可以学习 未学习或常规状态下都为0
|
||||
front_tire_pressure_loading();
|
||||
}
|
||||
/*else{
|
||||
DEBUG_PRINT("tire_state =%d || ago_pressure mac_address existence.\r\n",tire_state);
|
||||
}*/
|
||||
|
||||
}else if(count==1){//学习后胎压
|
||||
//rear_tire_pressure_loading(win);
|
||||
if(tire_state==0 && mac_address_normal(after_pressure.mac_address,6) == 0){//为0才可以学习 未学习或常规状态下都为0
|
||||
rear_tire_pressure_loading();
|
||||
}
|
||||
/*else{
|
||||
DEBUG_PRINT("tire_state =%d || after_pressure mac_address existence.\r\n",tire_state);
|
||||
}*/
|
||||
}
|
||||
|
||||
}else if(evt->key == TK_KEY_e){
|
||||
return navigator_back();
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
//回调函数
|
||||
|
||||
static ret_t tire_data_refresh(const timer_info_t* timer){ //demo Progress bar Color change
|
||||
widget_t*win = WIDGET(timer->ctx);
|
||||
uint8_t signal = Get_sys_pressure_signal();
|
||||
/*if(front_time!=50)
|
||||
DEBUG_PRINT("front_time =%d .\n",front_time);*/
|
||||
switch(signal){
|
||||
case 0://常规状态下 刷新胎压数据
|
||||
if(front_time!=DETECTION_TIME)front_time =DETECTION_TIME;
|
||||
refresh_front_tire_oressure(win);
|
||||
refresh_rear_tire_oressure(win);
|
||||
//胎压界面长按事件标志
|
||||
if(tire_pressure_loading==1){//异常可以学习
|
||||
// Pressure_t ago_pressure = Get_sys_front_pressure();
|
||||
// if(ago_pressure.blow_by_state || ago_pressure.voltage_state || ago_pressure.temp_state || ago_pressure.lose_flag){//异常
|
||||
// front_tire_pressure_loading();
|
||||
// tire_pressure_loading=3;
|
||||
// }else if(ago_pressure.temp<70 && (ago_pressure.psi>=TIRE_PRESSURE_FRONT_LOWER && ago_pressure.psi<=TIRE_PRESSURE_FRONT_UPPER)){//正常禁止学习
|
||||
// tire_pressure_loading=0;
|
||||
// }else{//异常
|
||||
// front_tire_pressure_loading();
|
||||
// tire_pressure_loading=3;
|
||||
// }
|
||||
front_tire_pressure_loading();
|
||||
tire_pressure_loading=3;
|
||||
}else if(tire_pressure_loading==2){
|
||||
// Pressure_t after_pressure = Get_sys_rear_pressure();
|
||||
// if(after_pressure.blow_by_state || after_pressure.voltage_state || after_pressure.temp_state || after_pressure.lose_flag){//异常
|
||||
// rear_tire_pressure_loading();
|
||||
// tire_pressure_loading=3;
|
||||
// }else if(after_pressure.temp<70 && (after_pressure.psi>=TIRE_PRESSURE_REAR_LOWER && after_pressure.psi<=TIRE_PRESSURE_REAR_UPPER)){//正常禁止学习
|
||||
// tire_pressure_loading=0;
|
||||
// }else{//异常
|
||||
// rear_tire_pressure_loading();
|
||||
// tire_pressure_loading=3;
|
||||
// }
|
||||
rear_tire_pressure_loading();
|
||||
tire_pressure_loading=3;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
front_tire_detection(win);
|
||||
refresh_rear_tire_oressure(win);
|
||||
break;
|
||||
case 2:
|
||||
rear_tire_detection(win);
|
||||
refresh_front_tire_oressure(win);
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
return RET_REPEAT;
|
||||
}
|
||||
|
||||
static ret_t on_destroy_key_down(void* ctx, event_t* e){
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t*tire_view = widget_lookup(win, "tire_view", TRUE);
|
||||
if(front_time != DETECTION_TIME){
|
||||
copy_user_tire_pressure_front();
|
||||
copy_user_tire_pressure_rear();
|
||||
Send_tire_pressure_information();
|
||||
power_on_flag = 1;
|
||||
}
|
||||
widget_remove_timer(tire_view,tire_id);
|
||||
DEBUG_PRINT("exit tire_pressure end------\n");
|
||||
widget_destroy(tire_view);
|
||||
if(Get_sys_pressure_signal())
|
||||
Set_sys_pressure_signal(0);
|
||||
tire_pressure_loading = 0;
|
||||
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static void set_tire_pressure_theme_init(widget_t* win){
|
||||
widget_t* view = widget_lookup(win, "tire_view", TRUE);
|
||||
// widget_t* label = widget_lookup(win, "label", TRUE);
|
||||
widget_t* page_label = widget_lookup(win, "page_label", TRUE);
|
||||
widget_t* top_bg = widget_lookup(win, "top_bg", TRUE);
|
||||
widget_t* img_moto = widget_lookup(win, "img_moto", TRUE);
|
||||
widget_t* label_view = widget_lookup(win, "label_view", TRUE);
|
||||
widget_t* pressure_view = widget_lookup(win, "pressure_view", TRUE);
|
||||
|
||||
widget_t*tire_view = widget_lookup(win, "tire_view", TRUE);
|
||||
widget_t*Front = widget_lookup(win, "Front", TRUE);
|
||||
widget_t* btn = NULL;
|
||||
|
||||
Pressure_t ago_pressure = Get_sys_front_pressure();
|
||||
Pressure_t after_pressure = Get_sys_rear_pressure();
|
||||
|
||||
front_loading_state = 0;
|
||||
rear_loading_state = 0;
|
||||
front_time = DETECTION_TIME;
|
||||
|
||||
refresh_front_tire_oressure(win);
|
||||
refresh_rear_tire_oressure(win);
|
||||
|
||||
/*#ifndef AWTK_630HV
|
||||
strcpy(ago_pressure.mac_address,"ABCDE");
|
||||
ago_pressure.temp = 30;
|
||||
ago_pressure.psi = 395;
|
||||
strcpy(after_pressure.mac_address,"EFGHI");
|
||||
after_pressure.temp = 40;
|
||||
after_pressure.psi = 430;
|
||||
Set_sys_front_pressure(ago_pressure);
|
||||
Set_sys_rear_pressure(after_pressure);
|
||||
#endif*/
|
||||
|
||||
widget_set_focused(Front,TRUE);
|
||||
btn = widget_get_child(Front,1);
|
||||
widget_set_visible(btn,TRUE);
|
||||
|
||||
tire_id = widget_add_timer(tire_view, tire_data_refresh, 500);
|
||||
|
||||
|
||||
uint8_t count = widget_count_children(label_view);//获取子类个数
|
||||
if(Get_sys_theme_state()){
|
||||
widget_use_style(view, "page_view_bg_wt");
|
||||
widget_use_style(top_bg, "top_bg_wt");
|
||||
widget_use_style(img_moto, "tire_moto_wt");
|
||||
|
||||
widget_set_style_color(page_label, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
for(uint8_t i=0;i<count;i++){
|
||||
btn = widget_get_child(label_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
}
|
||||
for(uint8_t i=0;i<2;i++){
|
||||
btn = widget_get_child(pressure_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_BLACK);
|
||||
}
|
||||
}else{
|
||||
widget_use_style(view, "page_view_bg_bk");
|
||||
widget_use_style(top_bg, "top_bg_bk");
|
||||
widget_use_style(img_moto, "tire_moto_bk");
|
||||
|
||||
widget_set_style_color(page_label, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
for(uint8_t i=0;i<count;i++){
|
||||
widget_t* btn = widget_get_child(label_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
for(uint8_t i=0;i<2;i++){
|
||||
widget_t* btn = widget_get_child(pressure_view,i);
|
||||
widget_set_style_color(btn, "normal:text_color", OUTPUT_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
if (tk_str_eq(name, "set_tire_pressure")) {
|
||||
widget_on(widget, EVT_KEY_DOWN, on_set_tire_pressure_key_down, win);
|
||||
widget_on(widget, EVT_DESTROY, on_destroy_key_down, win);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t set_tire_pressure_init(widget_t* win, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(win != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(win, visit_init_child, win);
|
||||
|
||||
set_tire_pressure_theme_init(win);
|
||||
winflag = 4;
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
widget_t* component = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t settingview1_init(widget_t* component, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(component != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(component, visit_init_child, component);
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
//widget_t* component = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t settingview2_init(widget_t* component, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(component != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(component, visit_init_child, component);
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
//widget_t* component = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t settingview3_init(widget_t* component, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(component != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(component, visit_init_child, component);
|
||||
|
||||
return RET_OK;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#include "awtk.h"
|
||||
#include "../common/navigator.h"
|
||||
|
||||
/**
|
||||
* 初始化窗口的子控件
|
||||
*/
|
||||
static ret_t visit_init_child(void* ctx, const void* iter) {
|
||||
widget_t* component = WIDGET(ctx);
|
||||
widget_t* widget = WIDGET(iter);
|
||||
const char* name = widget->name;
|
||||
|
||||
// 初始化指定名称的控件(设置属性或注册事件),请保证控件名称在窗口上唯一
|
||||
if (name != NULL && *name != '\0') {
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化窗口
|
||||
*/
|
||||
ret_t settingview4_init(widget_t* component, void* ctx) {
|
||||
(void)ctx;
|
||||
return_value_if_fail(component != NULL, RET_BAD_PARAMS);
|
||||
|
||||
widget_foreach(component, visit_init_child, component);
|
||||
|
||||
return RET_OK;
|
||||
}
|
Reference in New Issue
Block a user