mirror of
https://github.com/jscrane/r65emu.git
synced 2024-12-30 09:30:46 +00:00
move more functionality onto utftdisplay
This commit is contained in:
parent
8ac8ad1edf
commit
270af3b930
1
r65emu.h
1
r65emu.h
@ -8,6 +8,7 @@
|
||||
#include "spiram.h"
|
||||
#include "prom.h"
|
||||
#include "ps2drv.h"
|
||||
#include "utftdisplay.h"
|
||||
#include "hardware.h"
|
||||
|
||||
#endif
|
||||
|
50
utftdisplay.cpp
Normal file
50
utftdisplay.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include <UTFT.h>
|
||||
|
||||
#include "memory.h"
|
||||
#include "utftdisplay.h"
|
||||
|
||||
extern UTFT utft;
|
||||
|
||||
void UTFTDisplay::begin(unsigned bg, unsigned fg) {
|
||||
_bg = bg;
|
||||
_fg = fg;
|
||||
_dx = utft.getDisplayXSize();
|
||||
_dy = utft.getDisplayYSize();
|
||||
_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;
|
||||
}
|
19
utftdisplay.h
Normal file
19
utftdisplay.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef _UTFT_DISPLAY_H
|
||||
#define _UTFT_DISPLAY_H
|
||||
|
||||
class Stream;
|
||||
|
||||
class UTFTDisplay: public Memory::Device {
|
||||
public:
|
||||
void begin(unsigned bg, unsigned fg);
|
||||
void clear();
|
||||
void error(char *);
|
||||
void status(const char *);
|
||||
|
||||
protected:
|
||||
UTFTDisplay(unsigned size): Memory::Device(size) {}
|
||||
|
||||
unsigned _bg, _fg, _cx, _cy, _dx, _dy, _oxs;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user