Nspire I/O  3.0
 All Data Structures Files Functions Pages
Data Structures | Macros | Typedefs | Functions
nspireio.h File Reference
#include <os.h>

Go to the source code of this file.

Data Structures

struct  nio_console
 

Macros

#define NIO_CURSOR_BLOCK   0
 
#define NIO_CURSOR_UNDERSCORE   1
 
#define NIO_CURSOR_VERTICAL   2
 
#define NIO_CURSOR_CUSTOM   3
 
#define NIO_CHAR_WIDTH   6
 
#define NIO_CHAR_HEIGHT   8
 
#define NIO_MAX_ROWS   30
 
#define NIO_MAX_COLS   53
 
#define nio_getc   nio_fgetc
 
#define nio_putc   nio_fputc
 

Typedefs

typedef struct nio_console nio_console
 

Functions

void nio_grid_puts (const int offset_x, const int offset_y, const int x, const int y, const char *str, const char bgColor, const char textColor)
 
void nio_grid_putc (const int offset_x, const int offset_y, const int x, const int y, const char ch, const char bgColor, const char textColor)
 
void nio_load (const char *path, nio_console *c)
 
void nio_save (const char *path, const nio_console *c)
 
void nio_set_default (nio_console *c)
 
void nio_clear (nio_console *c)
 
void nio_scroll (nio_console *c)
 
void nio_csl_drawchar (nio_console *c, const int pos_x, const int pos_y)
 
void nio_csl_savechar (nio_console *c, const char ch, const int pos_x, const int pos_y)
 
char nio_getch (nio_console *c)
 
void nio_color (nio_console *c, const char background_color, const char foreground_color)
 
void nio_drawing_enabled (nio_console *c, const BOOL enable_drawing)
 
void nio_init (nio_console *c, const int size_x, const int size_y, const int offset_x, const int offset_y, const char background_color, const char foreground_color, const BOOL drawing_enabled)
 
void nio_free (nio_console *c)
 
void nio_use_stdio (void)
 
void nio_free_stdio (void)
 
int nio_fflush (nio_console *c)
 
char nio_fputc (char ch, nio_console *c)
 
char nio_putchar (const char ch)
 
int nio_fputs (const char *str, nio_console *c)
 
int nio_puts (const char *str)
 
char nio_fgetc (nio_console *c)
 
char nio_getchar (void)
 
char * nio_fgets (char *str, int num, nio_console *c)
 
char * nio_gets (char *str)
 
int nio_fprintf (nio_console *c, const char *format,...)
 
int nio_printf (const char *format,...)
 
void nio_perror (const char *str)
 
int reg_store (void *dataptr, size_t size, char *regpath)
 
void * reg_get (char *regpath)
 
BOOL uart_ready (void)
 
char uart_getchar (void)
 
char * uart_gets (char *str)
 
char uart_putchar (char character)
 
int uart_puts (const char *str)
 
void uart_printf (char *format,...)
 
unsigned nio_time_get ()
 
void nio_cursor_draw (nio_console *c)
 
void nio_cursor_erase (nio_console *c)
 
void nio_cursor_blinking_draw (nio_console *c)
 
void nio_cursor_blinking_reset (nio_console *c)
 
void nio_cursor_enable (nio_console *c, BOOL enable_cursor)
 
void nio_cursor_blinking_enable (nio_console *c, BOOL enable_cursor_blink)
 
void nio_cursor_blinking_duration (nio_console *c, int duration)
 
void nio_cursor_type (nio_console *c, int cursor_type)
 
void nio_cursor_width (nio_console *c, int cursor_width)
 
void nio_cursor_custom (nio_console *c, unsigned char cursor_data[6])
 

Detailed Description

Author
Julian Mackeben aka compu compu.nosp@m.juck.nosp@m.el@go.nosp@m.ogle.nosp@m.mail..nosp@m.com
Version
3.0

LICENSE

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

DESCRIPTION

Nspire I/O 3.0 header file

Function Documentation

void nio_clear ( nio_console c)

Clears a console.

