Skip to content

Commit

Permalink
Move debug options to runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Oct 22, 2024
1 parent 266916a commit ecea951
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 14 deletions.
5 changes: 4 additions & 1 deletion drivers/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ bool soft_serial_transaction(int sstd_index);
#ifdef SERIAL_DEBUG
# include <debug.h>
# include <print.h>
# define serial_dprintf(...) dprintf(__VA_ARGS__)
# define serial_dprintf(fmt, ...) \
do { \
if (debug_config.serial) xprintf(fmt, ##__VA_ARGS__); \
} while (0)
#else
# define serial_dprintf(...) \
do { \
Expand Down
4 changes: 2 additions & 2 deletions quantum/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void process_record_handler(keyrecord_t *record) {
action_t action = store_or_get_action(record->event.pressed, record->event.key);
#endif
ac_dprintf("ACTION: ");
debug_action(action);
debug_action_fn(action);
#ifndef NO_ACTION_LAYER
ac_dprintf(" layer_state: ");
layer_debug();
Expand Down Expand Up @@ -1219,7 +1219,7 @@ void debug_record(keyrecord_t record) {
*
* FIXME: Needs documentation.
*/
void debug_action(action_t action) {
void debug_action_fn(action_t action) {
switch (action.kind.id) {
case ACT_LMODS:
ac_dprintf("ACT_LMODS");
Expand Down
7 changes: 5 additions & 2 deletions quantum/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
#ifdef ACTION_DEBUG
# include "debug.h"
# include "print.h"
# define ac_dprintf(...) dprintf(__VA_ARGS__)
# define ac_dprintf(fmt, ...) \
do { \
if (debug_config.action) xprintf(fmt, ##__VA_ARGS__); \
} while (0)
#else
# define ac_dprintf(...) \
do { \
Expand All @@ -153,7 +156,7 @@ uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
/* debug */
void debug_event(keyevent_t event);
void debug_record(keyrecord_t record);
void debug_action(action_t action);
void debug_action_fn(action_t action);

#ifdef __cplusplus
}
Expand Down
13 changes: 8 additions & 5 deletions quantum/logging/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"

debug_config_t debug_config = {
.enable = false, //
.matrix = false, //
.keyboard = false, //
.mouse = false, //
.reserved = 0 //
.enable = false,
.matrix = false,
.keyboard = false,
.mouse = false,
.pointing = false,
.action = false,
.serial = false,
.quantum_painter = false,
};
12 changes: 10 additions & 2 deletions quantum/logging/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ typedef union {
bool matrix : 1;
bool keyboard : 1;
bool mouse : 1;
uint8_t reserved : 4;
bool pointing :1;
bool action : 1;
bool serial: 1;
bool quantum_painter : 1;
// bool backing_store : 1;
// bool wear_leveling : 1;
};
uint8_t raw;
} debug_config_t;
Expand All @@ -50,7 +55,10 @@ extern debug_config_t debug_config;
#define debug_matrix (debug_config.matrix)
#define debug_keyboard (debug_config.keyboard)
#define debug_mouse (debug_config.mouse)

#define debug_pointing (debug_config.pointing)
#define debug_action (debug_config.action)
#define debug_serial (debug_config.serial)
#define debug_quantum_painter (debug_config.quantum_painter)
/*
* Debug print utils
*/
Expand Down
5 changes: 4 additions & 1 deletion quantum/painter/qp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
#ifdef QUANTUM_PAINTER_DEBUG
# include <debug.h>
# include <print.h>
# define qp_dprintf(...) dprintf(__VA_ARGS__)
# define qp_dprintf(fmt, ...) \
do { \
if (debug_config.quantum_painter) xprintf(fmt, ##__VA_ARGS__); \
} while (0)
#else
# define qp_dprintf(...) \
do { \
Expand Down
5 changes: 4 additions & 1 deletion quantum/pointing_device_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
#ifdef POINTING_DEVICE_DEBUG
# include "debug.h"
# include "print.h"
# define pd_dprintf(...) dprintf(__VA_ARGS__)
# define pd_dprintf(fmt, ...) \
do { \
if (debug_config.pointing) xprintf(fmt, ##__VA_ARGS__); \
} while (0)
#else
# define pd_dprintf(...) \
do { \
Expand Down

0 comments on commit ecea951

Please sign in to comment.