922 lines
28 KiB
C
922 lines
28 KiB
C
#include "awtk.h"
|
||
#include "common/navigator.h"
|
||
#include "common/user_data.h"
|
||
#include "common/data_port.h"
|
||
#include "common/universal.h"
|
||
#include "tkc/object_date_time.h"
|
||
|
||
#ifndef APP_SYSTEM_BAR
|
||
#define APP_SYSTEM_BAR ""
|
||
#endif /*APP_SYSTEM_BAR*/
|
||
|
||
#ifndef APP_BOTTOM_SYSTEM_BAR
|
||
#define APP_BOTTOM_SYSTEM_BAR ""
|
||
#endif /*APP_BOTTOM_SYSTEM_BAR*/
|
||
|
||
#ifndef APP_START_PAGE
|
||
#define APP_START_PAGE "ui_demo1"
|
||
#endif /*APP_START_PAGE*/
|
||
|
||
uint32_t flash_trip_mile = 0;
|
||
uint32_t flash_total_mile = 0;
|
||
|
||
static uint16_t animo_time = 0;
|
||
#ifndef AMT630HV100
|
||
static int time_second;
|
||
#endif
|
||
extern uint8_t power_on_flag;
|
||
static uint32_t idletick = 0;
|
||
static uint32_t refresh500ms_idletick = 0;
|
||
uint8_t refresh500ms_flag = 0;
|
||
|
||
|
||
/**
|
||
* 注册自定义控件
|
||
*/
|
||
static ret_t custom_widgets_register(void) {
|
||
|
||
return RET_OK;
|
||
}
|
||
|
||
/**
|
||
* 当程序初始化完成时调用,全局只触发一次。
|
||
*/
|
||
static ret_t application_on_launch(void) {
|
||
|
||
return RET_OK;
|
||
}
|
||
|
||
/**
|
||
* 当程序退出时调用,全局只触发一次。
|
||
*/
|
||
static ret_t application_on_exit(void) {
|
||
|
||
return RET_OK;
|
||
}
|
||
#define LANGUAGE_ZH_CN 0
|
||
|
||
uint8_t light_buffer[SAVE_DATA_SIZE];
|
||
|
||
extern uint32_t tire_front_time;
|
||
extern uint32_t tire_rear_time;
|
||
extern uint8_t tire_pressure_flag;//再main函数中
|
||
extern uint8_t bt2_switch_time;
|
||
static uint8_t light_storage = 0;
|
||
|
||
|
||
uint8_t flash_save_flag = 0;
|
||
uint8_t save_flag = 0;
|
||
extern void SaveDataToFlash(SfudData_t user_data);
|
||
extern void Send_defect_code(void);
|
||
extern void BT2_Switch(int type);
|
||
extern void read_mileage(uint32_t trip_data,uint32_t total_data);
|
||
|
||
extern void A270F_ui_refresh(widget_t* win);
|
||
char UI_uuid[32] = "";
|
||
char strQrText[100] = "";
|
||
char key_value = 0;
|
||
|
||
// uint8_t uart3_flag = 0;
|
||
extern void UART3_Modification_Type(void);
|
||
extern void UART3_Type_regression(void);
|
||
// extern uint8_t urtflag;
|
||
extern uint8_t uart_state;
|
||
extern uint8_t uart_flag;
|
||
extern uint8_t bt_communication_heartbeat;
|
||
|
||
extern uint8_t flash_bt_state;
|
||
void A27_BT_init(void){
|
||
//蓝牙初始化
|
||
printf("enter A27_BT_init state = %d ,flash_bt_state=%d.\r\n",Get_sys_bt_on_off(),flash_bt_state);
|
||
|
||
#if (CALL_BW121_KEY)
|
||
if(!flash_bt_state){
|
||
console_send_atcmd("AT+BTEN=0\r\n", strlen("AT+BTEN=0\r\n"));//关蓝牙
|
||
// }else{
|
||
// console_send_atcmd("AT+BTEN=1\r\n", strlen("AT+BTEN=1\r\n"));//开蓝牙
|
||
}
|
||
|
||
#ifdef AMT630HV100
|
||
vTaskDelay(10);
|
||
#else
|
||
sleep_ms(10);
|
||
#endif
|
||
printf("BW121 HFP >> Open .\r\n");
|
||
console_send_atcmd("AT+HFPCFG=5\r\n", strlen("AT+HFPCFG=5\r\n"));//开三方通话使能
|
||
|
||
#else
|
||
if(Get_sys_bt_on_off()==0){
|
||
DEBUG_PRINT("BT_SWITCH close .\r\n");
|
||
BT2_Switch(0);
|
||
}else
|
||
DEBUG_PRINT("BT_SWITCH open .\r\n");
|
||
#endif
|
||
}
|
||
|
||
uint8_t velocity_light_flag = 0;
|
||
uint8_t update_light = 0;
|
||
uint8_t veer_velocity_state = 1;
|
||
void pwm_backlight_changes_slowly(void){
|
||
uint8_t now_light;
|
||
uint8_t light;
|
||
uint8_t num;
|
||
if((Get_sys_light_value() != 6)){
|
||
return;
|
||
}
|
||
|
||
|
||
num = now_light = Get_sys_light();
|
||
light = Get_sys_light_perception_value();
|
||
if(light<=30)
|
||
light = 30;
|
||
|
||
if(now_light == light)
|
||
return;
|
||
|
||
if(light>now_light){//变亮
|
||
// DEBUG_PRINT("light = %d , now_light = %d \n",light,now_light);
|
||
num += 1;
|
||
if(num>=light-1)//-1是因为做数据保护 保证num不超过100.
|
||
Unified_brightness_processing(light,1);
|
||
else
|
||
Unified_brightness_processing(num,1);
|
||
}else{//变暗
|
||
num -= 1;
|
||
// if(num<30)
|
||
// return;
|
||
if(num <=light+1 )//+1是因为做数据保护 保证num不为负数不出错
|
||
Unified_brightness_processing(light,1);
|
||
else
|
||
Unified_brightness_processing(num,1);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
extern void Power_On_Self_Test(void);
|
||
|
||
static uint8_t nrCalculation_flag = 0;//计算数组的标志
|
||
|
||
uint8_t data_storage;
|
||
// extern void cat1_enable(void);
|
||
uint8_t now_theme_state;//主题标识 判断切换黑夜还是白天
|
||
|
||
extern double test_data;
|
||
|
||
extern uint32_t tire_front_time;
|
||
extern uint32_t tire_rear_time;
|
||
extern uint8_t tire_pressure_flag;//再main函数中
|
||
extern uint8_t bt2_state_now_flag;
|
||
extern uint8_t bt_reset_flag;
|
||
extern uint8_t wifi_time_flag;
|
||
uint8_t bw_121_time = 0;
|
||
// extern uint8_t bt_connect_flag;
|
||
|
||
void UI_init(void){
|
||
printf("UI_init ...........................................\r\n");
|
||
|
||
Set_sys_power_on_self_test(DEMO_UI_SELF_FINISH);//自检完成
|
||
animo_time = 511;
|
||
if(bt2_switch_time)
|
||
bt2_switch_time = 0;
|
||
|
||
#ifdef AMT630HV100
|
||
|
||
#if (CARLINK_TP_CP && CARLINK_TP_AA)
|
||
if(!Get_sys_tp_state()){//carplay
|
||
printf("cp+aa init carplay.\r\n");
|
||
Set_sys_tp_state(0);
|
||
carlink_cp_enable(1);
|
||
carlink_aa_enable(0);
|
||
carlink_ec_enable(0);
|
||
|
||
}else{//android
|
||
printf("cp+aa init android.\r\n");
|
||
Set_sys_tp_state(1);
|
||
|
||
carlink_cp_enable(1);
|
||
carlink_aa_enable(0);
|
||
carlink_ec_enable(0);
|
||
}
|
||
#elif (CARLINK_TP_CP && CARLINK_TP_EC)
|
||
if (!Get_sys_tp_state()) { // carplay
|
||
printf("cp+ec init carplay.\r\n");
|
||
Set_sys_tp_state(0);
|
||
carlink_cp_enable(1);
|
||
carlink_aa_enable(0);
|
||
carlink_ec_enable(0);
|
||
}else{ // 亿连
|
||
printf("cp+ec init ec.\r\n");
|
||
Set_sys_tp_state(1);
|
||
carlink_cp_enable(0);
|
||
carlink_aa_enable(0);
|
||
carlink_ec_enable(1);
|
||
}
|
||
|
||
#elif (CARLINK_TP_CP)
|
||
printf("only tp init cp.\r\n");
|
||
Set_sys_tp_state(0);
|
||
carlink_cp_enable(1);
|
||
carlink_aa_enable(0);
|
||
carlink_ec_enable(0);
|
||
|
||
#elif (CARLINK_TP_EC)
|
||
printf("only tp init EC.\r\n");
|
||
Set_sys_tp_state(2);
|
||
carlink_cp_enable(0);
|
||
carlink_aa_enable(0);
|
||
carlink_ec_enable(1);
|
||
|
||
#endif
|
||
|
||
#endif
|
||
|
||
// console_send_atcmd("AT+ADDR\r\n", strlen("AT+ADDR\r\n"));//开蓝牙
|
||
// #ifdef AMT630HV100
|
||
// vTaskDelay(10);
|
||
// #else
|
||
// sleep_ms(10);
|
||
// #endif
|
||
// #if (MOTO_WARE_HOSE == MOTO_ICMX_GB518_A270T)
|
||
// console_send_atcmd("AT+NAME=A27_MOTO_Phone,1\r\n", strlen("AT+NAME=A27_MOTO_Phone,1\r\n"));//修改蓝牙名
|
||
// #else
|
||
// console_send_atcmd("AT+NAME=A59_MOTO_Phone,1\r\n", strlen("AT+NAME=A59_MOTO_Phone,1\r\n"));//修改蓝牙名
|
||
// #endif
|
||
// #ifdef AMT630HV100
|
||
// vTaskDelay(10);
|
||
// #else
|
||
// sleep_ms(10);
|
||
// #endif
|
||
console_send_atcmd("AT+NAME\r\n", strlen("AT+NAME\r\n"));//查询蓝牙名
|
||
|
||
A27_BT_init();
|
||
|
||
//光感数据计算
|
||
if(data_storage){
|
||
uint32_t light_num=0;
|
||
uint16_t light=0;
|
||
uint8_t light_count = 0;
|
||
|
||
for(uint8_t i=0;i<SAVE_DATA_SIZE;i++){
|
||
if(light_buffer[i] != 0){
|
||
light += light_buffer[i];
|
||
light_count++;
|
||
}
|
||
|
||
}
|
||
light_num = (int)(light/light_count);
|
||
Set_sys_light_perception_value(light_num);
|
||
|
||
#ifndef AMT630HV100
|
||
if(Get_sys_light_perception_value()>=50){//光感大于70 白天 白色背景
|
||
Set_sys_display_theme(1);
|
||
}else if(Get_sys_light_perception_value()<=20){
|
||
Set_sys_display_theme(0);
|
||
}
|
||
#endif
|
||
}
|
||
|
||
//允许AP连接
|
||
cp_wlan_start();
|
||
|
||
}
|
||
|
||
static ret_t on_timer(const idle_info_t* idle){
|
||
static uint16_t time_num =0;
|
||
uint32_t light_num=0;
|
||
uint16_t light=0;
|
||
uint8_t power_state =0;
|
||
uint8_t light_count = 0;
|
||
static uint8_t light_time = 0;
|
||
power_state = Get_sys_power_on_self_test();
|
||
|
||
if(light_time>=4){
|
||
pwm_backlight_changes_slowly();//光感控制亮度
|
||
light_time = 0;
|
||
}
|
||
light_time++;
|
||
|
||
if(power_state == 100){
|
||
// #ifndef AMT630HV100
|
||
// Simulating_data_changes();
|
||
// #endif
|
||
widget_t* win = window_manager();
|
||
widget_t* child = window_manager_get_top_main_window(win);
|
||
|
||
if(child != NULL && strcmp(child->name,"set_list")==0){
|
||
list_win_init(child);
|
||
// }else if(child != NULL && strcmp(child->name,"ui_demo1")==0){
|
||
// new_refreshes(child);
|
||
// //灯光刷新
|
||
// light_refresh(child);
|
||
// //通话界面刷新
|
||
// call_refresh(child);
|
||
}
|
||
|
||
//光感数据计算
|
||
if(light_storage != data_storage){
|
||
light_storage = data_storage;
|
||
for(uint8_t i=0;i<SAVE_DATA_SIZE;i++){
|
||
if(light_buffer[i] != 0){
|
||
light += light_buffer[i];
|
||
light_count++;
|
||
}
|
||
}
|
||
light_num = (int)(light/light_count);
|
||
Set_sys_light_perception_value(light_num);
|
||
if(Get_sys_light_perception_value()>=50){//光感大于70 白天 白色背景
|
||
Set_sys_display_theme(1);
|
||
}else if(Get_sys_light_perception_value()<=20){
|
||
Set_sys_display_theme(0);
|
||
}
|
||
}
|
||
|
||
//回到主菜单
|
||
if(Get_sys_return_demo() ==2){
|
||
time_num = 1;
|
||
Set_sys_return_demo(1);
|
||
}else if(Get_sys_return_demo() ==1){
|
||
if(time_num %600 ==0 || Get_sys_velocity() != 0 || Get_sys_call_state()){//10s左右 || 有速度的情况下直接退回主界面 || 有通话
|
||
time_num = 0;
|
||
printf("time ok return demo . %d \r\n",Get_sys_return_demo());
|
||
Return_demo_win();
|
||
}
|
||
time_num++;
|
||
}else if(Get_sys_return_demo() ==3){
|
||
Return_demo_win();//如果目标是非主demo界面or投屏界面 则返回主demo界面
|
||
}
|
||
|
||
// if(uart3_flag == 1){
|
||
// //uart_init();
|
||
// //将通讯串口配置为gpio端口
|
||
// UART3_Modification_Type();
|
||
// printf("uart3>>close.\r\n");
|
||
// uart3_flag = 2;
|
||
// }
|
||
|
||
if(Get_sys_upgrade_Flag()==2){//退出升级标志
|
||
DEBUG_PRINT("exit >> prompt .\r\n");
|
||
navigator_replace("ui_demo1");
|
||
Set_sys_upgrade_Flag(0);
|
||
Set_sys_plan(0);//1.修复升级一定进度失败后 再次进入升级 进度条未清零问题
|
||
Set_sys_pace(0);
|
||
}
|
||
#ifdef AMT630HV100
|
||
//1s一刷
|
||
if(xTaskGetTickCount() - idletick > configTICK_RATE_HZ){
|
||
if(ttrb_mesg()){ //查询时间 首次开机需要去询问时间
|
||
Send_software_version();
|
||
#if UI_VIEW_TIRE_PRESSURE
|
||
}else if(!tire_pressure_mesg()){ //发送胎压信息
|
||
Send_tire_pressure_information();
|
||
#endif
|
||
}else if(!ttrb_time_mesg()){ //发送时间 当用户通过UI设置时间后,需要检测是否发送时间
|
||
Send_bt_time();
|
||
#ifndef DATA_CAN
|
||
}else if(!odo_reset_mesg()){ //发送清零命令 当用户长按时清零
|
||
Send_trip_reset();
|
||
#endif
|
||
}else if(fault_code_mesg()){ //发送故障码 为1是需要发送故障码
|
||
Send_defect_code();
|
||
}
|
||
|
||
if(bw_121_time)//蓝牙按钮时间控制
|
||
bw_121_time--;
|
||
|
||
// if(bt_connect_flag){
|
||
// select_bt_conntect();
|
||
// bt_connect_flag = 0;
|
||
// }
|
||
if(wifi_time_flag)
|
||
wifi_time_flag--;
|
||
|
||
|
||
// //串口检测蓝牙通讯
|
||
// if(uart_state && (Get_sys_bt_upgrade()==0 && Get_sys_upgrade_Flag()==0)){
|
||
// uart_state--;
|
||
// if(!uart_state){
|
||
// printf("uart3 >gpio.\r\n");
|
||
// UART3_Modification_Type();//将通讯串口配置为gpio端口
|
||
// }
|
||
// }else{
|
||
// uart_state = 5;
|
||
// printf("uart3 > regression.\r\n");
|
||
// UART3_Type_regression();//串口恢复正常
|
||
// }
|
||
if(bt_reset_flag){
|
||
if(bt_reset_flag==2){
|
||
Send_software_version();
|
||
#if UI_VIEW_TIRE_PRESSURE
|
||
}else{
|
||
Send_tire_pressure_init_information();
|
||
#endif
|
||
}
|
||
|
||
bt_reset_flag--;
|
||
}
|
||
|
||
//串口检测蓝牙心跳 + 接收发送
|
||
if(bt_communication_heartbeat && (Get_sys_bt_upgrade()==0 && Get_sys_upgrade_Flag()==0)){
|
||
bt_communication_heartbeat--;
|
||
|
||
if(!bt_communication_heartbeat){//需要去重新初始化一次串口
|
||
uart_flag = 1;
|
||
bt_communication_heartbeat = 10;
|
||
}
|
||
}
|
||
idletick = xTaskGetTickCount();
|
||
}
|
||
|
||
if(xTaskGetTickCount() - refresh500ms_idletick > 500){
|
||
refresh500ms_flag = refresh500ms_flag?0:1;
|
||
refresh500ms_idletick = xTaskGetTickCount();
|
||
}
|
||
#else
|
||
refresh500ms_flag = 1;
|
||
printf("refresh500ms_flag = %d.\r\n",refresh500ms_flag);
|
||
#endif
|
||
|
||
}
|
||
|
||
return RET_OK;
|
||
}
|
||
|
||
static void ui_system_timer(void){
|
||
static uint16_t time_num =0;
|
||
uint32_t light_num=0;
|
||
uint16_t light=0;
|
||
uint8_t power_state =0;
|
||
uint8_t light_count = 0;
|
||
static uint8_t light_time = 0;
|
||
power_state = Get_sys_power_on_self_test();
|
||
|
||
if(light_time>=4){
|
||
pwm_backlight_changes_slowly();//光感控制亮度
|
||
light_time = 0;
|
||
}
|
||
light_time++;
|
||
|
||
if(power_state == 100){
|
||
// #ifndef AMT630HV100
|
||
// Simulating_data_changes();
|
||
// #endif
|
||
#if(MOTO_WARE_HOSE == MOTO_TEST_DEMO)
|
||
Simulating_data_changes();
|
||
#endif
|
||
widget_t* win = window_manager();
|
||
widget_t* child = window_manager_get_top_main_window(win);
|
||
|
||
if(child != NULL && strcmp(child->name,"set_list")==0){
|
||
list_win_init(child);
|
||
// }else if(child != NULL && strcmp(child->name,"ui_demo1")==0){
|
||
// new_refreshes(child);
|
||
// //灯光刷新
|
||
// light_refresh(child);
|
||
// //通话界面刷新
|
||
// call_refresh(child);
|
||
}
|
||
|
||
//光感数据计算
|
||
if(light_storage != data_storage){
|
||
light_storage = data_storage;
|
||
for(uint8_t i=0;i<SAVE_DATA_SIZE;i++){
|
||
if(light_buffer[i] != 0){
|
||
light += light_buffer[i];
|
||
light_count++;
|
||
}
|
||
}
|
||
light_num = (int)(light/light_count);
|
||
Set_sys_light_perception_value(light_num);
|
||
if(Get_sys_light_perception_value()>=50){//光感大于70 白天 白色背景
|
||
Set_sys_display_theme(1);
|
||
}else if(Get_sys_light_perception_value()<=20){
|
||
Set_sys_display_theme(0);
|
||
}
|
||
}
|
||
|
||
//回到主菜单
|
||
if(Get_sys_return_demo() ==2){
|
||
time_num = 1;
|
||
Set_sys_return_demo(1);
|
||
}else if(Get_sys_return_demo() ==1){
|
||
#if(MOTO_WARE_HOSE == MOTO_TEST_DEMO)
|
||
if(time_num %600 ==0 || Get_sys_call_state()){//10s左右 || 有速度的情况下直接退回主界面 || 有通话
|
||
#else
|
||
if(time_num %600 ==0 || Get_sys_velocity() != 0 || Get_sys_call_state()){//10s左右 || 有速度的情况下直接退回主界面 || 有通话
|
||
#endif
|
||
time_num = 0;
|
||
printf("time ok return demo . %d \r\n",Get_sys_return_demo());
|
||
Return_demo_win();
|
||
}
|
||
time_num++;
|
||
}else if(Get_sys_return_demo() ==3){
|
||
Return_demo_win();//如果目标是非主demo界面or投屏界面 则返回主demo界面
|
||
}
|
||
|
||
// if(uart3_flag == 1){
|
||
// //uart_init();
|
||
// //将通讯串口配置为gpio端口
|
||
// UART3_Modification_Type();
|
||
// printf("uart3>>close.\r\n");
|
||
// uart3_flag = 2;
|
||
// }
|
||
|
||
if(Get_sys_upgrade_Flag()==2){//退出升级标志
|
||
DEBUG_PRINT("exit >> prompt .\r\n");
|
||
navigator_replace("ui_demo1");
|
||
Set_sys_upgrade_Flag(0);
|
||
Set_sys_plan(0);//1.修复升级一定进度失败后 再次进入升级 进度条未清零问题
|
||
Set_sys_pace(0);
|
||
}
|
||
#ifdef AMT630HV100
|
||
//1s一刷
|
||
if(xTaskGetTickCount() - idletick > configTICK_RATE_HZ){
|
||
if(ttrb_mesg()){ //查询时间 首次开机需要去询问时间
|
||
Send_software_version();
|
||
#if UI_VIEW_TIRE_PRESSURE
|
||
}else if(!tire_pressure_mesg()){ //发送胎压信息
|
||
Send_tire_pressure_information();
|
||
#endif
|
||
}else if(!ttrb_time_mesg()){ //发送时间 当用户通过UI设置时间后,需要检测是否发送时间
|
||
Send_bt_time();
|
||
#ifndef DATA_CAN
|
||
}else if(!odo_reset_mesg()){ //发送清零命令 当用户长按时清零
|
||
Send_trip_reset();
|
||
#endif
|
||
}else if(fault_code_mesg()){ //发送故障码 为1是需要发送故障码
|
||
Send_defect_code();
|
||
}
|
||
|
||
if(bw_121_time)//蓝牙按钮时间控制
|
||
bw_121_time--;
|
||
|
||
// if(bt_connect_flag){
|
||
// select_bt_conntect();
|
||
// bt_connect_flag = 0;
|
||
// }
|
||
|
||
|
||
// //串口检测蓝牙通讯
|
||
// if(uart_state && (Get_sys_bt_upgrade()==0 && Get_sys_upgrade_Flag()==0)){
|
||
// uart_state--;
|
||
// if(!uart_state){
|
||
// printf("uart3 >gpio.\r\n");
|
||
// UART3_Modification_Type();//将通讯串口配置为gpio端口
|
||
// }
|
||
// }else{
|
||
// uart_state = 5;
|
||
// printf("uart3 > regression.\r\n");
|
||
// UART3_Type_regression();//串口恢复正常
|
||
// }
|
||
if(bt_reset_flag){
|
||
if(bt_reset_flag==2){
|
||
Send_software_version();
|
||
#if UI_VIEW_TIRE_PRESSURE
|
||
}else{
|
||
Send_tire_pressure_init_information();
|
||
#endif
|
||
}
|
||
|
||
bt_reset_flag--;
|
||
}
|
||
|
||
//串口检测蓝牙心跳 + 接收发送
|
||
if(bt_communication_heartbeat && (Get_sys_bt_upgrade()==0 && Get_sys_upgrade_Flag()==0)){
|
||
bt_communication_heartbeat--;
|
||
|
||
if(!bt_communication_heartbeat){//需要去重新初始化一次串口
|
||
uart_flag = 1;
|
||
bt_communication_heartbeat = 10;
|
||
}
|
||
}
|
||
idletick = xTaskGetTickCount();
|
||
}
|
||
|
||
if(xTaskGetTickCount() - refresh500ms_idletick > 500){
|
||
refresh500ms_flag = refresh500ms_flag?0:1;
|
||
refresh500ms_idletick = xTaskGetTickCount();
|
||
}
|
||
#else
|
||
refresh500ms_flag = 1;
|
||
#endif
|
||
|
||
}
|
||
|
||
}
|
||
|
||
static ret_t ui_timer_refresh(const timer_info_t* timer){ //demo Progress bar Color change
|
||
// widget_t *win = WIDGET(timer->ctx); // home_page
|
||
// static uint32_t count = 0;
|
||
// count++;
|
||
// printf("count = %d.\r\n",count);
|
||
|
||
if(animo_time < 510){
|
||
#ifndef AMT630HV100
|
||
date_time_t dt;
|
||
date_time_init(&dt);
|
||
#endif
|
||
animo_time++;
|
||
if(Get_sys_power_on_self_test()<DEMO_UI_SELF_START){
|
||
#ifndef AMT630HV100
|
||
Set_sys_power_on_self_test(DEMO_UI_SELF_START);
|
||
#endif
|
||
#ifdef ANIMO_CLOSE
|
||
if(animo_time>110){
|
||
BrightnessPowerOnSetting();
|
||
pwm_enable(2);
|
||
pwm_enable(3);
|
||
extern void anim_close_lcd_open(void);
|
||
anim_close_lcd_open();
|
||
}
|
||
|
||
if(animo_time>=130)
|
||
Set_sys_power_on_self_test(DEMO_UI_SELF_START);
|
||
#endif
|
||
}else if(Get_sys_power_on_self_test()==DEMO_UI_SELF_START){
|
||
|
||
if(!power_on_flag)
|
||
power_on_flag = 1;
|
||
Send_tire_pressure_init_information();//胎压
|
||
|
||
Set_sys_power_on_self_test(DEMO_UI_SELF_START_OK);
|
||
|
||
}else if(Get_sys_power_on_self_test()==DEMO_UI_SELF_START_OK){
|
||
if(animo_time>=35){
|
||
printf("animo_time = %d.\r\n",animo_time);
|
||
#ifdef AMT630HV100
|
||
idletick = xTaskGetTickCount();
|
||
#else
|
||
time_second = dt.second;
|
||
printf("time_second = %d .",time_second);
|
||
printf("start demo animo .\n");
|
||
#endif
|
||
|
||
Set_sys_power_on_self_test(DEMO_UI_SELF_CHECKING);//设置为自检中
|
||
Power_On_Self_Test();
|
||
}
|
||
#ifdef AMT630HV100
|
||
}else if(Get_sys_power_on_self_test()==DEMO_UI_SELF_CHECKING){
|
||
if(xTaskGetTickCount() - idletick > configTICK_RATE_HZ * 2.5){
|
||
UI_init();
|
||
// Set_sys_power_on_self_test(100);//设置为自检中
|
||
}
|
||
}
|
||
#else
|
||
}else if(time_second<57){
|
||
if((dt.second-time_second)>2){
|
||
printf("animo_time <57 ,second = %d ,end demo animo \n",dt.second);
|
||
UI_init();
|
||
}
|
||
}else if(time_second==57){
|
||
if(dt.second==0){
|
||
printf("animo_time ==57 ,second = %d ,end demo animo \n",dt.second);
|
||
UI_init();
|
||
}
|
||
}else if(time_second==58){
|
||
if(dt.second==1){
|
||
printf("animo_time ==58 ,second = %d ,end demo animo \n",dt.second);
|
||
UI_init();
|
||
}
|
||
}else{
|
||
if(dt.second==2){
|
||
printf("animo_time ==59 ,second = %d ,end demo animo \n",dt.second);
|
||
UI_init();
|
||
}
|
||
}
|
||
#endif
|
||
}
|
||
|
||
if(Get_sys_power_on_self_test() != DEMO_UI_SELF_UPGRADE_BEGINS){
|
||
ui_system_timer();
|
||
}else if(Get_sys_upgrade_Flag()==1){
|
||
DEBUG_PRINT("start >> prompt .\r\n");
|
||
navigator_replace("prompt");
|
||
Set_sys_upgrade_Flag(3);
|
||
DEBUG_PRINT("screen >> prompt ok .\r\n");
|
||
}
|
||
|
||
//立即保存flash
|
||
if(save_flag){
|
||
SaveDataToFlash(custom_data.user_data);
|
||
save_flag = 0;
|
||
}
|
||
|
||
|
||
return RET_REPEAT;
|
||
}
|
||
|
||
|
||
extern uint8_t power_on_flag;
|
||
|
||
void* test_timer_queue(void *args){
|
||
// int test_time =0 ;
|
||
#ifndef AMT630HV100
|
||
// // Set_sys_power_on_self_test(DEMO_UI_SELF_START);
|
||
// char produce[5] = {0};
|
||
// produce[0] = 65;
|
||
// produce[1] = 53;
|
||
// produce[2] = 56;
|
||
// produce[3] = 48;
|
||
// produce[4] = 65;
|
||
// Set_device_produce_num(produce);
|
||
// char dtc[5] = {0};
|
||
// dtc[4] = 0x31;
|
||
// dtc[3] = 0x30;
|
||
// dtc[2] = 0x32;
|
||
// dtc[1] = 0x31;
|
||
// dtc[0] = 0x43;
|
||
// // Set_can_abs_dtc(dtc);
|
||
// dtc[4] = 0x33;
|
||
// dtc[3] = 0x32;
|
||
// // Set_can_abs_his_dtc(dtc);
|
||
// strcpy(UI_uuid,"CARBITDC0D3050230C");
|
||
// strcpy(strQrText,"http://www.carbit.com.cn/down6/642/643/_ylqx?modelid=49801&sn=ZAT4&action=9&ssid=AP630_CARLINK_7A8D&pwd=88888888&auth=WPA-PSK&name=DIRECT-AP630_CARLINK_p2p_7A8D");
|
||
// extern char bt121_name[50];
|
||
// strcpy(bt121_name,"AWTK_TEST");
|
||
|
||
#endif
|
||
|
||
//收数据
|
||
for(;;){
|
||
|
||
if(animo_time < 510){
|
||
date_time_t dt;
|
||
date_time_init(&dt);
|
||
animo_time++;
|
||
if(Get_sys_power_on_self_test()<DEMO_UI_SELF_START){
|
||
#ifndef AMT630HV100
|
||
Set_sys_power_on_self_test(DEMO_UI_SELF_START);
|
||
#endif
|
||
#ifdef ANIMO_CLOSE
|
||
if(animo_time>110){
|
||
BrightnessPowerOnSetting();
|
||
pwm_enable(2);
|
||
pwm_enable(3);
|
||
extern void anim_close_lcd_open(void);
|
||
anim_close_lcd_open();
|
||
}
|
||
|
||
if(animo_time>=130)
|
||
Set_sys_power_on_self_test(DEMO_UI_SELF_START);
|
||
#endif
|
||
}else if(Get_sys_power_on_self_test()==DEMO_UI_SELF_START){
|
||
|
||
#ifdef AMT630HV100
|
||
idletick = xTaskGetTickCount();
|
||
#else
|
||
time_second = dt.second;
|
||
printf("time_second = %d .",time_second);
|
||
printf("start demo animo .\n");
|
||
#endif
|
||
|
||
if(!power_on_flag)
|
||
power_on_flag = 1;
|
||
Send_tire_pressure_init_information();//胎压
|
||
Set_sys_power_on_self_test(DEMO_UI_SELF_CHECKING);//设置为自检中
|
||
// console_send_atcmd("AT+NAME=A27_MOTO_Phone,1\r\n", strlen("AT+NAME=A27_MOTO_Phone,1\r\n"));//修改蓝牙名
|
||
#ifdef AMT630HV100
|
||
vTaskDelay(1000);
|
||
#else
|
||
sleep_ms(100);
|
||
#endif
|
||
Power_On_Self_Test();
|
||
|
||
// console_send_atcmd("AT+BTEN=0\r\n", strlen("AT+BTEN=0\r\n"));//关蓝牙
|
||
|
||
#ifdef AMT630HV100
|
||
}else if(Get_sys_power_on_self_test()==DEMO_UI_SELF_CHECKING){
|
||
if(xTaskGetTickCount() - idletick > configTICK_RATE_HZ * 3){
|
||
// #ifdef AMT630HV100
|
||
// vTaskDelay(100);
|
||
// #else
|
||
// sleep_ms(100);
|
||
// #endif
|
||
UI_init();
|
||
}
|
||
}
|
||
#else
|
||
}else if(time_second<57){
|
||
if((dt.second-time_second)>2){
|
||
printf("animo_time <57 ,second = %d ,end demo animo \n",dt.second);
|
||
UI_init();
|
||
}
|
||
}else if(time_second==57){
|
||
if(dt.second==0){
|
||
printf("animo_time ==57 ,second = %d ,end demo animo \n",dt.second);
|
||
UI_init();
|
||
}
|
||
}else if(time_second==58){
|
||
if(dt.second==1){
|
||
printf("animo_time ==58 ,second = %d ,end demo animo \n",dt.second);
|
||
UI_init();
|
||
}
|
||
}else{
|
||
if(dt.second==2){
|
||
printf("animo_time ==59 ,second = %d ,end demo animo \n",dt.second);
|
||
UI_init();
|
||
}
|
||
}
|
||
#endif
|
||
}
|
||
|
||
if(Get_sys_power_on_self_test() != DEMO_UI_SELF_UPGRADE_BEGINS){
|
||
idle_queue(on_timer,args);
|
||
}else if(Get_sys_upgrade_Flag()==1){
|
||
DEBUG_PRINT("start >> prompt .\r\n");
|
||
navigator_replace("prompt");
|
||
Set_sys_upgrade_Flag(3);
|
||
DEBUG_PRINT("screen >> prompt ok .\r\n");
|
||
}
|
||
#ifdef AMT630HV100
|
||
vTaskDelay(20);
|
||
#else
|
||
sleep_ms(20);
|
||
#endif
|
||
|
||
//立即保存flash
|
||
if(save_flag){
|
||
SaveDataToFlash(custom_data.user_data);
|
||
save_flag = 0;
|
||
}
|
||
|
||
//printf(".\r\n");
|
||
}
|
||
return NULL;
|
||
}
|
||
|
||
/**
|
||
* 初始化程序
|
||
*/
|
||
ret_t application_init(void) {
|
||
//uint8_t count = 0;
|
||
animo_time = 0;
|
||
custom_widgets_register();
|
||
application_on_launch();
|
||
if (strlen(APP_SYSTEM_BAR) > 0) {
|
||
navigator_to(APP_SYSTEM_BAR);
|
||
}
|
||
|
||
if (strlen(APP_BOTTOM_SYSTEM_BAR) > 0) {
|
||
navigator_to(APP_BOTTOM_SYSTEM_BAR);
|
||
}
|
||
|
||
//custom_widgets_init();
|
||
//fps显示
|
||
window_manager_set_show_fps(window_manager(), FALSE);
|
||
system_date_init();
|
||
now_theme_state = 5;
|
||
system_flash_to_date_event_handling();//上电后数据同步
|
||
// Send_software_version();
|
||
|
||
printf("******************************************\n");
|
||
printf("MXC-A27 version information :\nsoftware version: MXC-A271O-V%d.%d \nhardware version: %s \n",custom_data.softwar_host,custom_data.softwar_order,HARD_WARE);
|
||
printf("mac: %02X%02X%02X%02X%02X%02X , %02X%02X%02X%02X%02X%02X end\r\n",
|
||
custom_data.user_data.f_mac_address[0],custom_data.user_data.f_mac_address[1],custom_data.user_data.f_mac_address[2],
|
||
custom_data.user_data.f_mac_address[3],custom_data.user_data.f_mac_address[4],custom_data.user_data.f_mac_address[5],
|
||
custom_data.user_data.r_mac_address[0],custom_data.user_data.r_mac_address[1],custom_data.user_data.r_mac_address[2],
|
||
custom_data.user_data.r_mac_address[3],custom_data.user_data.r_mac_address[4],custom_data.user_data.r_mac_address[5]);
|
||
printf("data:%02X %02X%02X , %02X %02X%02X end\r\n"
|
||
,custom_data.user_data.f_mac_address[6],custom_data.user_data.f_mac_address[7],custom_data.user_data.f_mac_address[8]
|
||
,custom_data.user_data.r_mac_address[6],custom_data.user_data.r_mac_address[7],custom_data.user_data.r_mac_address[8]);
|
||
printf("******************************************\n");
|
||
|
||
// Set_sys_light_perception_value(30);
|
||
Set_sys_light(30);
|
||
|
||
// //UI刷新线程
|
||
// tk_thread_t *thread = NULL;
|
||
// thread =tk_thread_create(test_timer_queue,NULL);
|
||
// tk_thread_start(thread);
|
||
|
||
widget_add_timer(window_manager(), ui_timer_refresh, 20);//进度条颜色刷新
|
||
|
||
char country[3];
|
||
char language[3];
|
||
|
||
if(Get_sys_language() == LANGUAGE_ZH_CN){
|
||
strncpy(language, "zh_CN", 2);
|
||
strncpy(country, "zh_CN" + 3, 2);
|
||
}else{
|
||
strncpy(language, "en_US", 2);
|
||
strncpy(country, "en_US" + 3, 2);
|
||
}
|
||
locale_info_change(locale_info(), language, country);
|
||
|
||
DEBUG_PRINT("tire data>%02X-%04X, %02X-%04X end\r\n"
|
||
,custom_data.front_pressure.temp,custom_data.front_pressure.psi
|
||
,custom_data.rear_pressure.temp,custom_data.rear_pressure.psi);
|
||
|
||
return navigator_to("ui_demo1");
|
||
}
|
||
|
||
/**
|
||
* 退出程序
|
||
*/
|
||
ret_t application_exit(void) {
|
||
application_on_exit();
|
||
log_debug("application_exit\n");
|
||
|
||
return RET_OK;
|
||
}
|