1010# define TOUCH_LIMIT 20
1111#endif
1212
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+
1321namespace audio_driver {
1422
1523/* * @file */
@@ -59,7 +67,7 @@ enum class PinFunction {
5967 * @ingroup enumerations
6068 * @ingroup audio_driver
6169 */
62- enum AudioDriverKeys {
70+ enum AudioDriverKey {
6371 KEY_REC = 0 ,
6472 KEY_MODE,
6573 KEY_PLAY,
@@ -629,10 +637,18 @@ class PinsLyratMiniClass : public DriverPins {
629637 addPin (PinFunction::KEY, 39 , PinLogic::Input, 0 );
630638 }
631639
640+ // / When the button is released we might get some missreadings: so we read twice
641+ // / to guarantee a stable result
632642 bool isKeyPressed (uint8_t key) override {
633643 if (key > 5 ) return false ;
634644 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;
636652 }
637653
638654 void setRange (int value) {
@@ -642,7 +658,7 @@ class PinsLyratMiniClass : public DriverPins {
642658protected:
643659 // analog values for rec, mute, play, set, vol-, vol+
644660 int analog_values[6 ] {2802 , 2270 , 1754 , 1284 , 827 , 304 };
645- int range = 5 ;
661+ int range = LYRAT_MINI_RANGE ;
646662
647663 bool inRange (int in, int toBe){
648664 return in >= (toBe-range) && in <= (toBe+range);
0 commit comments