1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-12-22 03:30:02 +00:00
r65emu/utftdisplay.cpp

56 lines
1.0 KiB
C++
Raw Normal View History

#include <UTFT.h>
#include "memory.h"
#include "utftdisplay.h"
2014-11-16 21:45:00 +00:00
#include "TinyFont.h"
extern UTFT utft;
2014-12-01 08:42:24 +00:00
void UTFTDisplay::begin(unsigned bg, unsigned fg, orientation_t orient) {
_bg = bg;
_fg = fg;
2014-11-30 21:17:08 +00:00
utft.InitLCD(orient);
_dx = utft.getDisplayXSize();
_dy = utft.getDisplayYSize();
2014-11-13 14:10:11 +00:00
2014-11-16 21:45:00 +00:00
utft.setFont((uint8_t *)TinyFont);
2014-11-13 14:10:11 +00:00
utft.setColor(fg);
_cx = utft.getFontXsize();
_cy = utft.getFontYsize();
_oxs = _dx;
}
void UTFTDisplay::clear() {
utft.fillScr(_bg);
}
void UTFTDisplay::error(char *s)
{
utft.setColor(_fg);
char *lines[5];
int l = 0;
for (char *p = s, *q = s; *p; p++)
if (*p == '\n') {
*p++ = 0;
lines[l++] = q;
q = p;
}
unsigned y = (_dy - l*_cy)/2;
for (int i = 0; i < l; i++) {
char *p = lines[i];
unsigned x = (_dx - strlen(p)*_cx)/2;
utft.print(p, x, y);
y += _cy;
}
}
void UTFTDisplay::status(const char *s)
{
utft.setColor(_fg);
unsigned y = _dy - _cy, n = strlen(s), xs = _dx - n*_cx;
for (unsigned x = _oxs; x < xs; x += _cx)
utft.print(" ", x, y);
utft.print(s, xs, y);
_oxs = xs;
}