Debug
Overview
Section titled “Overview”Debug methods should be called inside a prepared environment, so be sure to do both a calcInit()
, calcEnd()
and some manual LCD_Refresh()
when using them.
Some of the debug methods use a cursor position internally, which can be changed using Debug_SetCursorPosition
. Units are character size and not pixels, so setting the cursor at (1,1)
means the second line second character.
Methods
Section titled “Methods”Set Cursor Position
Section titled “Set Cursor Position”void Debug_GetCursorPosition(int x, int y);void Debug_GetCursorPosition(int *x, int *y);
x
and y
are the position of the cursor in character size.
Print String
Section titled “Print String”bool Debug_PrintString(const char *string, bool invert);
Prints a string
in debug text mode, either in normal black-on-white or inverted white-on-black (controlled by the invert
parameter)
Print Advanced String
Section titled “Print Advanced String”void Debug_Printf(int x, int y, bool invert, int zero, const char *format, ...);
Print a formatted string in small debug text mode, either in normal black-on-white or inverted white-on-black (controlled by the invert
parameter)
Supports most format specifiers:
%s
for strings%d
for decimals
Check the Usage on how to use it.
Print Hex
Section titled “Print Hex”void Debug_PrintNumberHex_Nibble(uint8_t value, int x, int y);void Debug_PrintNumberHex_Byte(uint8_t value, int x, int y);void Debug_PrintNumberHex_Word(uint16_t value, int x, int y);void Debug_PrintNumberHex_Dword(uint32_t value, int x, int y);
Depending on the value
:
- nibble are 4-bit number
- byte are 8-bit number
- word are 16-bit number
- Dword are 32-bit number
Waits for a key
Section titled “Waits for a key”int Debug_WaitKey();
Waits until a key is pressed, then returns a number representing the key.
More details about its return and behavior in the SDK source code
#include <sdk/os/debug.hpp>// Print "Hello, world!" at 0, 0 in black on whiteDebug_SetCursorPosition(0, 0);Debug_PrintString("Hello, world!", false);
// Print "Inverted text" at 1, 1 in white on blackDebug_SetCursorPosition(1, 1);Debug_PrintString("Inverted text", true);
// Print the number 0x1322 at 3, 7Debug_PrintNumberHex_Word(0x1322, 3, 7);
// Print small text with a format stringDebug_Printf(10, 10, false, 0, "Just one number : %d", 42);Debug_Printf(20, 20, false, 0, "Format strings are %s in %d!", "cool", 2018);
// Draw the changes we made to VRAM onto the LCD// Defined in sdk/os/lcd.hppLCD_Refresh();
// Block until the user presses a keyDebug_WaitKey();