Fix flicker in Controller Test

This commit is contained in:
sanni 2022-10-08 23:07:15 +02:00
parent a49d8c6590
commit 21e7468dfd
3 changed files with 114 additions and 46 deletions

View File

@ -789,7 +789,7 @@ byte starting_letter() {
// Main menu // Main menu
static const char modeItem1[] PROGMEM = "Game Boy"; static const char modeItem1[] PROGMEM = "Game Boy";
static const char modeItem2[] PROGMEM = "NES/Famicom"; 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 modeItem4[] PROGMEM = "Nintendo 64 (3V)";
static const char modeItem5[] PROGMEM = "Mega Drive"; static const char modeItem5[] PROGMEM = "Mega Drive";
static const char modeItem6[] PROGMEM = "SMS/GG/MIII/SG-1000"; static const char modeItem6[] PROGMEM = "SMS/GG/MIII/SG-1000";
@ -977,9 +977,17 @@ void mainMenu() {
#else #else
// Main menu // Main menu
static const char modeItem1[] PROGMEM = "Add-ons"; 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 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 modeItem5[] PROGMEM = "Game Boy";
static const char modeItem6[] PROGMEM = "About"; static const char modeItem6[] PROGMEM = "About";
static const char modeItem7[] PROGMEM = "Reset"; static const char modeItem7[] PROGMEM = "Reset";
@ -2208,6 +2216,17 @@ void display_Clear() {
#endif #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 RGB LED
*****************************************/ *****************************************/

View File

@ -181,7 +181,7 @@ void n64ControllerMenu() {
display_Clear(); display_Clear();
display_Update(); display_Update();
#if (defined(enable_OLED) || defined(enable_LCD)) #if (defined(enable_OLED) || defined(enable_LCD))
controllerTest_LCD(); controllerTest_Display();
#elif defined(enable_serial) #elif defined(enable_serial)
controllerTest_Serial(); controllerTest_Serial();
#endif #endif
@ -979,7 +979,7 @@ void nextscreen()
} }
} }
void controllerTest_LCD() { void controllerTest_Display() {
int mode = 0; int mode = 0;
//name of the current displayed result //name of the current displayed result
@ -1028,6 +1028,12 @@ void controllerTest_LCD() {
int results = 0; int results = 0;
int prevStickX = 0; int prevStickX = 0;
String stickx;
String sticky;
String stickx_old;
String sticky_old;
String button_old;
while (quit) { while (quit) {
// Get Button and analog stick // Get Button and analog stick
get_button(); get_button();
@ -1036,21 +1042,41 @@ void controllerTest_LCD() {
{ {
case 1: case 1:
{ {
delay(20);
display.clearDisplay();
display.drawStr(32, 8, "Controller Test"); display.drawStr(32, 8, "Controller Test");
display.drawLine(0, 10, 128, 10); 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); printSTR(" " + button + " ", CENTER, 20);
// Save value
button_old = button;
// Print Stick X Value // Update stick values
String stickx = String("X: " + String(N64_status.stick_x, DEC) + " "); 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); printSTR(stickx, 36, 38);
// Print Stick Y Value
String sticky = String("Y: " + String(N64_status.stick_y, DEC) + " ");
printSTR(sticky, 74, 38); printSTR(sticky, 74, 38);
// Save values
stickx_old = stickx;
sticky_old = sticky;
printSTR("(Continue with START)", 16, 55); 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); display.drawCircle(10 + xax + N64_status.stick_x / 4, 12 + yax - N64_status.stick_y / 4, 2);
//Update LCD //Update LCD
display.updateDisplay(); display.updateDisplay();
delay(20); display_Clear_Slow();
display.clearDisplay();
} }
// switch mode // switch mode
@ -1164,7 +1189,7 @@ void controllerTest_LCD() {
{ {
case 0: case 0:
{ {
anastick = "YOURS"; anastick = "Your Stick";
upx = bupx; upx = bupx;
upy = bupy; upy = bupy;
uprightx = buprightx; uprightx = buprightx;
@ -1187,13 +1212,38 @@ void controllerTest_LCD() {
// reset button // reset button
lastbutton = "N/A"; lastbutton = "N/A";
results = 1; 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; break;
} }
case 1: case 1:
{ {
anastick = "ORIG"; anastick = "Original";
upx = 1; upx = 1;
upy = 84; upy = 84;
uprightx = 67; uprightx = 67;
@ -1216,38 +1266,37 @@ void controllerTest_LCD() {
// reset button // reset button
lastbutton = "N/A"; lastbutton = "N/A";
results = 0; 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; break;
} }
} //results } //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; break;
} //display results } //display results

View File

@ -29,8 +29,8 @@ boolean altconf = 0;
Menu Menu
*****************************************/ *****************************************/
// SNES/Nintendo Power SF Memory start menu // SNES/Nintendo Power SF Memory start menu
static const char snsMenuItem1[] PROGMEM = "Super Nintendo"; static const char snsMenuItem1[] PROGMEM = "SNES/SFC cartridge";
static const char snsMenuItem2[] PROGMEM = "NPower SF Memory"; static const char snsMenuItem2[] PROGMEM = "SF Memory Cassette";
static const char snsMenuItem3[] PROGMEM = "Satellaview BS-X"; static const char snsMenuItem3[] PROGMEM = "Satellaview BS-X";
static const char snsMenuItem4[] PROGMEM = "Flash repro"; static const char snsMenuItem4[] PROGMEM = "Flash repro";
#ifdef clockgen_calibration #ifdef clockgen_calibration