Skip to content

Commit

Permalink
Fixup housekeeping from being invoked twice per loop. (#12933)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc authored May 18, 2021
1 parent 6cdc996 commit 58142f0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
12 changes: 9 additions & 3 deletions tmk_core/common/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ __attribute__((weak)) void housekeeping_task_kb(void) {}
*/
__attribute__((weak)) void housekeeping_task_user(void) {}

/** \brief housekeeping_task
*
* Invokes hooks for executing code after QMK is done after each loop iteration.
*/
void housekeeping_task(void) {
housekeeping_task_kb();
housekeeping_task_user();
}

/** \brief keyboard_init
*
* FIXME: needs doc
Expand Down Expand Up @@ -374,9 +383,6 @@ void keyboard_task(void) {
bool encoders_changed = false;
#endif

housekeeping_task_kb();
housekeeping_task_user();

uint8_t matrix_changed = matrix_scan();
if (matrix_changed) last_matrix_activity_trigger();

Expand Down
5 changes: 3 additions & 2 deletions tmk_core/common/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ void keyboard_pre_init_user(void);
void keyboard_post_init_kb(void);
void keyboard_post_init_user(void);

void housekeeping_task_kb(void);
void housekeeping_task_user(void);
void housekeeping_task(void); // To be executed by the main loop in each backend TMK protocol
void housekeeping_task_kb(void); // To be overridden by keyboard-level code
void housekeeping_task_user(void); // To be overridden by user/keymap-level code

uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder activity
uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder activity
Expand Down
3 changes: 3 additions & 0 deletions tmk_core/protocol/arm_atsam/main_arm_atsam.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ int main(void) {
// dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired);
}
#endif // CONSOLE_ENABLE

// Run housekeeping
housekeeping_task();
}

return 1;
Expand Down
3 changes: 1 addition & 2 deletions tmk_core/protocol/chibios/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ int main(void) {
#endif

// Run housekeeping
housekeeping_task_kb();
housekeeping_task_user();
housekeeping_task();
}
}
3 changes: 1 addition & 2 deletions tmk_core/protocol/lufa/lufa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,7 @@ int main(void) {
#endif

// Run housekeeping
housekeeping_task_kb();
housekeeping_task_user();
housekeeping_task();
}
}

Expand Down
3 changes: 1 addition & 2 deletions tmk_core/protocol/vusb/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ int main(void) {
#endif

// Run housekeeping
housekeeping_task_kb();
housekeeping_task_user();
housekeeping_task();
}
}
}

0 comments on commit 58142f0

Please sign in to comment.