69 lines
1.7 KiB
C
69 lines
1.7 KiB
C
#ifdef _CONSOLE_H
|
|
#define _CONSOLE_H
|
|
#else
|
|
|
|
/* Width of display in characters */
|
|
#define _CONSOLE_WIDTH 21
|
|
|
|
/* Height of the display in lines */
|
|
#define _CONSOLE_HEIGHT 8
|
|
|
|
/*
|
|
* Size of the internal buffer in chars/bytes.
|
|
* Can be set arbitrarily (but must not be 0)
|
|
*/
|
|
#define _CONSOLE_BUF_WIDTH (_CONSOLE_WIDTH + 1)
|
|
|
|
|
|
/* Width of a tab (amount of spaces) */
|
|
#define _CONSOLE_TAB_LEN 4
|
|
|
|
|
|
/*
|
|
* Structure to store the state of the console.
|
|
* Contains the cursor position and an internal buffer.
|
|
*/
|
|
typedef struct {
|
|
/*
|
|
* Cursor position (column) of the next char to be written.
|
|
* Unlike the convention set by CASIO:
|
|
* the cursor position is 0-based!
|
|
* The actual Casio cursor will not be set until the
|
|
* consol is flushed!
|
|
*/
|
|
unsigned char cursor_x;
|
|
|
|
/*
|
|
* Cursor position (row) of the next char to be written.
|
|
* Unlike the convention set by CASIO:
|
|
* the cursor position is 0-based!
|
|
* The actual Casio cursor will not be set until the
|
|
* consol is flushed!
|
|
*/
|
|
unsigned char cursor_y;
|
|
|
|
/*
|
|
* Internal buffer of the console.
|
|
* All those characters will be consecutive and in the same line.
|
|
* If the cursor changes position, the buffer needs to be flushed.
|
|
*/
|
|
char buf[_CONSOLE_BUF_WIDTH];
|
|
|
|
/*
|
|
* Amount of characters in the internal buffer.
|
|
*/
|
|
unsigned char buf_strlen;
|
|
} _console;
|
|
|
|
/*
|
|
* Console instance for the stdio functions like printf etc.
|
|
*/
|
|
extern _console _console_ctx;
|
|
|
|
int _console_write(_console *ctx, int file, char *ptr, int len);
|
|
void _console_set_cursor(_console *ctx, unsigned char x, unsigned char y);
|
|
void _console_flush(_console *ctx);
|
|
void _console_putc(_console *ctx, char c);
|
|
|
|
|
|
#endif /* _CONSOLE_H */ |