Browse Source

Add NO_PRINT and NO_DEBUG config options.

- NO_PRINT: disable print.h API(also disable debug.h)
- NO_DEBUG: disable debug.h API
tags/v1.9
tmk 11 years ago
parent
commit
9a106537f6
7 changed files with 77 additions and 32 deletions
  1. 3
    0
      common.mk
  2. 2
    13
      common/command.c
  3. 27
    4
      common/debug.h
  4. 1
    1
      common/keyboard.c
  5. 10
    3
      common/print.c
  6. 29
    11
      common/print.h
  7. 5
    0
      keyboard/gh60/config.h

+ 3
- 0
common.mk View File



ifdef CONSOLE_ENABLE ifdef CONSOLE_ENABLE
OPT_DEFS += -DCONSOLE_ENABLE OPT_DEFS += -DCONSOLE_ENABLE
else
OPT_DEFS += -DNO_PRINT
OPT_DEFS += -DNO_DEBUG
endif endif


ifdef NKRO_ENABLE ifdef NKRO_ENABLE

+ 2
- 13
common/command.c View File

***********************************************************/ ***********************************************************/
static void command_common_help(void) static void command_common_help(void)
{ {
print_enable = true;
print("\n\n----- Command Help -----\n"); print("\n\n----- Command Help -----\n");
print("c: enter console mode\n"); print("c: enter console mode\n");
print("d: toggle debug enable\n"); print("d: toggle debug enable\n");
eebyte = eeconfig_read_keyconf(); eebyte = eeconfig_read_keyconf();
print("keyconf: "); print_hex8(eebyte); print("\n"); 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.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.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n");
print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n"); print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n");
command_common_help(); command_common_help();
break; break;
case KC_C: case KC_C:
print_enable = true;
debug_matrix = false; debug_matrix = false;
debug_keyboard = false; debug_keyboard = false;
debug_mouse = false; debug_mouse = false;
case KC_T: // print timer case KC_T: // print timer
print_val_hex32(timer_count); print_val_hex32(timer_count);
break; 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: case KC_S:
print("\n\n----- Status -----\n"); print("\n\n----- Status -----\n");
print_val_hex8(host_keyboard_leds()); print_val_hex8(host_keyboard_leds());
***********************************************************/ ***********************************************************/
static void command_console_help(void) static void command_console_help(void)
{ {
print_enable = true;
print("\n\n----- Console Help -----\n"); print("\n\n----- Console Help -----\n");
print("ESC/q: quit\n"); print("ESC/q: quit\n");
#ifdef MOUSEKEY_ENABLE #ifdef MOUSEKEY_ENABLE

+ 27
- 4
common/debug.h View File

#include "print.h" #include "print.h"




#ifndef NO_DEBUG

#define debug(s) do { if (debug_enable) print(s); } while (0) #define debug(s) do { if (debug_enable) print(s); } while (0)
#define debugln(s) do { if (debug_enable) println(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) #define debug_S(s) do { if (debug_enable) print_S(s); } while (0)
print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \ print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \
} \ } \
} while (0) } while (0)


#define debug_dec(data) do { if (debug_enable) print_dec(data); } 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_decs(data) do { if (debug_enable) print_decs(data); } while (0)
#define debug_hex4(data) do { if (debug_enable) print_hex4(data); } while (0) #define debug_hex4(data) do { if (debug_enable) print_hex4(data); } while (0)
#define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0) #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_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_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0)

#define debug_hex(data) debug_hex8(data) #define debug_hex(data) debug_hex8(data)
#define debug_bin(data) debug_bin8(data) #define debug_bin(data) debug_bin8(data)
#define debug_bin_reverse(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 #ifdef __cplusplus
extern "C" { extern "C" {

+ 1
- 1
common/keyboard.c View File

void keyboard_init(void) void keyboard_init(void)
{ {
// TODO: configuration of sendchar impl // TODO: configuration of sendchar impl
print_sendchar_func = sendchar;
print_set_sendchar(sendchar);


timer_init(); timer_init();
matrix_init(); matrix_init();

+ 10
- 3
common/print.c View File

#include "print.h" #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 string stored in data memory(SRAM)
* print_P("hello world"); * print_P("hello world");
print_bin_reverse8(data>>16); print_bin_reverse8(data>>16);
print_bin_reverse8(data>>24); print_bin_reverse8(data>>24);
} }

#endif

+ 29
- 11
common/print.h View File

#include <avr/pgmspace.h> #include <avr/pgmspace.h>




// avoid collision with arduino/Print.h
#ifndef __cplusplus
// this macro allows you to write print("some text") and // this macro allows you to write print("some text") and
// the string is automatically placed into flash memory :) // the string is automatically placed into flash memory :)
// TODO: avoid collision with arduino/Print.h
#ifndef __cplusplus
#define print(s) print_P(PSTR(s)) #define print(s) print_P(PSTR(s))
#endif #endif

#define println(s) print_P(PSTR(s "\n")) #define println(s) print_P(PSTR(s "\n"))


/* for old name */ /* for old name */
#define pbin_reverse(data) print_bin_reverse8(data) #define pbin_reverse(data) print_bin_reverse8(data)
#define pbin_reverse16(data) print_bin_reverse16(data) #define pbin_reverse16(data) print_bin_reverse16(data)



/* print value utility */ /* 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_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_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_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_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_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_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) #define print_val_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0)






#ifndef NO_PRINT

#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

/* function pointer of sendchar to be used by print utility */ /* 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) */ /* print string stored in data memory(SRAM) */
void print_S(const char *s); void print_S(const char *s);
void print_bin_reverse8(uint8_t data); void print_bin_reverse8(uint8_t data);
void print_bin_reverse16(uint16_t data); void print_bin_reverse16(uint16_t data);
void print_bin_reverse32(uint32_t data); void print_bin_reverse32(uint32_t data);

#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #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 #endif

+ 5
- 0
keyboard/gh60/config.h View File

*/ */
#define BOOTLOADER_SIZE 4096 #define BOOTLOADER_SIZE 4096


/* disable debug print */
//#define NO_DEBUG

/* disable print */
//#define NO_PRINT


#endif #endif

Loading…
Cancel
Save