添加反射率定标

This commit is contained in:
2025-03-26 09:27:34 +08:00
parent 09256a1972
commit 7558731dc4
642 changed files with 104260 additions and 255 deletions

View File

@ -212,32 +212,13 @@ void setup()
digitalWrite(37, LOW);
vTaskDelay(1000);
Serial.begin(115200);
// while (1)
// {
// Serial.println("LOW");
// digitalWrite(36,LOW);
// vTaskDelay(1000);
// Serial.println("HIGH");
// digitalWrite(36,HIGH);
// vTaskDelay(1000);
// }
log_init();
// wb485Serial.begin(115200);
// wb485Serial.begin(115200, SERIAL_8N1, wb485PORT_RX, wb485PORT_TX, false);
wb485Serial.begin(115200);
vTaskDelay(1000);
// while(1)
// {
// Serial.println("start");
// vTaskDelay(1000);
// }
vTaskDelay(5000);
IS1Serial =new HardwareSerial(IS1Serial_port);
@ -255,21 +236,6 @@ void setup()
sdcard::Mkdir("/system");
///
// while(1)
// {
// write_log(log_path,"hello world",10);
// if(SD_MMC.exists("/guangpu_data/0"))
// {
// rm_dir_or_file("/guangpu_data/0");
// }
// }
// dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
// dingbiao_init("/dingbiao/dingbiao_up_offset.bin");
// dingbiao_init("/dingbiao/dingbiao_down_gain.bin");
// dingbiao_init("/dingbiao/dingbiao_down_offset.bin");
//检查SD卡是否有log.log文件 没有则创建
// unsigned char log_level = 10;
if(!SD_MMC.exists(log_path))
@ -289,19 +255,7 @@ void setup()
}
// 初始化DS18b20
uint8_t temp_number = DS18b20_init();
// float temp[temp_number];
// getall_temp(temp);
// while (1)
// {
// getall_temp(temp);
// for (size_t i = 0; i < temp_number; i++)
// {
// write_log(log_path,"temp " + String(i + 1) + ": " + String(temp[i]),10);
// }
// vTaskDelay(10);
// }
// sd_read_set_ds18b20_address();
//ADC电压采集初始化
// adc_init();
// write_log(log_path,"adc_read: " + String(adc_read()),10);
@ -313,132 +267,19 @@ void setup()
//初始化蜂鸣器
beep_init(6,2000,12);
// while (1)
// {
// servo_set_angle(120);
// vTaskDelay(1000 * 1.5);
// servo_set_angle(0);
// beep_run(2000,1000);
// vTaskDelay(1000 * 3);
// beep_stop();
// }
// while(1)
// {
// beep_run(2000,1000);
// vTaskDelay(1000 * 3);
// beep_stop();
// vTaskDelay(1000 * 3);
// }
//初始化时间
rtc.init();
// now.year = 24;
// now.month = 5;
// now.day = 9;
// now.hour = 6;
// now.minute = 41;
// now.second = 0;
// now.dow = Ds1302::DOW_TUE;
// rtc.setDateTime(&now);
// vTaskDelay(1000);
// while(1)
// {
// rtc.getDateTime(&now);
// String time = String(now.year)+String(now.month)+String(now.day)+String(now.hour)+String(now.minute)+String(now.second);
// Serial.println(time);
// vTaskDelay(1000 * 5);
// }
String time = String(now.year)+String(now.month)+String(now.day)+String(now.hour)+String(now.minute)+String(now.second);
write_log(log_path,time,20);
write_log(log_path,"system start",20);
//初始化74hc595
my74hc595_init();
/////////////////////////加热测试////////////////////////////////////
// while(1)
// {
// write_log(log_path,"start jiaresi",10);
// tuigan(tui);
// vTaskDelay(1000 * 10);
// write_log(log_path,"stop jiaresi",10);
// tuigan(suo);
// vTaskDelay(1000 * 10);
// }
///////////////////////////加热测试////////////////////////////////////
///////////////////////////推杆测试/////////////////////////////////////
// uint32_t x = 0;
// float n = 20;
// uint32_t data_length;
// uint8_t read_buf[100];
// while (1)
// {
// while(wb485Serial.available())
// {
// data_length += wb485Serial.readBytes(&read_buf[data_length],100);
// for (uint32_t i = 0; i < 5000; i++)
// {
// if(wb485Serial.available() > 0)
// {
// break;
// }
// }
// }
// //如果接收到数据
// if (data_length > 0)
// {
// if(read_buf[0] == 'n')
// {
// //将转换为数字
// n = atof((const char *) (read_buf+1));
// if(n<5) n = 5;
// }
// if(read_buf[0] == 'H')
// {
// wb485Serial.println("n = " + String(n));
// }
// memset(read_buf, 0, sizeof(read_buf));
// data_length = 0;
// }
// if(x == 1)
// {
// wb485Serial.println("start tuigan tui");
// tuigan(tui);
// }
// else if(x == 1000 *n)
// {
// wb485Serial.println("start tuigan suo");
// tuigan(suo);
// }
// else if(x == 1000 * 2 * n)
// {
// x = 0;
// }
// x++;
// vTaskDelay(1);
// }
///////////////////////////推杆测试/////////////////////////////////////
#ifdef GPS_4G
// //初始化AIR780EG
gsmmanger = new GSMMannger(SIMUARTNUMER, SIMUART_RX, SIMUART_TX);
@ -461,52 +302,6 @@ void setup()
#endif
// while(1)
// {
// String Date = getnetData();
// write_log(log_path,"date is :"+Date,10);
// vTaskDelay(1000);
// }
// //初始化AIR780EG
// gsmmanger = new GSMMannger();
// //获取GPS
//计算日出日落
// double transit, sunrise, sunset;
// double utc_offset = 8;
// while (1)
// {
// String Date = getnetData();
// write_log(log_path,"date is :"+Date,10);
// gpsbac = get_GPS(&gps_structure);
// write_log(log_path,"gpsbac: " + gpsbac,10);
// vTaskDelay(1000);
// }
// int i=0;
// while(1)
// {
// gpsbac = get_GPS(&gps_structure);
// write_log(log_path,String(i)+"Getting GPS " + gpsbac,10);
// vTaskDelay(1000);
// i++;
// if (gpsbac != "-1")
// {
// calcSunriseSunset(now.year+2000, now.month, now.day,gps_structure.latitude, gps_structure.longitude, transit, sunrise, sunset);
// write_log(log_path,"sunrise: " + String(sunrise),10);
// write_log(log_path,"sunset: " + String(sunset),10);
// write_log(log_path,"transit: " + String(transit),10);
// write_log(log_path,"latitude: " + String(gps_structure.latitude),10);
// write_log(log_path,"longitude: " + String(gps_structure.longitude),10);
// write_log(log_path,"gps_date: " + gpsbac,10);
// }
// }
//开启光谱仪
// pinMode(36,OUTPUT);
digitalWrite(36,HIGH);
@ -514,17 +309,6 @@ void setup()
InitFunction(serialwrite,serialread);
is11Sensor = new SensorIS11();
STRSensorInfos_structure = is11Sensor->initSensor();
// while(1)
// {
// is11Sensor->SetShutter(2);
// vTaskDelay(1000);
// is11Sensor->SetShutter(1);
// vTaskDelay(1000);
// }
// 删除原来SD卡的系统信息
sys_info_init();
@ -539,13 +323,6 @@ void setup()
vTaskDelay(1000 * 1.5);
beep_stop();
// sys_sd_doc["is_spacial"] = "yes";
// deserializeJson(sys_sd_doc,system_info);
// while (1)
// {
// }
xMutexInventory = xSemaphoreCreateMutex(); //创建MUTEX
if (xMutexInventory == NULL) {
@ -554,7 +331,7 @@ void setup()
xTaskCreatePinnedToCore(
Task0, /* 任务函数 */
"Task0", /* 任务名称 */
1024 * 100, /* 栈大小 */
1024 * 60, /* 栈大小 */
NULL, /* 任务参数 */
2, /* 任务优先级 */
&Task0_Handler, /* 任务句柄 */
@ -570,19 +347,18 @@ void setup()
0);
//创建并启动Core0的任务
xTaskCreatePinnedToCore(
int hhh = xTaskCreatePinnedToCore(
Task2, /* 任务函数 */
"Task2", /* 任务名称 */
1024 * 60, /* 栈大小 */
NULL, /* 任务参数 */
20, /* 任务优先级 */
200, /* 任务优先级 */
&Task2_Handler, /* 任务句柄 */
1);
wb485Serial.printf("Task2 %d \r\n",hhh);
}
// write_log(log_path,"setup ok",log_level);
// beep_run(2000,512);
// vTaskDelay(1000 * 3);
// beep_stop();
// write_log(log_path,"setup ok",10);
}
void loop()
@ -692,7 +468,7 @@ void Task0(void *pvParameters)
//Task1的实现
void Task1(void *pvParameters)
{
vTaskDelay(10);
vTaskDelay(3);
write_log(log_path,"task 1",10);
uint8_t last_day = 100;
uint32_t count=10;
@ -971,9 +747,9 @@ void Task1(void *pvParameters)
float temperature[8];
getall_temp(temperature);
vTaskDelay(10 * 1);
vTaskDelay(100);
getall_temp(temperature);
vTaskDelay(10 * 1);
vTaskDelay(100);
getall_temp(temperature);
for(uint8_t n=0; n<8 ;n++)
{
@ -986,17 +762,18 @@ void Task1(void *pvParameters)
write_log(log_path,"temperature " + String(n) +":" + String(temperature[n]),10);
}
if((temperature[1] + temperature[2]) / 2 > maximum_temperature)
if(temperature[2] / 2 > maximum_temperature)
{
write_log(log_path,"stop_jiare",20);
jiaresi(7,stop_jiare);
}
if((temperature[1]+ temperature[2]) / 2 < Minimum_temperature)
if( temperature[2] < Minimum_temperature)
{
if(temperature[1] <-120 || temperature[2] < -120)
if(temperature[2] < -120)
{
write_log(log_path,"temperature 2,3 is broken.",20);
write_log(log_path,"temperature 2 is broken.",20);
jiaresi(7,stop_jiare);
}
else
{
@ -1004,7 +781,7 @@ void Task1(void *pvParameters)
jiaresi(7,start_jiare);
}
}
vTaskDelay(1000 * 1);
// vTaskDelay(1000 * 1);
// sdcard::Mkdir(path);
// float temp4 = getone_temp(4);
@ -1024,7 +801,7 @@ void Task1(void *pvParameters)
// // jiaresi(5,stop_jiare);
// }
count++;
vTaskDelay(1000 * 60 * 10);
vTaskDelay(1000 * 60 * 1);
}
}
@ -1033,7 +810,7 @@ void Task1(void *pvParameters)
void Task2(void *pvParameters)
{
vTaskDelay(5);
// write_log(log_path,"task 2",10);
write_log(log_path,"task 2",10);
unsigned char read_buf[1024*10];
unsigned char command_data[1024 * 10];
unsigned char data_type;
@ -1042,12 +819,12 @@ void Task2(void *pvParameters)
uint8_t low_power_sta = 1;
u_char send_buff[300];
wb485Serial.setTimeout(1);
// u_char data_buff[300];
dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
dingbiao_init("/dingbiao/dingbiao_up_offset.bin");
dingbiao_init("/dingbiao/dingbiao_down_gain.bin");
dingbiao_init("/dingbiao/dingbiao_down_offset.bin");
dingbiao_init("/dingbiao/fanshelv_gain.bin");
while(1)
{
vTaskDelay(1);
@ -1093,7 +870,7 @@ void Task2(void *pvParameters)
case 0x03:
{
String dingbiao_path;
if (command_data[0] == 4 || command_data[0] == 5)
if (command_data[0] == 4 || command_data[0] == 5 || command_data[0] == 6 )
{
// is11Sensor->save_dingbiao(command_data);
//保存到sd卡
@ -1107,6 +884,11 @@ void Task2(void *pvParameters)
if(command_data[1] == 0) dingbiao_path = "/dingbiao/dingbiao_down_gain.bin";
else if(command_data[1] == 1) dingbiao_path = "/dingbiao/dingbiao_down_offset.bin";
}
else if(command_data[0] == 6)
{
if(command_data[1] == 0) dingbiao_path = "/dingbiao/fanshelv_gain.bin";
}
is11Sensor->save_dingbiao(command_data);
File file = SD_MMC.open(dingbiao_path, "wb");
file.write((uint8_t *)&command_data, ret);
@ -2290,6 +2072,10 @@ void json_command()
ret = IRIS_Protocol_Pack(0x00,(uint16_t)send_str.length(), (uint8_t *)send_str.c_str(),send_buff);
wb485Serial.write(send_buff, ret);
}
else if(doc["command"] == "get_fanshelv_gain")
{
send_dingbiao("/dingbiao/fanshelv_gain.bin");
}
//command error
else
{
@ -2380,8 +2166,7 @@ String get_GPS(gps_struct *gps)
// if(Date.indexOf(",") != -1)
// {
// return "-1";
// }
// }
// return Date;
//////////////////////////////////////////////////////////////////////////////