1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-06-12 20:08:04 +00:00

centering display (#16)

This commit is contained in:
Stephen Crane 2023-07-26 15:32:11 +01:00 committed by GitHub
parent 28f23d2aad
commit f4dbc8ae26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -55,9 +55,18 @@ static inline void setColor(colour_t c) {
#endif
}
void Display::begin(unsigned bg, unsigned fg, orientation_t orient) {
void Display::begin(colour_t bg, colour_t fg, orientation_t orient, unsigned dispx, unsigned dispy) {
begin(bg, fg, orient);
_xoff = (_dx - dispx) / 2;
_yoff = (_dy - dispy) / 2;
_dx -= _xoff;
_dy -= _yoff;
}
void Display::begin(colour_t bg, colour_t fg, orientation_t orient) {
_bg = bg;
_fg = fg;
_xoff = _yoff = 0;
#if defined(USE_UTFT)
utft.InitLCD(orient);
@ -131,6 +140,8 @@ void Display::status(const char *s) {
}
void Display::drawPixel(unsigned x, unsigned y, colour_t col) {
x += _xoff;
y += _yoff;
#if defined(USE_UTFT)
utft.setColor(col);
utft.drawPixel(x, y);
@ -142,6 +153,8 @@ void Display::drawPixel(unsigned x, unsigned y, colour_t col) {
}
void Display::drawString(const char *s, unsigned x, unsigned y) {
x += _xoff;
y += _yoff;
#if defined(USE_UTFT)
utft.print(s, x, y);
#elif defined(USE_ESPI)

View File

@ -29,7 +29,9 @@ const colour_t PINK = 0xFC9F;
class Display {
public:
void begin(colour_t bg, colour_t fg, orientation_t o = landscape);
void begin(colour_t bg, colour_t fg, orientation_t o);
void begin(colour_t bg, colour_t fg, orientation_t o, unsigned dispx, unsigned dispy);
void clear();
void status(const char *s);
@ -37,7 +39,7 @@ public:
void drawString(const char *s, unsigned x, unsigned y);
protected:
unsigned _bg, _fg, _cx, _cy, _dx, _dy, _oxs;
unsigned _bg, _fg, _cx, _cy, _dx, _dy, _oxs, _xoff, _yoff;
};
#endif