tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
3.98k stars 1.7k forks source link

Better debug mode control in build time #75

Open tmk opened 10 years ago

tmk commented 10 years ago

If your keyboard already work well enough to make magic key combo you can use bootmagic or magic command to enable debug print. https://github.com/tmk/tmk_keyboard#magic-comannds

If you are during early development stage and the keyboard doen't work yet there is no handy options of build at this moment you need to place code like below somewhere.

debug_config.enable = true; // to enable debug print
debug_config.matrix = true; // to enable matrix print
debug_config.keyboard = true;  // to enable keyboard report print
debug_config.mouse = true;  // to enable mouse report print

Some idea for better way:

tmk commented 9 years ago

If boot magic is enabled it overrides debug config in matrix_init() like:

debug_enable = true;
debug_keyboard = true;

In keyboard_init() bootmagic() is called after matrix_init() is executed. https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/common/keyboard.c#L71-L93

void keyboard_init(void)             
{    
    timer_init();
    matrix_init();
#ifdef PS2_MOUSE_ENABLE
    ps2_mouse_init();
#endif                               
#ifdef SERIAL_MOUSE_ENABLE
    serial_mouse_init();             
#endif 
#ifdef ADB_MOUSE_ENABLE
    adb_mouse_init();                
#endif

#ifdef BOOTMAGIC_ENABLE
    bootmagic();
#endif      

#ifdef BACKLIGHT_ENABLE
    backlight_init();
#endif      
} 

WORKAROUND: Disable bootmgaic in Makefile so that debug config in matrix_init() isn't overidden.

TODO: Place for init code for each project so user can set debug config temprarily and run project specific codes. The palce should be after bootmagic() to avoid the override.

njbair commented 8 years ago

TODO: Place for init code for each project so user can set debug config temprarily and run project specific codes. The palce should be after bootmagic() to avoid the override.

It seems like this functionality is provided by hook_keyboard_init() in the newapi branch (#304), is that correct?

tmk commented 8 years ago

True. Using that hook is way better than matrix_init.

Also options for debug print control in Makefile or config.h would be useful.