|
|
@ -1,32 +1,14 @@ |
|
|
|
#include "task_screen.h" |
|
|
|
#include "../app/app_config.h" |
|
|
|
#include "app_config.h" |
|
|
|
#include "../msp/uart/msp_uart1.h" |
|
|
|
#include "msp_uart1.h" |
|
|
|
#include "../msp_uart1.h" |
|
|
|
#include "debug_drv.h" |
|
|
|
#include "../msp/msp_eeprom.h" |
|
|
|
#include "app_screen_save.h" |
|
|
|
|
|
|
|
#include "../msp/uart/msp_uart1.h" |
|
|
|
|
|
|
|
S_TASK_SCREEN _s_task_screen; |
|
|
|
|
|
|
|
// SCRSetValPkg scrSetValPkg =
|
|
|
|
// {
|
|
|
|
// 0xA5, 0x5A, //帧头
|
|
|
|
// 0x1C, //长度
|
|
|
|
// 0x82, //指令
|
|
|
|
// 0x02, 0xA1, //起始地址
|
|
|
|
// 0x00, 0x00, //体重
|
|
|
|
// 0x00, 0x00, //电量
|
|
|
|
// 0x00, 0x00, //网络状态
|
|
|
|
// 0x00, 0x00, //单位标志
|
|
|
|
// 0x00, 0x00, //语言标志
|
|
|
|
// 0x00, 0x00, //蜂鸣器状态
|
|
|
|
// 0x00, 0x00, //
|
|
|
|
// 0x00, 0x00, //离床报警标志
|
|
|
|
// 0x00, 0x00, //
|
|
|
|
// 0x1C, 0x78, //CRC
|
|
|
|
// };
|
|
|
|
|
|
|
|
// 实时重量
|
|
|
|
SCRSetValPkg scrSetValPkg = |
|
|
|
{ |
|
|
|
0xA5, 0x5A, //帧头
|
|
|
@ -37,6 +19,36 @@ SCRSetValPkg scrSetValPkg = |
|
|
|
0x1C, 0x78, //CRC
|
|
|
|
}; |
|
|
|
|
|
|
|
// 历史重量
|
|
|
|
SCRSaveValPkg scrSaveValPkg = |
|
|
|
{ |
|
|
|
0xA5, 0x5A, //帧头
|
|
|
|
0x2D, //长度
|
|
|
|
0x82, //指令
|
|
|
|
0x02, 0xB1, //起始地址
|
|
|
|
0x00, 0x01, //序号1
|
|
|
|
0x00, 0x01, //历史重量1
|
|
|
|
0x00, 0x02, //序号2
|
|
|
|
0x00, 0x02, //历史重量2
|
|
|
|
0x00, 0x03, //序号3
|
|
|
|
0x00, 0x03, //历史重量3
|
|
|
|
0x00, 0x04, //序号4
|
|
|
|
0x00, 0x00, //历史重量4
|
|
|
|
0x00, 0x05, //序号5
|
|
|
|
0x00, 0x00, //历史重量5
|
|
|
|
0x00, 0x06, //序号6
|
|
|
|
0x00, 0x00, //历史重量6
|
|
|
|
0x00, 0x07, //序号7
|
|
|
|
0x00, 0x00, //历史重量7
|
|
|
|
0x00, 0x08, //序号8
|
|
|
|
0x00, 0x00, //历史重量8
|
|
|
|
0x00, 0x09, //序号9
|
|
|
|
0x00, 0x00, //历史重量9
|
|
|
|
0x00, 0x0A, //序号10
|
|
|
|
0x00, 0x00, //历史重量10
|
|
|
|
0x97, 0xCE, //CRC
|
|
|
|
}; |
|
|
|
|
|
|
|
//息屏指令
|
|
|
|
SCRControlPkg scrPingOffPkg = { |
|
|
|
0xA5, 0x5A, |
|
|
@ -55,20 +67,23 @@ SCRControlPkg scrPingOnPkg = { |
|
|
|
0x71, 0xAC, // CRC
|
|
|
|
}; |
|
|
|
|
|
|
|
//蜂鸣器指令A5 5A 05 80 02 C8 70 DE
|
|
|
|
SCRControlPkg scrBeepOnPkg = { |
|
|
|
0xA5, 0x5A, |
|
|
|
0x05, //长度
|
|
|
|
0x80, //指令
|
|
|
|
0x02, 0xC8, //数据
|
|
|
|
0x70, 0xDE, // CRC
|
|
|
|
}; |
|
|
|
|
|
|
|
//=============================================
|
|
|
|
void L3_task_screen_init(void) |
|
|
|
{ |
|
|
|
L1_task_init(&_s_task_screen.task); |
|
|
|
_s_task_screen.power_mode = R.power_mode; |
|
|
|
L3_task_s_go(_s_task_screen, D_task_init); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// #define D_TASK_SCREEN_SEND_CONTROL 0x50
|
|
|
|
// #define D_TASK_SCREEN_SEND_VAL 0x51
|
|
|
|
// #define D_task_RFID_SET 0x52
|
|
|
|
|
|
|
|
#define D_task_RS485_SEND_BEFORE 0x50 |
|
|
|
#define D_task_RS485_SEND 0x51 |
|
|
|
#define D_task_RS485_SEND_AFTER 0x52 |
|
|
@ -92,6 +107,7 @@ void L3_task_screen_handler(S_TASK_SCREEN *s) |
|
|
|
// L0_uart1_uchex(s->power_mode );
|
|
|
|
// L0_uart1_0d0a();
|
|
|
|
|
|
|
|
//检测到模式转变
|
|
|
|
if(s->power_mode != R.power_mode) |
|
|
|
{ |
|
|
|
s->power_mode = R.power_mode; |
|
|
@ -106,10 +122,15 @@ void L3_task_screen_handler(S_TASK_SCREEN *s) |
|
|
|
L1_uart1_Array((U8 *)&scrPingOnPkg, sizeof(scrPingOnPkg)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (R.beep == beep_on) |
|
|
|
{ |
|
|
|
//发送蜂鸣器指令
|
|
|
|
L1_uart1_Array((U8 *)&scrBeepOnPkg, sizeof(scrBeepOnPkg)); |
|
|
|
} |
|
|
|
L2_task_go_Tdelay(D_task_RS485_SEND, D_Tdelay_400ms); |
|
|
|
//发送
|
|
|
|
TTSS_Task_step(D_task_RS485_SEND): |
|
|
|
if (R.power_mode == POWER_NORMAL) |
|
|
|
if(R.power_mode == POWER_NORMAL) |
|
|
|
{ |
|
|
|
//构造pkg
|
|
|
|
constructor_scr_pkg(); |
|
|
@ -118,10 +139,10 @@ void L3_task_screen_handler(S_TASK_SCREEN *s) |
|
|
|
} |
|
|
|
L2_task_go_Tdelay(D_task_RS485_SEND_BEFORE, D_Tdelay_400ms); |
|
|
|
//发送后
|
|
|
|
TTSS_Task_step(D_task_RS485_SEND_AFTER): |
|
|
|
L2_task_go_Tdelay(D_task_RS485_SEND, D_Tdelay_100ms); |
|
|
|
// TTSS_Task_step(D_task_RS485_SEND_AFTER):
|
|
|
|
// L2_task_go_Tdelay(D_task_RS485_SEND, D_Tdelay_100ms);
|
|
|
|
|
|
|
|
TTSS_Task_end(); |
|
|
|
TTSS_Task_end(); |
|
|
|
} |
|
|
|
|
|
|
|
//构造屏幕协议包
|
|
|
@ -164,6 +185,23 @@ void constructor_scr_pkg() |
|
|
|
scrSetValPkg.crc[0] = CRC >> 8; |
|
|
|
} |
|
|
|
|
|
|
|
//构造历史重量数据协议包
|
|
|
|
void constructor_weightsave_pkg() |
|
|
|
{ |
|
|
|
U16 CRC = 0; |
|
|
|
U8 i = 0; |
|
|
|
|
|
|
|
for (i = 0; i < SCREEN_SAVE_LEN; i++) |
|
|
|
{ |
|
|
|
scrSaveValPkg.weight_save[i].save_val[0] = (screen_save_arr[i].kgx100_out ) >> 8; |
|
|
|
scrSaveValPkg.weight_save[i].save_val[1] = screen_save_arr[i].kgx100_out; |
|
|
|
} |
|
|
|
|
|
|
|
CRC = CRC_16(((U8 *)&scrSaveValPkg) + 3, 43); |
|
|
|
scrSaveValPkg.crc[1] = CRC; |
|
|
|
scrSaveValPkg.crc[0] = CRC >> 8; |
|
|
|
} |
|
|
|
|
|
|
|
// 屏幕回传协议解析 A5 5A 07 83 00 01 02 22 00 00
|
|
|
|
void parse_screen_pkg() |
|
|
|
{ |
|
|
@ -174,8 +212,6 @@ void parse_screen_pkg() |
|
|
|
{ |
|
|
|
if(p->cmd == 0x83) |
|
|
|
{ |
|
|
|
//L0_uart1_str("Enter1->:");
|
|
|
|
// L0_uart1_0d0a();
|
|
|
|
R.ScrTouch_flag = 1; |
|
|
|
R.power_mode = POWER_NORMAL; |
|
|
|
R.ScrTouch_time = D_sys_now; //2024.9.13 15:04:59
|
|
|
@ -210,11 +246,19 @@ void parse_screen_pkg() |
|
|
|
R.danwei = p->Data[1]; |
|
|
|
break; |
|
|
|
case 0xD8://查看历史数据
|
|
|
|
L0_Iap_Read_array(EEPROM_WEIGHT_ADDR, screen_save_arr,sizeof(screen_save_arr));//1先从eeprom中读出数组
|
|
|
|
// 判断头尾
|
|
|
|
|
|
|
|
// 2推送到屏幕
|
|
|
|
|
|
|
|
// 1.从eeprom中读出数组
|
|
|
|
L0_Iap_Read_array(EEPROM_WEIGHT_ADDR, screen_save_arr,sizeof(screen_save_arr)); |
|
|
|
// 2.判断头尾
|
|
|
|
if(screen_save_arr[0].head[0] != HEAD0 || screen_save_arr[0].head[1] != HEAD1 |
|
|
|
|| screen_save_arr[0].tail[0] != TAIL0 || screen_save_arr[0].tail[1] != TAIL1) |
|
|
|
{ |
|
|
|
screen_save_init(); |
|
|
|
} |
|
|
|
// 3.推送到屏幕
|
|
|
|
// 构造pkg
|
|
|
|
constructor_weightsave_pkg(); |
|
|
|
// 发送pkg
|
|
|
|
L1_uart1_Array((U8 *)&scrSaveValPkg, sizeof(scrSaveValPkg)); |
|
|
|
break; |
|
|
|
case 0xD9://校准确认 buf[index] 放入寄存器,写入eeprom
|
|
|
|
// ts_weight_SPara.ts_WPoint[pd485->buf[0]].kg = D_2uc_u16(pd485->buf[1],pd485->buf[2]);
|
|
|
@ -230,7 +274,7 @@ void parse_screen_pkg() |
|
|
|
} |
|
|
|
} |
|
|
|
// 数据录入(确认键)
|
|
|
|
if(p->start_addr[0] == 0x07) |
|
|
|
else if(p->start_addr[0] == 0x07) |
|
|
|
{ |
|
|
|
switch (p->start_addr[1]) |
|
|
|
{ |
|
|
@ -245,6 +289,13 @@ void parse_screen_pkg() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 亮屏时回传A5 5A 06 81 01 01 40 79 B8
|
|
|
|
if(p->cmd == 0x81 && p->num_word == 0x40 ) |
|
|
|
{ |
|
|
|
R.ScrTouch_flag = 1; |
|
|
|
R.power_mode = POWER_NORMAL; |
|
|
|
R.ScrTouch_time = D_sys_now; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -266,10 +317,10 @@ U16 CRC_16(U8 *pMsg, U16 Len) |
|
|
|
} |
|
|
|
|
|
|
|
// 180s无操作 判定函数
|
|
|
|
void ScreenPingOff_judge(void) |
|
|
|
void ScreenPingOff_judge() |
|
|
|
{ |
|
|
|
U32 Nowtime = D_sys_now; |
|
|
|
if( Nowtime - R.ScrTouch_time > D_COUNT_JIFFIES(5000)) //180000 180秒
|
|
|
|
if( Nowtime - R.ScrTouch_time > D_COUNT_JIFFIES(30000)) //180000 180秒
|
|
|
|
{ |
|
|
|
R.ScrTouch_flag = 0; |
|
|
|
R.power_mode = POWER_LOW; |
|
|
|