Parameters
cConsole
void nio_color ( nio_console c,
const char  background_color,
const char  foreground_color 
)

Sets the background- and text color of a console. Possible values are 0-15.

Parameters
cConsole
background_colorBackground color
foreground_colorText color
void nio_csl_drawchar ( nio_console c,
const int  pos_x,
const int  pos_y 
)

Draws a char from the console to the screen. For internal use.

Parameters
cConsole
pos_xx position
pos_yy position
void nio_csl_savechar ( nio_console c,
const char  ch,
const int  pos_x,
const int  pos_y 
)

Saves a char in a console without drawing it. For internal use.

Parameters
cConsole
chChar
pos_xx position
pos_yy position
void nio_cursor_blinking_draw ( nio_console c)

Draws a blinking cursor, if enabled. Blinking occurs on an interval set inside the console.

Parameters
cConsole
void nio_cursor_blinking_duration ( nio_console c,
int  duration 
)

Sets the console cursor blink duration (the time it takes to switch on or off)

Parameters
cConsole
durationThe time (in seconds) it takes to switch on or off.
void nio_cursor_blinking_enable ( nio_console c,
BOOL  enable_cursor_blink 
)

Enables console cursor blinking.

Parameters
cConsole
enable_cursor_blinkWhen this is true, the cursor will blink, false: no cursor blinking will occur.
void nio_cursor_blinking_reset ( nio_console c)

Resets the blinking cursor timer.

Parameters
cConsole
void nio_cursor_custom ( nio_console c,
unsigned char  cursor_data[6] 
)

Sets the console cursor width.

Parameters
cConsole
cursor_dataThe custom cursor data. This is in the form of a char[6] array. This pretty much uses the format (and the drawing code) for character drawing, so take a look at charmap.h for examples. Note that the characters in charmap.h are truncated, so they will display differently.

By default, if this is not specified and the cursor type is set to the custom cursor type (3), the custom cursor will be set to {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} (a block cursor).

void nio_cursor_draw ( nio_console c)

Draws the cursor of the console, if enabled.

Parameters
cConsole
void nio_cursor_enable ( nio_console c,
BOOL  enable_cursor 
)

Enables the console cursor.

Parameters
cConsole
enable_cursorWhen this is true, a cursor will be drawn to the screen, false: no cursor shown.
void nio_cursor_erase ( nio_console c)

Erases the cursor of the console, if enabled.

Parameters
cConsole
void nio_cursor_type ( nio_console c,
int  cursor_type 
)

Sets the console cursor type.

Parameters
cConsole
cursor_typeThe cursor type. 0 is a block cursor (default, like a Linux X11 terminal), 1 is an underscore cursor (like a Windows Command Prompt window), 2 is a vertical bar cursor (like a regular text box), and 3 is a custom cursor that is set via SetCursorCustom.

If you specify an invalid value, NspireIO will silenty fail and set the cursor type to 0, a block cursor.

You may also use the predefined types as arguments. (NIO_CURSOR_*)

void nio_cursor_width ( nio_console c,
int  cursor_width 
)

Sets the console cursor width.

Parameters
cConsole
cursor_widthThe cursor line width. This only applies to cursors 1 and 2 (underscore and vertical bar). All others cursor types will not be affected by this setting.

For the underscore cursor, it must be greater than 0 and less than or equal to CHAR_HEIGHT (as defined by charmap.h). At the time of writing, CHAR_HEIGHT is 8. Therefore, for an underscore cursor, 0 < cursor_width <= 8.

For a vertical bar cursor, it must be greater than 0 and less than or equal to CHAR_WIDTH (as defined by charmap.h). At the time of writing, CHAR_WIDTH is 6. Therefore, for a vertical bar cursor, 0 < cursor_width < 6.

If you wish to draw a blank cursor, you probably should disable the cursor altogether with EnableCursor(nio_console, FALSE).

Note that if you specify an out-of-range value, NspireIO will silently fail and reset the cursor width to 1.

void nio_drawing_enabled ( nio_console c,
const BOOL  enable_drawing 
)

Changes the drawing behavior of a console.

