hollyhock
Loading...
Searching...
No Matches
Variables
debug.h File Reference

Functions useful during debugging. More...

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

Go to the source code of this file.

Variables

void(* Debug_GetCursorPosition )(unsigned int *x, unsigned int *y)
 
void(* Debug_Printf )(unsigned int x, unsigned int y, bool invert, int zero, const char *format,...) __attribute__((format(printf
 
void(* access )(read_only, 5)
 
void(* null_terminated_string_arg )(5)))
 
void(* Debug_PrintNumberHex_Byte )(uint8_t value, unsigned int x, unsigned int y)
 
void(* Debug_PrintNumberHex_Dword )(uint32_t value, unsigned int x, unsigned int y)
 
void(* Debug_PrintNumberHex_Nibble )(uint8_t value, unsigned int x, unsigned int y)
 
void(* Debug_PrintNumberHex_Word )(uint16_t value, unsigned int x, unsigned int y)
 
bool(* Debug_PrintString )(const char *string, bool invert) __attribute__((null_terminated_string_arg(1)))
 
int(* Debug_SetCursorPosition )(unsigned int x, unsigned 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
int(* Debug_SetCursorPosition)(unsigned int x, unsigned int y)
bool(* Debug_PrintString)(const char *string, bool invert) __attribute__((null_terminated_string_arg(1)))
void(* Debug_PrintNumberHex_Word)(uint16_t value, unsigned int x, unsigned int y)
void(* Debug_Printf)(unsigned int x, unsigned int y, bool invert, int zero, const char *format,...) __attribute__((format(printf
int(* Debug_WaitKey)()
void(* LCD_Refresh)()

Variable Documentation

◆ Debug_GetCursorPosition

void(* Debug_GetCursorPosition) (unsigned int *x, unsigned int *y) ( unsigned int *  x,
unsigned int *  y 
)
extern

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

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

◆ Debug_Printf

void(* Debug_Printf) (unsigned int x, unsigned int y, bool invert, int zero, const char *format,...) __attribute__((format(printf ( unsigned int  x,
unsigned int  y,
bool  invert,
int  zero,
const char *  format,
  ... 
)
extern

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, unsigned int x, unsigned int y) ( uint8_t  value,
unsigned int  x,
unsigned int  y 
)
extern

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, unsigned int x, unsigned int y) ( uint32_t  value,
unsigned int  x,
unsigned int  y 
)
extern

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, unsigned int x, unsigned int y) ( uint8_t  value,
unsigned int  x,
unsigned int  y 
)
extern

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, unsigned int x, unsigned int y) ( uint16_t  value,
unsigned int  x,
unsigned int  y 
)
extern

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) __attribute__((null_terminated_string_arg(1))) ( const char *  string,
bool  invert 
)
extern

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) (unsigned int x, unsigned int y) ( unsigned int  x,
unsigned int  y 
)
extern

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) () ( )
extern

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. NEW in 7002: also returns on touch events.

Returns
A number representing the key that was pressed.