From ccda84df80eca1dcd7b2f69f59986f278f32964a Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Thu, 1 Jul 2021 09:50:09 +0200 Subject: [PATCH] Make buttons' ADC decision levels "inclusive" especially because of the zero level, which is very likely to be a valid button0 level --- src/modules/buttons.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/buttons.cpp b/src/modules/buttons.cpp index 581277e..0d32fa7 100644 --- a/src/modules/buttons.cpp +++ b/src/modules/buttons.cpp @@ -14,11 +14,11 @@ int8_t Buttons::DecodeADC(uint16_t rawADC) { // Button 3 - 516 // Doesn't handle multiple pressed buttons at once - if (rawADC > config::button0ADCMin && rawADC < config::button0ADCMax) + if (rawADC >= config::button0ADCMin && rawADC <= config::button0ADCMax) return 0; - else if (rawADC > config::button1ADCMin && rawADC < config::button1ADCMax) + else if (rawADC >= config::button1ADCMin && rawADC <= config::button1ADCMax) return 1; - else if (rawADC > config::button2ADCMin && rawADC < config::button2ADCMax) + else if (rawADC >= config::button2ADCMin && rawADC <= config::button2ADCMax) return 2; return -1; }