]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Add NO_PRINT and NO_DEBUG config options.
authortmk <nobody@nowhere>
Tue, 19 Mar 2013 05:08:40 +0000 (14:08 +0900)
committertmk <nobody@nowhere>
Tue, 19 Mar 2013 05:08:40 +0000 (14:08 +0900)
- NO_PRINT: disable print.h API(also disable debug.h)
- NO_DEBUG: disable debug.h API

common.mk
common/command.c
common/debug.h
common/keyboard.c
common/print.c
common/print.h
keyboard/gh60/config.h

index 4054893b44768945cc587a419166d85e7ba8cddf..2ce4e32da50a48d6e5bab4ddc88a384e67905841 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -31,6 +31,9 @@ endif
 
 ifdef CONSOLE_ENABLE
     OPT_DEFS += -DCONSOLE_ENABLE
+else
+    OPT_DEFS += -DNO_PRINT
+    OPT_DEFS += -DNO_DEBUG
 endif
 
 ifdef NKRO_ENABLE
index 372ca291e2cf4e0417f8f744921987134b5b153d..cb98e1d5f206803fbcc84cb2266aebaeed564502 100644 (file)
@@ -98,7 +98,6 @@ bool command_extra(uint8_t code)
  ***********************************************************/
 static void command_common_help(void)
 {
-    print_enable = true;
     print("\n\n----- Command Help -----\n");
     print("c:  enter console mode\n");
     print("d:  toggle debug enable\n");
@@ -137,7 +136,8 @@ static void print_eeprom_config(void)
     eebyte = eeconfig_read_keyconf();
     print("keyconf: "); print_hex8(eebyte); print("\n");
 
-    keyconf kc = (keyconf){ .raw = eebyte };
+    keyconf kc;
+    kc = (keyconf){ .raw = eebyte };
     print("keyconf.swap_control_capslock: "); print_hex8(kc.swap_control_capslock); print("\n");
     print("keyconf.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n");
     print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n");
@@ -173,7 +173,6 @@ static bool command_common(uint8_t code)
             command_common_help();
             break;
         case KC_C:
-            print_enable = true;
             debug_matrix   = false;
             debug_keyboard = false;
             debug_mouse    = false;
@@ -239,15 +238,6 @@ static bool command_common(uint8_t code)
         case KC_T: // print timer
             print_val_hex32(timer_count);
             break;
-        case KC_P: // print toggle
-            if (print_enable) {
-                print("print disabled.\n");
-                print_enable = false;
-            } else {
-                print_enable = true;
-                print("print enabled.\n");
-            }
-            break;
         case KC_S:
             print("\n\n----- Status -----\n");
             print_val_hex8(host_keyboard_leds());
@@ -320,7 +310,6 @@ static bool command_common(uint8_t code)
  ***********************************************************/
 static void command_console_help(void)
 {
-    print_enable = true;
     print("\n\n----- Console Help -----\n");
     print("ESC/q:      quit\n");
 #ifdef MOUSEKEY_ENABLE
index e63d46f0e9e0dbd398da756b45a7d0218f939f8c..e16ea14af4053786b23cbbb0b5f7042f0bdf4eeb 100644 (file)
@@ -22,6 +22,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "print.h"
 
 
+#ifndef NO_DEBUG
+
 #define debug(s)                  do { if (debug_enable) print(s); } while (0)
 #define debugln(s)                do { if (debug_enable) println(s); } while (0)
 #define debug_S(s)                do { if (debug_enable) print_S(s); } while (0)
@@ -31,9 +33,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
         print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \
     } \
 } while (0)
-
-    
-
 #define debug_dec(data)           do { if (debug_enable) print_dec(data); } while (0)
 #define debug_decs(data)          do { if (debug_enable) print_decs(data); } while (0)
 #define debug_hex4(data)          do { if (debug_enable) print_hex4(data); } while (0)
@@ -46,11 +45,35 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define debug_bin_reverse8(data)  do { if (debug_enable) print_bin_reverse8(data); } while (0)
 #define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0)
 #define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0)
-
 #define debug_hex(data)           debug_hex8(data)
 #define debug_bin(data)           debug_bin8(data)
 #define debug_bin_reverse(data)   debug_bin8(data)
 
