first commit

This commit is contained in:
2025-02-19 14:46:14 +08:00
commit cde431e41c
221 changed files with 204599 additions and 0 deletions

53
APP/communication.c Normal file
View File

@ -0,0 +1,53 @@
//
// Created by IRIS on 25-2-7.
//
#include "communication.h"
#define maxValue 65535
//
void Send_Shutter_Time(uint32_t shutter_time) {
uint32_t tt = shutter_time*1000;
// printf("t %d \n",t);
// printf("tt %d \n",tt);
uint8_t t_buff[4];
t_buff[0] = *((uint8_t *)&tt+3);
t_buff[1] = *((uint8_t *)&tt+2);
t_buff[2] = *((uint8_t *)&tt+1);
t_buff[3] = *((uint8_t *)&tt);
// HAL_UART_Transmit(&huart1,t_buff,4,100);
__HAL_UART_ENABLE(&huart2);
HAL_UART_Transmit(&huart2,t_buff,4,100);
}
uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size,uint32_t Shutter_Now) {
int maxvalue=maxValue*1.0*persent / 100;
int maxvaluenow = 0;
uint32_t shutter_time;
uint32_t max_shutter_time = 100;
uint32_t min_shutter_time = 10;
for (int i = 0; i < Size; i++) {
if (data[i] > maxvaluenow) {
maxvaluenow = data[i];
}
}
if (Shutter_Now<=min_shutter_time || Shutter_Now>=max_shutter_time) return 0;
if (maxvaluenow<maxvalue*0.95 || maxvaluenow>maxvalue) {
shutter_time = Shutter_Now * maxvaluenow / maxvalue;
Send_Shutter_Time(shutter_time);
HAL_Delay(1000);
return shutter_time;
}
return 0;
}