|
@ -229,11 +229,15 @@ void MarlinHAL::adc_init() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef ADC_REFERENCE_VOLTAGE |
|
|
|
|
|
#define ADC_REFERENCE_VOLTAGE 3.3 |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
void MarlinHAL::adc_start(const pin_t pin) { |
|
|
void MarlinHAL::adc_start(const pin_t pin) { |
|
|
const adc1_channel_t chan = get_channel(pin); |
|
|
const adc1_channel_t chan = get_channel(pin); |
|
|
uint32_t mv; |
|
|
uint32_t mv; |
|
|
esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv); |
|
|
esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv); |
|
|
adc_result = mv * 1023.0 / 3300.0; |
|
|
adc_result = mv * 1023.0f / float(ADC_REFERENCE_VOLTAGE) / 1000.0f; |
|
|
|
|
|
|
|
|
// Change the attenuation level based on the new reading
|
|
|
// Change the attenuation level based on the new reading
|
|
|
adc_atten_t atten; |
|
|
adc_atten_t atten; |
|
|