add key enable

This commit is contained in:
Steven Dan
2026-01-19 22:57:03 +08:00
parent b6349594f2
commit 7315c5f8ae

View File

@@ -746,6 +746,7 @@ void hid_button_task(chanend_t cc_mic_level, chanend_t c_hidRcvData, chanend_t c
static uint8_t leds1_val = 1; // LED off
static uint8_t is_mute_t1 = 0;
static uint8_t mute_tmr;
unsigned key_enable = 0;
uint8_t tmp = 0;
static uint8_t is_stable = 1;
@@ -859,6 +860,7 @@ void hid_button_task(chanend_t cc_mic_level, chanend_t c_hidRcvData, chanend_t c
}
port_out(p_leds, leds1_val);
port_out(p_leds2, leds2_val);
key_enable = 1;
// 模式接收完成后继续,不处理按键
} else {
// 正常的mic level命令处理
@@ -934,6 +936,7 @@ void hid_button_task(chanend_t cc_mic_level, chanend_t c_hidRcvData, chanend_t c
{
hwtimer_set_trigger_time(timer, hwtimer_get_time(timer) + KEY_POLLING_INTERVAL);
//uint32_t key_in = port_in_when_pinsneq(p_keys, PORT_UNBUFFERED, last_status);
if (key_enable == 1) {
uint32_t key_in = port_in(p_keys);
// debug_printf("event_polling: key_in=0x%08X, last_status=0x%08X, is_stable=%d, press_hold_cnt=%d\n",
// key_in, last_status, is_stable, press_hold_cnt);
@@ -1035,27 +1038,8 @@ void hid_button_task(chanend_t cc_mic_level, chanend_t c_hidRcvData, chanend_t c
else {
blink_counter = 0;
}
#if 0
if (current_mode_local == 0) {
leds2_val |= (1<<BLUE_LED_PIN); // Blue LED off
leds1_val |= 1; // Red LED off
port_out(p_leds, leds1_val);
port_out(p_leds2, leds2_val);
}
else if (current_mode_local == 1) {
leds1_val &= (~1); // Red LED on
leds2_val |= (1<<BLUE_LED_PIN); // Blue LED off
port_out(p_leds, leds1_val);
port_out(p_leds2, leds2_val);
}
else if (current_mode_local == 2) {
leds2_val &= (~(1<<BLUE_LED_PIN)); // Blue LED on
leds1_val |= 1; // Red LED off
port_out(p_leds, leds1_val);
port_out(p_leds2, leds2_val);
}
#endif
}
}
continue;
}
}