|
有谁可以解释一下这个外部温度和光敏数据的处理程序吗??具体的有些看不懂啊
// Get the result
adc_value = ADCL;
adc_value |= ((uint16) ADCH) << 8;
adc_value = adc_value/8; //这句不懂为什么除8
// Subtract old adc value from sum
adcSum -= adcBuf[adcBufCnt]; //这个也不懂
// Store new adc value in ring buffer, will add it to sum later
adcBuf[adcBufCnt] = adc_value;
// Add the new adc value to sum
adcSum += adcBuf[adcBufCnt];
if (++adcBufCnt == MAXADCBUF)
{
adcAvg = adcSum/40; //这里也是
//adjust the temperature values
if (adcAvg < 17) //这里
{
adcAvg = 0;
}
else
{
adcAvg = adcAvg - 17;
}
adcBufCnt = 0; // Wrap ring buffer counter
}
}
adc_value = ADCL;
adc_value |= ((uint16) ADCH) << 8;
adc_value = adc_value/8;
// Subtract old adc value from sum
LsensAdcSum -= LsensAdcBuf[LsensAdcBufCnt];
// Store new adc value in ring buffer, will add it to sum later
LsensAdcBuf[LsensAdcBufCnt] = adc_value;
// Add the new adc value to sum
LsensAdcSum += LsensAdcBuf[LsensAdcBufCnt];
if (++LsensAdcBufCnt == MAXADCBUF)
{
LsensAdcAvg = LsensAdcSum/40;
LsensAdcBufCnt = 0; // Wrap ring buffer counter
}
} |
|