Skip to content

Commit 5520715

Browse files
committed
Headphon Detection
1 parent af283ec commit 5520715

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/AudioLibs/AudioKit.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,21 +545,25 @@ class AudioKitStream : public AudioStreamX {
545545

546546
// pin conflicts with AIThinker A101 and headphone detection
547547
if (! (cfg.sd_active && AUDIOKIT_BOARD==6)) {
548-
actions.add(kit.pinHeadphoneDetect(), actionHeadphoneDetection);
548+
LOGD("actionHeadphoneDetection pin:%d",kit.pinHeadphoneDetect())
549+
actions.add(kit.pinHeadphoneDetect(), actionHeadphoneDetection, AudioActions::ActiveChange);
549550
} else {
550551
LOGW("Headphone detection ignored because of conflict: %d ",kit.pinHeadphoneDetect());
551552
}
552553

553554
// pin conflicts with the SD CS pin for AIThinker and buttons
554555
if (! (cfg.sd_active && (AUDIOKIT_BOARD==5 || AUDIOKIT_BOARD==6))){
556+
LOGD("actionStartStop")
555557
addAction(kit.pinInputMode(), actionStartStop);
556558
} else {
557559
LOGW("Mode Button ignored because of conflict: %d ",kit.pinInputMode());
558560
}
559561

560562
// pin conflicts with SD Lyrat SD CS Pin and buttons
561563
if (! (cfg.sd_active && AUDIOKIT_BOARD==1)){
564+
LOGD("actionVolumeDown")
562565
addAction(kit.pinVolumeDown(), actionVolumeDown);
566+
LOGD("actionVolumeUp")
563567
addAction(kit.pinVolumeUp(), actionVolumeUp);
564568
} else {
565569
LOGW("Volume Buttons ignored because of conflict: %d ",kit.pinVolumeDown());

src/AudioTools/AudioActions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ class AudioActions {
108108
} else if (a->activeLogic == ActiveChange) {
109109
bool active = (a->activeLogic == ActiveLow) ? !value : value;
110110
// reports pin state
111-
if (value != a->lastState) {
111+
if (value != a->lastState && millis() > a->debounceTimeout) {
112112
//LOGI("processActions: ActiveChange");
113113
// execute action
114114
a->actionOn(active, a->pin, a->ref);
115115
a->lastState = value;
116+
a->debounceTimeout = millis() + DEBOUNCE_DELAY;
116117
}
117118
} else {
118119
bool active = (a->activeLogic == ActiveLow) ? !value : value;

0 commit comments

Comments
 (0)