Compare commits

...

7 Commits

Author SHA1 Message Date
steve 3af6b4d3f7 bugfixes 2023-11-18 21:46:06 +00:00
steve 12f9989a1d small cleanups 2023-11-18 20:08:16 +00:00
steve b2519c5ff0 updates 2023-11-18 13:23:52 +00:00
steve 73964abe4b new display apis 2023-11-18 11:03:47 +00:00
steve c22812413c bugfix 2023-11-18 10:58:15 +00:00
steve c6d18c8cc0 ... 2023-11-18 10:57:50 +00:00
steve 0fc3575c93 template param for chip capacity 2023-11-18 10:57:40 +00:00
10 changed files with 125 additions and 21 deletions

View File

@ -11,6 +11,7 @@ Sample Applications
- [Pacman](https://github.com/jscrane/pacman)
- [Commodore PET](https://github.com/jscrane/PET)
- [Compukit UK101](https://github.com/jscrane/UK101)
- [Commodore Chessmate](https://github.com/jscrane/Chessmate)
Configuration for Arduino
--------------
@ -51,5 +52,5 @@ ESP8266 board, e.g., [WeMOS](https://www.wemos.cc/en/latest/d1/d1_mini.html), _o
ESP32-based board, e.g., [Node32s](https://www.esp32.com/viewtopic.php?t=459),
- An SD drive to store programs (for Stellarpad),
- A 23k256 SPI RAM chip (for Stellarpad, optional),
- A supported TFT screen, such as [this one](http://forum.stellarisiti.com/topic/626-ssd1289-32-320x240-tft-16bit-parallel-interface-touch-libraries/),
- A supported TFT screen (if not using a board with VGA),
- A PS/2 keyboard.

View File

@ -63,10 +63,8 @@ void Display::begin(colour_t bg, colour_t fg, orientation_t orient, unsigned dis
_dx -= _xoff;
_dy -= _yoff;
#if defined(DEBUGGING)
Serial.printf("xoff %d yoff %d dx %d dy %d", _xoff, _yoff, _dx, _dy);
Serial.println();
#endif
DBG(printf("xoff %d yoff %d dx %d dy %d", _xoff, _yoff, _dx, _dy));
DBG(println());
}
void Display::begin(colour_t bg, colour_t fg, orientation_t orient) {
@ -76,6 +74,7 @@ void Display::begin(colour_t bg, colour_t fg, orientation_t orient) {
#if defined(USE_UTFT)
utft.InitLCD(orient);
utft.setBackColor(_bg);
_dx = utft.getDisplayXSize();
_dy = utft.getDisplayYSize();
@ -109,11 +108,7 @@ void Display::begin(colour_t bg, colour_t fg, orientation_t orient) {
_dx = canvas.getWidth();
_dy = canvas.getHeight();
#if defined(DEBUGGING)
Serial.printf("w %d h %d", _dx, _dy);
Serial.println();
#endif
DBG(printf("w %d h %d\r\n", _dx, _dy));
#endif
setColor(fg);
@ -173,17 +168,90 @@ void Display::drawPixel(unsigned x, unsigned y, colour_t col) {
#endif
}
void Display::drawString(const char *s, unsigned x, unsigned y) {
void Display::drawLine(unsigned x1, unsigned y1, unsigned x2, unsigned y2, colour_t col) {
x1 += _xoff;
y1 += _yoff;
x2 += _xoff;
y2 += _yoff;
#if defined(USE_UTFT)
utft.setColor(col);
utft.drawLine(x1, y1, x2, y2);
#elif defined(USE_ESPI)
espi.drawLine(x1, y1, x2, y2, col);
#elif defined(USE_VGA)
canvas.setPenColor(rgb(col));
canvas.drawLine(x1, y1, x2, y2);
#endif
}
void Display::drawCircle(unsigned x, unsigned y, unsigned r, colour_t col) {
x += _xoff;
y += _yoff;
#if defined(USE_UTFT)
utft.setColor(col);
utft.drawCircle(x, y, r);
#elif defined(USE_ESPI)
espi.drawCircle(x, y, r, col);
#elif defined(USE_VGA)
canvas.setPenColor(rgb(col));
canvas.drawEllipse(x, y, r, r);
#endif
}
void Display::fillCircle(unsigned x, unsigned y, unsigned r, colour_t col) {
x += _xoff;
y += _yoff;
#if defined(USE_UTFT)
utft.setColor(col);
utft.fillCircle(x, y, r);
#elif defined(USE_ESPI)
espi.fillCircle(x, y, r, col);
#elif defined(USE_VGA)
canvas.setBrushColor(rgb(col));
canvas.fillEllipse(x, y, r, r);
#endif
}
void Display::drawRectangle(unsigned x, unsigned y, unsigned w, unsigned h, colour_t col) {
x += _xoff;
y += _yoff;
#if defined(USE_UTFT)
utft.setColor(col);
utft.drawRect(x, y, x+w, y+h);
#elif defined(USE_ESPI)
espi.drawRect(x, y, w, h, col);
#elif defined(USE_VGA)
canvas.setPenColor(rgb(col));
canvas.drawRectangle(x, y, x+w, y+h);
#endif
}
void Display::fillRectangle(unsigned x, unsigned y, unsigned w, unsigned h, colour_t col) {
x += _xoff;
y += _yoff;
#if defined(USE_UTFT)
utft.setColor(col);
utft.fillRect(x, y, x+w, y+h);
#elif defined(USE_ESPI)
espi.fillRect(x, y, w, h, col);
#elif defined(USE_VGA)
canvas.setBrushColor(rgb(col));
canvas.fillRectangle(x, y, x+w, y+h);
#endif
}
void Display::drawString(const char *s, unsigned x, unsigned y, colour_t col) {
x += _xoff;
y += _yoff;
#if defined(USE_UTFT)
utft.setColor(col);
utft.print(s, x, y);
#elif defined(USE_ESPI)
espi.setTextDatum(TL_DATUM);
unsigned w = espi.textWidth(s);
espi.fillRect(x, y, w, _cy, _bg);
espi.setTextColor(col, _bg, true);
espi.drawString(s, x, y);
#elif defined(USE_VGA)
canvas.setPenColor(rgb(col));
canvas.drawText(x, y, s);
#endif
}

View File

@ -37,7 +37,25 @@ public:
void statusf(const char *fmt, ...);
void drawPixel(unsigned x, unsigned y, colour_t col);
void drawString(const char *s, unsigned x, unsigned y);
void drawPixel(unsigned x, unsigned y) { drawPixel(x, y, _fg); }
void drawLine(unsigned x1, unsigned y1, unsigned x2, unsigned y2, colour_t col);
void drawLine(unsigned x1, unsigned y1, unsigned x2, unsigned y2) { drawLine(x1, y1, x2, y2, _fg); }
void drawCircle(unsigned x, unsigned y, unsigned r, colour_t col);
void drawCircle(unsigned x, unsigned y, unsigned r) { drawCircle(x, y, r, _fg); }
void fillCircle(unsigned x, unsigned y, unsigned r, colour_t col);
void fillCircle(unsigned x, unsigned y, unsigned r) { fillCircle(x, y, r, _fg); }
void drawRectangle(unsigned x, unsigned y, unsigned w, unsigned h, colour_t col);
void drawRectangle(unsigned x, unsigned y, unsigned w, unsigned h) { drawRectangle(x, y, w, h, _fg); }
void fillRectangle(unsigned x, unsigned y, unsigned w, unsigned h, colour_t col);
void fillRectangle(unsigned x, unsigned y, unsigned w, unsigned h) { fillRectangle(x, y, w, h, _fg); }
void drawString(const char *s, unsigned x, unsigned y, colour_t col);
void drawString(const char *s, unsigned x, unsigned y) { drawString(s, x, y, _fg); }
protected:
unsigned _bg, _fg, _cx, _cy, _dx, _dy, _oxs, _xoff, _yoff;

View File

@ -12,7 +12,9 @@
#include "filer.h"
#include "flash_filer.h"
#if defined(USE_SPIFFS) || defined(USE_LITTLEFS)
static File files[MAX_FILES];
#endif
#if defined(USE_SPIFFS)
static File dir;
@ -141,8 +143,10 @@ const char *flash_filer::checkpoint() {
hardware_checkpoint(file);
file.close();
start();
#endif
return buf;
#else
return "";
#endif
}
void flash_filer::restore(const char *filename) {

View File

@ -22,16 +22,20 @@
#define KBD_DATA D4
// SPI-RAM
#if !defined(NO_SPIRAM)
#define USE_SPIRAM
#define SPIRAM_DEV SPI
#define SPIRAM_CS D0
#define SPIRAM_SIZE 0x8000u
#endif
// "tape" storage...
// flash storage
#if !defined(NO_STORAGE)
#undef USE_SD
//#define SD_CS D0
#undef USE_SPIFFS
#define USE_LITTLEFS
#endif
// sound
#define PWM_SOUND D2

View File

@ -28,10 +28,12 @@
#define KBD_DATA 34
#define KBD_IRQ 35
// storage
// Storage
#if !defined(NO_STORAGE)
#undef USE_SD
#undef USE_LITTLEFS
#define USE_SPIFFS
#endif
// sound: dac and pwm
#define DAC_SOUND 25

View File

@ -7,12 +7,15 @@
#define KBD_DATA PE_4
#define KBD_IRQ PE_5
// "tape" storage...
// Storage
#if !defined(NO_STORAGE)
#define USE_SD
#define SD_CS PF_3
#define SD_SPI 1
#endif
// 23k256 SPI-RAM
#if !defined(NO_SPIRAM)
#define USE_SPIRAM
#define SPI_CS PF_3
#define SPIRAM_CS PE_0
@ -20,6 +23,7 @@
#define SPIRAM_MODULE 1
#define SPIRAM_CLKDIV 1
#define SPIRAM_SIZE 0x8000u
#endif
// TFT display...
// NOTE: edit memorysaver.h to select the correct chip for your display!

View File

@ -20,7 +20,9 @@
#define DAC_SOUND 25
#define PWM_SOUND 25
// "tape" storage...
// Storage
#if !defined(NO_STORAGE)
#undef USE_SD
#undef USE_LITTLEFS
#define USE_SPIFFS
#endif

3
ram.h
View File

@ -1,9 +1,10 @@
#ifndef __RAM_H__
#define __RAM_H__
template<unsigned n = 1024>
class ram: public Memory::Device {
public:
static const unsigned page_size = 1024;
static const unsigned page_size = n;
virtual void operator= (uint8_t c) { _mem[_acc] = c; }
virtual operator uint8_t () { return _mem[_acc]; }

View File

@ -3,9 +3,9 @@
#include "timed.h"
#include "sound_dac.h"
#if defined(DAC_SOUND) && defined(ESP_PLATFORM)
static DAC *s;
#if defined(DAC_SOUND) && defined(ESP_PLATFORM)
#include <driver/dac.h>
static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;