Skip to content

Commit

Permalink
A bit more of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mskvortsov committed May 24, 2024
1 parent f4023a5 commit f6c4e4e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ class AnalogBatteryLevel : public HasBatteryLevel
// ADC2 wifi bug workaround not required, breaks compile
// On ESP32S3, ADC2 can take turns with Wifi (?)

int32_t adc_buf;
int adc_buf;
esp_err_t read_result;

// Multiple samples
for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) {
adc_buf = 0;
read_result = -1;

read_result = adc2_get_raw(adc_channel, ADC_WIDTH_BIT_12, &adc_buf);
read_result = adc_oneshot_read(adc_unit_handle, adc_channel, &adc_buf);
if (read_result == ESP_OK) {
raw += adc_buf;
raw_c++; // Count valid samples
Expand Down
2 changes: 1 addition & 1 deletion src/platform/esp32/quirks.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if QUIRK_RTTTL
#if QUIRK_RTTTL || QUIRK_LOVYAN
#define ledcSetup(ch, freq, res) \
uint32_t __freq = freq; \
uint8_t __res = res; \
Expand Down
4 changes: 3 additions & 1 deletion src/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
#include <esp_adc/adc_cali.h>
#include <esp_adc/adc_oneshot.h>
#include <soc/adc_channel.h>
#include <soc/sens_reg.h>
#include <soc/soc.h>
#ifndef CONFIG_IDF_TARGET_ESP32C3
#include <soc/sens_reg.h>
#endif
#endif

#ifndef NUM_OCV_POINTS
Expand Down
4 changes: 2 additions & 2 deletions variants/heltec_wireless_paper_v1/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define ADC_CHANNEL ADC2_GPIO20_CHANNEL
#define ADC_MULTIPLIER 2 // Voltage divider is roughly 1:1
#define BAT_MEASURE_ADC_UNIT 2 // Use ADC2
#define ADC_ATTENUATION ADC_ATTEN_DB_11 // Voltage divider output is quite high
#define ADC_ATTENUATION ADC_ATTEN_DB_12 // Voltage divider output is quite high

#define USE_SX1262

Expand All @@ -54,4 +54,4 @@
#define SX126X_RESET LORA_RESET

#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
#define SX126X_DIO3_TCXO_VOLTAGE 1.8

0 comments on commit f6c4e4e

Please sign in to comment.