ADC ok with interrupt or drdy

This commit is contained in:
Emanuele Trabattoni
2026-04-17 12:21:35 +02:00
parent 1b8ba88b05
commit bea29dc8f5
3 changed files with 652 additions and 623 deletions

View File

@@ -131,35 +131,6 @@ void loop()
#endif
LOG_DEBUG("Init SPI OK");
uint8_t chs[8] = {
SING_0, SING_1, SING_2, SING_3, SING_4, SING_5, SING_6, SING_7};
float res[8];
auto timeout = Serial.getTimeout();
Serial.setTimeout(0);
uint64_t count = 0;
while (Serial.read() != 's') // The conversion is stopped by a character received from the serial port
{
auto start = esp_timer_get_time();
for (int i = 0; i < 8; i++)
{
// dev->m_adc_a->setMUX(chs[i]);
res[i] += 0.1f * (dev->m_adc_a->convertToVoltage(dev->m_adc_a->cycleSingle()) - res[i]);
}
auto stop = esp_timer_get_time();
if (count++ % 25 == 0)
{
clearScreen();
for (int j = 0; j < 8; j++)
{
Serial.printf("ADC_A SING_%d: %5.4f\n", j, res[j]);
}
Serial.printf("ADC Time: %5.3f ms\n", (float)((stop - start) / 1000.0f));
}
}
Serial.setTimeout(timeout);
dev->m_adc_a->stopConversion();
//////// INIT I2C INTERFACES ////////
LOG_DEBUG("Init I2C Interfaces");
bool i2c_ok = true;