It looks like
esp_adc_cal.c ( https://github.com/espressif/esp-idf/bl ... _adc_cal.c )
is in the currently-used ESP-IDF branch, and so I was wondering if
machine_adc.c ( https://github.com/micropython/micropyt ... hine_adc.c )
could have just a few tweaks done to the read() function, similar to the example at
adc1_example_main.c ( https://github.com/espressif/esp-idf/bl ... ple_main.c ).
I think it would be along the lines of
Code: Select all
STATIC mp_obj_t madc_read(mp_obj_t self_in) {
madc_obj_t *self = self_in;
esp_adc_cal_characteristics_t characteristics;
esp_adc_cal_get_characteristics(1100, self->width, self->atten, &characteristics);
//int val = adc1_get_raw(self->adc1_id);
int val = adc1_to_voltage(self->adc1_id, &characteristics);
if (val == -1) mp_raise_ValueError("Parameter Error");
return MP_OBJ_NEW_SMALL_INT(val);
}
MP_DEFINE_CONST_FUN_OBJ_1(madc_read_obj, madc_read);
"Guru Meditation Error of type IllegalInstruction occurred on core 0. Exception was unhandled." on build/flash/boot.
Okay, so the five-minute edit version didn't work... what am I missing?