mirror of
https://github.com/jscrane/r65emu.git
synced 2024-12-22 03:30:02 +00:00
initial changes for LilyGO board
This commit is contained in:
parent
b20119558a
commit
9fac3649dc
@ -1,7 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include "hardware.h"
|
||||
#include "memory.h"
|
||||
#include "tftdisplay.h"
|
||||
#include "display.h"
|
||||
|
||||
#if defined(USE_UTFT)
|
||||
#pragma message "UTFT configured"
|
||||
@ -20,6 +20,25 @@ static UTFT utft(TFT_MODEL, TFT_RS, TFT_WR, TFT_CS, TFT_RST, TFT_SER);
|
||||
|
||||
static TFT_eSPI espi;
|
||||
|
||||
#elif defined(USE_VGA)
|
||||
#pragma message "FabGL VGA configured"
|
||||
#include <fabgl.h>
|
||||
|
||||
static fabgl::VGAController vga;
|
||||
static fabgl::Canvas canvas(&vga);
|
||||
|
||||
static const fabgl::RGB888 rgb(colour_t c) {
|
||||
switch(c) {
|
||||
case BLACK: return Color::Black;
|
||||
case WHITE: return Color::White;
|
||||
case GREEN: return Color::Green;
|
||||
case YELLOW: return Color::Yellow;
|
||||
case BLUE: return Color::Blue;
|
||||
case MAGENTA: return Color::Magenta;
|
||||
case CYAN: return Color::Cyan;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#pragma error "Display not configured!"
|
||||
#endif
|
||||
@ -29,10 +48,12 @@ static inline void setColor(colour_t c) {
|
||||
utft.setColor(c);
|
||||
#elif defined(USE_ESPI)
|
||||
espi.setTextColor(c);
|
||||
#elif defined(USE_VGA)
|
||||
canvas.setPenColor(rgb(c));
|
||||
#endif
|
||||
}
|
||||
|
||||
void TFTDisplay::begin(unsigned bg, unsigned fg, orientation_t orient) {
|
||||
void Display::begin(unsigned bg, unsigned fg, orientation_t orient) {
|
||||
_bg = bg;
|
||||
_fg = fg;
|
||||
|
||||
@ -52,21 +73,41 @@ void TFTDisplay::begin(unsigned bg, unsigned fg, orientation_t orient) {
|
||||
_dy = espi.height();
|
||||
_cy = espi.fontHeight();
|
||||
_cx = 6; // FIXME
|
||||
|
||||
#elif defined(USE_VGA)
|
||||
static bool init;
|
||||
|
||||
if (init)
|
||||
vga.end();
|
||||
init = true;
|
||||
vga.begin();
|
||||
vga.setResolution(VGA_480x300_75Hz);
|
||||
|
||||
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();
|
||||
#endif
|
||||
|
||||
setColor(fg);
|
||||
_oxs = _dx;
|
||||
}
|
||||
|
||||
void TFTDisplay::clear() {
|
||||
void Display::clear() {
|
||||
#if defined(USE_UTFT)
|
||||
utft.fillScr(_bg);
|
||||
#elif defined(USE_ESPI)
|
||||
espi.fillScreen(_bg);
|
||||
#elif defined(USE_VGA)
|
||||
canvas.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
void TFTDisplay::status(const char *s) {
|
||||
void Display::status(const char *s) {
|
||||
setColor(_fg);
|
||||
|
||||
#if defined(USE_UTFT)
|
||||
@ -80,19 +121,25 @@ void TFTDisplay::status(const char *s) {
|
||||
_oxs = espi.textWidth(s);
|
||||
espi.setTextDatum(BR_DATUM);
|
||||
espi.drawString(s, _dx, _dy);
|
||||
#elif defined(USE_VGA)
|
||||
canvas.fillRectangle(_dx - _oxs, _dy - _cy, _dx, _dy);
|
||||
_oxs = canvas.textExtent(s) + _cx;
|
||||
canvas.drawText(_dx - _oxs, _dy - _cy, s);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TFTDisplay::drawPixel(unsigned x, unsigned y, colour_t col) {
|
||||
void Display::drawPixel(unsigned x, unsigned y, colour_t col) {
|
||||
#if defined(USE_UTFT)
|
||||
utft.setColor(col);
|
||||
utft.drawPixel(x, y);
|
||||
#elif defined(USE_ESPI)
|
||||
espi.drawPixel(x, y, col);
|
||||
#elif defined(USE_VGA)
|
||||
canvas.setPixel(x, y, rgb(col));
|
||||
#endif
|
||||
}
|
||||
|
||||
void TFTDisplay::drawString(const char *s, unsigned x, unsigned y) {
|
||||
void Display::drawString(const char *s, unsigned x, unsigned y) {
|
||||
#if defined(USE_UTFT)
|
||||
utft.print(s, x, y);
|
||||
#elif defined(USE_ESPI)
|
||||
@ -100,5 +147,7 @@ void TFTDisplay::drawString(const char *s, unsigned x, unsigned y) {
|
||||
unsigned w = espi.textWidth(s);
|
||||
espi.fillRect(x, y, w, _cy, _bg);
|
||||
espi.drawString(s, x, y);
|
||||
#elif defined(USE_VGA)
|
||||
canvas.drawText(x, y, s);
|
||||
#endif
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#ifndef __TFTDISPLAY_H__
|
||||
#define __TFTDISPLAY_H__
|
||||
#ifndef __DISPLAY_H__
|
||||
#define __DISPLAY_H__
|
||||
|
||||
typedef enum {
|
||||
portrait, landscape, reverse_portrait, reverse_landscape
|
||||
@ -27,7 +27,7 @@ const colour_t ORANGE = 0xFDA0;
|
||||
const colour_t GREENYELLOW = 0xB7E0;
|
||||
const colour_t PINK = 0xFC9F;
|
||||
|
||||
class TFTDisplay {
|
||||
class Display {
|
||||
public:
|
||||
void begin(colour_t bg, colour_t fg, orientation_t o = landscape);
|
||||
void clear();
|
22
hw/lilygo-vga32.h
Normal file
22
hw/lilygo-vga32.h
Normal file
@ -0,0 +1,22 @@
|
||||
// LilyGO TTGO VGA32
|
||||
|
||||
#define USE_VGA
|
||||
|
||||
#define USE_KBD
|
||||
#define KBD_DATA 32
|
||||
#define KBD_IRQ 33
|
||||
|
||||
#define RAM_SIZE 0x10000u
|
||||
|
||||
// sound: dac and pwm
|
||||
#define DAC_SOUND 25
|
||||
|
||||
// PWM doesn't work
|
||||
// "assert failed: ledc_clk_cfg_to_global_clk ledc.c:443 (false)"
|
||||
//#define PWM_SOUND 25
|
||||
//#define PWM_DUTY 20 // 20/1024 -> volume
|
||||
|
||||
// "tape" storage...
|
||||
#undef USE_SD
|
||||
#undef USE_FS
|
||||
#define USE_SPIFFS
|
Loading…
Reference in New Issue
Block a user