ESP32: menu

This commit is contained in:
folkert van heusden 2022-03-17 21:50:48 +01:00
parent d9a56801f7
commit 22b48083ce
2 changed files with 30 additions and 4 deletions

View file

@ -72,7 +72,7 @@ void setup() {
b->add_tty(tty_);
Serial.println(F("Load RK05"));
b->add_rk05(new rk05("xxdp+.rk", b));
b->add_rk05(new rk05("", b));
setBootLoader(b);
Serial.print(F("Free RAM after init: "));

View file

@ -35,13 +35,39 @@ rk05::rk05(const std::string & file, bus *const b) : b(b)
Serial.print(F("SS : "));
Serial.println(int(SS));
Serial.println(F("Files on SD-card:"));
if (!sd.begin(SS, SD_SCK_MHZ(15)))
sd.initErrorHalt();
Serial.print(F("Opening: "));
Serial.println(file.c_str());
sd.ls("/", LS_DATE | LS_SIZE | LS_R);
if (!fh.open(file.c_str(), O_RDWR))
std::string selected_file;
while(Serial.available())
Serial.read();
Serial.print(F("Enter filename: "));
for(;;) {
if (Serial.available()) {
char c = Serial.read();
if (c == 13 || c == 10)
break;
if (c >= 32 && c < 127) {
selected_file += c;
Serial.print(c);
}
}
}
Serial.print(F("Opening file: "));
Serial.println(selected_file.c_str());
if (!fh.open(selected_file.c_str(), O_RDWR))
sd.errorHalt(F("rk05: open failed"));
#else
fh = fopen(file.c_str(), "rb");