注册会员
- 积分
- 32
- 威望
- 20
- 贡献
- 10
- 兑换币
- 8
- 注册时间
- 2015-12-19
- 在线时间
- 1 小时
- 毕业学校
- 东南大学
|
void CalculateIntegrationTime(void) {
/* 计算128个像素点的平均AD值 */
PixelAverageValue = PixelAverage();
/* 计算128个像素点的平均电压值,实际值的10倍 */
PixelAverageVoltage = (u8)((s16)PixelAverageValue * 25 / 128);
PixelAverageVoltageError = TargetPixelAverageVoltage - PixelAverageVoltage;
if(PixelAverageVoltageError < -TargetPixelAverageVoltageAllowError)
IntegrationTime-=1;
if(PixelAverageVoltageError > TargetPixelAverageVoltageAllowError)
IntegrationTime+=1;
if(IntegrationTime <= 1)
IntegrationTime = 1;
if(IntegrationTime >= 20)
IntegrationTime = 20;
}
void StartIntegration(void) {
//unsigned char i;
SI=1; /* SI = 1 */
delay200ns();
CLK=1; /* CLK = 1 */
delay200ns();
SI=0; /* SI = 0 */
delay200ns();
CLK=0; /* CLK = 0 */
for(u8 i=0; i<127; i++) {
delay200ns();
delay200ns();
CLK=1; /* CLK = 1 */
delay200ns();
delay200ns();
CLK=0; /* CLK = 0 */
}
delay200ns();
delay200ns();
CLK=1; /* CLK = 1 */
delay200ns();
delay200ns();
CLK=0; /* CLK = 0 */
}
void SendHex(unsigned char hex) {
unsigned char temp;
temp = hex >> 4;
if(temp < 10) {
uart_putchar (UART5,temp + '0');
} else {
uart_putchar (UART5,temp - 10 + 'A');
}
temp = hex & 0x0F;
if(temp < 10) {
uart_putchar (UART5,temp + '0');
} else {
uart_putchar (UART5,temp - 10 + 'A');
}
}
void SendImageData()
{
u8 crc = 0;
/* Send Data */
uart_putchar (UART5,'*');
uart_putchar (UART5,'L');
uart_putchar (UART5,'D');
SendHex(0);
SendHex(0);
SendHex(0);
SendHex(0);
for(u8 i=0; i<128; i++) {
SendHex(im[i]);
}Q
SendHex(crc);
uart_putchar (UART5,'#');
}
|
|