mirror of
https://github.com/jscrane/r65emu.git
synced 2024-10-28 07:25:06 +00:00
parent
9da8a503a2
commit
e4cc6249ff
@ -18,6 +18,7 @@ static UTFT utft(TFT_MODEL, TFT_RS, TFT_WR, TFT_CS, TFT_RST, TFT_SER);
|
||||
#elif defined(USE_ESPI)
|
||||
#pragma message "Configure TFT_eSPI in Makefile or <TFT_eSPI/User_Setup.h>"
|
||||
#include <TFT_eSPI.h>
|
||||
#include <Fonts/GFXFF/gfxfont.h>
|
||||
|
||||
static TFT_eSPI espi;
|
||||
|
||||
@ -85,6 +86,14 @@ inline int rot(orientation_t r) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void textSize(const char *s, unsigned &w, unsigned &h) {
|
||||
int16_t x, y;
|
||||
uint16_t width, height;
|
||||
dvi.getTextBounds(s, 0, 0, &x, &y, &width, &height);
|
||||
w = width;
|
||||
h = height;
|
||||
}
|
||||
|
||||
#else
|
||||
#pragma error "Display not configured!"
|
||||
#endif
|
||||
@ -112,6 +121,27 @@ void Display::setScreen(unsigned sx, unsigned sy) {
|
||||
}
|
||||
}
|
||||
|
||||
void Display::setFont(const void *font) {
|
||||
#if defined(USE_UTFT)
|
||||
utft.setFont((uint8_t *)font);
|
||||
_cx = utft.getFontXsize();
|
||||
_cy = utft.getFontYsize();
|
||||
#elif defined(USE_ESPI)
|
||||
const GFXfont *f = (const GFXfont *)font;
|
||||
espi.setFreeFont(f);
|
||||
_cy = espi.fontHeight();
|
||||
_cx = espi.textWidth("M");
|
||||
#elif defined(USE_DVI)
|
||||
dvi.setFont((const GFXfont *)font);
|
||||
textSize("M", _cx, _cy);
|
||||
#elif defined(USE_VGA)
|
||||
fabgl::FontInfo const *f = (fabgl::FontInfo const *)font;
|
||||
canvas.selectFont(f);
|
||||
_cy = f->height;
|
||||
_cx = f->width;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Display::begin(colour_t bg, colour_t fg, orientation_t orient) {
|
||||
_bg = bg;
|
||||
_fg = fg;
|
||||
@ -122,18 +152,14 @@ void Display::begin(colour_t bg, colour_t fg, orientation_t orient) {
|
||||
utft.setBackColor(_bg);
|
||||
_dx = utft.getDisplayXSize();
|
||||
_dy = utft.getDisplayYSize();
|
||||
|
||||
utft.setFont((uint8_t *)TinyFont);
|
||||
_cx = utft.getFontXsize();
|
||||
_cy = utft.getFontYsize();
|
||||
setFont(TinyFont);
|
||||
|
||||
#elif defined(USE_ESPI)
|
||||
espi.init();
|
||||
espi.setRotation(orient);
|
||||
_dx = espi.width();
|
||||
_dy = espi.height();
|
||||
_cy = espi.fontHeight();
|
||||
_cx = 6;
|
||||
setFont(ESPI_DEFAULT_FONT);
|
||||
|
||||
#elif defined(USE_DVI)
|
||||
static bool init;
|
||||
@ -142,14 +168,10 @@ void Display::begin(colour_t bg, colour_t fg, orientation_t orient) {
|
||||
success = dvi.begin();
|
||||
|
||||
init = true;
|
||||
dvi.setRotation(rot(orient));
|
||||
_dx = dvi.width();
|
||||
_dy = dvi.height();
|
||||
|
||||
// Adafruit_GFX default font size
|
||||
_cx = 6;
|
||||
_cy = 8;
|
||||
|
||||
dvi.setRotation(rot(orient));
|
||||
setFont(DVI_DEFAULT_FONT);
|
||||
|
||||
#if DVI_BIT_DEPTH == 8
|
||||
for (int i = 0; i < NCOLOURS; i++)
|
||||
@ -165,15 +187,13 @@ void Display::begin(colour_t bg, colour_t fg, orientation_t orient) {
|
||||
init = true;
|
||||
vga.begin();
|
||||
vga.setResolution(VGA_RESOLUTION);
|
||||
_dx = canvas.getWidth();
|
||||
_dy = canvas.getHeight();
|
||||
|
||||
canvas.setBrushColor(rgb(_bg));
|
||||
canvas.clear();
|
||||
canvas.setGlyphOptions(GlyphOptions().FillBackground(true));
|
||||
canvas.selectFont(&fabgl::FONT_5x7);
|
||||
_cy = canvas.getFontInfo()->height;
|
||||
_cx = canvas.getFontInfo()->width;
|
||||
_dx = canvas.getWidth();
|
||||
_dy = canvas.getHeight();
|
||||
setFont(VGA_DEFAULT_FONT);
|
||||
|
||||
DBG(printf("VGA: w %d h %d\r\n", _dx, _dy));
|
||||
#endif
|
||||
@ -216,9 +236,9 @@ void Display::status(const char *s) {
|
||||
canvas.drawText(_dx - _oxs, _dy - _cy, s);
|
||||
#elif defined(USE_DVI)
|
||||
int16_t x, y;
|
||||
uint16_t w, h;
|
||||
unsigned w, h;
|
||||
dvi.fillRect(_dx - _oxs, _dy - _cy, _oxs, _cy, _bg);
|
||||
dvi.getTextBounds(s, 0, 0, &x, &y, &w, &h);
|
||||
textSize(s, w, h);
|
||||
dvi.setCursor(_dx - w, _dy - h);
|
||||
dvi.print(s);
|
||||
_oxs = _dx - w;
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
void begin(colour_t bg, colour_t fg, orientation_t o);
|
||||
void setScreen(unsigned sx, unsigned sy);
|
||||
void clear();
|
||||
void setFont(const void *font);
|
||||
|
||||
void status(const char *s);
|
||||
void statusf(const char *fmt, ...);
|
||||
|
@ -49,6 +49,10 @@
|
||||
//#define DVI_DOUBLE_BUFFERED true
|
||||
#endif
|
||||
|
||||
#if !defined(DVI_DEFAULT_FONT)
|
||||
#define DVI_DEFAULT_FONT 0
|
||||
#endif
|
||||
|
||||
// 64kB RAM
|
||||
#define RAM_SIZE 0x10000u
|
||||
|
||||
|
@ -13,6 +13,10 @@
|
||||
//#define TFT_RST -1
|
||||
//#define SPI_FREQUENCY 40000000
|
||||
//#define LOAD_GLCD
|
||||
//#define LOAD_GFXFF
|
||||
#if !defined(ESPI_DEFAULT_FONT)
|
||||
#define ESPI_DEFAULT_FONT 0
|
||||
#endif
|
||||
|
||||
// use alternative TFT display library...
|
||||
//#define USE_UTFT
|
||||
|
@ -15,6 +15,10 @@
|
||||
//#define TFT_RST -1
|
||||
//#define SPI_FREQUENCY 40000000
|
||||
//#define LOAD_GLCD
|
||||
//#define LOAD_GFXFF
|
||||
#if !defined(ESPI_DEFAULT_FONT)
|
||||
#define ESPI_DEFAULT_FONT 0
|
||||
#endif
|
||||
|
||||
// PS/2 keyboard
|
||||
#if !defined(USE_OWN_KBD)
|
||||
|
@ -7,6 +7,9 @@
|
||||
#define VGA_RESOLUTION VGA_480x300_75Hz
|
||||
//#define VGA_RESOLUTION VGA_320x200_75HzRetro
|
||||
#endif
|
||||
#if !defined(VGA_DEFAULT_FONT)
|
||||
#define VGA_DEFAULT_FONT &fabgl::FONT_6x10
|
||||
#endif
|
||||
|
||||
// PS/2 Keyboard
|
||||
#if !defined(USE_OWN_KBD)
|
||||
|
Loading…
Reference in New Issue
Block a user