V7.3: more LCD bugfxes

This commit is contained in:
sanni 2021-11-29 13:10:04 +01:00
parent 8486e64bb6
commit cac5392a07
2 changed files with 304 additions and 113 deletions

View File

@ -4,8 +4,8 @@
This project represents a community-driven effort to provide This project represents a community-driven effort to provide
an easy to build and easy to modify cartridge dumper. an easy to build and easy to modify cartridge dumper.
Date: 18.11.2021 Date: 29.11.2021
Version: 7.2 Version: 7.3
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat
OLED lib: https://github.com/adafruit/Adafruit_SSD1306 OLED lib: https://github.com/adafruit/Adafruit_SSD1306
@ -45,7 +45,7 @@
**********************************************************************************/ **********************************************************************************/
char ver[5] = "7.2"; char ver[5] = "7.3";
/****************************************** /******************************************
Libraries Libraries
@ -643,8 +643,6 @@ void aboutScreen() {
wait_serial(); wait_serial();
resetArduino(); resetArduino();
#endif #endif
setColor_RGB(random(0, 255), random(0, 255), random(0, 255));
delay(random(50, 100));
} }
} }
@ -1196,7 +1194,7 @@ void blinkLED() {
#if (defined(enable_OLED) || defined(enable_serial)) #if (defined(enable_OLED) || defined(enable_serial))
PORTB ^= (1 << 4); PORTB ^= (1 << 4);
#elif defined(enable_LCD) #elif defined(enable_LCD)
PORTB ^= (1 << 7); //PORTB ^= (1 << 7);
#endif #endif
} }
@ -1227,6 +1225,9 @@ int checkButton() {
return 0; return 0;
} }
} }
else if (reading == buttonState) {
return 0;
}
// Check if button has changed // Check if button has changed
else { else {
if (reading != lastButtonState) { if (reading != lastButtonState) {
@ -1777,7 +1778,7 @@ unsigned char questionBox_OLED(const __FlashStringHelper * question, char answer
Filebrowser Module Filebrowser Module
*****************************************/ *****************************************/
void fileBrowser(const __FlashStringHelper * browserTitle) { void fileBrowser(const __FlashStringHelper * browserTitle) {
char fileNames[30][FILENAME_LENGTH]; char fileNames[7][FILENAME_LENGTH];
int currFile; int currFile;
filebrowse = 1; filebrowse = 1;
@ -1804,25 +1805,17 @@ browserstart:
print_Error(F("SD Error"), true); print_Error(F("SD Error"), true);
} }
// Read in File as long as there are files // Count files in directory
while (myFile.openNext(&myDir, O_READ) && (currFile < 29)) { while (myFile.openNext(&myDir, O_READ)) {
// Get name of file
myFile.getName(nameStr, FILENAME_LENGTH);
// Ignore if hidden // Ignore if hidden
if (myFile.isHidden()) { if (myFile.isHidden()) {
} }
// Indicate a directory. // Indicate a directory.
else if (myFile.isDir()) { else if (myFile.isDir()) {
// Copy full dirname into fileNames
snprintf(fileNames[currFile], FILENAME_LENGTH, "%s%s", "/", nameStr);
currFile++; currFile++;
} }
// It's just a file // It's just a file
else if (myFile.isFile()) { else if (myFile.isFile()) {
// Copy full filename into fileNames
snprintf(fileNames[currFile], FILENAME_LENGTH, "%s", nameStr);
currFile++; currFile++;
} }
myFile.close(); myFile.close();
@ -1872,9 +1865,45 @@ page:
wait(); wait();
} }
// Open filepath directory
if (!myDir.open(filePath)) {
display_Clear();
print_Error(F("SD Error"), true);
}
int countFile = 0;
byte i = 0;
// Cycle through all files
while ((myFile.openNext(&myDir, O_READ)) && (i < 8)) {
// Get name of file
myFile.getName(nameStr, FILENAME_LENGTH);
// Ignore if hidden
if (myFile.isHidden()) {
}
// Directory
else if (myFile.isDir()) {
if (countFile == ((currPage - 1) * 7 + i)) {
snprintf(fileNames[i], FILENAME_LENGTH, "%s%s", "/", nameStr);
i++;
}
countFile++;
}
// File
else if (myFile.isFile()) {
if (countFile == ((currPage - 1) * 7 + i)) {
snprintf(fileNames[i], FILENAME_LENGTH, "%s", nameStr);
i++;
}
countFile++;
}
myFile.close();
}
myDir.close();
for (byte i = 0; i < 8; i++ ) { for (byte i = 0; i < 8; i++ ) {
// Copy short string into fileOptions // Copy short string into fileOptions
snprintf( answers[i], FILEOPTS_LENGTH, "%s", fileNames[ ((currPage - 1) * 7 + i)] ); snprintf( answers[i], FILEOPTS_LENGTH, "%s", fileNames[i] );
} }
// Create menu with title and 1-7 options to choose from // Create menu with title and 1-7 options to choose from
@ -1901,31 +1930,31 @@ page:
switch (answer) switch (answer)
{ {
case 0: case 0:
strncpy(fileName, fileNames[0 + ((currPage - 1) * 7)], FILENAME_LENGTH - 1); strncpy(fileName, fileNames[0], FILENAME_LENGTH - 1);
break; break;
case 1: case 1:
strncpy(fileName, fileNames[1 + ((currPage - 1) * 7)], FILENAME_LENGTH - 1); strncpy(fileName, fileNames[1], FILENAME_LENGTH - 1);
break; break;
case 2: case 2:
strncpy(fileName, fileNames[2 + ((currPage - 1) * 7)], FILENAME_LENGTH - 1); strncpy(fileName, fileNames[2], FILENAME_LENGTH - 1);
break; break;
case 3: case 3:
strncpy(fileName, fileNames[3 + ((currPage - 1) * 7)], FILENAME_LENGTH - 1); strncpy(fileName, fileNames[3], FILENAME_LENGTH - 1);
break; break;
case 4: case 4:
strncpy(fileName, fileNames[4 + ((currPage - 1) * 7)], FILENAME_LENGTH - 1); strncpy(fileName, fileNames[4], FILENAME_LENGTH - 1);
break; break;
case 5: case 5:
strncpy(fileName, fileNames[5 + ((currPage - 1) * 7)], FILENAME_LENGTH - 1); strncpy(fileName, fileNames[5], FILENAME_LENGTH - 1);
break; break;
case 6: case 6:
strncpy(fileName, fileNames[6 + ((currPage - 1) * 7)], FILENAME_LENGTH - 1); strncpy(fileName, fileNames[6], FILENAME_LENGTH - 1);
break; break;
//case 7: //case 7:

View File

@ -1126,7 +1126,8 @@ unsigned char* getNES20HeaderBytesFromDatabaseRow(const char* crctest) {
Config Functions Config Functions
*****************************************/ *****************************************/
void setMapper() { void setMapper() {
#if (defined(enable_LCD) || defined(enable_OLED)) // OLED
#if defined(enable_OLED)
chooseMapper: chooseMapper:
// Read stored mapper // Read stored mapper
EEPROM_readAnything(7, newmapper); EEPROM_readAnything(7, newmapper);
@ -1140,19 +1141,18 @@ chooseMapper:
// Cycle through al 3 digits // Cycle through al 3 digits
for (byte digit = 0; digit < 3; digit++) { for (byte digit = 0; digit < 3; digit++) {
while (1) { while (1) {
display.clearDisplay(); display_Clear();
display.setCursor(0, 0); println_Msg("Select Mapper:");
display.println("Select Mapper:");
display.setCursor(23, 20); display.setCursor(23, 20);
display.println(hundreds); println_Msg(hundreds);
display.setCursor(43, 20); display.setCursor(43, 20);
display.println(tens); println_Msg(tens);
display.setCursor(63, 20); display.setCursor(63, 20);
display.println(units); println_Msg(units);
display.println(""); println_Msg("");
display.println(F("Press to Change")); println_Msg(F("Press to Change"));
display.println(F("Hold to Select")); println_Msg(F("Hold to Select"));
#ifdef enable_OLED
if (digit == 0) { if (digit == 0) {
display.drawLine(20, 30, 30, 30, WHITE); display.drawLine(20, 30, 30, 30, WHITE);
display.drawLine(40, 30, 50, 30, BLACK); display.drawLine(40, 30, 50, 30, BLACK);
@ -1168,30 +1168,7 @@ chooseMapper:
display.drawLine(40, 30, 50, 30, BLACK); display.drawLine(40, 30, 50, 30, BLACK);
display.drawLine(60, 30, 70, 30, WHITE); display.drawLine(60, 30, 70, 30, WHITE);
} }
#else
if (digit == 0) {
display.setDrawColor(1);
display.drawLine(20, 30, 30, 30);
display.setDrawColor(0);
display.drawLine(40, 30, 50, 30);
display.drawLine(60, 30, 70, 30);
}
else if (digit == 1) {
display.setDrawColor(0);
display.drawLine(20, 30, 30, 30);
display.setDrawColor(1);
display.drawLine(40, 30, 50, 30);
display.setDrawColor(0);
display.drawLine(60, 30, 70, 30);
}
else if (digit == 2) {
display.setDrawColor(0);
display.drawLine(20, 30, 30, 30);
display.drawLine(40, 30, 50, 30);
display.setDrawColor(1);
display.drawLine(60, 30, 70, 30);
}
#endif
/* Check Button /* Check Button
1 click 1 click
2 doubleClick 2 doubleClick
@ -1258,15 +1235,11 @@ chooseMapper:
else if (b == 3) { else if (b == 3) {
break; break;
} }
#ifdef enable_OLED
display.display(); display.display();
#else
display.updateDisplay();
#endif
} }
} }
display.clearDisplay(); display_Clear();
display.setCursor(0, 0);
newmapper = hundreds * 100 + tens * 10 + units; newmapper = hundreds * 100 + tens * 10 + units;
@ -1281,16 +1254,74 @@ chooseMapper:
if (!validMapper) { if (!validMapper) {
errorLvl = 1; errorLvl = 1;
display.println("Mapper not supported"); display.println("Mapper not supported");
#ifdef enable_OLED
display.display(); display.display();
#else
display.updateDisplay();
#endif
wait(); wait();
goto chooseMapper; goto chooseMapper;
} }
#endif
#ifdef enable_serial // LCD
#elif defined(enable_LCD)
int i = 0;
display_Clear();
mapselect = pgm_read_byte(mapsize + i * 7);
print_Msg(F("Mapper: "));
println_Msg(mapselect);
println_Msg(F(""));
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
display_Update();
while (1) {
int b = checkButton();
if (b == 2) { // Previous Mapper
if (i == 0)
i = mapcount - 1;
else
i--;
display_Clear();
mapselect = pgm_read_byte(mapsize + i * 7);
print_Msg(F("Mapper: "));
println_Msg(mapselect);
println_Msg(F(""));
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
display_Update();
}
else if (b == 1) { // Next Mapper
if (i == (mapcount - 1))
i = 0;
else
i++;
display_Clear();
mapselect = pgm_read_byte(mapsize + i * 7);
print_Msg(F("Mapper: "));
println_Msg(mapselect);
println_Msg(F(""));
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
display_Update();
}
else if (b == 3) { // Long Press - Execute
newmapper = mapselect;
break;
}
}
display.setCursor(0, 56 + 8);
print_Msg(F("MAPPER "));
print_Msg(newmapper);
println_Msg(F(" SELECTED"));
display_Update();
delay(1000);
// Serial Monitor
#elif defined(enable_serial)
setmapper: setmapper:
String newmap; String newmap;
mapfound = false; mapfound = false;
@ -1356,26 +1387,55 @@ void setPRGSize() {
else { else {
b = 0; b = 0;
int i = prglo; int i = prglo;
display_Clear();
print_Msg(F("PRG Size: "));
println_Msg(PRG[i]);
println_Msg(F(""));
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
display_Update();
while (1) { while (1) {
display_Clear();
print_Msg(F("PRG Size: "));
println_Msg(PRG[i]);
println_Msg(F(""));
println_Msg(F("Press to Change"));
println_Msg(F("Hold to Select"));
display_Update();
b = checkButton(); b = checkButton();
if (b == doubleclick) { // Previous if (b == doubleclick) { // Previous
if (i == prglo) if (i == prglo)
i = prghi; i = prghi;
else else
i--; i--;
display_Clear();
print_Msg(F("PRG Size: "));
println_Msg(PRG[i]);
println_Msg(F(""));
#if defined(enable_OLED)
println_Msg(F("Press left to change"));
println_Msg(F("Press right to select"));
#elif defined(enable_LCD)
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
#endif
display_Update();
} }
if (b == press) { // Next if (b == press) { // Next
if (i == prghi) if (i == prghi)
i = prglo; i = prglo;
else else
i++; i++;
display_Clear();
print_Msg(F("PRG Size: "));
println_Msg(PRG[i]);
println_Msg(F(""));
#if defined(enable_OLED)
println_Msg(F("Press left to change"));
println_Msg(F("Press right to select"));
#elif defined(enable_LCD)
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
#endif
display_Update();
} }
if (b == hold) { // Long Press - Execute if (b == hold) { // Long Press - Execute
newprgsize = i; newprgsize = i;
@ -1390,8 +1450,8 @@ void setPRGSize() {
println_Msg(F("K")); println_Msg(F("K"));
display_Update(); display_Update();
delay(1000); delay(1000);
#endif
#ifdef enable_serial #elif defined(enable_serial)
if (prglo == prghi) if (prglo == prghi)
newprgsize = prglo; newprgsize = prglo;
else { else {
@ -1431,27 +1491,63 @@ void setCHRSize() {
else { else {
b = 0; b = 0;
int i = chrlo; int i = chrlo;
display_Clear();
print_Msg(F("CHR Size: "));
println_Msg(CHR[i]);
println_Msg(F(""));
#if defined(enable_OLED)
println_Msg(F("Press left to change"));
println_Msg(F("Press right to select"));
#elif defined(enable_LCD)
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
#endif
display_Update();
while (1) { while (1) {
display_Clear();
print_Msg(F("CHR Size: "));
println_Msg(CHR[i]);
println_Msg(F(""));
println_Msg(F("Press to Change"));
println_Msg(F("Hold to Select"));
display_Update();
b = checkButton(); b = checkButton();
if (b == doubleclick) { // Previous if (b == doubleclick) { // Previous
if (i == chrlo) if (i == chrlo)
i = chrhi; i = chrhi;
else else
i--; i--;
display_Clear();
print_Msg(F("CHR Size: "));
println_Msg(CHR[i]);
println_Msg(F(""));
#if defined(enable_OLED)
println_Msg(F("Press left to change"));
println_Msg(F("Press right to select"));
#elif defined(enable_LCD)
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
#endif
display_Update();
} }
if (b == press) { // Next if (b == press) { // Next
if (i == chrhi) if (i == chrhi)
i = chrlo; i = chrlo;
else else
i++; i++;
display_Clear();
print_Msg(F("CHR Size: "));
println_Msg(CHR[i]);
println_Msg(F(""));
#if defined(enable_OLED)
println_Msg(F("Press left to change"));
println_Msg(F("Press right to select"));
#elif defined(enable_LCD)
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
#endif
display_Update();
} }
if (b == hold) { // Long Press - Execute if (b == hold) { // Long Press - Execute
newchrsize = i; newchrsize = i;
break; break;
@ -1464,8 +1560,8 @@ void setCHRSize() {
println_Msg(F("K")); println_Msg(F("K"));
display_Update(); display_Update();
delay(1000); delay(1000);
#endif
#ifdef enable_serial #elif defined(enable_serial)
if (chrlo == chrhi) if (chrlo == chrhi)
newchrsize = chrlo; newchrsize = chrlo;
else { else {
@ -1505,42 +1601,108 @@ void setRAMSize() {
else { else {
b = 0; b = 0;
int i = 0; int i = 0;
while (1) {
display_Clear(); display_Clear();
print_Msg(F("RAM Size: ")); print_Msg(F("RAM Size: "));
if (mapper == 0) if (mapper == 0)
println_Msg(RAM[i] / 4); println_Msg(RAM[i] / 4);
else if (mapper == 16) else if (mapper == 16)
println_Msg(RAM[i] * 32); println_Msg(RAM[i] * 32);
else if (mapper == 19) { else if (mapper == 19) {
if (i == 2) if (i == 2)
println_Msg(F("128")); println_Msg(F("128"));
else
println_Msg(RAM[i]);
}
else if ((mapper == 159) || (mapper == 80))
println_Msg(RAM[i] * 16);
else if (mapper == 82)
println_Msg(i * 5);
else else
println_Msg(RAM[i]); println_Msg(RAM[i]);
println_Msg(F("")); }
println_Msg(F("Press to Change")); else if ((mapper == 159) || (mapper == 80))
println_Msg(F("Hold to Select")); println_Msg(RAM[i] * 16);
display_Update(); else if (mapper == 82)
println_Msg(i * 5);
else
println_Msg(RAM[i]);
println_Msg(F(""));
#if defined(enable_OLED)
println_Msg(F("Press left to change"));
println_Msg(F("Press right to select"));
#elif defined(enable_LCD)
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
#endif
display_Update();
while (1) {
b = checkButton(); b = checkButton();
if (b == doubleclick) { // Previous Mapper if (b == doubleclick) { // Previous Mapper
if (i == 0) if (i == 0)
i = ramhi; i = ramhi;
else else
i--; i--;
display_Clear();
print_Msg(F("RAM Size: "));
if (mapper == 0)
println_Msg(RAM[i] / 4);
else if (mapper == 16)
println_Msg(RAM[i] * 32);
else if (mapper == 19) {
if (i == 2)
println_Msg(F("128"));
else
println_Msg(RAM[i]);
}
else if ((mapper == 159) || (mapper == 80))
println_Msg(RAM[i] * 16);
else if (mapper == 82)
println_Msg(i * 5);
else
println_Msg(RAM[i]);
println_Msg(F(""));
#if defined(enable_OLED)
println_Msg(F("Press left to change"));
println_Msg(F("Press right to select"));
#elif defined(enable_LCD)
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
#endif
display_Update();
} }
if (b == press) { // Next if (b == press) { // Next
if (i == ramhi) if (i == ramhi)
i = 0; i = 0;
else else
i++; i++;
display_Clear();
print_Msg(F("RAM Size: "));
if (mapper == 0)
println_Msg(RAM[i] / 4);
else if (mapper == 16)
println_Msg(RAM[i] * 32);
else if (mapper == 19) {
if (i == 2)
println_Msg(F("128"));
else
println_Msg(RAM[i]);
}
else if ((mapper == 159) || (mapper == 80))
println_Msg(RAM[i] * 16);
else if (mapper == 82)
println_Msg(i * 5);
else
println_Msg(RAM[i]);
println_Msg(F(""));
#if defined(enable_OLED)
println_Msg(F("Press left to change"));
println_Msg(F("Press right to select"));
#elif defined(enable_LCD)
println_Msg(F("Rotate to change"));
println_Msg(F("Press to select"));
#endif
display_Update();
} }
if (b == hold) { // Long Press - Execute if (b == hold) { // Long Press - Execute
newramsize = i; newramsize = i;
break; break;
@ -1585,8 +1747,8 @@ void setRAMSize() {
} }
display_Update(); display_Update();
delay(1000); delay(1000);
#endif
#ifdef enable_serial #elif defined(enable_serial)
if (ramlo == ramhi) if (ramlo == ramhi)
newramsize = ramlo; newramsize = ramlo;
else { else {