diff --git a/platform/drivers/ADC/ADC1_MDx.c b/platform/drivers/ADC/ADC1_MDx.c index 1a62b9fa..a3ebe685 100644 --- a/platform/drivers/ADC/ADC1_MDx.c +++ b/platform/drivers/ADC/ADC1_MDx.c @@ -104,8 +104,8 @@ void adc1_init() | (15 << 5); /* CH15, HTEMP value on PC5 */ #elif defined(PLATFORM_MD3x0) ADC1->SQR1 = 3 << 20; /* Four channels to be converted */ - ADC1->SQR3 |= (1 << 0) /* CH1, battery voltage on PA1 */ - | (0 << 5) /* CH0, volume potentiometer level on PA0 */ + ADC1->SQR3 |= (0 << 0) /* CH0, volume potentiometer level on PA0 */ + | (1 << 5) /* CH1, battery voltage on PA1 */ | (8 << 10) /* CH8, RSSI value on PB0 */ | (3 << 15); /* CH3, vox level on PA3 */ #else diff --git a/platform/targets/DM-1801/platform.c b/platform/targets/DM-1801/platform.c index b37c37e8..ff5cae30 100644 --- a/platform/targets/DM-1801/platform.c +++ b/platform/targets/DM-1801/platform.c @@ -144,8 +144,11 @@ bool platform_pwrButtonStatus() { /* * When power knob is set to off, battery voltage measurement returns 0V. + * Here we set the threshold to 1V since, with knob in off position, there + * is always a bit of noise in the ADC measurement making the returned + * voltage not to be exactly zero. */ - return (platform_getVbat() > 0.0f) ? true : false; + return (platform_getVbat() > 1.0f) ? true : false; } void platform_ledOn(led_t led) diff --git a/platform/targets/GD-77/platform.c b/platform/targets/GD-77/platform.c index 6c5c757f..a1feeadc 100644 --- a/platform/targets/GD-77/platform.c +++ b/platform/targets/GD-77/platform.c @@ -143,8 +143,11 @@ bool platform_pwrButtonStatus() { /* * When power knob is set to off, battery voltage measurement returns 0V. + * Here we set the threshold to 1V since, with knob in off position, there + * is always a bit of noise in the ADC measurement making the returned + * voltage not to be exactly zero. */ - return (platform_getVbat() > 0.0f) ? true : false; + return (platform_getVbat() > 1.0f) ? true : false; } void platform_ledOn(led_t led) diff --git a/platform/targets/MD-3x0/platform.c b/platform/targets/MD-3x0/platform.c index 4c4739a4..72519314 100644 --- a/platform/targets/MD-3x0/platform.c +++ b/platform/targets/MD-3x0/platform.c @@ -126,8 +126,11 @@ bool platform_pwrButtonStatus() { /* * When power knob is set to off, battery voltage measurement returns 0V. + * Here we set the threshold to 1V since, with knob in off position, there + * is always a bit of noise in the ADC measurement making the returned + * voltage not to be exactly zero. */ - return (adc1_getMeasurement(ADC_VBAT_CH) > 0.0f) ? true : false; + return (platform_getVbat() > 1.0f) ? true : false; } void platform_ledOn(led_t led) diff --git a/platform/targets/MD-UV3x0/platform.c b/platform/targets/MD-UV3x0/platform.c index 836d6fbb..42d43995 100644 --- a/platform/targets/MD-UV3x0/platform.c +++ b/platform/targets/MD-UV3x0/platform.c @@ -120,8 +120,11 @@ bool platform_pwrButtonStatus() { /* * When power knob is set to off, battery voltage measurement returns 0V. + * Here we set the threshold to 1V since, with knob in off position, there + * is always a bit of noise in the ADC measurement making the returned + * voltage not to be exactly zero. */ - return (adc1_getMeasurement(ADC_VBAT_CH) > 0.0f) ? true : false; + return (platform_getVbat() > 1.0f) ? true : false; } void platform_ledOn(led_t led)