Functions useful during debugging.  
More...
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
 | 
| 
constexpr unsigned int  | debug_char_width = 8 | 
|   | 
| 
constexpr unsigned int  | debug_char_height = 12 | 
|   | 
| 
constexpr unsigned int  | debug_line_height = 14 | 
|   | 
| 
constexpr unsigned int  | debug_max_columns = 40 | 
|   | 
| 
constexpr unsigned int  | debug_max_rows = 37 | 
|   | 
| 
uint16_t *  | DEBUG_FONTBASE | 
|   | 
| 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 )() | 
|   | 
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: 
 
 
 
Debug_Printf(20, 20, 
false, 0, 
"Format strings are %s in %d!", 
"cool", 2018);
 
 
 
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
 
   
◆ 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,y | The 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,y | The coordinates to print the formatted string at.  | 
     | invert | True if the colors used to print the text should be inverted.  | 
     | zero | Must be passed 0.  | 
    | [in] | format | The 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
 - 
  
    | value | The byte to print.  | 
    | x,y | The 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
 - 
  
    | value | The dword to print.  | 
    | x,y | The 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
 - 
  
    | value | The nibble to print. High 4 bits are ignored.  | 
    | x,y | The 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
 - 
  
    | value | The word to print.  | 
    | x,y | The 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] | string | The string to print.  | 
     | invert | True 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,y | The 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.