Parameters
cConsole
enable_drawingIf this is true, a console will automatically be updated if text is written to it.
int nio_fflush ( nio_console c)

See fflush

Note
This is useful for consoles with enable_drawing set to false. Using this function will result in the console being drawn.
char nio_fgetc ( nio_console c)

See fgetc

char* nio_fgets ( char *  str,
int  num,
nio_console c 
)

See fgets

Todo:
Do not ignore num
int nio_fprintf ( nio_console c,
const char *  format,
  ... 
)

See fprintf

char nio_fputc ( char  ch,
nio_console c 
)

See fputc

int nio_fputs ( const char *  str,
nio_console c 
)

See fputs

void nio_free ( nio_console c)

Uninitializes a console. This should always be called before the program ends.

Parameters
cConsole
void nio_free_stdio ( void  )

For use with NIO_REPLACE_STDIO. Use at the end of your program.

char nio_getch ( nio_console c)

Immediately gets a char from the keyboard. For internal use.

Parameters
cConsole
Returns
Char
char nio_getchar ( void  )

See getchar

char* nio_gets ( char *  str)

See gets

void nio_grid_putc ( const int  offset_x,
const int  offset_y,
const int  x,
const int  y,
const char  ch,
const char  bgColor,
const char  textColor 
)

Draws a char to the screen on the given position. For internal use.

Parameters
offset_xx offset in px
offset_yy offset in px
xx position in columns (px*6)
yy position in rows (px*8)
cChar
bgColorBackground color
textColortext color
void nio_grid_puts ( const int  offset_x,
const int  offset_y,
const int  x,
const int  y,
const char *  str,
const char  bgColor,
const char  textColor 
)

Draws a string to the screen on the given position. For internal use.

Parameters
offset_xx offset in px
offset_yy offset in px
xx position in columns (px*6)
yy position in rows (px*8)
strString
bgColorBackground color
textColortext color
void nio_init ( nio_console c,
const int  size_x,
const int  size_y,
const int  offset_x,
const int  offset_y,
const char  background_color,
const char  foreground_color,
const BOOL  drawing_enabled 
)

Initializes a console.

Parameters
cConsole
size_xconsole width
size_yconsole height
offset_xx position
offset_yy position
background_colorBackground color
foreground_colorText color
drawing_enabledSee nio_enable_drawing()
void nio_load ( const char *  path,
nio_console c 
)

Loads a console from a file on flash storage.

Parameters
pathFile path
cConsole
void nio_perror ( const char *  str)

See perror

int nio_printf ( const char *  format,
  ... 
)

See printf

char nio_putchar ( const char  ch)

See putchar

int nio_puts ( const char *  str)

See puts

void nio_save ( const char *  path,
const nio_console c 
)

Saves a console to a file in flash storage.

Parameters
pathFile path
cConsole
void nio_scroll ( nio_console c)

Scrolls a console one line down.

Parameters
cConsole
void nio_set_default ( nio_console c)

Sets a default console that will be used for all functions without console argument, e.g. nio_puts()

Parameters
cConsole
unsigned nio_time_get ( )
inline

Returns the current time.

Returns
Current RTC time
void nio_use_stdio ( void  )

For use with NIO_REPLACE_STDIO. Use at the beginning of your program.

void* reg_get ( char *  regpath)

Reads binary data from a file.

Parameters
regpathPath to file
Returns
Pointer to the data, NULL on failure
int reg_store ( void *  dataptr,
size_t  size,
char *  regpath 
)

Stores binary data in a file.

Parameters
dataptrPointer to the data to be stored
sizeLength in bytes
regpathPath to file
Returns
0 on success, -1 on failure
char uart_getchar ( void  )

See getchar

Returns
Char
char* uart_gets ( char *  str)

See gets

Returns
Destination
void uart_printf ( char *  format,
  ... 
)

See printf

char uart_putchar ( char  character)

See putchar

int uart_puts ( const char *  str)

See puts

Note
This DOES NOT append a newline (\n) character.
BOOL uart_ready ( void  )

Checks if there is data available at the serial port.

Returns
TRUE if new data is available.