SparkFun SSD168x Library  v1.0.2
Library for SSD1680 / SSD1681 e-paper displays on SPI
Loading...
Searching...
No Matches
sfe_debug.h
Go to the documentation of this file.
1
19/*
20 debugPrint()/debugPrintln() live in their own small base class, SfeDebugPrint, so that any class
21 can inherit real, working debug-print support. This is the same class as used in the SparkFun
22 u-blox GNSS v4 library.
23
24 The SSD168x device classes (SpiSsd1680, SpiSsd1680Rotated, SpiSsd1681) inherit SfeDebugPrint.
25 The user-facing classes (SSD1680SPI184x88 etc.) own the device class BY VALUE (m_device) and
26 provide enableDebugging() / disableDebugging(), which select the default debug port for the
27 platform and pass it on to m_device.
28
29 Plain (non-static) inheritance means each object gets its OWN copy of _debugSerial/_printDebug/
30 _printLimitedDebug. So debug can be enabled for one display and not another. copyDebugStateFrom()
31 allows the state to be pushed from one object to another if needed.
32*/
33
34#pragma once
35
36#include "sfe_platform.h"
37#include "sfe_bus.h"
38
39namespace SparkFun_SSD168x
40{
41
43 {
44 public:
52 void enableDebugging(sfe_print_t &debugPort, bool printLimitedDebug = false)
53 {
54 _debugSerial.init(debugPort); // Grab which port the user wants us to use for debugging
55 _printDebug = true; // Should we print the debug messages?
56 _printLimitedDebug = printLimitedDebug;
57 }
58
63 {
64 _printDebug = false;
65 _printLimitedDebug = false;
66 }
67
77 void debugPrint(const char *message, bool important = false); // Safely print debug statements
84 void debugPrint(uint32_t value, bool important = false); // Safely print debug values
92 void debugPrint(uint32_t value, int printBase, bool important = false); // Safely print debug values in a given base (e.g. HEX)
99 void debugPrintln(const char *message, bool important = false); // Safely print debug statements
106 void debugPrintln(uint32_t value, bool important = false); // Safely print debug values
114 void debugPrintln(uint32_t value, int printBase, bool important = false); // Safely print debug values in a given base (e.g. HEX)
118 void debugPrintln(void); // Safely print a blank debug line
119
126 {
128 _printDebug = other._printDebug;
130 }
131
132 protected:
133 SfePrint _debugSerial; // The stream to send debug messages to if enabled
134 bool _printDebug = false; // Flag to print debug messages
135 bool _printLimitedDebug = false; // Flag to print limited (important-only) debug messages
136 };
137
138} // namespace SparkFun_SSD168x
Definition: sfe_debug.h:43
void enableDebugging(sfe_print_t &debugPort, bool printLimitedDebug=false)
Enable debug messages, sent to the given port.
Definition: sfe_debug.h:52
bool _printDebug
Definition: sfe_debug.h:134
bool _printLimitedDebug
Definition: sfe_debug.h:135
void debugPrint(const char *message, bool important=false)
Print a debug message (no trailing newline), if debugging is enabled.
Definition: sfe_debug.cpp:27
void debugPrintln(void)
Print a blank debug line, if debugging is enabled and not in limited-debug mode.
Definition: sfe_debug.cpp:75
void copyDebugStateFrom(const SfeDebugPrint &other)
Copy debug state (output stream and enabled flags) from another SfeDebugPrint.
Definition: sfe_debug.h:125
SfePrint _debugSerial
Definition: sfe_debug.h:133
void disableDebugging(void)
Turn off debug message printing.
Definition: sfe_debug.h:62
Definition: sfe_bus.h:34