Skip to content

Commit

Permalink
fix sleep issues on slower boards
Browse files Browse the repository at this point in the history
  • Loading branch information
adi4086 committed Jun 11, 2024
1 parent 2747fa3 commit 9a14509
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion keyboards/nuphy/air75_v2/ansi/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool pre_process_record_kb(uint16_t keycode, keyrecord_t *record) {
// wake up immediately
if (f_wakeup_prepare) {
exit_light_sleep(false);
f_wakeup_prepare = 0;
// f_wakeup_prepare = 0;
}

if (!pre_process_record_user(keycode, record)) {
Expand Down
2 changes: 1 addition & 1 deletion keyboards/nuphy/air75_v2/ansi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define WS2812_SPI_USE_CIRCULAR_BUFFER
#define EECONFIG_KB_DATA_SIZE 12
#define MCU_SLEEP_ENABLE 1
#define GPIO_INPUT_PIN_DELAY 1
#define GPIO_INPUT_PIN_DELAY 6
#define RF_QUEUE_SIZE 64

#define RGB_MATRIX_DISABLE_KEYCODES
19 changes: 10 additions & 9 deletions keyboards/nuphy/air75_v2/ansi/mcu_pwr.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static bool f_usb_deinit = 0;
static bool rgb_led_on = 0;
static bool side_led_on = 0;

// void clear_report_buffer_and_queue(void);
void clear_report_buffer_and_queue(void);
void clear_report_buffer(void);

#if (MCU_SLEEP_ENABLE)
Expand Down Expand Up @@ -92,8 +92,8 @@ void enter_light_sleep(void) {
}

led_pwr_sleep_handle();
break_all_key();
// clear_report_buffer_and_queue();
// break_all_key();
clear_report_buffer_and_queue();
}

/**
Expand Down Expand Up @@ -175,6 +175,12 @@ void enter_deep_sleep(void) {
* @note This is Nuphy's "open sourced" wake logic with some modifications. It's not deep sleep.
*/
void exit_light_sleep(bool stm32_init) {

// Resume normal operations
no_act_time = 0;
f_rf_sleep = 0;
f_wakeup_prepare = 0;

// Power on LEDs
led_pwr_wake_handle();
#if (MCU_SLEEP_ENABLE)
Expand Down Expand Up @@ -230,15 +236,10 @@ void exit_deep_sleep(void) {
// dev_info.rf_state = RF_DISCONNECT;
rf_disconnect_delay = 0xff;
rf_link_show_time = 250;
// rf_linking_time = 0;
rf_linking_time = 0;

// wait_us(1);

// Resume normal operations
no_act_time = 0;
f_rf_sleep = 0;
f_wakeup_prepare = 0;

exit_light_sleep(true);
}

Expand Down
2 changes: 1 addition & 1 deletion keyboards/nuphy/air96_v2/ansi/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bool pre_process_record_kb(uint16_t keycode, keyrecord_t *record) {
// wake up immediately
if (f_wakeup_prepare) {
exit_light_sleep(false);
f_wakeup_prepare = 0;
// f_wakeup_prepare = 0;
}

if (!pre_process_record_user(keycode, record)) {
Expand Down
2 changes: 1 addition & 1 deletion keyboards/nuphy/air96_v2/ansi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#define EECONFIG_KB_DATA_SIZE 12
#define MCU_SLEEP_ENABLE 1
#define GPIO_INPUT_PIN_DELAY 1
#define GPIO_INPUT_PIN_DELAY 6
#define RF_QUEUE_SIZE 64

#define RGB_MATRIX_DISABLE_KEYCODES
19 changes: 10 additions & 9 deletions keyboards/nuphy/air96_v2/ansi/mcu_pwr.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static bool f_usb_deinit = 0;
static bool rgb_led_on = 0;

// void clear_report_buffer_and_queue(void);
void clear_report_buffer_and_queue(void);
void clear_report_buffer(void);

#if (MCU_SLEEP_ENABLE)
Expand Down Expand Up @@ -95,8 +95,8 @@ void enter_light_sleep(void) {
}

led_pwr_sleep_handle();
break_all_key();
// clear_report_buffer_and_queue();
// break_all_key();
clear_report_buffer_and_queue();
}

/**
Expand Down Expand Up @@ -186,6 +186,12 @@ void enter_deep_sleep(void) {
* @note This is Nuphy's "open sourced" wake logic with some modifications. It's not deep sleep.
*/
void exit_light_sleep(bool stm32_init) {

// Resume normal operations
no_act_time = 0;
f_rf_sleep = 0;
f_wakeup_prepare = 0;

// Power on LEDs
led_pwr_wake_handle();

Expand Down Expand Up @@ -246,15 +252,10 @@ void exit_deep_sleep(void) {
// dev_info.rf_state = RF_DISCONNECT;
rf_disconnect_delay = 0xff;
rf_link_show_time = 250;
// rf_linking_time = 0;
rf_linking_time = 0;

// wait_us(1);

// Resume normal operations
no_act_time = 0;
f_rf_sleep = 0;
f_wakeup_prepare = 0;

exit_light_sleep(true);
}

Expand Down

0 comments on commit 9a14509

Please sign in to comment.