Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Commit 2d963f1

Browse files
committed
Added support for VGA-32 v1.4 using #ifdef VGA32V14
1 parent 088cff6 commit 2d963f1

File tree

6 files changed

+80
-7
lines changed

6 files changed

+80
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ platformio.ini
88
/work
99
.piolibdeps/
1010
.vscode
11+
.pio
1112
data/boot.cfg
1213
data/sna/**
1314
!data/sna/sppong.sna

include/Disk.h

+6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ extern String cfg_wssid;
2121
extern String cfg_wpass;
2222

2323
// Declared methods
24+
25+
#ifdef VGA32V14
26+
void IRAM_ATTR mount_sd();
27+
#else
2428
void IRAM_ATTR mount_spiffs();
29+
#endif
30+
2531
String getAllFilesFrom(const String path);
2632
void listAllFiles();
2733
File IRAM_ATTR open_read_file(String filename);

include/def/hardware.h

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
#ifdef VGA32V14
2+
3+
#define SPEAKER_PIN 25
4+
#define EAR_PIN 34
5+
#define MIC_PIN 39
6+
7+
#define KEYBOARD_DATA 32
8+
#define KEYBOARD_CLK 33
9+
10+
#define COLOUR_16
11+
12+
// 16b pins
13+
#define RED_PINS 21, 21, 22, 22, 22
14+
#define GREEN_PINS 18, 18, 19, 19, 19
15+
#define BLUE_PINS 4, 4, 5, 5
16+
17+
// VGA sync pins
18+
#define HSYNC_PIN 23
19+
#define VSYNC_PIN 15
20+
21+
#else
22+
123
#define SPEAKER_PIN 5
224
#define EAR_PIN 34
325
#define MIC_PIN 0
@@ -22,6 +44,9 @@
2244
#define HSYNC_PIN 32
2345
#define VSYNC_PIN 33
2446

47+
48+
#endif
49+
2550
#ifdef COLOUR_8
2651
#define BLACK 0x08
2752
#define BLUE 0x0c

platformio.ini.vga32

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Use this configuration to build for VGA32 v1.4
2+
3+
[env:pico32]
4+
platform = espressif32
5+
board = pico32
6+
framework = arduino
7+
board_build.partitions = noota_3g.csv
8+
lib_deps = bitluni/bitluni ESP32Lib@0.2.1
9+
build_flags =
10+
-DVGA32V14
11+

src/Disk.cpp

+27-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
#include "def/types.h"
99
#include "osd.h"
1010
#include <FS.h>
11+
12+
#ifdef VGA32V14
13+
#include <SD.h>
14+
#else
1115
#include <SPIFFS.h>
16+
#endif
1217

1318
void errorHalt(String errormsg);
1419
void IRAM_ATTR kb_interruptHandler(void);
@@ -26,16 +31,32 @@ boolean cfg_wconn = false;
2631
String cfg_wssid = "none";
2732
String cfg_wpass = "none";
2833

34+
static fs::FS* fileSystem;
35+
36+
#ifdef VGA32V14
37+
void IRAM_ATTR mount_sd() {
38+
SPI.begin(14, 2, 12);
39+
if (!SD.begin(13))
40+
{
41+
errorHalt(ERR_MOUNT_FAIL);
42+
}
43+
44+
fileSystem = &SD;
45+
vTaskDelay(2);
46+
}
47+
#else
2948
void IRAM_ATTR mount_spiffs() {
3049
if (!SPIFFS.begin())
3150
errorHalt(ERR_MOUNT_FAIL);
3251

52+
fileSystem = &SPIFFS;
3353
vTaskDelay(2);
3454
}
55+
#endif
3556

3657
String getAllFilesFrom(const String path) {
3758
KB_INT_STOP;
38-
File root = SPIFFS.open("/");
59+
File root = fileSystem->open("/");
3960
File file = root.openNextFile();
4061
String listing;
4162

@@ -54,7 +75,7 @@ String getAllFilesFrom(const String path) {
5475

5576
void listAllFiles() {
5677
KB_INT_STOP;
57-
File root = SPIFFS.open("/");
78+
File root = fileSystem->open("/");
5879
Serial.println("fs opened");
5980
File file = root.openNextFile();
6081
Serial.println("fs openednextfile");
@@ -74,11 +95,11 @@ File open_read_file(String filename) {
7495
filename.trim();
7596
if (cfg_slog_on)
7697
Serial.printf("%s '%s'\n", MSG_LOADING, filename.c_str());
77-
if (!SPIFFS.exists(filename.c_str())) {
98+
if (!fileSystem->exists(filename.c_str())) {
7899
KB_INT_START;
79100
errorHalt((String)ERR_READ_FILE + "\n" + filename);
80101
}
81-
f = SPIFFS.open(filename.c_str(), FILE_READ);
102+
f = fileSystem->open(filename.c_str(), FILE_READ);
82103
vTaskDelay(2);
83104

84105
return f;
@@ -235,7 +256,7 @@ String getFileEntriesFromDir(String path) {
235256
KB_INT_STOP;
236257
Serial.printf("Getting entries from: '%s'\n", path.c_str());
237258
String filelist;
238-
File root = SPIFFS.open(path.c_str());
259+
File root = fileSystem->open(path.c_str());
239260
if (!root || !root.isDirectory()) {
240261
errorHalt((String)ERR_DIR_OPEN + "\n" + root);
241262
}
@@ -379,7 +400,7 @@ void config_read() {
379400
void config_save() {
380401
KB_INT_STOP;
381402
Serial.printf("Saving config file '%s':\n", DISK_BOOT_FILENAME);
382-
File f = SPIFFS.open(DISK_BOOT_FILENAME, FILE_WRITE);
403+
File f = fileSystem->open(DISK_BOOT_FILENAME, FILE_WRITE);
383404
// Architecture
384405
Serial.printf(" + arch:%s\n", cfg_arch.c_str());
385406
f.printf("arch:%s\n", cfg_arch.c_str());

src/ZX-ESPectrum.ino

+10-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ void setup_cpuspeed();
4949
void config_read();
5050
void do_OSD();
5151
void errorHalt(String);
52+
53+
#ifdef VGA32V14
54+
void mount_sd();
55+
#else
5256
void mount_spiffs();
57+
#endif
5358

5459
// GLOBALS
5560
volatile byte z80ports_in[128];
@@ -75,7 +80,6 @@ VGA3Bit vga;
7580
VGA14Bit vga;
7681
#endif
7782

78-
7983
void setup() {
8084
// Turn off peripherals to gain memory (?do they release properly)
8185
esp_bt_controller_deinit();
@@ -88,7 +92,12 @@ void setup() {
8892

8993
Serial.printf("HEAP BEGIN %d\n", ESP.getFreeHeap());
9094

95+
#ifdef VGA32V14
96+
mount_sd();
97+
#else
9198
mount_spiffs();
99+
#endif
100+
92101
config_read();
93102
// wifiConn();
94103
Serial.printf("HEAP AFTER WIFI %d\n", ESP.getFreeHeap());

0 commit comments

Comments
 (0)