X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=tmk_core%2Fcommon%2Fcommand.c;h=d3884d9fa9725d9e3839be04ff7542ad78f8e824;hb=207e50c5347adeb6d66c092d5f41d7dc52d4a166;hp=b4cd3ca56b9dc87e6dd342dfbc7d4652b13ba80e;hpb=7635958270964c9685134396c2350449f819d463;p=qmk_firmware.git diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index b4cd3ca56..d3884d9fa 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c @@ -16,7 +16,7 @@ along with this program. If not, see . */ #include #include -#include +#include "wait.h" #include "keycode.h" #include "host.h" #include "keymap.h" @@ -33,22 +33,28 @@ along with this program. If not, see . #include "led.h" #include "command.h" #include "backlight.h" +#include "quantum.h" +#include "version.h" #ifdef MOUSEKEY_ENABLE #include "mousekey.h" #endif #ifdef PROTOCOL_PJRC -# include "usb_keyboard.h" -# ifdef EXTRAKEY_ENABLE -# include "usb_extra.h" -# endif + #include "usb_keyboard.h" + #ifdef EXTRAKEY_ENABLE + #include "usb_extra.h" + #endif #endif #ifdef PROTOCOL_VUSB -# include "usbdrv.h" + #include "usbdrv.h" #endif +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif /* AUDIO_ENABLE */ + static bool command_common(uint8_t code); static void command_common_help(void); @@ -61,7 +67,6 @@ static bool mousekey_console(uint8_t code); static void mousekey_console_help(void); #endif -static uint8_t numkey2num(uint8_t code); static void switch_default_layer(uint8_t layer); @@ -99,12 +104,14 @@ bool command_proc(uint8_t code) bool command_extra(uint8_t code) __attribute__ ((weak)); bool command_extra(uint8_t code) { + (void)code; return false; } bool command_console_extra(uint8_t code) __attribute__ ((weak)); bool command_console_extra(uint8_t code) { + (void)code; return false; } @@ -122,7 +129,7 @@ static void command_common_help(void) STR(MAGIC_KEY_VERSION ) ": Version\n" STR(MAGIC_KEY_STATUS ) ": Status\n" STR(MAGIC_KEY_CONSOLE ) ": Activate Console Mode\n" - + #if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM STR(MAGIC_KEY_LAYER0 ) ": Switch to Layer 0\n" STR(MAGIC_KEY_LAYER1 ) ": Switch to Layer 1\n" @@ -136,25 +143,25 @@ static void command_common_help(void) STR(MAGIC_KEY_LAYER9 ) ": Switch to Layer 9\n" #endif -#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS +#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS "F1-F10: Switch to Layer 0-9 (F10 = L0)\n" #endif -#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS +#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS "0-9: Switch to Layer 0-9\n" #endif - STR(MAGIC_KEY_LAYER0_ALT1 ) ": Switch to Layer 0 (alternate key 1)\n" - STR(MAGIC_KEY_LAYER0_ALT2 ) ": Switch to Layer 0 (alternate key 2)\n" - STR(MAGIC_KEY_BOOTLOADER ) ": Jump to Bootloader (Reset)\n" + STR(MAGIC_KEY_LAYER0_ALT ) ": Switch to Layer 0 (alternate)\n" + + STR(MAGIC_KEY_BOOTLOADER ) ": Jump to Bootloader\n" + STR(MAGIC_KEY_BOOTLOADER_ALT) ": Jump to Bootloader (alternate)\n" #ifdef KEYBOARD_LOCK_ENABLE - STR(MAGIC_KEY_LOCK ) ": Lock\n" + STR(MAGIC_KEY_LOCK ) ": Lock Keyboard\n" #endif -#ifdef BOOTMAGIC_ENABLE STR(MAGIC_KEY_EEPROM ) ": Print EEPROM Settings\n" -#endif + STR(MAGIC_KEY_EEPROM_CLEAR) ": Clear EEPROM\n" #ifdef NKRO_ENABLE STR(MAGIC_KEY_NKRO ) ": NKRO Toggle\n" @@ -174,7 +181,11 @@ static void print_version(void) print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " "VER: " STR(DEVICE_VER) "\n"); - print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n"); +#ifdef SKIP_VERSION + print("BUILD: (" __DATE__ ")\n"); +#else + print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n"); +#endif /* build options */ print("OPTIONS:" @@ -213,8 +224,11 @@ static void print_version(void) " " STR(BOOTLOADER_SIZE) "\n"); print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__) +#if defined(__AVR__) " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__ - " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n"); + " AVR_ARCH: avr" STR(__AVR_ARCH__) +#endif + "\n"); return; } @@ -225,12 +239,15 @@ static void print_status(void) print("\n\t- Status -\n"); print_val_hex8(host_keyboard_leds()); +#ifndef PROTOCOL_VUSB + // these aren't set on the V-USB protocol, so we just ignore them for now print_val_hex8(keyboard_protocol); print_val_hex8(keyboard_idle); +#endif #ifdef NKRO_ENABLE - print_val_hex8(keyboard_nkro); + print_val_hex8(keymap_config.nkro); #endif - print_val_hex32(timer_count); + print_val_hex32(timer_read32()); #ifdef PROTOCOL_PJRC print_val_hex8(UDCON); @@ -248,9 +265,12 @@ static void print_status(void) return; } -#ifdef BOOTMAGIC_ENABLE static void print_eeconfig(void) { + +// Print these variables if NO_PRINT or USER_PRINT are not defined. +#if !defined(NO_PRINT) && !defined(USER_PRINT) + print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n"); debug_config_t dc; @@ -279,9 +299,11 @@ static void print_eeconfig(void) print("backlight_config.raw: "); print_hex8(bc.raw); print("\n"); print(".enable: "); print_dec(bc.enable); print("\n"); print(".level: "); print_dec(bc.level); print("\n"); -#endif +#endif /* BACKLIGHT_ENABLE */ + +#endif /* !NO_PRINT */ + } -#endif static bool command_common(uint8_t code) { @@ -302,14 +324,17 @@ static bool command_common(uint8_t code) break; #endif -#ifdef BOOTMAGIC_ENABLE - // print stored eeprom config - case MAGIC_KC(MAGIC_KEY_EEPROM): + case MAGIC_KC(MAGIC_KEY_EEPROM): print("eeconfig:\n"); print_eeconfig(); break; -#endif + + // clear eeprom + case MAGIC_KC(MAGIC_KEY_EEPROM_CLEAR): + print("Clearing EEPROM\n"); + eeconfig_init(); + break; #ifdef KEYBOARD_LOCK_ENABLE @@ -328,8 +353,8 @@ static bool command_common(uint8_t code) #endif // print help - case MAGIC_KC(MAGIC_KEY_HELP1): - case MAGIC_KC(MAGIC_KEY_HELP2): + case MAGIC_KC(MAGIC_KEY_HELP): + case MAGIC_KC(MAGIC_KEY_HELP_ALT): command_common_help(); break; @@ -346,9 +371,15 @@ static bool command_common(uint8_t code) // jump to bootloader case MAGIC_KC(MAGIC_KEY_BOOTLOADER): + case MAGIC_KC(MAGIC_KEY_BOOTLOADER_ALT): clear_keyboard(); // clear to prevent stuck keys print("\n\nJumping to bootloader... "); - _delay_ms(1000); + #ifdef AUDIO_ENABLE + stop_all_notes(); + shutdown_user(); + #else + wait_ms(1000); + #endif bootloader_jump(); // not return break; @@ -357,9 +388,6 @@ static bool command_common(uint8_t code) debug_enable = !debug_enable; if (debug_enable) { print("\ndebug: on\n"); - debug_matrix = true; - debug_keyboard = true; - debug_mouse = true; } else { print("\ndebug: off\n"); debug_matrix = false; @@ -369,7 +397,7 @@ static bool command_common(uint8_t code) break; // debug matrix toggle - case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX): + case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX): debug_matrix = !debug_matrix; if (debug_matrix) { print("\nmatrix: on\n"); @@ -380,7 +408,7 @@ static bool command_common(uint8_t code) break; // debug keyboard toggle - case MAGIC_KC(MAGIC_KEY_DEBUG_KBD): + case MAGIC_KC(MAGIC_KEY_DEBUG_KBD): debug_keyboard = !debug_keyboard; if (debug_keyboard) { print("\nkeyboard: on\n"); @@ -416,18 +444,18 @@ static bool command_common(uint8_t code) // NKRO toggle case MAGIC_KC(MAGIC_KEY_NKRO): clear_keyboard(); // clear to prevent stuck keys - keyboard_nkro = !keyboard_nkro; - if (keyboard_nkro) + keymap_config.nkro = !keymap_config.nkro; + if (keymap_config.nkro) { print("NKRO: on\n"); - else + } else { print("NKRO: off\n"); + } break; #endif // switch layers - case MAGIC_KC(MAGIC_KEY_LAYER0_ALT1): - case MAGIC_KC(MAGIC_KEY_LAYER0_ALT2): + case MAGIC_KC(MAGIC_KEY_LAYER0_ALT): switch_default_layer(0); break; @@ -551,6 +579,8 @@ static uint8_t mousekey_param = 0; static void mousekey_param_print(void) { +// Print these variables if NO_PRINT or USER_PRINT are not defined. +#if !defined(NO_PRINT) && !defined(USER_PRINT) print("\n\t- Values -\n"); print("1: delay(*10ms): "); pdec(mk_delay); print("\n"); print("2: interval(ms): "); pdec(mk_interval); print("\n"); @@ -558,6 +588,8 @@ static void mousekey_param_print(void) print("4: time_to_max: "); pdec(mk_time_to_max); print("\n"); print("5: wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n"); print("6: wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); +#endif /* !NO_PRINT */ + } //#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n"); @@ -677,7 +709,7 @@ static void mousekey_console_help(void) "pgdown: -10\n" "\n" "speed = delta * max_speed * (repeat / time_to_max)\n"); - xprintf("where delta: cursor=%d, wheel=%d\n" + xprintf("where delta: cursor=%d, wheel=%d\n" "See http://en.wikipedia.org/wiki/Mouse_keys\n", MOUSEKEY_MOVE_DELTA, MOUSEKEY_WHEEL_DELTA); } @@ -734,10 +766,11 @@ static bool mousekey_console(uint8_t code) print("?"); return false; } - if (mousekey_param) + if (mousekey_param) { xprintf("M%d> ", mousekey_param); - else + } else { print("M>" ); + } return true; } #endif @@ -746,7 +779,7 @@ static bool mousekey_console(uint8_t code) /*********************************************************** * Utilities ***********************************************************/ -static uint8_t numkey2num(uint8_t code) +uint8_t numkey2num(uint8_t code) { switch (code) { case KC_1: return 1;