-
Notifications
You must be signed in to change notification settings - Fork 1
/
lcdprint_u8g.cpp
98 lines (82 loc) · 2.35 KB
/
lcdprint_u8g.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* @file lcdprint_u8g.c
* @brief LCD print api for u8glib
* @author Yunhui Fu ([email protected])
* @version 1.0
* @date 2016-08-19
* @copyright GPL/BSD
*/
#include "fontutils.h"
#include "u8g_fontutf8.h"
#include "lcdprint.h"
////////////////////////////////////////////////////////////
#if ENABLED(DOGLCD)
#if defined(ARDUINO)
#include <U8glib.h>
extern U8GLIB *pu8g;
#define _lcd_write(a) pu8g->print(a)
#define _lcd_setcursor(col, row) pu8g->setPrintPos((col), (row));
#else
#define _lcd_write(a) TRACE ("Write LCD: %c (%d)", (a), (int)(a));
#define _lcd_setcursor(col, row) TRACE ("Set cursor LCD: (%d,%d)", (col), (row));
#endif
int
lcd_glyph_height(void)
{
return u8g_GetFontBBXHeight(pu8g->getU8g());
//return u8g_GetFontBBXOffY(pu8g->getU8g());
}
void
lcd_moveto (int col, int row)
{
TRACE ("Move to: (%d,%d)", col, row);
_lcd_setcursor(col, row);
}
int
lcd_print_uchar (wchar_t c, pixel_len_t max_length)
{
if (c < 128) {
TRACE ("draw char: regular %d", (int)c);
_lcd_write ((char)c);
return u8g_GetFontBBXWidth(pu8g->getU8g());
}
unsigned int ret;
unsigned int x;
unsigned int y;
x = pu8g->getPrintCol();
y = pu8g->getPrintRow();
TRACE ("uxg_DrawWchar(x=%d,y=%d,maxlen=%d", x, y, max_length);
ret = uxg_DrawWchar (pu8g->getU8g(), x, y, c, max_length);
TRACE ("u8g->setPrintPos(x=%d + ret=%d,y=%d", x, ret, y);
pu8g->setPrintPos (x + ret, y);
return ret;
}
int
lcd_printstr (const char * utf8_str, pixel_len_t max_length)
{
unsigned int ret;
unsigned int x;
unsigned int y;
x = pu8g->getPrintCol();
y = pu8g->getPrintRow();
TRACE ("uxg_DrawUtf8Str(x=%d,y=%d,maxlen=%d", x, y, max_length);
ret = uxg_DrawUtf8Str (pu8g->getU8g(), x, y, utf8_str, max_length);
TRACE ("u8g->setPrintPos(x=%d + ret=%d,y=%d", x, ret, y);
pu8g->setPrintPos (x + ret, y);
return ret;
}
int
lcd_printstr_P (const char * utf8_str_P, pixel_len_t max_length)
{
unsigned int ret;
unsigned int x;
unsigned int y;
x = pu8g->getPrintCol();
y = pu8g->getPrintRow();
TRACE ("uxg_DrawUtf8StrP(x=%d,y=%d,maxlen=%d", x, y, max_length);
ret = uxg_DrawUtf8StrP (pu8g->getU8g(), x, y, utf8_str_P, max_length);
TRACE ("u8g->setPrintPos(x=%d + ret=%d,y=%d", x, ret, y);
pu8g->setPrintPos (x + ret, y);
return ret;
}
#endif // ! USE_HD44780