Libndls: Difference between revisions
Jump to navigation
Jump to search
m (→Data manipulation: fix previous change) |
mNo edit summary |
||
Line 1: | Line 1: | ||
''libndls'' is a set of macros and functions available as a [http://en.wikipedia.org/wiki/Static_library static library] when building with Ndless. The library is automatically linked by <tt>nspire-ld</tt> if required. | ''libndls'' is a set of macros and functions available as a [http://en.wikipedia.org/wiki/Static_library static library] when building with Ndless. The library is automatically linked by <tt>nspire-ld</tt> if required. | ||
These definitions are available in Ndless 1.7 | These definitions are available in Ndless 1.7. Definitions marked with (asm) are only available in assembly. | ||
==Common types== | ==Common types== |
Revision as of 20:04, 27 February 2011
libndls is a set of macros and functions available as a static library when building with Ndless. The library is automatically linked by nspire-ld if required.
These definitions are available in Ndless 1.7. Definitions marked with (asm) are only available in assembly.
Common types
- typedef enum bool {FALSE = 0, TRUE = 1} BOOL;
Data manipulation
- uint16_t bswap16(uint16_t): swap the bytes of a 2-bytes integer
- uint32_t bswap32(uint32_t): swap the bytes of a 4-bytes integer
Math
- number abs(number)
- number min(number, number)
- number max(number, number)
Screen
- SCREEN_BASE_ADDRESS: address of the screen buffer. Each grayscaled pixel is 4-bit long. 1111 is white, 0000 is black.
- SCREEN_BYTES_SIZE: size of the screen buffer
- SCREEN_WIDTH: screen width in pixels
- SCREEN_HEIGHT: screen height in pixels
- void clrscr(void): clears the screen
UI
- void show_msgbox(const char *title, const char *msg): show a message box, with a single button OK"
Keyboard
- BOOL any_key_pressed(void): non-blocking key press test. Returns TRUE if one or more keys are being pressed.
- BOOL isKeyPressed(key): non-blocking key press test. key must be one of the KEY_NSPIRE_* constants defined in include/libndls.h.
- void wait_key_pressed(void): block until a key is pressed
- void wait_no_key_pressed(void): block until all the keys are released
CPU
- void clear_cache(void): flushes the data cache and invalidate the instruction and data caches of the processor. Should be called before loading code dynamically, after a code patch or with self-modifying code.
Hardware
BOOL is_touchpad : TRUE on a TI-Nspire Touchpad.
Time
- void idle(void): switch to low-power state until the next interrupt occurs. The use of this function is encouraged when waiting in loops for an event to save the batteries.
- void sleep(unsigned m): delay for a specified amount of time. The CPU is regularly switched to low-power state while blocking.
Debugging
- void halt(void): stops the execution flow with an endless loop. If you are using the Ncubate emulator, use the j debugger command to jump over the instruction.
- halt (asm) (macro): similar to halt()