ESP32C3: Get analogRead working correctly

Thanks to SimonGAndrews!
we need to call it twice to get a decent value on the C3 for some reason!
https://forum.espruino.com/conversations/395499/?offset=100#17482163
This commit is contained in:
Gordon Williams 2024-08-09 15:54:21 +01:00
parent 9b3cc7f806
commit 5f3f6782ad
2 changed files with 7 additions and 0 deletions

View File

@ -1,3 +1,5 @@
: ESP32C3: Get analogRead working correctly
2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
Fix for unexpected power draw on newest batch of Bangle.js devices

View File

@ -145,6 +145,11 @@ int readADC(Pin pin){
#if ESP_IDF_VERSION_MAJOR>=4
// ESP_IDF 4.x - int adc1_get_voltage(adc1_channel_t channel) //Deprecated. Use adc1_get_raw() instead
int value=adc1_get_raw(channel);
#if CONFIG_IDF_TARGET_ESP32C3
// we need to call it twice to get a decent value on the C3 for some reason!
// https://forum.espruino.com/conversations/395499/?offset=100#17482163
value=adc1_get_raw(channel);
#endif
#else
value = adc1_get_voltage(channel);
#endif