Prusa MINI Firmware overview
term.h
Go to the documentation of this file.
1 // term.h
2 #ifndef _TERM_H
3 #define _TERM_H
4 
5 #include <inttypes.h>
6 #include <stdio.h>
7 
8 #define TERM_ATTR_BACK_MASK 0x00
9 #define TERM_ATTR_BACK_BLACK 0x00
10 #define TERM_ATTR_BACK_WHITE 0x00
11 
12 #define TERM_ATTR_TEXT_MASK 0x00
13 #define TERM_ATTR_TEXT_BLACK 0x00
14 #define TERM_ATTR_TEXT_WHITE 0x00
15 
16 #define TERM_ATTR_INVERT 0x40
17 #define TERM_ATTR_BLINK 0x80
18 
19 #define TERM_COLOR_BLACK 0
20 #define TERM_COLOR_RED 1
21 #define TERM_COLOR_GREEN 2
22 #define TERM_COLOR_YELLOW 3
23 #define TERM_COLOR_BLUE 4
24 #define TERM_COLOR_MAGENTA 5
25 #define TERM_COLOR_CYAN 6
26 #define TERM_COLOR_WHITE 7
27 
28 #define TERM_FLG_FREEMEM 0x0080
29 #define TERM_FLG_CHANGED 0x0040
30 #define TERM_FLG_ESCAPE 0x0020
31 #define TERM_FLG_AUTOCR 0x0010
32 
33 #define TERM_DEF_CHAR ' '
34 #define TERM_DEF_ATTR (TERM_ATTR_BACK_BLACK | TERM_ATTR_TEXT_WHITE)
35 
36 #define TERM_BUFF_SIZE(c, r) ((r * c * 2) + (r * c + 7) / 8)
37 
38 #define TERM_PRINTF_MAX 0xff
39 
40 #pragma pack(push)
41 #pragma pack(1)
42 
43 typedef struct _term_t {
46  uint16_t flg;
48  uint16_t size;
52  FILE *file;
53 } term_t;
54 
55 #pragma pack(pop)
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif //__cplusplus
60 
61 extern void term_init(term_t *pt, uint8_t cols, uint8_t rows, uint8_t *buff);
62 
63 extern void term_done(term_t *pt);
64 
65 extern void term_clear(term_t *pt);
66 
67 extern uint8_t term_get_char_at(term_t *pt, uint8_t col, uint8_t row);
68 
69 extern void term_set_char_at(term_t *pt, uint8_t col, uint8_t row, uint8_t ch);
70 
71 extern uint8_t term_get_attr_at(term_t *pt, uint8_t col, uint8_t row);
72 
73 extern void term_set_attr_at(term_t *pt, uint8_t col, uint8_t row, uint8_t attr);
74 
75 extern void term_set_attr(term_t *pt, uint8_t attr);
76 
77 extern void term_set_pos(term_t *pt, uint8_t col, uint8_t row);
78 
79 extern void term_write_char(term_t *pt, uint8_t ch);
80 
81 extern int term_printf(term_t *pt, const char *fmt, ...);
82 
83 extern int vterm_printf(term_t *pt, const char *fmt, va_list va);
84 
85 #ifdef __cplusplus
86 }
87 #endif //__cplusplus
88 
89 #endif // _TERM_H
_term_t::attr
uint8_t attr
Definition: term.h:49
term_clear
void term_clear(term_t *pt)
Definition: term.c:34
term_get_char_at
uint8_t term_get_char_at(term_t *pt, uint8_t col, uint8_t row)
Definition: term.c:51
term_get_attr_at
uint8_t term_get_attr_at(term_t *pt, uint8_t col, uint8_t row)
Definition: term.c:71
_term_t::row
uint8_t row
Definition: term.h:51
_term_t::rows
uint8_t rows
Definition: term.h:45
_term_t
Definition: term.h:43
term_done
void term_done(term_t *pt)
Definition: term.c:26
term_set_attr
void term_set_attr(term_t *pt, uint8_t attr)
Definition: term.c:97
_term_t::col
uint8_t col
Definition: term.h:50
term_set_attr_at
void term_set_attr_at(term_t *pt, uint8_t col, uint8_t row, uint8_t attr)
Definition: term.c:80
term_set_char_at
void term_set_char_at(term_t *pt, uint8_t col, uint8_t row, uint8_t ch)
Definition: term.c:60
_term_t::cols
uint8_t cols
Definition: term.h:44
_term_t::flg
uint16_t flg
Definition: term.h:46
term_set_pos
void term_set_pos(term_t *pt, uint8_t col, uint8_t row)
Definition: term.c:103
uint8_t
const uint8_t[]
Definition: 404_html.c:3
term_t
struct _term_t term_t
term_init
void term_init(term_t *pt, uint8_t cols, uint8_t rows, uint8_t *buff)
Definition: term.c:6
vterm_printf
int vterm_printf(term_t *pt, const char *fmt, va_list va)
Definition: term.c:191
term_write_char
void term_write_char(term_t *pt, uint8_t ch)
Definition: term.c:157
_term_t::file
FILE * file
Definition: term.h:52
_term_t::buff
uint8_t * buff
Definition: term.h:47
term_printf
int term_printf(term_t *pt, const char *fmt,...)
Definition: term.c:178
_term_t::size
uint16_t size
Definition: term.h:48