Nspire I/O  3.0
 All Data Structures Files Functions Pages
nspireio.h
Go to the documentation of this file.
1 
27 #include <os.h>
28 
29 #ifndef NSPIREIO2_H
30 #define NSPIREIO2_H
31 
33 {
34  char* data;
35  char* color;
36  int cursor_x;
37  int cursor_y;
38  int max_x;
39  int max_y;
40  int offset_x;
41  int offset_y;
42  char default_background_color;
43  char default_foreground_color;
44  BOOL drawing_enabled;
45  BOOL cursor_enabled;
46  int cursor_type;
47  int cursor_line_width;
48  unsigned char cursor_custom_data[6];
49  BOOL cursor_blink_enabled;
50  BOOL cursor_blink_status;
51  unsigned cursor_blink_timestamp;
52  unsigned cursor_blink_duration;
53 };
54 typedef struct nio_console nio_console;
55 
56 #define NIO_CURSOR_BLOCK 0
57 #define NIO_CURSOR_UNDERSCORE 1
58 #define NIO_CURSOR_VERTICAL 2
59 #define NIO_CURSOR_CUSTOM 3
60 
61 #define NIO_CHAR_WIDTH 6
62 #define NIO_CHAR_HEIGHT 8
63 
64 #define NIO_MAX_ROWS 30
65 #define NIO_MAX_COLS 53
66 
76 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);
77 
87 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);
88 
93 void nio_load(const char* path, nio_console* c);
94 
99 void nio_save(const char* path, const nio_console* c);
100 
105 
109 void nio_clear(nio_console* c);
110 
114 void nio_scroll(nio_console* c);
115 
121 void nio_csl_drawchar(nio_console* c, const int pos_x, const int pos_y);
122 
129 void nio_csl_savechar(nio_console* c, const char ch, const int pos_x, const int pos_y);
130 
135 char nio_getch(nio_console* c);
136 
142 void nio_color(nio_console* c, const char background_color, const char foreground_color);
143 
148 void nio_drawing_enabled(nio_console* c, const BOOL enable_drawing);
149 
160 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);
161 
165 void nio_free(nio_console* c);
166 
169 void nio_use_stdio(void);
170 
173 void nio_free_stdio(void);
174 
178 int nio_fflush(nio_console* c);
179 
182 char nio_fputc(char ch, nio_console* c);
183 
186 char nio_putchar(const char ch);
187 
190 int nio_fputs(const char* str, nio_console* c);
191 
194 int nio_puts(const char* str);
195 
198 char nio_fgetc(nio_console* c);
199 
202 char nio_getchar(void);
203 
207 char* nio_fgets(char* str, int num, nio_console* c);
208 
211 char* nio_gets(char* str);
212 
213 //int nio_vfprintf(nio_console* c, const char* format, va_list* arglist);
214 
217 int nio_fprintf(nio_console* c, const char* format, ...);
218 
221 int nio_printf(const char* format, ...);
222 
225 void nio_perror(const char* str);
226 
227 // Macro of nio_fgetc
228 #define nio_getc nio_fgetc
229 
230 // Macro of nio_fputc
231 #define nio_putc nio_fputc
232 
239 int reg_store(void* dataptr, size_t size, char* regpath);
240 
245 void* reg_get(char* regpath);
246 
250 BOOL uart_ready(void);
251 
255 char uart_getchar(void);
256 
260 char* uart_gets(char* str);
261 
264 char uart_putchar(char character);
265 
269 int uart_puts(const char *str);
270 
273 void uart_printf(char *format, ...);
274 
278 inline unsigned nio_time_get();
279 
284 
289 
294 
299 
304 void nio_cursor_enable(nio_console* c, BOOL enable_cursor);
305 
310 void nio_cursor_blinking_enable(nio_console* c, BOOL enable_cursor_blink);
311 
316 void nio_cursor_blinking_duration(nio_console* c, int duration);
317 
330 void nio_cursor_type(nio_console* c, int cursor_type);
331 
353 void nio_cursor_width(nio_console* c, int cursor_width);
354 
366 void nio_cursor_custom(nio_console* c, unsigned char cursor_data[6]);
367 
368 #ifdef NIO_KEEP_COMPATIBILITY
369 #define nio_InitConsole(a,b,c,d,e,f,g) nio_init(a,b,c,d,e,f,g,TRUE)
370 #define nio_DrawConsole nio_fflush
371 #define nio_Clear nio_clear
372 #define nio_PrintChar(a,b) nio_fputc(b,a)
373 #define nio_EnableDrawing nio_drawing_enabled
374 #define nio_PrintStr(a,b) nio_fputs(b,a)
375 #define nio_GetChar nio_fgetc
376 #define nio_GetStr(a,b) nio_fgets(b,1000,a)
377 #define nio_SetColor nio_color
378 #define nio_CleanUp nio_free
379 #define setPixel nio_pixel_set
380 #define putChar nio_pixel_putc
381 #define putStr nio_pixel_puts
382 #define nio_drawstr nio_grid_puts
383 #define nio_drawch nio_grid_putc
384 #define nio_ScrollDown nio_scroll
385 #define nio_DrawChar nio_csl_drawchar
386 #define nio_SetChar nio_csl_savechar
387 #define nio_printf nio_fprintf
388 
389 #define uart_putc uart_putchar
390 #define uart_getc uart_getchar
391 
392 #define get_current_time nio_time_get
393 #define nio_DrawCursor nio_cursor_draw
394 #define nio_EraseCursor nio_cursor_erase
395 #define nio_DrawBlinkingCursor nio_cursor_blinking_draw
396 #define nio_ResetBlinkingCursor nio_cursor_blinking_reset
397 #define nio_EnableCursor nio_cursor_enable
398 #define nio_EnableCursorBlink nio_cursor_blinking_enable
399 #define nio_SetCursorBlinkDuration nio_cursor_blinking_duration
400 #define nio_SetCursorType nio_cursor_type
401 #define nio_SetCursorWidth nio_cursor_width
402 #define nio_SetCursorCustom nio_cursor_custom
403 #endif
404 
405 #ifdef NIO_REPLACE_STDIO
406 #define putchar nio_putchar
407 #define puts nio_puts
408 #define getchar nio_getchar
409 #define gets nio_gets
410 #define printf nio_printf
411 #define perror nio_perror
412 #endif
413 
414 #ifdef UART_REPLACE_STDIO
415 #define putchar uart_putchar
416 #define puts uart_puts
417 #define getchar uart_getchar
418 #define gets uart_gets
419 #define printf uart_printf
420 #endif
421 
422 #endif