+#else
+
+#define debug(s)
+#define debugln(s)
+#define debug_S(s)
+#define debug_P(s)
+#define debug_msg(s)
+#define debug_dec(data)
+#define debug_decs(data)
+#define debug_hex4(data)
+#define debug_hex8(data)
+#define debug_hex16(data)
+#define debug_hex32(data)
+#define debug_bin8(data)
+#define debug_bin16(data)
+#define debug_bin32(data)
+#define debug_bin_reverse8(data)
+#define debug_bin_reverse16(data)
+#define debug_bin_reverse32(data)
+#define debug_hex(data)
+#define debug_bin(data)
+#define debug_bin_reverse(data)
+
+#endif
+
 
 #ifdef __cplusplus
 extern "C" {
index 42c57ac96fad956d8ed323afb2f10443538ab14e..cb0dc06e60903285ebe976eac0e8e3d1706fd53d 100644 (file)
@@ -54,7 +54,7 @@ static bool has_ghost_in_row(uint8_t row)
 void keyboard_init(void)
 {
     // TODO: configuration of sendchar impl
-    print_sendchar_func = sendchar;
+    print_set_sendchar(sendchar);
 
     timer_init();
     matrix_init();
index 08d211f206a81a7b5b27ebe019e2263da76cf67a..329f835125ac569397a256b517a78e35cc079c9f 100644 (file)
 #include "print.h"
 
 
-#define sendchar(c)    do { if (print_enable && print_sendchar_func) (print_sendchar_func)(c); } while (0)
+#ifndef NO_PRINT
 
+#define sendchar(c)    do { if (print_sendchar_func) (print_sendchar_func)(c); } while (0)
 
-int8_t (*print_sendchar_func)(uint8_t) = 0;
-bool print_enable = true;
 
+static int8_t (*print_sendchar_func)(uint8_t) = 0;
+
+void print_set_sendchar(int8_t (*sendchar_func)(uint8_t))
+{
+    print_sendchar_func = sendchar_func;
+}
 
 /* print string stored in data memory(SRAM)
  *     print_P("hello world");
@@ -184,3 +189,5 @@ void print_bin_reverse32(uint32_t data)
     print_bin_reverse8(data>>16);
     print_bin_reverse8(data>>24);
 }
+
+#endif
index b22509477fb903175bc348512381f2a0f7f32281..80858b3bc519b97ce2fee33fd5f0cda0fe0494ef 100644 (file)
 #include <avr/pgmspace.h>
 
 
-// avoid collision with arduino/Print.h
-#ifndef __cplusplus
 // this macro allows you to write print("some text") and
 // the string is automatically placed into flash memory :)
+// TODO: avoid collision with arduino/Print.h
+#ifndef __cplusplus
 #define print(s)                print_P(PSTR(s))
 #endif
-
 #define println(s)              print_P(PSTR(s "\n"))
 
 /* for old name */
 #define pbin_reverse(data)      print_bin_reverse8(data)
 #define pbin_reverse16(data)    print_bin_reverse16(data)
 
-
 /* print value utility */
-#define print_val_dec(v)          do { print_P(PSTR(#v ": ")); print_dec(v);  print_P(PSTR("\n")); } while (0)
+#define print_val_dec(v)           do { print_P(PSTR(#v ": ")); print_dec(v);  print_P(PSTR("\n")); } while (0)
 #define print_val_decs(v)          do { print_P(PSTR(#v ": ")); print_decs(v);  print_P(PSTR("\n")); } while (0)
-
 #define print_val_hex8(v)          do { print_P(PSTR(#v ": ")); print_hex8(v);  print_P(PSTR("\n")); } while (0)
 #define print_val_hex16(v)         do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0)
 #define print_val_hex32(v)         do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0)
-
 #define print_val_bin8(v)          do { print_P(PSTR(#v ": ")); print_bin8(v);  print_P(PSTR("\n")); } while (0)
 #define print_val_bin16(v)         do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0)
 #define print_val_bin32(v)         do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0)
 
 
 
+#ifndef NO_PRINT
+
 #ifdef __cplusplus
 extern "C" {
 #endif
-
 /* function pointer of sendchar to be used by print utility */
-extern int8_t (*print_sendchar_func)(uint8_t);
-extern bool print_enable;
+void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
 
 /* print string stored in data memory(SRAM) */
 void print_S(const char *s);
@@ -100,9 +96,31 @@ void print_bin32(uint32_t data);
 void print_bin_reverse8(uint8_t data);
 void print_bin_reverse16(uint16_t data);
 void print_bin_reverse32(uint32_t data);
-
 #ifdef __cplusplus
 }
 #endif
 
+#else
+
+#define print_set_sendchar(func)
+#define print_S(s)
+#define print_P(s)
+#define print_CRLF()
+#define print_dec(data)
+#define print_decs(data)
+#define print_hex4(data)
+#define print_hex8(data)
+#define print_hex16(data)
+#define print_hex32(data)
+#define print_bin4(data)
+#define print_bin8(data)
+#define print_bin16(data)
+#define print_bin32(data)
+#define print_bin_reverse8(data)
+#define print_bin_reverse16(data)
+#define print_bin_reverse32(data)
+
+#endif
+
+
 #endif
index 38d88eecc4b569e5ab1618982837592e0fefd81a..64a080e1c2bf1ef2152e1cf8bcb12ecf65a25bf0 100644 (file)
@@ -56,5 +56,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #define BOOTLOADER_SIZE 4096
 
+/* disable debug print */
+//#define NO_DEBUG
+
+/* disable print */
+//#define NO_PRINT
 
 #endif