@@ -595,7 +595,7 @@ static term nif_adc_sample(Context *ctx, int argc, term argv[])
595595
596596 term read_options = argv [2 ];
597597 VALIDATE_VALUE (read_options , term_is_list );
598- term samples = interop_kv_get_value_default (read_options , ATOM_STR ("\x7" , "samples" ), term_from_int32 (DEFAULT_SAMPLES ), ctx -> global );
598+ term samples = interop_kv_get_value_default (read_options , ATOM_STR ("\x7" , "samples" ), term_from_int28 (DEFAULT_SAMPLES ), ctx -> global );
599599 if (UNLIKELY (!term_is_integer (samples ))) {
600600 ESP_LOGE (TAG , "samples value must be an integer from 1 to 1024." );
601601 RAISE_ERROR (BADARG_ATOM );
@@ -625,20 +625,20 @@ static term nif_adc_sample(Context *ctx, int argc, term argv[])
625625 adc_raw /= samples_val ;
626626 ESP_LOGD (TAG , "read adc raw reading: %i" , adc_raw );
627627
628- raw = raw == TRUE_ATOM ? term_from_int32 (adc_raw ) : UNDEFINED_ATOM ;
628+ raw = raw == TRUE_ATOM ? term_from_int28 (adc_raw ) : UNDEFINED_ATOM ;
629629 if (voltage == TRUE_ATOM ) {
630630 int millivolts = 0 ;
631631 if (chan_rsrc -> calibration > ESTIMATED ) {
632632 err = adc_cali_raw_to_voltage (chan_rsrc -> cali_handle , adc_raw , & millivolts );
633633 if (UNLIKELY (err != ESP_OK )) {
634634 ESP_LOGW (TAG , "Failed to get calibrated voltage, returning estimated voltage" );
635- voltage = term_from_int32 (approximate_millivolts (adc_raw , chan_rsrc -> attenuation , chan_rsrc -> width ));
635+ voltage = term_from_int28 (approximate_millivolts (adc_raw , chan_rsrc -> attenuation , chan_rsrc -> width ));
636636 } else {
637- voltage = term_from_int32 (millivolts );
637+ voltage = term_from_int28 (millivolts );
638638 }
639639 } else {
640640 ESP_LOGD (TAG , "ADC channel not calibrated, using estimated voltage" );
641- voltage = term_from_int32 (approximate_millivolts (adc_raw , chan_rsrc -> attenuation , chan_rsrc -> width ));
641+ voltage = term_from_int28 (approximate_millivolts (adc_raw , chan_rsrc -> attenuation , chan_rsrc -> width ));
642642 }
643643 } else {
644644 voltage = UNDEFINED_ATOM ;
0 commit comments