Browse Source

Fix compile warning

Scott Lahteine 5 years ago
parent
commit
0ff57c640c
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      Marlin/src/HAL/HAL_ESP32/HAL.cpp

+ 7
- 5
Marlin/src/HAL/HAL_ESP32/HAL.cpp View File

187
   const adc1_channel_t chan = get_channel(adc_pin);
187
   const adc1_channel_t chan = get_channel(adc_pin);
188
   uint32_t mv;
188
   uint32_t mv;
189
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
189
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
190
+  HAL_adc_result = mv * 1023.0 / 3300.0;
190
 
191
 
191
   // Change the attenuation level based on the new reading
192
   // Change the attenuation level based on the new reading
192
   adc_atten_t atten;
193
   adc_atten_t atten;
193
   if (mv < thresholds[ADC_ATTEN_DB_0] - 100)
194
   if (mv < thresholds[ADC_ATTEN_DB_0] - 100)
194
-    adc1_set_attenuation(chan, ADC_ATTEN_DB_0);
195
+    atten = ADC_ATTEN_DB_0;
195
   else if (mv > thresholds[ADC_ATTEN_DB_0] - 50 && mv < thresholds[ADC_ATTEN_DB_2_5] - 100)
196
   else if (mv > thresholds[ADC_ATTEN_DB_0] - 50 && mv < thresholds[ADC_ATTEN_DB_2_5] - 100)
196
-    adc1_set_attenuation(chan, ADC_ATTEN_DB_2_5);
197
+    atten = ADC_ATTEN_DB_2_5;
197
   else if (mv > thresholds[ADC_ATTEN_DB_2_5] - 50 && mv < thresholds[ADC_ATTEN_DB_6] - 100)
198
   else if (mv > thresholds[ADC_ATTEN_DB_2_5] - 50 && mv < thresholds[ADC_ATTEN_DB_6] - 100)
198
-    adc1_set_attenuation(chan, ADC_ATTEN_DB_6);
199
+    atten = ADC_ATTEN_DB_6;
199
   else if (mv > thresholds[ADC_ATTEN_DB_6] - 50)
200
   else if (mv > thresholds[ADC_ATTEN_DB_6] - 50)
200
-    adc1_set_attenuation(chan, ADC_ATTEN_DB_11);
201
+    atten = ADC_ATTEN_DB_11;
202
+  else return;
201
 
203
 
202
-  HAL_adc_result = mv * 1023.0 / 3300.0;
204
+  adc1_set_attenuation(chan, atten);
203
 }
205
 }
204
 
206
 
205
 void analogWrite(pin_t pin, int value) {
207
 void analogWrite(pin_t pin, int value) {

Loading…
Cancel
Save