From 21e7468dfd5fd91446448f589ef13dd48667a2fb Mon Sep 17 00:00:00 2001 From: sanni Date: Sat, 8 Oct 2022 23:07:15 +0200 Subject: [PATCH] Fix flicker in Controller Test --- Cart_Reader/Cart_Reader.ino | 25 ++++++- Cart_Reader/N64.ino | 131 +++++++++++++++++++++++++----------- Cart_Reader/SNES.ino | 4 +- 3 files changed, 114 insertions(+), 46 deletions(-) diff --git a/Cart_Reader/Cart_Reader.ino b/Cart_Reader/Cart_Reader.ino index 26c5420..5c6e8cc 100644 --- a/Cart_Reader/Cart_Reader.ino +++ b/Cart_Reader/Cart_Reader.ino @@ -789,7 +789,7 @@ byte starting_letter() { // Main menu static const char modeItem1[] PROGMEM = "Game Boy"; static const char modeItem2[] PROGMEM = "NES/Famicom"; -static const char modeItem3[] PROGMEM = "Super Nintendo"; +static const char modeItem3[] PROGMEM = "Super Nintendo/SFC"; static const char modeItem4[] PROGMEM = "Nintendo 64 (3V)"; static const char modeItem5[] PROGMEM = "Mega Drive"; static const char modeItem6[] PROGMEM = "SMS/GG/MIII/SG-1000"; @@ -977,9 +977,17 @@ void mainMenu() { #else // Main menu static const char modeItem1[] PROGMEM = "Add-ons"; -static const char modeItem2[] PROGMEM = "Super Nintendo"; +#if defined(clockgen_installed) +static const char modeItem2[] PROGMEM = "SNES & SFC (CLK0+1)"; +#else +static const char modeItem2[] PROGMEM = "SNES & SFC"; +#endif static const char modeItem3[] PROGMEM = "Mega Drive"; -static const char modeItem4[] PROGMEM = "Nintendo 64 (3V)"; +#if defined(clockgen_installed) +static const char modeItem4[] PROGMEM = "N64 (3V EEP CLK1)"; +#else +static const char modeItem4[] PROGMEM = "Nintendo 64(3V EEP)"; +#endif static const char modeItem5[] PROGMEM = "Game Boy"; static const char modeItem6[] PROGMEM = "About"; static const char modeItem7[] PROGMEM = "Reset"; @@ -2208,6 +2216,17 @@ void display_Clear() { #endif } +void display_Clear_Slow() { +#if (defined(enable_LCD) || defined(enable_OLED)) + display.setDrawColor(0); + for (byte y = 0; y < 64; y++) { + display.drawLine(0, y, 128, y); + } + display.setDrawColor(1); + display.setCursor(0, 8); +#endif +} + /****************************************** RGB LED *****************************************/ diff --git a/Cart_Reader/N64.ino b/Cart_Reader/N64.ino index 5430ff3..9584a45 100644 --- a/Cart_Reader/N64.ino +++ b/Cart_Reader/N64.ino @@ -181,7 +181,7 @@ void n64ControllerMenu() { display_Clear(); display_Update(); #if (defined(enable_OLED) || defined(enable_LCD)) - controllerTest_LCD(); + controllerTest_Display(); #elif defined(enable_serial) controllerTest_Serial(); #endif @@ -979,7 +979,7 @@ void nextscreen() } } -void controllerTest_LCD() { +void controllerTest_Display() { int mode = 0; //name of the current displayed result @@ -1028,6 +1028,12 @@ void controllerTest_LCD() { int results = 0; int prevStickX = 0; + String stickx; + String sticky; + String stickx_old; + String sticky_old; + String button_old; + while (quit) { // Get Button and analog stick get_button(); @@ -1036,21 +1042,41 @@ void controllerTest_LCD() { { case 1: { - delay(20); - display.clearDisplay(); display.drawStr(32, 8, "Controller Test"); display.drawLine(0, 10, 128, 10); - // Print Button + // Delete old button value + if (button_old != button) { + display.setDrawColor(0); + for (byte y = 13; y < 22; y++) { + display.drawLine(0, y, 128, y); + } + display.setDrawColor(1); + } + // Print button printSTR(" " + button + " ", CENTER, 20); + // Save value + button_old = button; - // Print Stick X Value - String stickx = String("X: " + String(N64_status.stick_x, DEC) + " "); + // Update stick values + stickx = String("X: " + String(N64_status.stick_x, DEC) + " "); + sticky = String("Y: " + String(N64_status.stick_y, DEC) + " "); + + // Delete old stick values + if ((stickx_old != stickx) || (sticky_old != sticky)) { + display.setDrawColor(0); + for (byte y = 31; y < 38; y++) { + display.drawLine(0, y, 128, y); + } + display.setDrawColor(1); + } + + // Print stick values printSTR(stickx, 36, 38); - - // Print Stick Y Value - String sticky = String("Y: " + String(N64_status.stick_y, DEC) + " "); printSTR(sticky, 74, 38); + // Save values + stickx_old = stickx; + sticky_old = sticky; printSTR("(Continue with START)", 16, 55); @@ -1102,8 +1128,7 @@ void controllerTest_LCD() { display.drawCircle(10 + xax + N64_status.stick_x / 4, 12 + yax - N64_status.stick_y / 4, 2); //Update LCD display.updateDisplay(); - delay(20); - display.clearDisplay(); + display_Clear_Slow(); } // switch mode @@ -1164,7 +1189,7 @@ void controllerTest_LCD() { { case 0: { - anastick = "YOURS"; + anastick = "Your Stick"; upx = bupx; upy = bupy; uprightx = buprightx; @@ -1187,13 +1212,38 @@ void controllerTest_LCD() { // reset button lastbutton = "N/A"; results = 1; + display.clearDisplay(); + break; } + printSTR(anastick, 22 + 50, 15); + display.drawStr(22 + 50, 25, "U:"); + printSTR(String(upy), 100, 25); + display.drawStr(22 + 50, 35, "D:"); + printSTR(String(downy), 100, 35); + display.drawStr(22 + 50, 45, "L:"); + printSTR(String(leftx), 100, 45); + display.drawStr(22 + 50, 55, "R:"); + printSTR(String(rightx), 100, 55); + + display.drawLine(xax + upx / 4, yax - upy / 4, xax + uprightx / 4, yax - uprighty / 4); + display.drawLine(xax + uprightx / 4, yax - uprighty / 4, xax + rightx / 4, yax - righty / 4); + display.drawLine(xax + rightx / 4, yax - righty / 4, xax + downrightx / 4, yax - downrighty / 4); + display.drawLine(xax + downrightx / 4, yax - downrighty / 4, xax + downx / 4, yax - downy / 4); + display.drawLine(xax + downx / 4, yax - downy / 4, xax + downleftx / 4, yax - downlefty / 4); + display.drawLine(xax + downleftx / 4, yax - downlefty / 4, xax + leftx / 4, yax - lefty / 4); + display.drawLine(xax + leftx / 4, yax - lefty / 4, xax + upleftx / 4, yax - uplefty / 4); + display.drawLine(xax + upleftx / 4, yax - uplefty / 4, xax + upx / 4, yax - upy / 4); + + display.drawPixel(xax, yax); + + //Update LCD + display.updateDisplay(); break; } case 1: { - anastick = "ORIG"; + anastick = "Original"; upx = 1; upy = 84; uprightx = 67; @@ -1216,38 +1266,37 @@ void controllerTest_LCD() { // reset button lastbutton = "N/A"; results = 0; + display.clearDisplay(); + break; } + printSTR(anastick, 22 + 50, 15); + + display.drawStr(22 + 50, 25, "U:"); + printSTR(String(upy), 100, 25); + display.drawStr(22 + 50, 35, "D:"); + printSTR(String(downy), 100, 35); + display.drawStr(22 + 50, 45, "L:"); + printSTR(String(leftx), 100, 45); + display.drawStr(22 + 50, 55, "R:"); + printSTR(String(rightx), 100, 55); + + display.drawLine(xax + upx / 4, yax - upy / 4, xax + uprightx / 4, yax - uprighty / 4); + display.drawLine(xax + uprightx / 4, yax - uprighty / 4, xax + rightx / 4, yax - righty / 4); + display.drawLine(xax + rightx / 4, yax - righty / 4, xax + downrightx / 4, yax - downrighty / 4); + display.drawLine(xax + downrightx / 4, yax - downrighty / 4, xax + downx / 4, yax - downy / 4); + display.drawLine(xax + downx / 4, yax - downy / 4, xax + downleftx / 4, yax - downlefty / 4); + display.drawLine(xax + downleftx / 4, yax - downlefty / 4, xax + leftx / 4, yax - lefty / 4); + display.drawLine(xax + leftx / 4, yax - lefty / 4, xax + upleftx / 4, yax - uplefty / 4); + display.drawLine(xax + upleftx / 4, yax - uplefty / 4, xax + upx / 4, yax - upy / 4); + + display.drawPixel(xax, yax); + + //Update LCD + display.updateDisplay(); break; } } //results - delay(20); - display.clearDisplay(); - - printSTR(anastick, 22 + 50, 15); - - display.drawStr(22 + 50, 25, "U:"); - printSTR(String(upy), 100, 25); - display.drawStr(22 + 50, 35, "D:"); - printSTR(String(downy), 100, 35); - display.drawStr(22 + 50, 45, "L:"); - printSTR(String(leftx), 100, 45); - display.drawStr(22 + 50, 55, "R:"); - printSTR(String(rightx), 100, 55); - - display.drawLine(xax + upx / 4, yax - upy / 4, xax + uprightx / 4, yax - uprighty / 4); - display.drawLine(xax + uprightx / 4, yax - uprighty / 4, xax + rightx / 4, yax - righty / 4); - display.drawLine(xax + rightx / 4, yax - righty / 4, xax + downrightx / 4, yax - downrighty / 4); - display.drawLine(xax + downrightx / 4, yax - downrighty / 4, xax + downx / 4, yax - downy / 4); - display.drawLine(xax + downx / 4, yax - downy / 4, xax + downleftx / 4, yax - downlefty / 4); - display.drawLine(xax + downleftx / 4, yax - downlefty / 4, xax + leftx / 4, yax - lefty / 4); - display.drawLine(xax + leftx / 4, yax - lefty / 4, xax + upleftx / 4, yax - uplefty / 4); - display.drawLine(xax + upleftx / 4, yax - uplefty / 4, xax + upx / 4, yax - upy / 4); - - display.drawPixel(xax, yax); - - //Update LCD - display.updateDisplay(); break; } //display results diff --git a/Cart_Reader/SNES.ino b/Cart_Reader/SNES.ino index 225d777..9856401 100644 --- a/Cart_Reader/SNES.ino +++ b/Cart_Reader/SNES.ino @@ -29,8 +29,8 @@ boolean altconf = 0; Menu *****************************************/ // SNES/Nintendo Power SF Memory start menu -static const char snsMenuItem1[] PROGMEM = "Super Nintendo"; -static const char snsMenuItem2[] PROGMEM = "NPower SF Memory"; +static const char snsMenuItem1[] PROGMEM = "SNES/SFC cartridge"; +static const char snsMenuItem2[] PROGMEM = "SF Memory Cassette"; static const char snsMenuItem3[] PROGMEM = "Satellaview BS-X"; static const char snsMenuItem4[] PROGMEM = "Flash repro"; #ifdef clockgen_calibration