mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-21 15:12:02 +00:00
Fixed the issue that the tide65 keyboard does not work properly when powered by battery only in wired mode
This commit is contained in:
parent
49060b5f89
commit
8af4355646
@ -27,11 +27,13 @@
|
|||||||
#define HS_RGB_BLINK_INDEX_BT2 42
|
#define HS_RGB_BLINK_INDEX_BT2 42
|
||||||
#define HS_RGB_BLINK_INDEX_BT3 41
|
#define HS_RGB_BLINK_INDEX_BT3 41
|
||||||
#define HS_RGB_BLINK_INDEX_2G4 34
|
#define HS_RGB_BLINK_INDEX_2G4 34
|
||||||
|
#define HS_RGB_BLINK_INDEX_USB 39
|
||||||
|
|
||||||
#define HS_LBACK_COLOR_BT1 RGB_BLUE
|
#define HS_LBACK_COLOR_BT1 RGB_BLUE
|
||||||
#define HS_LBACK_COLOR_BT2 RGB_BLUE
|
#define HS_LBACK_COLOR_BT2 RGB_BLUE
|
||||||
#define HS_LBACK_COLOR_BT3 RGB_BLUE
|
#define HS_LBACK_COLOR_BT3 RGB_BLUE
|
||||||
#define HS_LBACK_COLOR_2G4 RGB_GREEN
|
#define HS_LBACK_COLOR_2G4 RGB_GREEN
|
||||||
|
#define HS_LBACK_COLOR_UBS RGB_WHITE
|
||||||
|
|
||||||
#define HS_PAIR_COLOR_BT1 RGB_BLUE
|
#define HS_PAIR_COLOR_BT1 RGB_BLUE
|
||||||
#define HS_PAIR_COLOR_BT2 RGB_BLUE
|
#define HS_PAIR_COLOR_BT2 RGB_BLUE
|
||||||
|
@ -194,13 +194,13 @@
|
|||||||
"val" :153,
|
"val" :153,
|
||||||
"speed" :204
|
"speed" :204
|
||||||
},
|
},
|
||||||
"sleep": false,
|
"sleep": true,
|
||||||
"timeout": 300000
|
"timeout": 60000
|
||||||
},
|
},
|
||||||
"tap_keycode_delay": 10,
|
"tap_keycode_delay": 10,
|
||||||
"url": "https://www.epomaker.com",
|
"url": "https://www.epomaker.com",
|
||||||
"usb": {
|
"usb": {
|
||||||
"device_version": "0.2.0",
|
"device_version": "0.3.0",
|
||||||
"force_nkro": true,
|
"force_nkro": true,
|
||||||
"pid": "0xE463",
|
"pid": "0xE463",
|
||||||
"suspend_wakeup_delay": 1000,
|
"suspend_wakeup_delay": 1000,
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#ifdef WIRELESS_ENABLE
|
#ifdef WIRELESS_ENABLE
|
||||||
# include "wireless.h"
|
# include "wireless.h"
|
||||||
|
# include "usb_main.h"
|
||||||
|
# include "lowpower.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
@ -56,6 +58,7 @@ bool charging_state = false;
|
|||||||
bool bat_full_flag = false;
|
bool bat_full_flag = false;
|
||||||
bool enable_bat_indicators = true;
|
bool enable_bat_indicators = true;
|
||||||
uint32_t bat_indicator_cnt = true;
|
uint32_t bat_indicator_cnt = true;
|
||||||
|
static uint32_t ee_clr_timer = 0;
|
||||||
|
|
||||||
void eeconfig_confinfo_update(uint32_t raw) {
|
void eeconfig_confinfo_update(uint32_t raw) {
|
||||||
|
|
||||||
@ -99,8 +102,8 @@ void keyboard_post_init_kb(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USB_POWER_EN_PIN
|
#ifdef USB_POWER_EN_PIN
|
||||||
gpio_set_pin_output(USB_POWER_EN_PIN);
|
|
||||||
gpio_write_pin_low(USB_POWER_EN_PIN);
|
gpio_write_pin_low(USB_POWER_EN_PIN);
|
||||||
|
gpio_set_pin_output(USB_POWER_EN_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HS_BAT_CABLE_PIN
|
#ifdef HS_BAT_CABLE_PIN
|
||||||
@ -113,6 +116,7 @@ void keyboard_post_init_kb(void) {
|
|||||||
|
|
||||||
#ifdef WIRELESS_ENABLE
|
#ifdef WIRELESS_ENABLE
|
||||||
wireless_init();
|
wireless_init();
|
||||||
|
wireless_devs_change(!confinfo.devs, confinfo.devs, false);
|
||||||
post_init_timer = timer_read32();
|
post_init_timer = timer_read32();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -153,6 +157,15 @@ void suspend_wakeup_init_kb(void) {
|
|||||||
suspend_wakeup_init_user();
|
suspend_wakeup_init_user();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lpwr_is_allow_timeout_hook(void) {
|
||||||
|
|
||||||
|
if (wireless_get_current_devs() == DEVS_USB) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void wireless_post_task(void) {
|
void wireless_post_task(void) {
|
||||||
|
|
||||||
// auto switching devs
|
// auto switching devs
|
||||||
@ -269,8 +282,10 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
|||||||
|
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case EE_CLR:{
|
case EE_CLR:{
|
||||||
if (record->event.pressed){
|
if (record->event.pressed) {
|
||||||
hs_reset_settings();
|
ee_clr_timer = timer_read32();
|
||||||
|
} else {
|
||||||
|
ee_clr_timer = 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
@ -587,7 +602,7 @@ void bat_indicators(void) {
|
|||||||
} else if (charging_state) {
|
} else if (charging_state) {
|
||||||
|
|
||||||
battery_process_time = 0;
|
battery_process_time = 0;
|
||||||
rgb_matrix_hs_bat_set(HS_MATRIX_BLINK_INDEX_BAT, (RGB){RGB_RED}, 300, 0xFF);
|
rgb_matrix_set_color(HS_MATRIX_BLINK_INDEX_BAT, RGB_RED);
|
||||||
} else if (*md_getp_bat() <= BATTERY_CAPACITY_LOW) {
|
} else if (*md_getp_bat() <= BATTERY_CAPACITY_LOW) {
|
||||||
|
|
||||||
rgb_matrix_hs_bat_set(HS_MATRIX_BLINK_INDEX_BAT, (RGB){RGB_RED}, 250, 1);
|
rgb_matrix_hs_bat_set(HS_MATRIX_BLINK_INDEX_BAT, (RGB){RGB_RED}, 250, 1);
|
||||||
@ -654,28 +669,55 @@ bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host_keyboard_led_state().caps_lock)
|
if (ee_clr_timer && timer_elapsed32(ee_clr_timer) > 3000) {
|
||||||
rgb_matrix_set_color(HS_RGB_INDEX_CAPS, RGB_WHITE);
|
hs_reset_settings();
|
||||||
|
ee_clr_timer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!keymap_is_mac_system() && keymap_config.no_gui)
|
extern RGB rgb_matrix_ws2812_array[HS_RGB_INDICATOR_COUNT];
|
||||||
rgb_matrix_set_color(HS_RGB_INDEX_WIN_LOCK, RGB_WHITE);
|
|
||||||
|
|
||||||
|
uint8_t r,g,b;
|
||||||
|
r = rgb_matrix_ws2812_array[1].r;
|
||||||
|
g = rgb_matrix_ws2812_array[1].g;
|
||||||
|
b = rgb_matrix_ws2812_array[1].b;
|
||||||
|
rgb_matrix_set_color(2,r,g,b);
|
||||||
|
|
||||||
|
if ((*md_getp_state() == MD_STATE_CONNECTED) || USB_DRIVER.state == USB_ACTIVE)
|
||||||
|
{
|
||||||
|
if (host_keyboard_led_state().caps_lock)
|
||||||
|
rgb_matrix_set_color(HS_RGB_INDEX_CAPS, RGB_WHITE);
|
||||||
|
|
||||||
|
if (!keymap_is_mac_system() && keymap_config.no_gui)
|
||||||
|
rgb_matrix_set_color(HS_RGB_INDEX_WIN_LOCK, RGB_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef WIRELESS_ENABLE
|
# ifdef WIRELESS_ENABLE
|
||||||
rgb_matrix_wls_indicator();
|
rgb_matrix_wls_indicator();
|
||||||
|
|
||||||
if (enable_bat_indicators) {
|
if (enable_bat_indicators && !inqbat_flag) {
|
||||||
rgb_matrix_hs_bat();
|
rgb_matrix_hs_bat();
|
||||||
bat_indicators();
|
bat_indicators();
|
||||||
bat_indicator_cnt = timer_read32();
|
bat_indicator_cnt = timer_read32();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!enable_bat_indicators){
|
if (!enable_bat_indicators) {
|
||||||
if(timer_elapsed32(bat_indicator_cnt) > 3000){
|
if (timer_elapsed32(bat_indicator_cnt) > 2000){
|
||||||
enable_bat_indicators = true;
|
enable_bat_indicators = true;
|
||||||
bat_indicator_cnt = timer_read32();
|
bat_indicator_cnt = timer_read32();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (confinfo.devs == DEVS_USB){
|
||||||
|
if (USB_DRIVER.state != USB_ACTIVE) {
|
||||||
|
if(enable_bat_indicators){
|
||||||
|
rgb_matrix_hs_indicator_set(HS_RGB_BLINK_INDEX_USB, (RGB){HS_LBACK_COLOR_UBS}, 500, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
lpwr_set_state(LPWR_WAKEUP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
rgb_matrix_hs_indicator();
|
rgb_matrix_hs_indicator();
|
||||||
@ -720,6 +762,10 @@ void hs_reset_settings(void) {
|
|||||||
eeconfig_update_keymap(keymap_config.raw);
|
eeconfig_update_keymap(keymap_config.raw);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIRELESS_ENABLE)
|
||||||
|
wireless_devs_change(wireless_get_current_devs(), DEVS_USB, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hs_reset_settings_user() != true) {
|
if (hs_reset_settings_user() != true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "lowpower.h"
|
#include "wireless.h"
|
||||||
|
#include "usb_main.h"
|
||||||
|
|
||||||
#ifndef LPWR_TIMEOUT
|
#ifndef LPWR_TIMEOUT
|
||||||
# define LPWR_TIMEOUT 300000 // 5min
|
# define LPWR_TIMEOUT 300000 // 5min
|
||||||
@ -132,6 +133,12 @@ bool lpwr_is_allow_timeout(void) {
|
|||||||
uint32_t timeout = lpwr_timeout_value_read();
|
uint32_t timeout = lpwr_timeout_value_read();
|
||||||
|
|
||||||
if (lpwr_is_allow_timeout_hook() != true) {
|
if (lpwr_is_allow_timeout_hook() != true) {
|
||||||
|
manual_timeout = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((wireless_get_current_devs() == DEVS_USB) && (USB_DRIVER.state == USB_ACTIVE)) {
|
||||||
|
manual_timeout = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
#include "usb_main.h"
|
#include "usb_main.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
|
||||||
|
#ifndef USB_POWER_DOWN_DELAY
|
||||||
|
# define USB_POWER_DOWN_DELAY 3000
|
||||||
|
#endif
|
||||||
|
|
||||||
extern host_driver_t chibios_driver;
|
extern host_driver_t chibios_driver;
|
||||||
extern host_driver_t wireless_driver;
|
extern host_driver_t wireless_driver;
|
||||||
|
|
||||||
@ -92,6 +96,7 @@ transport_t get_transport(void) {
|
|||||||
|
|
||||||
void usb_remote_wakeup(void) {
|
void usb_remote_wakeup(void) {
|
||||||
|
|
||||||
|
#ifdef USB_REMOTE_USE_QMK
|
||||||
if (USB_DRIVER.state == USB_SUSPENDED) {
|
if (USB_DRIVER.state == USB_SUSPENDED) {
|
||||||
dprintln("suspending keyboard");
|
dprintln("suspending keyboard");
|
||||||
while (USB_DRIVER.state == USB_SUSPENDED) {
|
while (USB_DRIVER.state == USB_SUSPENDED) {
|
||||||
@ -100,7 +105,7 @@ void usb_remote_wakeup(void) {
|
|||||||
/* Remote wakeup */
|
/* Remote wakeup */
|
||||||
if ((USB_DRIVER.status & 2U) && suspend_wakeup_condition()) {
|
if ((USB_DRIVER.status & 2U) && suspend_wakeup_condition()) {
|
||||||
usbWakeupHost(&USB_DRIVER);
|
usbWakeupHost(&USB_DRIVER);
|
||||||
#if USB_SUSPEND_WAKEUP_DELAY > 0
|
# if USB_SUSPEND_WAKEUP_DELAY > 0
|
||||||
// Some hubs, kvm switches, and monitors do
|
// Some hubs, kvm switches, and monitors do
|
||||||
// weird things, with USB device state bouncing
|
// weird things, with USB device state bouncing
|
||||||
// around wildly on wakeup, yielding race
|
// around wildly on wakeup, yielding race
|
||||||
@ -108,9 +113,55 @@ void usb_remote_wakeup(void) {
|
|||||||
//
|
//
|
||||||
// Pause for a while to let things settle...
|
// Pause for a while to let things settle...
|
||||||
wait_ms(USB_SUSPEND_WAKEUP_DELAY);
|
wait_ms(USB_SUSPEND_WAKEUP_DELAY);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Woken up */
|
/* Woken up */
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static uint32_t suspend_timer = 0x00;
|
||||||
|
|
||||||
|
if ((USB_DRIVER.state == USB_SUSPENDED)) {
|
||||||
|
if (!suspend_timer) suspend_timer = sync_timer_read32();
|
||||||
|
if (sync_timer_elapsed32(suspend_timer) >= USB_POWER_DOWN_DELAY) {
|
||||||
|
suspend_timer = 0x00;
|
||||||
|
suspend_power_down();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
suspend_timer = 0x00;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USB_REMOTE_USE_QMK
|
||||||
|
void usb_remote_host(void) {
|
||||||
|
|
||||||
|
if (USB_DRIVER.state == USB_SUSPENDED) {
|
||||||
|
if ((USB_DRIVER.status & 2U) && suspend_wakeup_condition()) {
|
||||||
|
usbWakeupHost(&USB_DRIVER);
|
||||||
|
# if USB_SUSPEND_WAKEUP_DELAY > 0
|
||||||
|
// Some hubs, kvm switches, and monitors do
|
||||||
|
// weird things, with USB device state bouncing
|
||||||
|
// around wildly on wakeup, yielding race
|
||||||
|
// conditions that can corrupt the keyboard state.
|
||||||
|
//
|
||||||
|
// Pause for a while to let things settle...
|
||||||
|
wait_ms(USB_SUSPEND_WAKEUP_DELAY);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
# if !defined(USB_REMOTE_USE_QMK) && USB_POWER_DOWN_DELAY
|
||||||
|
suspend_wakeup_init();
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_action_kb(keyrecord_t *record) {
|
||||||
|
|
||||||
|
(void)record;
|
||||||
|
if (get_transport() == TRANSPORT_USB){
|
||||||
|
usb_remote_host();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
@ -211,15 +211,6 @@ uint8_t wireless_get_current_devs(void) {
|
|||||||
return wls_devs;
|
return wls_devs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lpwr_is_allow_timeout_hook(void) {
|
|
||||||
|
|
||||||
if (wls_devs == DEVS_USB) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wireless_pre_task(void) __attribute__((weak));
|
void wireless_pre_task(void) __attribute__((weak));
|
||||||
void wireless_pre_task(void) {}
|
void wireless_pre_task(void) {}
|
||||||
|
|
||||||
@ -252,4 +243,4 @@ void wireless_task(void) {
|
|||||||
void housekeeping_task_kb(void) {
|
void housekeeping_task_kb(void) {
|
||||||
|
|
||||||
wireless_task();
|
wireless_task();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user