10
10
# define TOUCH_LIMIT 20
11
11
#endif
12
12
13
+ #ifndef LYRAT_MINI_RANGE
14
+ # define LYRAT_MINI_RANGE 5
15
+ #endif
16
+
17
+ #ifndef LYRAT_MINI_DELAY_MS
18
+ # define LYRAT_MINI_DELAY_MS 5
19
+ #endif
20
+
13
21
namespace audio_driver {
14
22
15
23
/* * @file */
@@ -59,7 +67,7 @@ enum class PinFunction {
59
67
* @ingroup enumerations
60
68
* @ingroup audio_driver
61
69
*/
62
- enum AudioDriverKeys {
70
+ enum AudioDriverKey {
63
71
KEY_REC = 0 ,
64
72
KEY_MODE,
65
73
KEY_PLAY,
@@ -629,10 +637,18 @@ class PinsLyratMiniClass : public DriverPins {
629
637
addPin (PinFunction::KEY, 39 , PinLogic::Input, 0 );
630
638
}
631
639
640
+ // / When the button is released we might get some missreadings: so we read twice
641
+ // / to guarantee a stable result
632
642
bool isKeyPressed (uint8_t key) override {
633
643
if (key > 5 ) return false ;
634
644
int value = analogRead (39 );
635
- return inRange (value, analog_values[key]);
645
+ bool result = inRange (value, analog_values[key]);
646
+ delay (LYRAT_MINI_DELAY_MS);
647
+ int value1 = analogRead (39 );
648
+ bool result1 = inRange (value, analog_values[key]);
649
+ result = result && result1;
650
+ AD_LOGD (" value: %d,%d for key: %d -> %d" , value1, key, result);
651
+ return result;
636
652
}
637
653
638
654
void setRange (int value) {
@@ -642,7 +658,7 @@ class PinsLyratMiniClass : public DriverPins {
642
658
protected:
643
659
// analog values for rec, mute, play, set, vol-, vol+
644
660
int analog_values[6 ] {2802 , 2270 , 1754 , 1284 , 827 , 304 };
645
- int range = 5 ;
661
+ int range = LYRAT_MINI_RANGE ;
646
662
647
663
bool inRange (int in, int toBe){
648
664
return in >= (toBe-range) && in <= (toBe+range);
0 commit comments