hollyhock
Functions
debug.hpp File Reference

Functions useful during debugging. More...

#include <stdint.h>
Include dependency graph for debug.hpp:

Go to the source code of this file.

Functions

void Debug_GetCursorPosition (int *x, int *y)
 
void Debug_Printf (int x, int y, bool invert, int zero, const char *format,...)
 
void Debug_PrintNumberHex_Byte (uint8_t value, int x, int y)
 
void Debug_PrintNumberHex_Dword (uint32_t value, int x, int y)
 
void Debug_PrintNumberHex_Nibble (uint8_t value, int x, int y)
 
void Debug_PrintNumberHex_Word (uint16_t value, int x, int y)
 
bool Debug_PrintString (const char *string, bool invert)
 
int Debug_SetCursorPosition (int x, int y)
 
int Debug_WaitKey ()
 

Detailed Description

Functions useful during debugging.

It can be useful to print text or numbers to the screen whilst debugging, without creating a full GUI, or pause execution and wait for a key press. Thoroughly recommended only for debugging - prefer GUI elements for user-facing input/output!

Example:

// Print "Hello, world!" at 0, 0 in black on white
Debug_PrintString("Hello, world!", false);
// Print "Inverted text" at 1, 1 in white on black
Debug_PrintString("Inverted text", true);
// Print the number 0x1322 at 3, 7
// Print small text with a format string
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.hpp
// Block until the user presses a key
void Debug_Printf(int x, int y, bool invert, int zero, const char *format,...)
int Debug_WaitKey()
bool Debug_PrintString(const char *string, bool invert)
int Debug_SetCursorPosition(int x, int y)
void Debug_PrintNumberHex_Word(uint16_t value, int x, int y)
void LCD_Refresh()

Function Documentation

◆ Debug_GetCursorPosition()

void Debug_GetCursorPosition ( int *  x,
int *  y 
)

Returns the current position of the cursor in debug text mode.

Parameters
[out]x,yThe position of the cursor.

◆ Debug_Printf()

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. Color inversion occurs if invert is true.

Supports most format specifiers.

Parameters
x,yThe coordinates to print the formatted string at.
invertTrue if the colors used to print the text should be inverted.
zeroMust be passed 0.
[in]formatThe format string to use.
...The values to substitute into the format string.

◆ Debug_PrintNumberHex_Byte()

void Debug_PrintNumberHex_Byte ( uint8_t  value,
int  x,
int  y 
)

Prints the hex representation of a byte (8-bit number) at the specified position in debug text mode.

Parameters
valueThe byte to print.
x,yThe coordinates to print the number at.

◆ Debug_PrintNumberHex_Dword()

void Debug_PrintNumberHex_Dword ( uint32_t  value,
int  x,
int  y 
)

Prints the hex representation of a dword (32-bit number) at the specified position in debug text mode.

Parameters
valueThe dword to print.
x,yThe coordinates to print the number at.

◆ Debug_PrintNumberHex_Nibble()

void Debug_PrintNumberHex_Nibble ( uint8_t  value,
int  x,
int  y 
)

Prints the hex representation of a nibble (4-bit number) at the specified position in debug text mode.

Parameters
valueThe nibble to print. High 4 bits are ignored.
x,yThe coordinates to print the number at.

◆ Debug_PrintNumberHex_Word()

void Debug_PrintNumberHex_Word ( uint16_t  value,
int  x,
int  y 
)

Prints the hex representation of a word (16-bit number) at the specified position in debug text mode.

Parameters
valueThe word to print.
x,yThe coordinates to print the number at.

◆ Debug_PrintString()

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. Color inversion occurs if invert is true.

Returns false if the string did not fit on the screen.

Parameters
[in]stringThe string to print.
invertTrue if the colors used to print the text should be inverted.
Returns
True if writing the string was successful, false otherwise.

◆ Debug_SetCursorPosition()

int Debug_SetCursorPosition ( int  x,
int  y 
)

Sets the position of the cursor in debug text mode.

Parameters
x,yThe cursor's new position.
Returns
Always returns 0.

◆ Debug_WaitKey()

int Debug_WaitKey ( )

Waits until a key is pressed, then returns a number representing the key. Only appears to react to number keys and the Power/Clear key. Returns 0x30 to 0x39 for keys 0 to 9, and 0x98 for the Power/Clear key.

Returns
A number representing the key that was pressed.