V10.1 Move HW1/2/3 to same display lib as HW4/5

... bugs are to be expected :D
This commit is contained in:
sanni 2022-10-08 16:23:33 +02:00
parent 18b37c72d8
commit 0ab7a18b05
7 changed files with 312 additions and 1082 deletions

View File

@ -423,11 +423,7 @@ void setCart_COL() {
display_Clear();
// Read game name
#if defined(enable_OLED)
get_line(gamename, &myFile, 42);
#else
get_line(gamename, &myFile, 96);
#endif
// Read CRC32 checksum
sprintf(checksumStr, "%c", myFile.read());

File diff suppressed because it is too large Load Diff

View File

@ -886,11 +886,7 @@ void getCartInfo_GBA() {
display_Clear();
// Read game name
#if defined(enable_OLED)
get_line(gamename, &myFile, 42);
#else
get_line(gamename, &myFile, 96);
#endif
// Skip over the CRC checksum
myFile.seekSet(myFile.curPosition() + 9);

View File

@ -812,11 +812,7 @@ void setCart_INTV() {
display_Clear();
// Read game name
#if defined(enable_OLED)
get_line(gamename, &myFile, 42);
#else
get_line(gamename, &myFile, 96);
#endif
// Read CRC32 checksum
sprintf(checksumStr, "%c", myFile.read());

View File

@ -180,9 +180,7 @@ void n64ControllerMenu() {
resetController();
display_Clear();
display_Update();
#if defined(enable_OLED)
controllerTest_OLED();
#elif defined(enable_LCD)
#if (defined(enable_OLED) || defined(enable_LCD))
controllerTest_LCD();
#elif defined(enable_serial)
controllerTest_Serial();
@ -940,7 +938,7 @@ void controllerTest_Serial() {
}
#endif
#ifdef enable_LCD
#if (defined(enable_LCD) || defined(enable_OLED))
#define CENTER 64
// on which screens do we start
int startscreen = 1;
@ -1414,532 +1412,6 @@ void controllerTest_LCD() {
}
#endif
#ifdef enable_OLED
#define CENTER 64
void oledPrint(const char string[], int x, int y) {
if (x == CENTER)
x = 64 - (strlen(string) / 2) * 6;
display.setCursor(x, y);
display.print(string);
}
void oledPrint(int number, int x, int y) {
display.setCursor(x, y);
display.print(number);
}
void printSTR(String st, int x, int y)
{
char buf[st.length() + 1];
st.toCharArray(buf, st.length() + 1);
oledPrint(buf, x, y);
}
void controllerTest_OLED() {
// on which screens do we start
int startscreen = 1;
int mode = 0;
int test = 1;
//name of the current displayed result
String anastick = "";
int prevStickX = 0;
// Graph
int xax = 22 + 24; // midpoint x
int yax = 24; // midpoint y
int zax = 24; // size
// variables to display test data of different sticks
int upx = 0;
int upy = 0;
int uprightx = 0;
int uprighty = 0;
int rightx = 0;
int righty = 0;
int downrightx = 0;
int downrighty = 0;
int downx = 0;
int downy = 0;
int downleftx = 0;
int downlefty = 0;
int leftx = 0;
int lefty = 0;
int upleftx = 0;
int uplefty = 0;
// variables to save test data
int bupx = 0;
int bupy = 0;
int buprightx = 0;
int buprighty = 0;
int brightx = 0;
int brighty = 0;
int bdownrightx = 0;
int bdownrighty = 0;
int bdownx = 0;
int bdowny = 0;
int bdownleftx = 0;
int bdownlefty = 0;
int bleftx = 0;
int blefty = 0;
int bupleftx = 0;
int buplefty = 0;
int results = 0;
while (quit) {
// Get Button and analog stick
get_button();
switch (startscreen)
{
case 1:
{
display.clearDisplay();
oledPrint("Button Test", CENTER, 0);
display.drawLine(22 + 0, 10, 22 + 84, 10, WHITE);
// Print Button
printSTR(" " + button + " ", CENTER, 20);
// Print Stick X Value
String stickx = String("X: " + String(N64_status.stick_x, DEC) + " ");
printSTR(stickx, 22 + 0, 38);
// Print Stick Y Value
String sticky = String("Y: " + String(N64_status.stick_y, DEC) + " ");
printSTR(sticky, 22 + 60, 38);
printSTR("(Continue with START)", 0, 55);
//Update LCD
display.display();
// go to next screen
if (button == "Press a button" && lastbutton == "START")
{
// reset button
lastbutton = "N/A";
display.clearDisplay();
if (startscreen != 4)
startscreen = startscreen + 1;
else
{
startscreen = 1;
test = 1;
}
}
else if (button == "Press a button" && lastbutton == "Z" && startscreen == 4)
{
// Quit
quit = 0;
}
break;
}
case 2:
{
oledPrint("Range Test", CENTER, 55);
display.drawLine(22 + 0, 50, 22 + 84, 50, WHITE);
// Print Stick X Value
String stickx = String("X:" + String(N64_status.stick_x, DEC) + " ");
printSTR(stickx, 22 + 54, 8);
// Print Stick Y Value
String sticky = String("Y:" + String(N64_status.stick_y, DEC) + " ");
printSTR(sticky, 22 + 54, 18);
// Draw Axis
//display.drawLine(xax - zax, yax, xax + zax, yax, WHITE);
//display.drawLine(xax, yax - zax, xax, yax + zax, WHITE);
display.drawPixel(xax, yax, WHITE);
display.drawPixel(xax, yax - 80 / 4, WHITE);
display.drawPixel(xax, yax + 80 / 4, WHITE);
display.drawPixel(xax + 80 / 4, yax, WHITE);
display.drawPixel(xax - 80 / 4, yax, WHITE);
// Draw corners
display.drawPixel(xax - 68 / 4, yax - 68 / 4, WHITE);
display.drawPixel(xax + 68 / 4, yax + 68 / 4, WHITE);
display.drawPixel(xax + 68 / 4, yax - 68 / 4, WHITE);
display.drawPixel(xax - 68 / 4, yax + 68 / 4, WHITE);
//Draw Analog Stick
if (mode == 1)
{
display.drawPixel(xax + N64_status.stick_x / 4, yax - N64_status.stick_y / 4, WHITE);
//Update LCD
display.display();
}
else
{
display.drawCircle(xax + N64_status.stick_x / 4, yax - N64_status.stick_y / 4, 2, WHITE);
//Update LCD
display.display();
display.clearDisplay();
}
// switch mode
if (button == "Press a button" && lastbutton == "Z")
{
if (mode == 0)
{
mode = 1;
display.clearDisplay();
}
else
{
mode = 0;
display.clearDisplay();
}
}
// go to next screen
if (button == "Press a button" && lastbutton == "START")
{
// reset button
lastbutton = "N/A";
display.clearDisplay();
if (startscreen != 4)
startscreen = startscreen + 1;
else
{
startscreen = 1;
test = 1;
}
}
else if (button == "Press a button" && lastbutton == "Z" && startscreen == 4)
{
// Quit
quit = 0;
}
break;
}
case 3:
{
display.drawPixel(22 + prevStickX, 40, BLACK);
oledPrint("Skipping Test", CENTER, 0);
display.drawLine(22 + 0, 10, 22 + 83, 10, WHITE);
display.drawRect(22 + 0, 15, 22 + 59, 21, WHITE);
if (N64_status.stick_x > 0) {
display.drawLine(22 + N64_status.stick_x, 15, 22 + N64_status.stick_x, 35, WHITE);
display.drawPixel(22 + N64_status.stick_x, 40, WHITE);
prevStickX = N64_status.stick_x;
}
printSTR("Try to fill box by", 0, 45);
printSTR("slowly moving right", 0, 55);
//Update LCD
display.display();
if (button == "Press a button" && lastbutton == "Z")
{
// reset button
lastbutton = "N/A";
display.clearDisplay();
}
// go to next screen
if (button == "Press a button" && lastbutton == "START")
{
// reset button
lastbutton = "N/A";
display.clearDisplay();
if (startscreen != 4)
startscreen = startscreen + 1;
else
{
startscreen = 1;
test = 1;
}
}
else if (button == "Press a button" && lastbutton == "Z" && startscreen == 4)
{
// Quit
quit = 0;
}
break;
}
case 4:
{
switch ( test )
{
case 0: // Display results
{
switch (results)
{
case 0:
{
anastick = "YOURS";
upx = bupx;
upy = bupy;
uprightx = buprightx;
uprighty = buprighty;
rightx = brightx;
righty = brighty;
downrightx = bdownrightx;
downrighty = bdownrighty;
downx = bdownx;
downy = bdowny;
downleftx = bdownleftx;
downlefty = bdownlefty;
leftx = bleftx;
lefty = blefty;
upleftx = bupleftx;
uplefty = buplefty;
if (button == "Press a button" && lastbutton == "A")
{
// 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
display.clearDisplay();
printSTR(anastick, 22 + 50, 0);
oledPrint("U:", 22 + 50, 10);
oledPrint(upy, 100, 10);
oledPrint("D:", 22 + 50, 20);
oledPrint(downy, 100, 20);
oledPrint("L:", 22 + 50, 30);
oledPrint(leftx, 100, 30);
oledPrint("R:", 22 + 50, 40);
oledPrint(rightx, 100, 40);
display.drawLine(xax + upx / 4, yax - upy / 4, xax + uprightx / 4, yax - uprighty / 4, WHITE);
display.drawLine(xax + uprightx / 4, yax - uprighty / 4, xax + rightx / 4, yax - righty / 4, WHITE);
display.drawLine(xax + rightx / 4, yax - righty / 4, xax + downrightx / 4, yax - downrighty / 4, WHITE);
display.drawLine(xax + downrightx / 4, yax - downrighty / 4, xax + downx / 4, yax - downy / 4, WHITE);
display.drawLine(xax + downx / 4, yax - downy / 4, xax + downleftx / 4, yax - downlefty / 4, WHITE);
display.drawLine(xax + downleftx / 4, yax - downlefty / 4, xax + leftx / 4, yax - lefty / 4, WHITE);
display.drawLine(xax + leftx / 4, yax - lefty / 4, xax + upleftx / 4, yax - uplefty / 4, WHITE);
display.drawLine(xax + upleftx / 4, yax - uplefty / 4, xax + upx / 4, yax - upy / 4, WHITE);
display.drawPixel(xax, yax, WHITE);
printSTR("(Quit with Z)", 25, 55);
//Update LCD
display.display();
break;
} //display results
case 1:// +y Up
{
oledPrint("Hold Stick Up", CENTER, 18);
oledPrint("then press A", CENTER, 28);
//myOLED.drawBitmap(110, 60, ana1);
if (button == "Press a button" && lastbutton == "A")
{
bupx = N64_status.stick_x;
bupy = N64_status.stick_y;
// reset button
lastbutton = "N/A";
display.clearDisplay();
test = 2;
}
break;
}
case 2:// +y+x Up-Right
{
oledPrint("Up-Right", CENTER, 22 );
//myOLED.drawBitmap(110, 60, ana2);
if (button == "Press a button" && lastbutton == "A")
{
buprightx = N64_status.stick_x;
buprighty = N64_status.stick_y;
test = 3;
// reset button
lastbutton = "N/A";
display.clearDisplay();
}
break;
}
case 3:// +x Right
{
oledPrint("Right", CENTER, 22 );
//myOLED.drawBitmap(110, 60, ana3);
if (button == "Press a button" && lastbutton == "A")
{
brightx = N64_status.stick_x;
brighty = N64_status.stick_y;
test = 4;
// reset button
lastbutton = "N/A";
display.clearDisplay();
}
break;
}
case 4:// -y+x Down-Right
{
oledPrint("Down-Right", CENTER, 22 );
//myOLED.drawBitmap(110, 60, ana4);
if (button == "Press a button" && lastbutton == "A")
{
bdownrightx = N64_status.stick_x;
bdownrighty = N64_status.stick_y;
test = 5;
// reset button
lastbutton = "N/A";
display.clearDisplay();
}
break;
}
case 5:// -y Down
{
oledPrint("Down", CENTER, 22 );
//myOLED.drawBitmap(110, 60, ana5);
if (button == "Press a button" && lastbutton == "A")
{
bdownx = N64_status.stick_x;
bdowny = N64_status.stick_y;
test = 6;
// reset button
lastbutton = "N/A";
display.clearDisplay();
}
break;
}
case 6:// -y-x Down-Left
{
oledPrint("Down-Left", CENTER, 22 );
//myOLED.drawBitmap(110, 60, ana6);
if (button == "Press a button" && lastbutton == "A")
{
bdownleftx = N64_status.stick_x;
bdownlefty = N64_status.stick_y;
test = 7;
// reset button
lastbutton = "N/A";
display.clearDisplay();
}
break;
}
case 7:// -x Left
{
oledPrint("Left", CENTER, 22 );
//myOLED.drawBitmap(110, 60, ana7);
if (button == "Press a button" && lastbutton == "A")
{
bleftx = N64_status.stick_x;
blefty = N64_status.stick_y;
test = 8;
// reset button
lastbutton = "N/A";
display.clearDisplay();
}
break;
}
case 8:// +y+x Up-Left
{
oledPrint("Up-Left", CENTER, 22);
//myOLED.drawBitmap(110, 60, ana8);
if (button == "Press a button" && lastbutton == "A")
{
bupleftx = N64_status.stick_x;
buplefty = N64_status.stick_y;
test = 0;
// reset button
lastbutton = "N/A";
display.clearDisplay();
}
break;
}
}
if (test != 0)
{
oledPrint("Benchmark", CENTER, 0);
display.drawLine(22 + 0, 9, 22 + 83, 9, WHITE);
printSTR("(Quit with Z)", 25, 55);
}
display.display();
// go to next screen
if (button == "Press a button" && lastbutton == "START")
{
// reset button
lastbutton = "N/A";
display.clearDisplay();
if (startscreen != 4)
startscreen = startscreen + 1;
else
{
startscreen = 1;
test = 1;
}
}
else if (button == "Press a button" && lastbutton == "Z" && startscreen == 4)
{
// Quit
quit = 0;
}
break;
}
}
}
}
#endif
/******************************************
N64 Controller Pak Functions
(connected via Controller)

View File

@ -576,11 +576,7 @@ boolean getMapping() {
display_Clear();
// Read game name
#if defined(enable_OLED)
get_line(gamename, &myFile, 42);
#else
get_line(gamename, &myFile, 96);
#endif
// Read CRC32 checksum
sprintf(checksumStr, "%c", myFile.read());
@ -848,21 +844,13 @@ void selectMapping() {
if ((myLetter > 0) && (myLetter <= 26)) {
while (myFile.available()) {
// Read current name
#if defined(enable_OLED)
get_line(gamename, &myFile, 42);
#else
get_line(gamename, &myFile, 96);
#endif
// Compare selected letter with first letter of current name until match
while (gamename[0] != 64 + myLetter) {
skip_line(&myFile);
skip_line(&myFile);
#if defined(enable_OLED)
get_line(gamename, &myFile, 42);
#else
get_line(gamename, &myFile, 96);
#endif
}
break;
}
@ -891,11 +879,7 @@ void selectMapping() {
display_Clear();
// Read game name
#if defined(enable_OLED)
get_line(gamename, &myFile, 42);
#else
get_line(gamename, &myFile, 96);
#endif
// Read CRC32 checksum
sprintf(checksumStr, "%c", myFile.read());
@ -2085,19 +2069,26 @@ chooseMapper:
println_Msg(F("Press right to select"));
if (digit == 0) {
display.drawLine(20, 30, 30, 30, WHITE);
display.drawLine(40, 30, 50, 30, BLACK);
display.drawLine(60, 30, 70, 30, BLACK);
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.drawLine(20, 30, 30, 30, BLACK);
display.drawLine(40, 30, 50, 30, WHITE);
display.drawLine(60, 30, 70, 30, BLACK);
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.drawLine(20, 30, 30, 30, BLACK);
display.drawLine(40, 30, 50, 30, BLACK);
display.drawLine(60, 30, 70, 30, WHITE);
display.setDrawColor(0);
display.drawLine(20, 30, 30, 30);
display.drawLine(40, 30, 50, 30);
display.setDrawColor(1);
display.drawLine(60, 30, 70, 30);
}
/* Check Button
@ -4853,10 +4844,7 @@ void writeFLASH() {
}
}
#if defined(enable_OLED)
display.print(F("*"));
display.display();
#elif defined(enable_LCD)
#if (defined(enable_LCD) || defined(enable_OLED))
display.print(F("*"));
display.updateDisplay();
#else

View File

@ -435,11 +435,7 @@ void setCart_WSV() {
display_Clear();
// Read game name
#if defined(enable_OLED)
get_line(gamename, &myFile, 42);
#else
get_line(gamename, &myFile, 96);
#endif
// Read CRC32 checksum
sprintf(checksumStr, "%c", myFile.read());