接收函数参数修正

check
Zeng wei (曾威) 2 years ago
parent 6e0866a990
commit 7bf5ded8ae

@ -19,6 +19,11 @@ PID pid;
int min_speed_count = 2000;
int max_speed_count = 4800;
extern u8 gpio_state;
extern u8 lights[9];
extern u8 lights_addresses[9];
/**
* PID init
*/
@ -80,6 +85,27 @@ void PID_Init()
}
void light_set_3(u8 address, u8 value) {
u8 data[8] = { address, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 };
if (value > 100) {
value = 100;
}
data[4] = value / 256;
data[5] = value % 256;
GetCRC16(data, 6, data + 6, data + 7);
delay_xms(10);
RS485_3_Send_Data(data, 8);
}
void light_set_all_3(void) {
for (int i = 0; i < 9; i++) {
// set light i
light_set_3(lights_addresses[i], lights[i]);
}
}
/**
@ -101,7 +127,8 @@ void set_compressor_power(int speed) {
RS485_3_Init(9600);
delay_xms(30);
RS485_3_Send_Data(data, 8);
delay_xms(30);
delay_xms(50);
light_set_all_3();
RS485_1_Init(9600);
}
@ -375,6 +402,15 @@ void PID_Calc() // pid calc
set_compressor_power(pid.c_speed);
set_heater_power(pid.h_percent);
// if the compressor is running, then open the bottom fan, else close
if (pid.c_speed > 0) {
gpio_state |= 0x40;
} else {
gpio_state &= 0xBF;
}
HC595_Send_Byte(gpio_state);
pid.Ek_prev = pid.Ek; // udpate difference
pid.C1ms = 0;

@ -1,17 +1,5 @@
继电器
8 加湿器
7 底部风扇
6 背部风扇

File diff suppressed because one or more lines are too long

@ -23,7 +23,7 @@ int main(void)
// RS485_1_Init(9600);
HC595_Pin_Init();
RTC_Init(); // 需要放在HC595_Pin_Init()后面
RTC_Init(); // need to after HC595_Pin_Init()
TIM2_Init();
Read_Init(); // 读flash的值赋值给total数组以及阶段
// Array(&now_stage,&hour,&min,&tem,&hum,&red,&blue,&white);
@ -42,7 +42,12 @@ int main(void)
// printf("init start\r\n");
// init_Net();//网络初始化
// printf("init_Net OK");
// while(!do_dns((u8 *)"hp8oQhMZJ67.iot-as-mqtt.cn-shanghai.aliyuncs.com"));//网域名称
// while(!do_dns((u8 *)"hp8oQhMZJ67.iot-as-mqtt.cn-shanghai.aliyuncs.com"));// network name
// default open back fan
gpio_state |= 0x04;
HC595_Send_Byte(gpio_state);
os_init();
while (1)
{

@ -240,6 +240,7 @@ void HotTestRequestTask(void *pvParameters) {
// PID_Calc();
// RS485_1_Upload_Params();
// }
vTaskDelay(5000);
}
}
@ -322,9 +323,6 @@ void Sensor_Communication_task(void *pvParameters)
Analysis(&n, &i, RS485_RX_BUF_COPY);
Array(&now_stage, &hour, &min, &tem, &hum, lights); // update param correspond to current stage
Write_Init();
// bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 9);
// bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 9, 13);
// RS485_1_Send_Data_1(RS485_DATA_TMP, 13);
RX_BUF_Transfer(0, 9);
light_set_all();
// if temp or humidity is been change, then calc pid right now, and upload params
@ -403,18 +401,18 @@ void Sensor_Communication_task(void *pvParameters)
{
RX_BUF_Transfer(0, 17);
}
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB1 && RS485_RX_BUF_COPY[2] == 0x11 && RS485_RX_BUF_COPY[14] == 0xFF && RS485_RX_BUF[15] == 0xFF)
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB1 && RS485_RX_BUF_COPY[2] == 0x11 && RS485_RX_BUF_COPY[17] == 0xFF && RS485_RX_BUF[18] == 0xFF)
{
RX_BUF_Transfer(0, 16);
RX_BUF_Transfer(0, 19);
}
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB1 && RS485_RX_BUF_COPY[2] == 0x11 && RS485_RX_BUF_COPY[12] == 0xFF && RS485_RX_BUF[13] == 0xFF)
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB1 && RS485_RX_BUF_COPY[2] == 0x11 && RS485_RX_BUF_COPY[14] == 0xFF && RS485_RX_BUF[15] == 0xFF)
{
process_hmi_btn_event(RS485_RX_BUF_COPY[3] * 256 + RS485_RX_BUF_COPY[4], RS485_RX_BUF_COPY[5] * 256 + RS485_RX_BUF_COPY[6], RS485_RX_BUF_COPY[9]);
RX_BUF_Transfer(0, 14);
RX_BUF_Transfer(0, 16);
}
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB1 && RS485_RX_BUF_COPY[2] == 0x01 && RS485_RX_BUF_COPY[7] == 0xFF && RS485_RX_BUF_COPY[8] == 0xFF)
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB1 && RS485_RX_BUF_COPY[2] == 0x01 && RS485_RX_BUF_COPY[8] == 0xFF && RS485_RX_BUF_COPY[9] == 0xFF)
{
RX_BUF_Transfer(0, 9);
RX_BUF_Transfer(0, 10);
}
else
{
@ -430,6 +428,7 @@ void Sensor_Communication_task(void *pvParameters)
}
RX_BUF_Transfer(0, ZERO_Count);
}
}
// if (red <= 1000 && blue <= 1000)
@ -445,6 +444,7 @@ void Sensor_Communication_task(void *pvParameters)
}
}
/**
* process sensor data
*/

Loading…
Cancel
Save