reduce redundant checks

This commit is contained in:
VeyPatch 2024-12-13 16:56:46 +01:00
commit 80682e8204

View file

@ -4,6 +4,7 @@
#include "halcyon.h"
#include "transactions.h"
#include "split_util.h"
#include "_wait.h"
__attribute__((weak)) bool module_post_init_kb(void) {
return module_post_init_user();
@ -76,30 +77,35 @@ void keyboard_post_init_kb(void) {
void housekeeping_task_kb(void) {
if (is_keyboard_master()) {
static bool synced = 0;
if(is_transport_connected() && synced == 0) {
static bool synced = false;
if (!synced) {
if(is_transport_connected()) {
transaction_rpc_send(MODULE_SYNC, sizeof(module), &module); // Sync to slave
wait_ms(10);
// Good moment to make sure the backlight wakes up after boot for both halves
backlight_wakeup();
synced = 1;
}
display_module_housekeeping_task_kb(false); // Is master so can never be the second display
}
if (!is_keyboard_master()) {
if (module_master == hlc_tft_display) {
display_module_housekeeping_task_kb(true); // If there is a display on master, become the second display
} else {
display_module_housekeeping_task_kb(false); // Otherwise be the main display
synced = true;
}
}
display_module_housekeeping_task_kb(false); // Is master so can never be the second display
}
if (!is_keyboard_master()) {
display_module_housekeeping_task_kb(module_master == hlc_tft_display);
}
// Backlight feature
if (backlight_off && last_input_activity_elapsed() <= HLC_BACKLIGHT_TIMEOUT) {
if (last_input_activity_elapsed() <= HLC_BACKLIGHT_TIMEOUT) {
if (backlight_off) {
backlight_wakeup();
}
if (!backlight_off && last_input_activity_elapsed() > HLC_BACKLIGHT_TIMEOUT) {
} else {
if (!backlight_off) {
backlight_suspend();
}
}
module_housekeeping_task_kb();