Commit 5459550e authored by limm's avatar limm

1,修复死机问题改为复位;

2,修复退出老化方式;
3,增加三个设备绑定,解绑操作;
parent 1de4b7b1
......@@ -88,7 +88,7 @@ typedef enum{
#define DisplayCharB 0x73 // ???
#define DisplayCharE 0x79 // E
#define DisplayCharF 0x78 // F
#define DisplayCharr 0x58 // r
#define DisplayCharr 0x30 // r
#define DisplayCharL 0x51
#define DisplayCharo 0x33
......
......@@ -28,8 +28,6 @@
#include <stdint.h>
/* Exported macro ------------------------------------------------------------*/
//#define USATR_1_DEBUG 1
#if (USATR_1_DEBUG == 1)
......@@ -68,7 +66,7 @@ typedef enum {TP_ERROR = 0, TP_SUCCESS = !TP_ERROR} TP_ErrorStatus;
#define SOF_LOW_BYTE_DEF 0X55
#define USART_RECIVE_LEN_DEF 40 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTH 5 //缓存的深度
#define USART_RECIVE_DEPTH 3 //缓存的深度
//透传数据接受最大间隔时间,超时未接收到数据,停止一串数据接收
#define DEF_TRANSPARENT_MAXIMUM_INTERVAL 100 //(ms)
......@@ -100,17 +98,14 @@ typedef struct _Recive_usart_data_deal
//homebuf buf缓存
#define _IO volatile /*!< Defines 'read / write' permissions */
typedef struct _Recive_usart_buff
{
TP_u8 Usart_buff[USART_RECIVE_DEPTH][USART_RECIVE_LEN_DEF]; //homebus 缓存存放区
TP_u8 Usart_buff_len[USART_RECIVE_DEPTH]; //homebus 缓存区长度
TP_u8 Buff_send_serial_num; //BUFF发送序列
TP_u8 Download_serial_num; //BUFF缓存序列
_IO TP_u8 Usart_buff_len[USART_RECIVE_DEPTH]; //homebus 缓存区长度
_IO TP_u8 Buff_send_serial_num; //BUFF发送序列
_IO TP_u8 Download_serial_num; //BUFF缓存序列
}RECIVE_USART_BUFF;
//协议中的功能码
......
......@@ -106,8 +106,8 @@ extern TIMEING_OPTION _Time_Power_Off;
#define ENABLE_FAST_AGING_TEST 0
#if ENABLE_FAST_AGING_TEST
#define FAST_AGING_STEP1_TIME 60 //1min
#define FAST_AGING_STEP2_TIME 150 //2.5min
#define FAST_AGING_STEP1_TIME (60) //1min
#define FAST_AGING_STEP2_TIME (3*60) //2.5min
#else
#define FAST_AGING_STEP1_TIME (15*60) //15min
#define FAST_AGING_STEP2_TIME (60*60*4) //4h
......@@ -276,6 +276,7 @@ void delay_operate_calibrate_temper_Task_Stop(void);
void delay_operate_delay_off_Task_Start(void);
void delay_operate_delay_off_Task_Stop(void);
void Reset_DelayOFF_timer(u8 device_type);
void task_exit_aging_test_start(void);
#define Network_Control(join_or_leave) Send_Device_Data(0,_OPCODE_SET_NET_STATE,&join_or_leave,1)
#define proximity_triagger_report_zigbee() do{ uint8_t res = 1; \
......
......@@ -54,6 +54,8 @@ typedef struct
u16 screen_save_time; //屏保时间 00 代表30
u16 filter_wash_time; //滤网清洗时间 3000
u8 no_disturb_mode; //勿扰模式 0
u8 air_product_id;
u8 air_type;
}OLED_AIR_DSD;
typedef struct
{
......@@ -173,6 +175,7 @@ void delay_confirm_fan_speed(void); //
void Control_LED_ON_OFF(u8 onoff_bits);
u8 Key_Operate_Config_Operation(u8 keyid,u8 keyEvent);
u8 IsLocalConfigMode(void);
u8 kAllLedIsBlinking(void);
void Display_Up_Contend(u8 device_type);
void Setup_Mode_Handle (void);
......
......@@ -2,7 +2,7 @@
#define __HARDWARE_INIT_H__
#include "Key.h"
#define Flash_Base_Addr 0x00007000
#define Flash_Base_Addr 0x00007400
#define NO_FMC_WRITE 0xFFFFFFFF
#define OFFSET_ADDR 4
#define BYTE_ADDR 8
......
......@@ -20,8 +20,8 @@
#define SOF_HIGH_BYTE_DEF 0XAA
#define SOF_LOW_BYTE_DEF 0X55
#define MAX_USART_RECIVE_LEN 50 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTHS 5 //缓存的深度
#define MAX_USART_RECIVE_LEN 56 //串口最多一次接受的数据量
#define USART_RECIVE_DEPTHS 3 //缓存的深度
......@@ -55,14 +55,10 @@ typedef struct
typedef struct
{
TP_u8 Usart_buff[USART_RECIVE_DEPTH][MAX_USART_RECIVE_LEN]; //homebus 缓存存放区
TP_u8 Usart_buff_len[USART_RECIVE_DEPTHS]; //homebus 缓存区长度
TP_u8 Buff_send_serial_num; //BUFF发送序列
TP_u8 Download_serial_num; //BUFF缓存序列
TP_u8 Usart_buff[USART_RECIVE_DEPTHS][MAX_USART_RECIVE_LEN]; //homebus 缓存存放区
_IO TP_u8 Usart_buff_len[USART_RECIVE_DEPTHS]; //homebus 缓存区长度
_IO TP_u8 Buff_send_serial_num; //BUFF发送序列
_IO TP_u8 Download_serial_num; //BUFF缓存序列
}RECIVE_USART_DATA_BUFF;
//协议中的功能码
typedef struct
......@@ -85,10 +81,10 @@ typedef struct
void uart0_data_deal_init(void);
void uart_msg_deal(void);
void proximity_triagger_report(void);
u8 Usart_recive_deal(TP_uc8 *data,TP_uc16 len);
u8 Usart_recive_deal(TP_uc8 *data,TP_uc8 len);
u8 uart_msg_recive(u8 RcvChar);
void ack_info(PROTOCOL_DEAL recv_data, TP_uc8* arg, TP_u8 len);
TP_u16 CreateCrc16_Self(const u8* msg, TP_u32 len) ;
TP_u16 CreateCrc16_Self(const u8* msg, TP_u8 len) ;
static void send_crc_error_data(TP_u16 seq_data);
void uart_protocol_send(PROTOCOL_SEND_MSG send_protocol,TP_u16 SEQ);
#endif
......
......@@ -75,6 +75,11 @@ Lcd_Status_Info_t LCDAutoSystemModeSettingIconCTR_t =
u16 guSetLCDShowTime = SysLCDShowTimer;
#if 1 // add by dingmz_frc.20201215
extern u8 g_u8Temp_Buffer[];
extern u8 g_u8Temp_Length;
#endif
void PWM_init(void)
{
// PWM0 frequency is 100Hz, duty 30%,
......@@ -102,113 +107,119 @@ u16 GetLCDShowTime( void )
void BL55072A_Init(uint8_t slaver_addr,u32 freq)
{
u8 err = 0xff;
u8 Send_Buffer[10] = {0};
u8 length = 0;
//u8 Send_Buffer[10] = {0};
//u8 length = 0;
g_u8slaver_addr = slaver_addr;
I2C_SW_Open(freq);
CLK_SysTickDelay(5000); //delay 5ms
Send_Buffer[length++] = BL55072A_CMD_APCTL_OFF;
Send_Buffer[length++] = BL55072A_CMD_MODESET_ON;
Send_Buffer[length++] = BL55072A_CMD_ICSET_RST;
Send_Buffer[length++] = BL55072A_CMD_DISCTL_PSM1;
Send_Buffer[length++] = BL55072A_CMD_ICSET;
g_u8Temp_Length = 0;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_APCTL_OFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_MODESET_ON;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_ICSET_RST;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_DISCTL_PSM1;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_ICSET;
err = I2C_SW_Send(g_u8slaver_addr,Send_Buffer,length);
err = I2C_SW_Send(g_u8slaver_addr, g_u8Temp_Buffer, g_u8Temp_Length);
printf("Bl55072A init err = (%d),length = (%d)\r\n", err, length);
//printf("Bl55072A init err = (%d),length = (%d)\r\n", err, length);
}
void BL55072A_DisplayON(void)
{
uint8_t buffer[20] = {0};
uint8_t length = 0;
//uint8_t buffer[20] = {0};
//uint8_t length = 0;
buffer[length++] = BL55072A_CMD_APCTL_OFF;
buffer[length++] = BL55072A_CMD_DISCTL_PSM1;
buffer[length++] = BL55072A_CMD_ICSET;
buffer[length++] = BL55072A_CMD_BLKCTL_OFF;
buffer[length++] = 0xFC;
buffer[length++] = BL55072A_CMD_MODESET_ON & 0x7F;
g_u8Temp_Length = 0;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_APCTL_OFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_DISCTL_PSM1;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_ICSET;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_BLKCTL_OFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFC;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_MODESET_ON & 0x7F;
I2C_SW_Send(g_u8slaver_addr,buffer,length);
I2C_SW_Send(g_u8slaver_addr, g_u8Temp_Buffer, g_u8Temp_Length);
//printf("BL55072A Display ON err = (%d),length = (%d)\r\n", err, length);
}
void BL55072A_Clear(void)
{
uint8_t buffer[20] = {0};
uint8_t length = 0;
buffer[length++] = BL55072A_CMD_DISCTL_PSM1;
buffer[length++] = BL55072A_CMD_BLKCTL_OFF;
buffer[length++] = 0xFC;
buffer[length++] = BL55072A_CMD_MODESET_ON;
buffer[length++] = BL55072A_CMD_ICSET;
buffer[length++] = BL55072A_CMD_ADSET;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
buffer[length++] = 0x00;
I2C_SW_Send(g_u8slaver_addr,buffer,length);
//uint8_t buffer[20] = {0};
//uint8_t length = 0;
g_u8Temp_Length = 0;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_DISCTL_PSM1;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_BLKCTL_OFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFC;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_MODESET_ON;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_ICSET;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_ADSET;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0x00;
I2C_SW_Send(g_u8slaver_addr, g_u8Temp_Buffer, g_u8Temp_Length);
//printf("BL55072A Display Test err = (%d),length = (%d)\r\n", err, length);
}
void BL55072A_DisplayALL(void)
{
u8 Send_Buffer[20] = {0};
u8 length = 0;
Send_Buffer[length++] = BL55072A_CMD_DISCTL_PSM1;
Send_Buffer[length++] = BL55072A_CMD_BLKCTL_OFF;
Send_Buffer[length++] = 0xFE;
Send_Buffer[length++] = BL55072A_CMD_MODESET_ON;
Send_Buffer[length++] = BL55072A_CMD_ICSET;
Send_Buffer[length++] = BL55072A_CMD_ADSET;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
Send_Buffer[length++] = 0xFF;
I2C_SW_Send(g_u8slaver_addr,Send_Buffer,length);
//u8 Send_Buffer[20] = {0};
//u8 length = 0;
g_u8Temp_Length = 0;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_DISCTL_PSM1;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_BLKCTL_OFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFE;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_MODESET_ON;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_ICSET;
g_u8Temp_Buffer[g_u8Temp_Length++] = BL55072A_CMD_ADSET;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
g_u8Temp_Buffer[g_u8Temp_Length++] = 0xFF;
I2C_SW_Send(g_u8slaver_addr, g_u8Temp_Buffer, g_u8Temp_Length);
//printf("BL55072A Display Test err = (%d),length = (%d)\r\n", err, length);
}
static u8 Buffer_Temp[5] = {0};
u8 BL55072A_ReadByte(u8 addr)
{
u8 buffer[4] = {0};
u8 length = 0;
u8 tmp;
static u8 tmp = 0;
buffer[length++] = BL55072A_CMD_ICSET;
buffer[length++] = BL55072A_CMD_ADSET | addr | 0x80; //cmd end
I2C_SW_Send(g_u8slaver_addr, buffer, length);
memset(Buffer_Temp,0,sizeof(Buffer_Temp));
Buffer_Temp[0] = BL55072A_CMD_ICSET;
Buffer_Temp[1] = BL55072A_CMD_ADSET | addr | 0x80; //cmd end
I2C_SW_Send(g_u8slaver_addr, Buffer_Temp, 2);
I2C_SW_Get_Without_Delay(g_u8slaver_addr,(u8 *)&tmp,1);
return (tmp&0xff);
}
void BL55072A_DisplayGeneral(u8 addr,u8 control_bits,u8 display_bits)
{
u8 buffer[6] = {0};
u8 length = 0;
u8 Data = 0;
u8 i = 0;
u8 tmp = BL55072A_ReadByte(addr);
static u8 Data = 0;
static u8 i = 0;
static u8 tmp = 0;
memset(Buffer_Temp,0,sizeof(Buffer_Temp));
i = Data = 0;
tmp = BL55072A_ReadByte(addr);
//printf("BL55072A_DisplayGeneral,Process Before TMP DATA = %x\r\n", tmp);
buffer[length++] = BL55072A_CMD_ICSET;
buffer[length++] = BL55072A_CMD_ADSET | addr; //cmd end
Buffer_Temp[0] = BL55072A_CMD_ICSET;
Buffer_Temp[1] = BL55072A_CMD_ADSET | addr; //cmd end
for(i = 0;i<4;i++)
{
......@@ -228,8 +239,8 @@ void BL55072A_DisplayGeneral(u8 addr,u8 control_bits,u8 display_bits)
}
tmp = ((tmp&0x0f) | (Data<<4) );
//printf("BL55072A_DisplayGeneral,Process After TMP=%x, DATA = %x\r\n",tmp, Data);
buffer[length++] = tmp; //cmd end
I2C_SW_Send(g_u8slaver_addr, buffer, length);
Buffer_Temp[2] = tmp; //cmd end
I2C_SW_Send(g_u8slaver_addr, Buffer_Temp, 3);
//printf("BL55072A_DisplayGeneral,err = (%d),length = (%d)\r\n", err, length);
}
......
......@@ -32,7 +32,6 @@ readme: 使
#include "hardware_init.h"
#include "Key.h"
/**************************************************************************************************************
此文件内部使用,不允许外部使用,不用更改
***************************************************************************************************************/
......@@ -44,13 +43,13 @@ static TP_u32 status_check_time = 0x00;
static void send_crc_error(TP_u16 seq_data);
static TP_u8 Usart_recive_write_buff(TP_uc8 *data,TP_uc16 len);
TP_u16 CreateCrc16(TP_uc8* msg, TP_u32 len);
TP_u16 CreateCrc16(TP_uc8* msg, TP_u8 len);
static void (*uart_data_send)(TP_uc8* msg,TP_u32 len);
static void (*non_permeable_opcode_analysis)(PROTOCOL_DEAL protocol_data);
static void (*transparent_opcode_analysis)(PROTOCOL_DEAL protocol_data);
static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data,TP_uc32 len);
static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data,TP_uc8 len);
/**************************************************************************************************************
全局变量,用于 transparent_protocol_send
......@@ -67,6 +66,10 @@ const PROTOCOL_SEND opcode_force_assert = {0x00,0x0002,0x10,&opcode_force_assert
//SEQ
TP_u16 tp_report_seq_num = 0;
#if 1 // add by dingmz_frc.20201215
extern u8 g_u8Temp_Buffer[];
extern u8 g_u8Temp_Length;
#endif
#define EXAMPLE
/**************************************************************************************************************
......@@ -346,27 +349,27 @@ void transparent_msg_deal(void)
void transparent_protocol_send(PROTOCOL_SEND send_protocol,TP_u16 SEQ)
{
static TP_u8 KK_Buf[125] = {0};
//static TP_u8 KK_Buf[125] = {0};
TP_u16 KK_CRC16_Num = 0; //计算校验值
memset(KK_Buf,0,sizeof(KK_Buf));
KK_Buf[0] = 0xAA;
KK_Buf[1] = 0x55;
KK_Buf[2] = send_protocol.ARG_len + 6; //长度 7
KK_Buf[4] = (SEQ & 0xff); //序列号L
KK_Buf[3] = send_protocol.ControlField; //控制域: 不需要ack
KK_Buf[5] = send_protocol.ARG_len+3;
KK_Buf[6] = send_protocol.Channel_ID; //下行协议: 信道00
KK_Buf[7] = ((send_protocol.Opcode >> 8) & 0xff); //下行协议: Opcode_H
KK_Buf[8] = (send_protocol.Opcode & 0xff); //下行协议: Opcode_L
memcpy(&KK_Buf[9],send_protocol.ARG,send_protocol.ARG_len);
//memset(KK_Buf,0,sizeof(KK_Buf));
g_u8Temp_Buffer[0] = 0xAA;
g_u8Temp_Buffer[1] = 0x55;
g_u8Temp_Buffer[2] = send_protocol.ARG_len + 6; //长度 7
g_u8Temp_Buffer[4] = (SEQ & 0xff); //序列号L
g_u8Temp_Buffer[3] = send_protocol.ControlField; //控制域: 不需要ack
g_u8Temp_Buffer[5] = send_protocol.ARG_len+3;
g_u8Temp_Buffer[6] = send_protocol.Channel_ID; //下行协议: 信道00
g_u8Temp_Buffer[7] = ((send_protocol.Opcode >> 8) & 0xff); //下行协议: Opcode_H
g_u8Temp_Buffer[8] = (send_protocol.Opcode & 0xff); //下行协议: Opcode_L
memcpy(&g_u8Temp_Buffer[9],send_protocol.ARG,send_protocol.ARG_len);
//KK_Buf[9] = 0X00;
KK_CRC16_Num = CreateCrc16((TP_uc8*)&KK_Buf[3],KK_Buf[2]);
KK_Buf[send_protocol.ARG_len + 9] = (KK_CRC16_Num>>8) & 0xff; //校验值 CRC_H
KK_Buf[send_protocol.ARG_len + 10] = KK_CRC16_Num & 0xff; //校验值 CRC_L
KK_CRC16_Num = CreateCrc16((TP_uc8*)&g_u8Temp_Buffer[3],g_u8Temp_Buffer[2]);
g_u8Temp_Buffer[send_protocol.ARG_len + 9] = (KK_CRC16_Num>>8) & 0xff; //校验值 CRC_H
g_u8Temp_Buffer[send_protocol.ARG_len + 10] = KK_CRC16_Num & 0xff; //校验值 CRC_L
uart_data_send(KK_Buf,send_protocol.ARG_len + 11);
uart_data_send(g_u8Temp_Buffer,send_protocol.ARG_len + 11);
}
......@@ -450,10 +453,16 @@ static TP_u8 Usart_recive_write_buff(TP_uc8 *data,TP_uc16 len)
*******************************************************************************/
//AA 55 07 80 01 04 00 10 11 01 F5 91
//0 1 2 3 4 5 6 7 8 9 10 11
static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data,TP_uc32 len)
static TP_ErrorStatus transparent_protocol_analysis(TP_uc8 *data, TP_uc8 len)
{
PROTOCOL_DEAL Usart_protocol_deal = {0};
if((data == NULL) || (len < 5) || (len > USART_RECIVE_LEN_DEF))
{
//printf("non valied msg,discard it all\r\n");
return TP_ERROR;
}
Usart_protocol_deal.SEQ = *(data + 4); //记录 seq 的值
if(BYTE_MOVE(*(data + len -2),*(data + len -1)) != CreateCrc16(data+ 3,len - 5)) //CRC校验
{ //校验不对
......@@ -501,10 +510,10 @@ static void send_crc_error(TP_u16 seq_data)
/*
接收到的数据crc错误回复
*/
TP_u16 CreateCrc16(u8* msg, TP_u32 len)
TP_u16 CreateCrc16(u8* msg, TP_u8 len)
{
TP_u16 crc = 0xFFFF;
TP_u32 i, j = 0;
TP_u8 i, j = 0;
for (i = 0; i < len; i++)
{
......
......@@ -60,19 +60,38 @@ u8 auto_type = 0;
static _Bool LongLongPress10s_Handler(u8 keyid,u8 KeyPressEvent)
{
//退老化处理
static u32 last_time = 0;
static u8 first_10s_press = 0;
if((keyid == 6) &&(KeyPressEvent == Button10sLongEvent))
{
if(Oled_Display_Info.aging_test_flag != 2) //老化期间
if(Oled_Display_Info.aging_test_flag != 2)
{
Spake_Start();
if( ((Oled_Display_Info.local_timer - last_time) <= 20*1000)&&first_10s_press )
{
first_10s_press = 0;
//所有指示灯闪烁一次
kNetIndicatorOptTrigger(7, 200,200, 5*1000/(200+200),0,1 );
LCD_CONTROL(1);
BL55072A_DisplayALL();
Oled_Display_Info.aging_test_flag = 2; //写入产测标志位
First_Exit_Factory_Mode = 1;
save_data();
aging_test_stop(); //停止老化事件
task_exit_aging_test_start();
return TRUE;
}
else
{
first_10s_press = 1;
last_time = Oled_Display_Info.local_timer;
//所有指示灯闪烁一次
if(LED1)
kNetIndicatorOptTrigger(7, 200,200, 1,0,1 );
else
kNetIndicatorOptTrigger(7, 200,200, 1,1,0 );
}
}
}
//滤网清洗事件错误清除
if((keyid == 2) &&(KeyPressEvent == Button10sLongEvent))
......@@ -336,9 +355,9 @@ u8 KeyScanState( KeyScan_t* Buttion_T, u8 ButtonState )
void key_scan(void)
{
u8 EventTemp[KeyTotalNum] = {NoButtonEvent,NoButtonEvent,NoButtonEvent,NoButtonEvent,NoButtonEvent,NoButtonEvent};
static u8 EventTemp[KeyTotalNum] = {NoButtonEvent,NoButtonEvent,NoButtonEvent,NoButtonEvent,NoButtonEvent,NoButtonEvent};
u8 i = 0;
memset(EventTemp,0,sizeof(EventTemp));
if(!GetkeyScanTime())
{
SetkeyScanTime(SyskeyScanTimer);
......@@ -369,10 +388,10 @@ static void LED_BEEP_Feedback(u8 key_id)
if(Oled_Display_Info.net_work_flage == IN_LINE)
{
kNetIndicatorOptTrigger(key_id, 200, 200, 2, 0, 1 );
kNetIndicatorOptTrigger(key_id, 200, 200, 1, 0, 1 );
}else{
kNetIndicatorOptTrigger(key_id, 200, 200, 4, 0, 1 );
kNetIndicatorOptTrigger(key_id, 200, 200, 3, 0, 1 );
}
}
void KeyProcess_Handler_Callbacks(u8 key_id,u8 KeyPressEvent)
......@@ -391,20 +410,19 @@ void KeyProcess_Handler_Callbacks(u8 key_id,u8 KeyPressEvent)
//printf("####KeyProcess_Handler_After ,keyid = %d,Key_Event = %x\r\n",key_id,KeyPressEvent);
if(KeyPressEvent != ButtonLongEvent)
{
Detect_Human_Dispaly();
if(IsLcdEnterScreenSave()) //息屏状态,触摸按键,该次触发只唤醒,不做有效触发
{
Detect_Human_Dispaly();
Reload_Save_Time();
return;
}
Reload_Save_Time();
//地暖的按键2无效
if( (Oled_Display_Info.screen_page == 2)&&(key_id == 2)&&(Oled_Display_Info.aging_test_flag == 2))
return;
LED_BEEP_Feedback(key_id);
}
Reload_Save_Time();
/******************************************
童锁打开后,操作按键处理
*******************************************/
......@@ -614,11 +632,13 @@ void Control_OnOff_handler(u8 device_type,u8 onoff)
{
if(onoff == 1)
{
Oled_Display_Info.Air_Device.on_off = 1;
Oled_Display_whole();
}
else
{
PowerOff();
Oled_Display_Info.Air_Device.on_off = 0;
if(Oled_Display_Info.Air_Device.power_off_time >0)
{
Oled_Display_Info.Air_Device.power_off_time = 0;
......@@ -715,6 +735,11 @@ static void KEY1_Botton_Process_Handler(u8 KeyPressEvent)
else
{
Control_OnOff_handler(AIR_CONDITION,0);
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_onoff_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
}
......@@ -738,6 +763,12 @@ static void KEY1_Botton_Process_Handler(u8 KeyPressEvent)
}
else{
Control_OnOff_handler(AIR_CONDITION,1);
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_onoff_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
}
}
......@@ -922,14 +953,15 @@ static void KEY2_Botton_Process_Handler(u8 KeyPressEvent)
{
case ButtonShortEvent:
{
if(Oled_Display_Info.device_type == AIR_CONDITION)
if(Oled_Display_Info.screen_page == AIR_CONDITION)
{
if(Oled_Display_Info.Air_Device.on_off == 0) //开机模式才能操作
return;
Fan_Button_Handler();
}
else if(Oled_Display_Info.device_type == FAN)
else if(Oled_Display_Info.screen_page == FAN)
{
if(Oled_Display_Info.FAN_Device.on_off == 0) //开机模式才能操作
return;
......@@ -975,6 +1007,13 @@ static void KEY3_Botton_Process_Handler(u8 KeyPressEvent)
return;
system_mode_temp = System_Mode_Trans(AIR_CONDITION,0);
Oled_Display_Info.Air_Device.system_type = system_mode_temp;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_system_mode_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
else if(Oled_Display_Info.screen_page == FLOOR_HEATING)
{
......@@ -1093,34 +1132,40 @@ static void KEY4_Botton_Process_Handler(u8 KeyPressEvent)
switch(KeyPressEvent)
{
case ButtonShortEvent:
{
u8 bind_device_len = 0;
u8 device1_type = 0;
u8 device2_type = 0;
if(Oled_Display_Info.binding_device == 0) //未绑定
return;
if(Oled_Display_Info.screen_page == Oled_Display_Info.device_type) //切换绑定设备界面
delay_confirm_system_control(0);
bind_device_len = ((Oled_Display_Info.binding_device&0xF0)>>4);
device1_type = Oled_Display_Info.binding_device&0x03;
device2_type = ((Oled_Display_Info.binding_device&0x0C)>>2);
if(bind_device_len == 1)
{
delay_confirm_system_control(0); //提前中断延时确认system mode
if(Oled_Display_Info.binding_device == 1){
Oled_Display_Info.screen_page = 1;
}
else if(Oled_Display_Info.binding_device == 2){
Oled_Display_Info.screen_page = 2;
}
else if(Oled_Display_Info.binding_device == 3){
Oled_Display_Info.screen_page = 3;
if(Oled_Display_Info.screen_page == Oled_Display_Info.device_type)
{
if(device1_type !=0)
Oled_Display_Info.screen_page = device1_type;
else
Oled_Display_Info.screen_page = device2_type;
}
else
Oled_Display_Info.screen_page = Oled_Display_Info.device_type;
}
else{ //切换原设备界面
else if(bind_device_len == 2)
{
if(Oled_Display_Info.screen_page == Oled_Display_Info.device_type)
Oled_Display_Info.screen_page = device1_type;
else if(Oled_Display_Info.screen_page == device1_type)
Oled_Display_Info.screen_page = device2_type;
else
Oled_Display_Info.screen_page = Oled_Display_Info.device_type;
}
//显示所有的界面
display_current_page();
break;
case ButtonLongEvent:
break;
case ButtonLongUpEvent:
}
break;
default:
break;
......@@ -1164,6 +1209,14 @@ static void KEY5_Botton_Process_Handler(u8 KeyPressEvent)
{
next_speed = Get_NextOne_By_Current_Speed_Level(1,Oled_Display_Info.Air_Device.wind_speed,0);
display_wind_speed(next_speed,0);
Oled_Display_Info.Air_Device.wind_speed = next_speed;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_fan_speed_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
//Control_AIR_CONDITION_By_RS485(AIR_CMD_FAN_SPEED,next_speed); //控制空调风速
}
}
else if(Oled_Display_Info.Air_Device.air_cond_type == 1) //风机盘管,新风只支持3档+自动调节
......@@ -1226,8 +1279,18 @@ static void KEY5_Botton_Process_Handler(u8 KeyPressEvent)
display_set_temp(0,sKey_Operation[0].set_temper_temp,0); //显示设置温度
if( (sKey_Operation[0].set_temper_temp /10) == (Oled_Display_Info.Air_Device.set_temperature/10)) //26.0调整到26.6度时,不管空调的反馈,直接上报
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
{
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
sKey_Operation[0].set_temper_temp = 0xff; //不需要下发控制命令给空调
}
else
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_set_temp_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
}
else if(Oled_Display_Info.screen_page == FLOOR_HEATING)
......@@ -1329,10 +1392,10 @@ static void KEY5_Botton_Process_Handler(u8 KeyPressEvent)
}
break;
case ButtonLongEvent:
break;
case ButtonLongUpEvent:
break;
// case ButtonLongEvent:
// break;
// case ButtonLongUpEvent:
// break;
default:
break;
}
......@@ -1378,18 +1441,21 @@ static void KEY6_Botton_Process_Handler(u8 KeyPressEvent)
next_speed = Get_NextOne_By_Current_Speed_Level(0,Oled_Display_Info.Air_Device.wind_speed,0);
display_wind_speed(next_speed,0);
Oled_Display_Info.Air_Device.wind_speed = next_speed;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_fan_speed_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
}
else if(Oled_Display_Info.Air_Device.air_cond_type == 1) //风机盘管,新风只支持3档+自动调节
{
next_speed = Get_NextOne_By_Current_Speed_Level(0,Oled_Display_Info.Air_Device.wind_speed,0);
display_wind_speed(next_speed,0);
Oled_Display_Info.Air_Device.wind_speed = next_speed;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
}
// else if(Oled_Display_Info.Air_Device.air_cond_type == 1) //风机盘管,新风只支持3档+自动调节
// {
// next_speed = Get_NextOne_By_Current_Speed_Level(0,Oled_Display_Info.Air_Device.wind_speed,0);
// display_wind_speed(next_speed,0);
// Oled_Display_Info.Air_Device.wind_speed = next_speed;
//
// state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
// }
break;
}
......@@ -1436,9 +1502,17 @@ static void KEY6_Botton_Process_Handler(u8 KeyPressEvent)
display_set_temp(0,sKey_Operation[0].set_temper_temp,0); //显示设置温度
if( (sKey_Operation[0].set_temper_temp /10) == (Oled_Display_Info.Air_Device.set_temperature/10)) //26.5调整到26度时,不管空调的反馈,直接上报
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
{
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
sKey_Operation[0].set_temper_temp = 0xff; //不需要下发控制命令给空调
}
else
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_set_temp_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
}
else if(Oled_Display_Info.screen_page == FLOOR_HEATING)
......
......@@ -26,8 +26,9 @@ void VCNL3040_Init(u8 i2cAddress)
}
static u32 VCNL3040_WriteCommand(ECommand_ID command,u16 Data)
{
u32 error = 0; // error code
u8 cmd_buf[4] = {0};
static u32 error = 0; // error code
static u8 cmd_buf[4] = {0};
error = 0;
cmd_buf[0] = command ;
cmd_buf[1] = Data ;
cmd_buf[2] = Data>>8 ;
......@@ -37,7 +38,7 @@ static u32 VCNL3040_WriteCommand(ECommand_ID command,u16 Data)
}
u16 VCNL3040_ReadBytes(ECommand_ID command)
{
u8 cmd_buf[4] = {0};
static u8 cmd_buf[4] = {0};
cmd_buf[0] = command ;
I2C_SW_Send_Without_Stop(_VCNL3040_Addr, cmd_buf,1);
memset(cmd_buf,0,sizeof(cmd_buf));
......
......@@ -99,7 +99,7 @@ static void send_temperature(uint8_t state)
static void send_poll_check(void)
{
uint8_t data[FRAME_LEN] = {0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
static uint8_t data[FRAME_LEN] = {0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
data[9] = CRC_check(data, 9);
......
......@@ -42,7 +42,7 @@ u8 network_state = OUT_LINE;
u8 send_data_seq = 0;
u8 Device_status[20]= {
u8 Device_status[25]= {
16, //len
0X00, //错误码 0
0X00, //开关状态 1
......@@ -69,6 +69,11 @@ ZIGBEE_UART_CONTROL sUartDetect = {1,0,0};
//STRAINER_OPTION Strainer_Net_Used_Time = {0,0,0,0}; //产测时间,状态保存
#if 1 // add by dingmz_frc.20201215
u8 g_u8Temp_Buffer[40] = { 0 };
u8 g_u8Temp_Length = 0;
#endif
u32 Strainer_Net_Used_Time = 0;
u16 Board_test_time = 0;
......@@ -689,14 +694,16 @@ void ReDefine_AIR_Condition_Syetem_Mode(void)
***********************************************************************/
static void sensor_measure_loop(void)
{
u16 CurrentValue = 0;
static u16 CurrentValue = 0;
static u16 LastValue = 0 ;
static u8 board_test_flag = 0;
static u8 report_times = 0;
extern u8 First_Exit_Factory_Mode ;
CurrentValue = VCNL3040_Get_Current_Data();
if( (CurrentValue > LastValue)&&( (CurrentValue - LastValue) >= PERSON_TRAGGER_MIN_RANGE ))
{
u8 board_test_flag = Oled_Display_Info.recv_lcd_off &0x80;
u8 report_times = Oled_Display_Info.recv_lcd_off&0x0f;
board_test_flag = Oled_Display_Info.recv_lcd_off &0x80;
report_times = Oled_Display_Info.recv_lcd_off&0x0f;
Reload_Save_Time();
if((First_Exit_Factory_Mode == 0)&&(board_test_flag == 0))
Detect_Human_Dispaly();
......@@ -853,7 +860,7 @@ void setup_handler(void)
temp_init();
//上电显示
Oled_Display_whole();
Detect_Human_Dispaly();
}
else if(count == 1){
count = 2;
......@@ -1016,6 +1023,7 @@ static void aging_test(void)
LCD_CONTROL(1);
BL55072A_DisplayALL();
light_or_dark_flang = 1;
if(!kAllLedIsBlinking())
Control_LED_ON_OFF(0xff);
#if DEVICE_TYPE_FLOOR_HEATING
Relay_Action(0x01,0x01);
......@@ -1029,6 +1037,7 @@ static void aging_test(void)
LCD_CONTROL(0);
BL55072A_Clear();
light_or_dark_flang = 0;
if(!kAllLedIsBlinking())
Control_LED_ON_OFF(0);
#if DEVICE_TYPE_FLOOR_HEATING
Relay_Action(0x01,0x00);
......@@ -1092,8 +1101,24 @@ static void delay_300ms_report_task(void)
//printf("start report proximity_triagger event\r\n");
}
/******************************5s退老化,延时复位*************************************/
void task_exit_aging_test_start(void)
{
task_comps[13].task_switch = SWITCH_ON;
}
static void task_exit_aging_test_stop(void)
{
task_comps[13].task_switch = SWITCH_OFF;
}
//强退老化后,主动复位
static void task_exit_aging_test(void)
{
task_exit_aging_test_stop();
SYS_UnlockReg();
SYS_ResetChip();
}
void Spake_Start(void)
{
......@@ -1115,9 +1140,9 @@ void Ararm_Init(void)
struct task_components_t task_comps[] =
{
{0, SWITCH_ON, ALWAYS_RUN, SET_FLAG_0, 0,0, main_task }, //主任务,无延时轮询
{1, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_5,Sec_5, NULL }, //使用时间记录
{1, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_5,Sec_5, record_dev_used_time }, //使用时间记录
{2, SWITCH_ON, RUN_FLAG_0, SET_FLAG_0, Ms_200,Ms_200, sensor_measure_loop }, //传感器数据采集
{3, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Ms_100,Ms_100, NULL }, //蜂鸣器控制 (未使用)
{3, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Ms_100,Ms_100, spake_control_loop }, //蜂鸣器控制 (未使用)
{4, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_3,Sec_3, delay_confirm_system_mode }, //空调模式延时确认
{5, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_10,Sec_10, delay_confirm_fan_speed }, //风速延时确认
{6, SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Ms_500,Ms_500, setup_handler }, //上电延时启动
......@@ -1132,8 +1157,8 @@ struct task_components_t task_comps[] =
#endif
{11,SWITCH_OFF, RUN_FLAG_1, SET_FLAG_0, Sec_1,Sec_1, aging_test }, //老化测试
{12,SWITCH_ON, RUN_FLAG_1, SET_FLAG_0, Sec_3,Sec_3, task_feed_dog }, //喂狗
{13,SWITCH_OFF, RUN_FLAG_1, SET_FLAG_0, Sec_5,Sec_5, NULL }, //离网闪烁五秒 (未使用)
{14,SWITCH_OFF, RUN_FLAG_1, SET_FLAG_0, Ms_300,Ms_300, delay_300ms_report_task }, //延时300ms上报接近感应触发事件
{13,SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_3,Sec_3, task_exit_aging_test }, //退老化5s快闪
{14,SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Ms_300,Ms_300, delay_300ms_report_task }, //延时300ms上报接近感应触发事件
{15,SWITCH_ON, RUN_FLAG_0, SET_FLAG_0, Sec_5,Sec_5, shtc3_sensor_measure_loop }, //温湿度传感器数据采集
#if DEVICE_TYPE_FLOOR_HEATING
{16,SWITCH_OFF, RUN_FLAG_0, SET_FLAG_0, Sec_3,Sec_3, Tap_Status_Scan }, //阀门实时动态开关
......@@ -1186,8 +1211,7 @@ void Reset_DelayOFF_timer(u8 device_type)
***********************************************************************/
void Power_Off_Scan (void)
{
u8 i;
u8 display_data[3] = {0};
static u8 i = 0;
for(i = 0;i<3;i++)
{
if((i == 0)&&(Oled_Display_Info.Air_Device.power_off_flage == 0))
......@@ -1217,6 +1241,7 @@ void Power_Off_Scan (void)
if (sKey_Operation[i].operate_delay_off_min >= 30)
{
u8 display_data[3] = {0};
sKey_Operation[i].operate_delay_off_min = 0;
if (i == 0){ //定时关机
if(Oled_Display_Info.Air_Device.power_off_time >=5)
......@@ -1298,7 +1323,7 @@ void Reset_Fiter_Time(u8 device_type)
***********************************************************************/
void Filter_Start_Scan (void)
{
u8 i = 0;
static u8 i = 0;
for(i = 0;i<3;i=i+2)
{
if((i == 0)&&(Oled_Display_Info.Air_Device.on_off == 0))
......@@ -1377,7 +1402,7 @@ void Backlight_Handle (void)
{
if (sBacklight.blacklight_flag)
{
u16 backlight_temp = 0;
static u16 backlight_temp = 0;
backlight_temp = Get_Current_Backlight_Time();
sBacklight.time_blacklight_ms ++;
if (sBacklight.time_blacklight_ms >= 1000)
......@@ -1426,7 +1451,6 @@ void Zigbee_Uart_Error_Handle (void)
sUartDetect.zigbee_uart_ms = 0;
}
}
/*
1:代表当前未处于屏保模式且状态为开,0表示处于关机或者进入屏保模式,
获取显示的状态
......@@ -1459,7 +1483,7 @@ u8 IsLcdEnterScreenSave(void)
//**********************************************************************/
void TMR0_IRQHandler(void)
{
u8 i = 0;
static u8 i = 0;
TIMER_ClearIntFlag(TIMER0);
for(i = 0; i < task_num; i++) // 逐个任务时间处理
{
......@@ -1505,6 +1529,8 @@ void TMR0_IRQHandler(void)
Setup_Mode_Handle(); //配置模式10s超时
Zigbee_Uart_Error_Handle(); //zigbee串口故障检测
//kLedModuleActionDetectCallback(); //zigbee指示灯操作
}
/*********************************************************************/
void zero_check_init(void)
......@@ -1529,6 +1555,7 @@ void zero_check_init(void)
void TMR1_IRQHandler(void) //过零点
{
TIMER_ClearIntFlag(TIMER1);
#if ( (DEV_TYPE == 1) &&(DEVICE_TYPE_AIR_CONDITION ==1)) ||(DEVICE_TYPE_FLOOR_HEATING) ||(DEVICE_TYPE_FAN)
switch(Tap_Control.set_tap)
{
case RELAY1: //新风高风阀 //地暖继电器
......@@ -1608,6 +1635,7 @@ void TMR1_IRQHandler(void) //
Tap_Control.tap_end_flage = 0;
Timer1_Close();
#endif
}
#define Delay1us 3//3*0.34
......@@ -1629,6 +1657,7 @@ void delay_us( u32 time)
//***********************************************************************/
void GPIO234_IRQHandler()
{
#if ( (DEV_TYPE == 1) &&(DEVICE_TYPE_AIR_CONDITION ==1)) ||(DEVICE_TYPE_FLOOR_HEATING) ||(DEVICE_TYPE_FAN)
if (( P2->INTSRC & BIT5) > 0) //过零信号检测中断 P25
{
P2->INTSRC = BIT5; /* 清中断标志 */
......@@ -1658,7 +1687,7 @@ void GPIO234_IRQHandler()
}
GPIO_DisableEINT0(P2, 5);
}
#endif
}
/***********************************************************************
* 函 数 名: Update_Dev_Info
......@@ -1673,7 +1702,7 @@ void Update_Dev_Info(u8 channel_id)
u8 i = 0;
if(channel_id == 1)
{
Device_status[i++] = 17; //长度
Device_status[i++] = 19; //长度
Device_status[i++] = Oled_Display_Info.Air_Device.error; //错误码
Device_status[i++] = Oled_Display_Info.Air_Device.on_off; //开关状态
......@@ -1703,6 +1732,8 @@ void Update_Dev_Info(u8 channel_id)
Device_status[i++] =Oled_Display_Info.Air_Device.correct_temperature; //校准温度
Device_status[i++] =Oled_Display_Info.Air_Device.no_disturb_mode; //勿扰模式
Device_status[i++] =Oled_Display_Info.Air_Device.air_product_id; //空调品牌
Device_status[i++] =Oled_Display_Info.Air_Device.air_type; //空调类型
}
else if(channel_id == 2)
{
......@@ -1771,35 +1802,6 @@ void Update_Dev_Info(u8 channel_id)
}
}
/////***********************************************************************
////* 函 数 名: Update_Error_Info
////* 功能说明: 更新系统状态信息
////* 形 参:无
////* 返 回 值: 无
////***********************************************************************/
////void Update_Error_Info(void)
////{
//// s16 temp_num = 0;
//// Device_status[0] = 0XE2;
//// Device_status[1] = Time_Power_Off.power_switch_status; //开关状态
//// Device_status[2] = Oled_Display_Info.operation_mode; //运行模式
//// temp_num = Oled_Display_Info.set_temperature; //获得设置温度
//// Device_status[3] = ((temp_num >> 8) &0XFF); //设定温度高字节
//// Device_status[4] = (temp_num & 0XFF); //设定温度低字节
//// temp_num = 0X8000;
//// Device_status[5] = ((temp_num >> 8) &0XFF); //环境温度高字节
//// Device_status[6] = (temp_num & 0XFF); //环境温度低字节
//// Device_status[7] = Oled_Display_Info.wind_speed; //当前风速
//// Device_status[8] = Oled_Display_Info.power_off_time; //定时关机时间
////}
/////***********************************************************************
////* 函 数 名: transparent_data_analyze
////* 功能说明: 透传数据解析
......@@ -1842,32 +1844,66 @@ void transparent_data_analyze(PROTOCOL_DEAL recv_data)
}
case OPCODE_GENERAL_BING_DEVICE: //绑定设备
{
u8 bind_type;
u8 bind_ep;
u8 temp = 0;
u8 temp1 = 0;
memset(arg_data,0,sizeof(arg_data));
arg_data[1] = recv_data.ARG[0];
if(device_type != recv_data.ARG[0])
bind_type = recv_data.ARG[0];
bind_ep = recv_data.ARG[1];
temp = Oled_Display_Info.binding_device&0x03;
temp1 = ((Oled_Display_Info.binding_device&0x0c)>>2);
if(bind_type == 1) //绑定
{
if(recv_data.ARG[0] ==0 ) //解绑
if((Oled_Display_Info.binding_device&0xf0) == 0) //绑定第一个设备
{
//如果当前不在主控页面,则切回到主页面
if(Oled_Display_Info.screen_page != Oled_Display_Info.device_type)
Oled_Display_Info.binding_device = 0x10; //绑定设备个数为1
Oled_Display_Info.binding_device |= bind_ep;
}
else if((Oled_Display_Info.binding_device&0xf0) == 0x10) //绑定第二个设备
{
Oled_Display_Info.screen_page = Oled_Display_Info.device_type;
//显示所有的界面
display_current_page();
if(temp != bind_ep)
{
temp = Oled_Display_Info.binding_device&0x03;
Oled_Display_Info.binding_device = 0x20 | temp; //绑定设备个数为2
Oled_Display_Info.binding_device |= (bind_ep<<2);
}
}
else //绑定
{
arg_data[0] = 0;
Oled_Display_Info.binding_device = recv_data.ARG[0];
}
else{ //解绑
if((Oled_Display_Info.binding_device&0xf0) == 0x10) //绑定第一个设备
{
if(temp == bind_ep)
Oled_Display_Info.binding_device = 0;
else if(temp1 == bind_ep)
Oled_Display_Info.binding_device = 0;
}
else{
arg_data[0] = 0xff;
else if((Oled_Display_Info.binding_device&0xf0) == 0x20) //绑定第二个设备
{
if(temp == bind_ep)
{
temp = Oled_Display_Info.binding_device&0x0c;
Oled_Display_Info.binding_device = (0x10 | temp); //绑定设备个数为2
}
ack_dev_info(recv_data,arg_data,2);
//printf("bind device result =%d bind device = 0x%x\r\n",arg_data[0] ,Oled_Display_Info.binding_device);
else if(temp1 == bind_ep)
{
temp = Oled_Display_Info.binding_device&0x03;
Oled_Display_Info.binding_device = (0x10 | temp); //绑定设备个数为2
}
}
if(Oled_Display_Info.screen_page == bind_ep)
{
Oled_Display_Info.screen_page = Oled_Display_Info.device_type;
//显示所有的界面
display_current_page();
}
arg_data[0] = 0;
}
save_data();
arg_data[1] = recv_data.ARG[0];
arg_data[2] = recv_data.ARG[1];
ack_dev_info(recv_data,arg_data,3);
break;
}
case OPCODE_GENERAL_MCU_DATA_QUERY: //zigbee读取mcu信息
......@@ -1904,9 +1940,16 @@ void transparent_data_analyze(PROTOCOL_DEAL recv_data)
network_state_machine(recv_data.ARG[0]);
//清除本地绑定信息
if(recv_data.ARG[0] == 0)
{
if(Oled_Display_Info.binding_device != 0)
{
Oled_Display_Info.binding_device = 0; //清除绑定信息
Oled_Display_Info.screen_page = Oled_Display_Info.device_type;
//显示所有的界面
display_current_page();
}
kNetIndicatorOptTrigger(0, 200, 200, (5*1000)/(200+200), 1, 0 );
if(Oled_Display_Info.device_type == 1)
Oled_Display_Info.Air_Device.no_disturb_mode = 0;
......@@ -2281,13 +2324,13 @@ u8 Get_Channel_Id(u8 device_type)
void Print_Buff(u8 *data,u8 len)
{
u8 i= 0;
printf("\r\n Buffer Data : ");
//printf("\r\n Buffer Data : ");
while(i<len)
{
printf("%4x",data[i]);
//printf("%4x",data[i]);
i++;
}
printf("\n");
//printf("\n");
}
......@@ -7,11 +7,11 @@
extern Lcd_Status_Info_t LCDShowTemp_state_t;
#if DEVICE_TYPE_AIR_CONDITION
OLED_ALL_DSD Oled_Display_Info = { 1,0,1,0,0,0x10,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0},{1,0,0,0,260,0,2,0,DEV_TYPE,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
OLED_ALL_DSD Oled_Display_Info = { 1,0,1,0,0,0x11,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff},{1,0,0,0,260,0,2,0,DEV_TYPE,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
#elif DEVICE_TYPE_FLOOR_HEATING
OLED_ALL_DSD Oled_Display_Info = { 2,0,2,0,0,0x10,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0},{1,0,0,0,260,0,2,0,DEV_TYPE,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
OLED_ALL_DSD Oled_Display_Info = { 2,0,2,0,0,0x11,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff},{1,0,0,0,260,0,2,0,DEV_TYPE,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
#elif DEVICE_TYPE_FAN
OLED_ALL_DSD Oled_Display_Info = { 3,0,3,0,0,0x10,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0},{1,0,0,0,260,0,2,0,0,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
OLED_ALL_DSD Oled_Display_Info = { 3,0,3,0,0,0x11,0,0,0,0,{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{1,0,0,0,260,0,3,0,5,0,2,1,0,0,3000,0,0xff,0xff},{1,0,0,0,260,0,2,0,0,0,0,0},{1,0,0,0,0,2,1,0,0,0,3000,0}};
#endif
Key_Operation_Status gKey_Press_Info = {0};
// .device_type = 1, //AIR_CONDITION
......@@ -118,9 +118,10 @@ void Display_Current_Temper(u16 temper)
***************************************************/
static void Display_Middle_Digtal(u8 control_bits,int data )
{
u8 temp[3] = {0};
u8 is_dispaly[3] = {0};
static u8 temp[3] = {0};
static u8 is_dispaly[3] = {0};
memset(temp,0,3);
memset(is_dispaly,0,3);
if(control_bits == 0x07) //显示三个字段
{
temp[0] = data / 100;
......@@ -429,6 +430,9 @@ static void LED_ONOFF(u8 id,u8 onoff)
case 6:
(onoff == 1)? (LED6 = 1):(LED6 = 0);
break;
case 7:
(onoff == 1)? (Control_LED_ON_OFF(0xff)):(Control_LED_ON_OFF(0));
break;
default:
break;
......@@ -535,8 +539,6 @@ void Display_Up_Contend(u8 device_type)
}
void Fan_Oled_Display()
{
Operate_Led_Button(FAN,1); // 显示可操作的按键
/********************************************
显示“新风”字样
*********************************************/
......@@ -565,11 +567,6 @@ void Fan_Oled_Display()
}
void Floor_Heating_Oled_Display()
{
//15min老化阶段,全显指示灯
if(Oled_Display_Info.aging_test_flag == 2)
Operate_Led_Button(FLOOR_HEATING,1); // 显示可操作的按键
else
Operate_Led_Button(AIR_CONDITION,1);
/********************************************
显示“地暖”字样
*********************************************/
......@@ -598,8 +595,6 @@ void Floor_Heating_Oled_Display()
}
void Air_Oled_Display(void)
{
Operate_Led_Button(AIR_CONDITION,1); // 显示可操作的按键
/********************************************
显示“空调”字样
*********************************************/
......@@ -656,43 +651,53 @@ void Oled_Display_whole(void)
void PowerOff(void)
{
if(Oled_Display_Info.screen_page == AIR_CONDITION)
{
if(Oled_Display_Info.Air_Device.on_off)
BL55072A_Clear();
LCDShowTemp_state_t.LCD_place = DEVICE_TYPE_AIRCONDITION_CHAR_DISPLAY;
LCDShowTemp_state_t.LCD_state = ON;
LcdShowCTR(LCDShowTemp_state_t);
if(!IsLcdEnterScreenSave())
{
Device_Type_Display(1,0,0);
LCDShowTemp_state_t.LCD_place = CHILD_LOCK_DISPLAY;
LCDShowTemp_state_t.LCD_state = Oled_Display_Info.Air_Device.lock_flage;
LcdShowCTR(LCDShowTemp_state_t);
}
else if(Oled_Display_Info.screen_page == FAN)
}
else if(Oled_Display_Info.screen_page == FLOOR_HEATING)
{
if(Oled_Display_Info.FLOOR_Device.on_off)
BL55072A_Clear();
LCDShowTemp_state_t.LCD_place = DEVICE_TYPE_FAN_CHAR_DISPLAY;
LCDShowTemp_state_t.LCD_state = ON;
LcdShowCTR(LCDShowTemp_state_t);
if(!IsLcdEnterScreenSave())
{
Device_Type_Display(0,1,0);
LCDShowTemp_state_t.LCD_place = CHILD_LOCK_DISPLAY;
LCDShowTemp_state_t.LCD_state = Oled_Display_Info.FAN_Device.lock_flage;
LCDShowTemp_state_t.LCD_state = Oled_Display_Info.FLOOR_Device.lock_flage;
LcdShowCTR(LCDShowTemp_state_t);
}
}
else
{
if(Oled_Display_Info.FAN_Device.on_off)
BL55072A_Clear();
LCDShowTemp_state_t.LCD_place = DEVICE_TYPE_HEATING_CHAR_DISPLAY;
LCDShowTemp_state_t.LCD_state = ON;
LcdShowCTR(LCDShowTemp_state_t);
if(!IsLcdEnterScreenSave())
{
Device_Type_Display(0,0,1);
LCDShowTemp_state_t.LCD_place = CHILD_LOCK_DISPLAY;
LCDShowTemp_state_t.LCD_state = Oled_Display_Info.FLOOR_Device.lock_flage;
LCDShowTemp_state_t.LCD_state = Oled_Display_Info.FAN_Device.lock_flage;
LcdShowCTR(LCDShowTemp_state_t);
}
}
if(IsLcdEnterScreenSave())
{
LCD_CONTROL(0); //关闭屏幕背景
return;
}
//关闭上放的显示
Delay_OFF_Rel_Display(1,0,NULL,0,0,0);
LCDShowTemp_state_t.LCD_place = SET_MIDDLE_DIGITRON_DISPLAY_01;
LCDShowTemp_state_t.LCD_code_data = 0;
......@@ -786,7 +791,7 @@ void EnterScreenSaveMode(void)
{
if((Oled_Display_Info.Air_Device.on_off)&&(Oled_Display_Info.Air_Device.no_disturb_mode == 0))
{
Operate_Led_Button(AIR_CONDITION,1); // 显示可操作的按键
Operate_Led_Button(AIR_CONDITION,0); // 显示可操作的按键
/********************************************
显示“空调”字样
......@@ -810,8 +815,6 @@ void EnterScreenSaveMode(void)
LcdShowCTR(LCDShowTemp_state_t);
}
Operation_LED(0); //全关led
}
else{
Operation_LED(0); //全关led
......@@ -903,6 +906,7 @@ void Detect_Human_Dispaly(void)
{
if(Oled_Display_Info.Air_Device.on_off)
{
Operate_Led_Button(AIR_CONDITION,1); // 显示可操作的按键
Oled_Display_whole();
}
else{
......@@ -914,6 +918,11 @@ void Detect_Human_Dispaly(void)
{
if(Oled_Display_Info.FLOOR_Device.on_off)
{
//15minà??ˉ?×??£?è?????ê?μ?
if(Oled_Display_Info.aging_test_flag == 2)
Operate_Led_Button(FLOOR_HEATING,1); // ??ê??é2ù×÷μ?°′?ü
else
Operate_Led_Button(AIR_CONDITION,1);
Oled_Display_whole();
}
else{
......@@ -925,6 +934,7 @@ void Detect_Human_Dispaly(void)
{
if(Oled_Display_Info.FAN_Device.on_off)
{
Operate_Led_Button(FAN,1);
Oled_Display_whole();
}
else{
......@@ -1126,6 +1136,16 @@ void delay_confirm_system_mode(void)
Displayt_System_Mode(Oled_Display_Info.FAN_Device.system_type);
}
}
void Fan_speed_and_direct_control(u8 windspeed_onoff,u8 winddirect_onoff)
{
LCDShowTemp_state_t.LCD_place = WIND_DIRECT_CHAR_DISPLAY; //关闭风向闪烁
LCDShowTemp_state_t.LCD_state = winddirect_onoff;
LcdShowCTR(LCDShowTemp_state_t);
LCDShowTemp_state_t.LCD_place = WIND_SPEED_CHAR_DISPLAY; //打开风速
LCDShowTemp_state_t.LCD_state = windspeed_onoff;
LcdShowCTR(LCDShowTemp_state_t);
}
/*************************************************
短按风扇按键操作空调模式
***************************************************/
......@@ -1138,15 +1158,9 @@ void Fan_Button_Handler(void)
press_count = 1;
if(press_count == 1) //第一次按下
{
LCDShowTemp_state_t.LCD_place = WIND_DIRECT_CHAR_DISPLAY; //关闭风向闪烁
LCDShowTemp_state_t.LCD_state = OFF;
LcdShowCTR(LCDShowTemp_state_t);
Fan_speed_and_direct_control(1,0);
display_wind_direct(0,0,0); //关闭风向显示
LCDShowTemp_state_t.LCD_place = WIND_SPEED_CHAR_DISPLAY; //打开风速
LCDShowTemp_state_t.LCD_state = ON;
LcdShowCTR(LCDShowTemp_state_t);
LCDShowTemp_state_t.LCD_place = WIND_SPEED_CHAR_DISPLAY; //风速
LCDShowTemp_state_t.LCD_state = FLASHING;
......@@ -1175,13 +1189,7 @@ void Fan_Button_Handler(void)
if(press_count == 2) //切换风向
{
press_count = 0;
LCDShowTemp_state_t.LCD_place = WIND_SPEED_CHAR_DISPLAY; //关闭风速闪烁
LCDShowTemp_state_t.LCD_state = OFF;
LcdShowCTR(LCDShowTemp_state_t);
LCDShowTemp_state_t.LCD_place = WIND_DIRECT_CHAR_DISPLAY; //打开风向闪烁
LCDShowTemp_state_t.LCD_state = ON;
LcdShowCTR(LCDShowTemp_state_t);
Fan_speed_and_direct_control(0,1);
LCDShowTemp_state_t.LCD_place = FAN_SPEED_DIGITRON_DISPLAY_01; //关闭风速等级显示
LCDShowTemp_state_t.LCD_state = OFF;
......@@ -1216,27 +1224,17 @@ void delay_confirm_fan_speed(void)
{
delay_confirm_fan_speed_control(0);
gKey_Press_Info.adjust_fan_speed_status = 0;
LCDShowTemp_state_t.LCD_place = WIND_DIRECT_CHAR_DISPLAY; //关闭风向字体
LCDShowTemp_state_t.LCD_state = OFF;
LcdShowCTR(LCDShowTemp_state_t);
Fan_speed_and_direct_control(0,0);
display_wind_direct(0,0,0); //关闭风向显示
LCDShowTemp_state_t.LCD_place = WIND_SPEED_CHAR_DISPLAY; //关闭风速字体
LCDShowTemp_state_t.LCD_state = OFF;
LcdShowCTR(LCDShowTemp_state_t);
LCDShowTemp_state_t.LCD_place = WIND_SPEED_CHAR_DISPLAY; //关闭风速字体
LCDShowTemp_state_t.LCD_state = OFF;
LcdShowCTR(LCDShowTemp_state_t);
LCDShowTemp_state_t.LCD_place = FAN_SPEED_DIGITRON_DISPLAY_01; //关闭风速等级显示
LCDShowTemp_state_t.LCD_state = OFF;
LcdShowCTR(LCDShowTemp_state_t);
}
void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
{
if(arg == NULL)
return;
switch(device_type)
{
case 1: //空调
......@@ -1250,21 +1248,31 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
{
//仅仅更新开关状态
Oled_Display_Info.Air_Device.on_off = onoff;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
break;
}
if(onoff == ON)
{
if(Oled_Display_Info.Air_Device.on_off == 0)
{
//Oled_Display_Info.Air_Device.on_off = 1;
Oled_Display_whole();
Control_OnOff_handler(AIR_CONDITION,1);
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_onoff_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
}
else
{
if(Oled_Display_Info.Air_Device.on_off == 1)
{
PowerOff();
Control_OnOff_handler(AIR_CONDITION,0);
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_onoff_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
}
......@@ -1275,16 +1283,26 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
case OPCODE_GENERAL_OPERATION_MODE:
{
u8 system_mode = arg[0];
if(Oled_Display_Info.Air_Device.on_off == 0)
return;
if(Oled_Display_Info.screen_page != device_type)
{
//仅仅更新状态
arg[0] = 0;
arg[1] = system_mode;
Oled_Display_Info.Air_Device.system_type = system_mode;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
break;
}
if(Oled_Display_Info.Air_Device.on_off)
{
Displayt_System_Mode(system_mode);
Oled_Display_Info.Air_Device.system_type = system_mode;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_system_mode_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
arg[0] = 0;
}
else
......@@ -1298,10 +1316,14 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
set_temper = (set_temper<<8) | (arg[1]&0xff);
arg[1] = set_temper >>8;
arg[2] = set_temper&0xff;
if(Oled_Display_Info.Air_Device.on_off == 0)
return;
if(Oled_Display_Info.screen_page != device_type)
{
//仅仅更新状态
arg[0] = 0;
Oled_Display_Info.Air_Device.set_temperature = set_temper;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
break;
}
//通风模式下不可以调节设定温度
......@@ -1311,10 +1333,18 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
sKey_Operation[0].set_temper_temp = set_temper;
arg[0] = 0;
if( (sKey_Operation[0].set_temper_temp /10) == (Oled_Display_Info.Air_Device.set_temperature/10)) //26.5调整到26度时,不管空调的反馈,直接上报
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
//else
//Control_AIR_CONDITION_By_RS485(AIR_CMD_SET_TEMPER,set_temper); //控制空调目标温度
{
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
sKey_Operation[0].set_temper_temp = 0xff;
}
else
Oled_Display_Info.Air_Device.set_temperature = sKey_Operation[0].set_temper_temp;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_set_temp_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
}
else
arg[0] = 0xff;
......@@ -1324,6 +1354,14 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
{
u8 wind_speed = arg[0];
arg[1] = wind_speed;
if(Oled_Display_Info.Air_Device.on_off == 0)
return;
Oled_Display_Info.Air_Device.wind_speed = wind_speed;
#if (DEV_TYPE == 0) &&(DEVICE_TYPE_AIR_CONDITION ==1)
delay_control_fan_speed_start();
#else
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态改变通知
#endif
arg[0] = 0;
}
break;
......@@ -1353,13 +1391,29 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
u8 delay_off_time = arg[0];
arg[1] = delay_off_time;
if(Oled_Display_Info.Air_Device.on_off == 0)
return;
if(Oled_Display_Info.screen_page != device_type)
{
//仅仅更新状态
arg[0] = 0;
arg[1] = delay_off_time;
Oled_Display_Info.Air_Device.power_off_time = delay_off_time;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,2);
break;
}
Oled_Display_Info.Air_Device.power_off_time = delay_off_time;
Oled_Display_Info.Air_Device.power_off_flage = 1;
if(delay_off_time >0)
Oled_Display_Info.Air_Device.power_off_flage = 1;
if( (Get_Display_Status())&&(delay_off_time >0) )
Display_poweroff_time(delay_off_time);
else if((Get_Display_Status())&&(delay_off_time ==0)&&(Oled_Display_Info.Air_Device.power_off_flage))
Delay_OFF_Rel_Display(1,0,NULL,0,0,0);
if(delay_off_time >0)
Oled_Display_Info.Air_Device.power_off_flage = 1;
else if(Oled_Display_Info.Air_Device.power_off_flage == 1)
Oled_Display_Info.Air_Device.power_off_flage = 0;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态更新上报
arg[0] = 0;
......@@ -1433,7 +1487,16 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
Oled_Display_Info.Air_Device.no_disturb_mode = no_disturb_mode;
save_data(); //保存token
if(IsLcdEnterScreenSave() &&(Oled_Display_Info.screen_page == device_type)&&no_disturb_mode)
{
LCD_CONTROL(0);
BL55072A_Clear();
}
else if(IsLcdEnterScreenSave()&&(no_disturb_mode == 0)&&(Oled_Display_Info.Air_Device.on_off))
{
LCD_CONTROL(1);
EnterScreenSaveMode();
}
arg[0] = 0;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,1); //状态更新上报
}
......@@ -1452,6 +1515,7 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
{
//仅仅更新开关状态
Oled_Display_Info.FLOOR_Device.on_off = onoff;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,2);
break;
}
if(onoff == ON)
......@@ -1480,12 +1544,15 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
case OPCODE_GENERAL_OPERATION_MODE:
{
u8 system_mode = arg[0];
if(Oled_Display_Info.FLOOR_Device.on_off == 0)
return;
if(Oled_Display_Info.screen_page != device_type)
{
//仅仅更新状态
arg[0] = 0;
arg[1] = system_mode;
Oled_Display_Info.FLOOR_Device.system_type = system_mode;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,2);
break;
}
if(Oled_Display_Info.FLOOR_Device.on_off)
......@@ -1506,11 +1573,14 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
u16 set_temper = ((u16)arg[0])<<8 | arg[1];
arg[1] = set_temper >>8;
arg[2] = set_temper&0xff;
if( Oled_Display_Info.FLOOR_Device.on_off == 0)
return;
if(Oled_Display_Info.screen_page != device_type)
{
//仅仅更新状态
arg[0] = 0;
Oled_Display_Info.FLOOR_Device.set_temperature = set_temper;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,2);
break;
}
if( (Oled_Display_Info.FLOOR_Device.on_off)&&(Oled_Display_Info.FLOOR_Device.system_type == SYSTEM_MODE_MANUAL) )
......@@ -1554,11 +1624,29 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
u8 delay_off_time = arg[0];
arg[1] = delay_off_time;
if(Oled_Display_Info.FLOOR_Device.on_off == 0)
return;
if(Oled_Display_Info.screen_page != device_type)
{
//仅仅更新状态
arg[0] = 0;
arg[1] = delay_off_time;
Oled_Display_Info.FLOOR_Device.power_off_time = delay_off_time;
if(delay_off_time >0)
Oled_Display_Info.FLOOR_Device.power_off_flage = 1;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,2);
break;
}
Oled_Display_Info.FLOOR_Device.power_off_time = delay_off_time;
if( (Get_Display_Status())&&(delay_off_time >0) )
Display_poweroff_time(delay_off_time);
else if((Get_Display_Status())&&(delay_off_time ==0)&&(Oled_Display_Info.FLOOR_Device.power_off_flage))
Delay_OFF_Rel_Display(1,0,NULL,0,0,0);
if(delay_off_time >0)
Oled_Display_Info.FLOOR_Device.power_off_flage = 1;
else if(Oled_Display_Info.FLOOR_Device.power_off_flage == 1)
Oled_Display_Info.FLOOR_Device.power_off_flage = 0;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,2);
arg[0] = 0;
......@@ -1608,7 +1696,16 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
arg[1] = no_disturb_mode;
Oled_Display_Info.FLOOR_Device.no_disturb_mode = no_disturb_mode;
if(IsLcdEnterScreenSave() &&(Oled_Display_Info.screen_page == device_type)&&no_disturb_mode)
{
LCD_CONTROL(0);
BL55072A_Clear();
}
else if(IsLcdEnterScreenSave()&&(no_disturb_mode == 0)&&(Oled_Display_Info.FLOOR_Device.on_off))
{
LCD_CONTROL(1);
EnterScreenSaveMode();
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,2);
save_data(); //保存token
......@@ -1629,6 +1726,7 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
{
//仅仅更新开关状态
Oled_Display_Info.FAN_Device.on_off = onoff;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
break;
}
if(onoff == ON)
......@@ -1663,6 +1761,7 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
arg[0] = 0;
arg[1] = system_mode;
Oled_Display_Info.FAN_Device.system_type = system_mode;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
break;
}
......@@ -1692,6 +1791,7 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
arg[0] = 0;
arg[1] = wind_speed;
Oled_Display_Info.FAN_Device.wind_speed = wind_speed;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
break;
}
......@@ -1728,6 +1828,7 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
arg[0] = 0;
arg[1] = child_lock;
Oled_Display_Info.FAN_Device.lock_flage = child_lock;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
break;
}
Oled_Display_Info.FAN_Device.lock_flage = child_lock;
......@@ -1750,13 +1851,20 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
arg[0] = 0;
arg[1] = delay_off_time;
Oled_Display_Info.FAN_Device.power_off_time = delay_off_time;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
break;
}
Oled_Display_Info.FAN_Device.power_off_time = delay_off_time;
if(delay_off_time >0)
Oled_Display_Info.FAN_Device.power_off_flage = 1;
if( (Get_Display_Status() ) &&(delay_off_time >0))
Display_poweroff_time(delay_off_time);
else if((Get_Display_Status())&&(delay_off_time ==0)&&(Oled_Display_Info.FAN_Device.power_off_flage))
Delay_OFF_Rel_Display(1,0,NULL,0,0,0);
if(delay_off_time >0)
Oled_Display_Info.FAN_Device.power_off_flage = 1;
else if(Oled_Display_Info.FAN_Device.power_off_flage == 1)
Oled_Display_Info.FAN_Device.power_off_flage = 0;
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
}
arg[0] = 0;
......@@ -1817,6 +1925,16 @@ void Set_CMD_Handler(u8 device_type,u16 opcode,u8 *arg,u8 arg_len)
arg[1] = no_disturb_mode;
Oled_Display_Info.FAN_Device.no_disturb_mode = no_disturb_mode;
if(IsLcdEnterScreenSave() &&(Oled_Display_Info.screen_page == device_type)&&no_disturb_mode)
{
LCD_CONTROL(0);
BL55072A_Clear();
}
else if(IsLcdEnterScreenSave()&&(no_disturb_mode == 0)&&(Oled_Display_Info.FAN_Device.on_off))
{
LCD_CONTROL(1);
EnterScreenSaveMode();
}
state_change_report(OPCODE_GENERAL_REPORT_STATUS,3);
save_data(); //保存token
......@@ -2134,8 +2252,15 @@ u8 kLedIsBlinking(u8 led_id)
{
return (g_NetOptIndicator[led_id].blink_cnt>0);
}
u8 kAllLedIsBlinking(void)
{
return (g_NetOptIndicator[7].blink_cnt>0);
}
/* DESP: Indicator lamp behavior control interface.
Auth: dingmz_frc.20191108.
Auth: lmm_frc.20201218.
id = 0,网络图标
id 1-6 指示灯1-6
id 7 所有指示灯
*/
void kNetIndicatorOptTrigger(uint8_t id, uint32_t duration_on_ms, uint32_t duration_off_ms, uint32_t times, u8 start, u8 end )
{
......@@ -2177,7 +2302,7 @@ void kLedModuleActionDetectCallback(void )
u8 i = 0;
SetNetScanTime(SysIndicatorScanTimer);
// PROCESS...
for(i = 0;i<7;i++)
for(i = 0;i<8;i++)
{
if( g_NetOptIndicator[i].blink_cnt > 0 ) {
......
......@@ -11,6 +11,11 @@ extern u8 boad_test_falg[6];
u16 g_u16 = 0;
#if 1 // add by dingmz_frc.20201215
extern u8 g_u8Temp_Buffer[];
extern u8 g_u8Temp_Length;
#endif
void uart0_data_deal_init(void)
{
memset(&static_transparent_msg_info,0,sizeof(RECIVE_USART_DATA_HANDLE));
......@@ -19,24 +24,19 @@ void uart0_data_deal_init(void)
static TP_u8 uart_recive_write_buff(TP_uc8 *data,TP_uc16 len)
{
TP_u8 rem_serial = 0;
if(len > USART_RECIVE_LEN_DEF)
{
//DEBUG_USATR1("data too long");
return 0;
}
if( len <= MAX_USART_RECIVE_LEN ) {
rem_serial = static_transprent_buff.Download_serial_num;
if(static_transprent_buff.Download_serial_num > (USART_RECIVE_DEPTHS - 1))
if( static_transprent_buff.Download_serial_num > (USART_RECIVE_DEPTHS - 1))
{
static_transprent_buff.Download_serial_num = 0;
rem_serial = static_transprent_buff.Download_serial_num; //add by YWQ
}
memcpy(&static_transprent_buff.Usart_buff[rem_serial][0],data,len);
static_transprent_buff.Usart_buff_len[static_transprent_buff.Download_serial_num] = len;
static_transprent_buff.Download_serial_num ++;
static_transprent_buff.Download_serial_num++;
if(static_transprent_buff.Download_serial_num == static_transprent_buff.Buff_send_serial_num)
{
......@@ -44,6 +44,7 @@ static TP_u8 uart_recive_write_buff(TP_uc8 *data,TP_uc16 len)
static_transprent_buff.Download_serial_num = rem_serial;
return 0;
}
}
return 1;
}
......@@ -66,7 +67,7 @@ u8 uart_msg_recive(u8 RcvChar)
}
else if(static_transparent_msg_info.Recive_len == 3)
{
if((RcvChar < (USART_RECIVE_LEN_DEF - 5)) && (RcvChar > 4)) //长度在正常值之间
if((RcvChar < (MAX_USART_RECIVE_LEN - 5)) && (RcvChar > 4)) //长度在正常值之间
{
static_transparent_msg_info.Data[static_transparent_msg_info.Recive_len ++] = RcvChar;
static_transparent_msg_info.Data_len = RcvChar;
......@@ -76,7 +77,7 @@ u8 uart_msg_recive(u8 RcvChar)
static_transparent_msg_info.Recive_len = 0x00; //这串数据不对
}
}
else if((static_transparent_msg_info.Recive_len > 3) && (static_transparent_msg_info.Recive_len < (USART_RECIVE_LEN_DEF - 2))) //接受数据
else if((static_transparent_msg_info.Recive_len > 3) && (static_transparent_msg_info.Recive_len < (MAX_USART_RECIVE_LEN - 2))) //接受数据
{
static_transparent_msg_info.Data[static_transparent_msg_info.Recive_len ++] = RcvChar;
......@@ -102,7 +103,7 @@ void uart_msg_deal(void)
if(static_transprent_buff.Buff_send_serial_num != static_transprent_buff.Download_serial_num)
{
if(static_transprent_buff.Buff_send_serial_num >5)
if((static_transprent_buff.Buff_send_serial_num >USART_RECIVE_DEPTHS)||(static_transprent_buff.Download_serial_num >USART_RECIVE_DEPTHS))
{
return; //防止内存溢出导致错误值
}
......@@ -117,15 +118,19 @@ void uart_msg_deal(void)
static_transprent_buff.Buff_send_serial_num++;
}
}
u8 Usart_recive_deal(TP_uc8 *data,TP_uc16 len)
u8 Usart_recive_deal(TP_uc8 *data, TP_uc8 len )
{
PROTOCOL_DEAL Usart_protocol_deal = {0};
u8 arg_data[20] = {0};
if( (data == NULL) ||(len >40))
//printf("66:len = %d\r\n", len);
if((data == NULL) || (len < 6) || (len > MAX_USART_RECIVE_LEN))
{
//printf("non valied msg,discard it all\r\n");
return 0;
return DEAL_ERROR;
}
//printf("77\r\n");
Usart_protocol_deal.SEQ = BYTE_MOVE(*(data + 5),*(data + 6));
// for(i = 0;i<len;i++)
// printf("data[%d] = %x",i,data[i] );
......@@ -257,30 +262,30 @@ void proximity_triagger_report(void)
void uart_protocol_send(PROTOCOL_SEND_MSG send_protocol,TP_u16 SEQ)
{
TP_u8 KK_Buf[125] = {0};
//TP_u8 KK_Buf[125] = {0};
TP_u16 KK_CRC16_Num = 0; //计算校验值
memset(KK_Buf,0,sizeof(KK_Buf));
KK_Buf[0] = 0xAA;
KK_Buf[1] = 0x55;
KK_Buf[2] = (send_protocol.ARG_len + 7)>>8; //长度 7
KK_Buf[3] = (send_protocol.ARG_len + 7)&0xff; //长度 7
KK_Buf[5] = (SEQ>>8) & 0xff; //序列号H
KK_Buf[6] = (SEQ & 0xff); //序列号L
KK_Buf[4] = send_protocol.ControlField; //控制域: 不需要ack
KK_Buf[7] = send_protocol.ARG_len+3; //长度
KK_Buf[8] = send_protocol.Channel_ID; //下行协议: 信道00
KK_Buf[9] = ((send_protocol.Opcode >> 8) & 0xff); //下行协议: Opcode_H
KK_Buf[10] = (send_protocol.Opcode & 0xff); //下行协议: Opcode_L
memcpy(&KK_Buf[11],send_protocol.ARG,send_protocol.ARG_len);
//memset(KK_Buf,0,sizeof(KK_Buf));
g_u8Temp_Buffer[0] = 0xAA;
g_u8Temp_Buffer[1] = 0x55;
g_u8Temp_Buffer[2] = (send_protocol.ARG_len + 7)>>8; //长度 7
g_u8Temp_Buffer[3] = (send_protocol.ARG_len + 7)&0xff; //长度 7
g_u8Temp_Buffer[5] = (SEQ>>8) & 0xff; //序列号H
g_u8Temp_Buffer[6] = (SEQ & 0xff); //序列号L
g_u8Temp_Buffer[4] = send_protocol.ControlField; //控制域: 不需要ack
g_u8Temp_Buffer[7] = send_protocol.ARG_len+3; //长度
g_u8Temp_Buffer[8] = send_protocol.Channel_ID; //下行协议: 信道00
g_u8Temp_Buffer[9] = ((send_protocol.Opcode >> 8) & 0xff); //下行协议: Opcode_H
g_u8Temp_Buffer[10] = (send_protocol.Opcode & 0xff); //下行协议: Opcode_L
memcpy(&g_u8Temp_Buffer[11],send_protocol.ARG,send_protocol.ARG_len);
//KK_Buf[9] = 0X00;
KK_CRC16_Num = CreateCrc16_Self((TP_uc8*)&KK_Buf[4],send_protocol.ARG_len + 7);
KK_Buf[send_protocol.ARG_len + 11] = (KK_CRC16_Num>>8) & 0xff; //校验值 CRC_H
KK_Buf[send_protocol.ARG_len + 12] = KK_CRC16_Num & 0xff; //校验值 CRC_L
KK_CRC16_Num = CreateCrc16_Self((TP_uc8*)&g_u8Temp_Buffer[4],send_protocol.ARG_len + 7);
g_u8Temp_Buffer[send_protocol.ARG_len + 11] = (KK_CRC16_Num>>8) & 0xff; //校验值 CRC_H
g_u8Temp_Buffer[send_protocol.ARG_len + 12] = KK_CRC16_Num & 0xff; //校验值 CRC_L
UART0_Send_Bytes(KK_Buf,send_protocol.ARG_len + 13);
UART0_Send_Bytes(g_u8Temp_Buffer,send_protocol.ARG_len + 13);
}
/*
接收到的数据crc错误回复
......@@ -305,7 +310,7 @@ static void send_crc_error_data(TP_u16 seq_data)
/*
接收到的数据crc错误回复
*/
TP_u16 CreateCrc16_Self(const u8* msg, TP_u32 len)
TP_u16 CreateCrc16_Self(const u8* msg, TP_u8 len)
{
TP_u16 crc = 0xFFFF;
TP_u32 i, j = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment