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
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
*****************************************/

View File

@ -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,43 +1212,9 @@ void controllerTest_LCD() {
// reset button
lastbutton = "N/A";
results = 1;
}
break;
}
case 1:
{
anastick = "ORIG";
upx = 1;
upy = 84;
uprightx = 67;
uprighty = 68;
rightx = 83;
righty = -2;
downrightx = 67;
downrighty = -69;
downx = 3;
downy = -85;
downleftx = -69;
downlefty = -70;
leftx = -85;
lefty = 0;
upleftx = -68;
uplefty = 68;
if (button == "Press a button" && lastbutton == "A")
{
// reset button
lastbutton = "N/A";
results = 0;
}
break;
}
} //results
delay(20);
display.clearDisplay();
break;
}
printSTR(anastick, 22 + 50, 15);
display.drawStr(22 + 50, 25, "U:");
@ -1249,6 +1240,64 @@ void controllerTest_LCD() {
//Update LCD
display.updateDisplay();
break;
}
case 1:
{
anastick = "Original";
upx = 1;
upy = 84;
uprightx = 67;
uprighty = 68;
rightx = 83;
righty = -2;
downrightx = 67;
downrighty = -69;
downx = 3;
downy = -85;
downleftx = -69;
downlefty = -70;
leftx = -85;
lefty = 0;
upleftx = -68;
uplefty = 68;
if (button == "Press a button" && lastbutton == "A")
{
// 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
break;
} //display results
case 1:// +y Up

View File

@ -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