修改自动曝光
This commit is contained in:
@ -21,13 +21,14 @@ void Send_Shutter_Time(uint32_t shutter_time) {
|
||||
HAL_UART_Transmit(&huart2,t_buff,4,100);
|
||||
}
|
||||
|
||||
|
||||
uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size,uint32_t Shutter_Now) {
|
||||
//自动曝光 成功返回曝光时间 失败返回0
|
||||
uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size) {
|
||||
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;
|
||||
static uint32_t shutter_time;
|
||||
shutter_time < min_shutter_time ? shutter_time = min_shutter_time : shutter_time;
|
||||
|
||||
for (int i = 0; i < Size; i++) {
|
||||
if (data[i] > maxvaluenow) {
|
||||
@ -35,15 +36,15 @@ uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size,uint32_t Shutter
|
||||
}
|
||||
}
|
||||
|
||||
if (Shutter_Now<=min_shutter_time || Shutter_Now>=max_shutter_time) return 0;
|
||||
if (maxvaluenow<maxvalue || maxvaluenow >= maxvalue*1.05 ) {
|
||||
shutter_time = shutter_time * maxvalue / maxvaluenow;
|
||||
|
||||
shutter_time < min_shutter_time ? shutter_time = min_shutter_time : shutter_time;
|
||||
|
||||
if (maxvaluenow<maxvalue*0.95 || maxvaluenow>maxvalue) {
|
||||
shutter_time = Shutter_Now * maxvaluenow / maxvalue;
|
||||
Send_Shutter_Time(shutter_time);
|
||||
|
||||
HAL_Delay(1000);
|
||||
return shutter_time;
|
||||
if (shutter_time <= min_shutter_time ) return shutter_time;
|
||||
}
|
||||
else return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -7,5 +7,5 @@
|
||||
#include "mymain.h"
|
||||
|
||||
void Send_Shutter_Time(uint32_t shutter_time);
|
||||
uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size,uint32_t Shutter_Now);
|
||||
uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size);
|
||||
#endif //COMMUNICATION_H
|
||||
|
@ -84,12 +84,12 @@ void mymain()
|
||||
// uint32_t a=0;
|
||||
while (1) {
|
||||
while (mode == 0) {
|
||||
shutter_time = 0x0000;
|
||||
commander_run();
|
||||
if (Receive_Data_Count != Last_Receive_Data_Count) {
|
||||
|
||||
uint32_t a = Opt_Snenser(90, Receive_Data_Buffer ,USART2_RX_BUFFER_SIZE,shutter_time );
|
||||
if (a != 0) shutter_time = a;
|
||||
else {
|
||||
uint32_t a = Opt_Snenser(90, Receive_Data_Buffer ,USART2_RX_BUFFER_SIZE);
|
||||
if (a != 0) {
|
||||
shutter_time = a;
|
||||
mode = 1;
|
||||
}
|
||||
Last_Receive_Data_Count = Receive_Data_Count;
|
||||
|
12
APP/mymain.h
12
APP/mymain.h
@ -28,3 +28,15 @@
|
||||
void mymain();
|
||||
void commander_run(void);
|
||||
#endif //FOC_N_MYMAIN_H
|
||||
|
||||
|
||||
// int _write (int fd, char *pBuffer, int size)
|
||||
// {
|
||||
// for (int i = 0; i < size; i++)
|
||||
// {
|
||||
// USART1->TDR = (unsigned char) *(pBuffer+i);
|
||||
// while((USART1->ISR & USART_ISR_TC) == 0)
|
||||
// {}
|
||||
// }
|
||||
// return size;
|
||||
// }
|
Reference in New Issue
Block a user