V7.0: Add basic support for MKS MINI12864 V3

https://www.aliexpress.com/item/1005003098864693.html
This commit is contained in:
sanni 2021-10-24 00:41:18 +02:00
parent e103b685bd
commit 05deb817ac
11 changed files with 483 additions and 97 deletions

View File

@ -4,15 +4,19 @@
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: 14.10.2021 Date: 24.10.2021
Version: 6.8 Version: 7.0
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/adafruit/Adafruit_SSD1306 OLED lib: https://github.com/adafruit/Adafruit_SSD1306
GFX Lib: https://github.com/adafruit/Adafruit-GFX-Library GFX Lib: https://github.com/adafruit/Adafruit-GFX-Library
BusIO: https://github.com/adafruit/Adafruit_BusIO BusIO: https://github.com/adafruit/Adafruit_BusIO
LCD lib: https://github.com/olikraus/u8g2
RGB Tools lib: https://github.com/joushx/Arduino-RGB-Tools RGB Tools lib: https://github.com/joushx/Arduino-RGB-Tools
Neopixel lib: https://github.com/adafruit/Adafruit_NeoPixel
Rotary Enc lib: https://github.com/mathertel/RotaryEncoder
SI5351 lib: https://github.com/etherkit/Si5351Arduino SI5351 lib: https://github.com/etherkit/Si5351Arduino
RTC lib: https://github.com/adafruit/RTClib
Compiled with Arduino 1.8.13 Compiled with Arduino 1.8.13
@ -33,14 +37,14 @@
Gens-gs - Megadrive checksum Gens-gs - Megadrive checksum
And a special Thank You to all coders and contributors on Github and the Arduino forum: And a special Thank You to all coders and contributors on Github and the Arduino forum:
jiyunomegami, splash5, Kreeblah, ramapcsx2, PsyK0p4T, Dakkaron, Pickle, sdhizumi, jiyunomegami, splash5, Kreeblah, ramapcsx2, PsyK0p4T, Dakkaron, majorpbx, Pickle, sdhizumi,
sakman55, Uzlopak, scrap-a, majorpbx, borti4938, Modman, philenotfound, vogelfreiheit Uzlopak, sakman55, scrap-a, borti4938, vogelfreiheit, Modman, philenotfound
And to nocash for figuring out the secrets of the SFC Nintendo Power cartridge. And to nocash for figuring out the secrets of the SFC Nintendo Power cartridge.
**********************************************************************************/ **********************************************************************************/
char ver[5] = "6.8"; char ver[5] = "7.0";
/****************************************** /******************************************
Libraries Libraries
@ -48,18 +52,18 @@ char ver[5] = "6.8";
// Options // Options
#include "options.h" #include "options.h"
// SD Card
#include "SdFat.h"
SdFs sd;
FsFile myDir;
FsFile myFile;
// Basic Libs // Basic Libs
#include <SPI.h> #include <SPI.h>
#include <Wire.h> #include <Wire.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <avr/wdt.h> #include <avr/wdt.h>
// SD Card
#include "SdFat.h"
SdFs sd;
FsFile myDir;
FsFile myFile;
// AVR Eeprom // AVR Eeprom
#include <EEPROM.h> #include <EEPROM.h>
// forward declarations for "T" (for non Arduino IDE) // forward declarations for "T" (for non Arduino IDE)
@ -82,24 +86,34 @@ template <class T> int EEPROM_readAnything(int ee, T& value) {
return i; return i;
} }
// Graphic I2C LCD // Graphic SPI LCD
#include <Adafruit_GFX.h> #ifdef enable_LCD
#include <Adafruit_SSD1306.h> #include <U8g2lib.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels U8G2_ST7567_OS12864_F_4W_HW_SPI display(U8G2_R2, /* cs=*/ 12, /* dc=*/ 11, /* reset=*/ 10);
#define SCREEN_HEIGHT 64 // OLED display height, in pixels #endif
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Adafruit Clock Generator // Rotary Encoder
#include <si5351.h> #ifdef enable_rotary
Si5351 clockgen; #include <RotaryEncoder.h>
#define PIN_IN1 18
#define PIN_IN2 19
RotaryEncoder encoder(PIN_IN1, PIN_IN2, RotaryEncoder::LatchMode::FOUR3);
int rotaryPos = 0;
#endif
// RGB LED // Choose RGB LED type
#ifdef enable_neopixel
// Neopixel
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel pixels(3, 13, NEO_GRB + NEO_KHZ800);
#else
#ifndef enable_LCD
// 4 Pin RGB LED
#include <RGBTools.h> #include <RGBTools.h>
// Set pins of red, green and blue // Set pins of red, green and blue
RGBTools rgb(12, 11, 10); RGBTools rgb(12, 11, 10);
#endif
#endif
typedef enum COLOR_T { typedef enum COLOR_T {
blue_color, blue_color,
@ -111,6 +125,21 @@ typedef enum COLOR_T {
white_color, white_color,
} color_t; } color_t;
// Graphic I2C OLED
#ifdef enable_OLED
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#endif
// Adafruit Clock Generator
#include <si5351.h>
Si5351 clockgen;
// RTC Library // RTC Library
#ifdef RTC_installed #ifdef RTC_installed
#include "RTC.h" #include "RTC.h"
@ -156,6 +185,14 @@ typedef enum COLOR_T {
/****************************************** /******************************************
Variables Variables
*****************************************/ *****************************************/
#ifdef enable_rotary
// Button debounce
boolean buttonState = HIGH; // the current reading from the input pin
boolean lastButtonState = HIGH; // the previous reading from the input pin
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
#endif
#ifdef enable_OLED #ifdef enable_OLED
// Button 1 // Button 1
boolean buttonVal1 = HIGH; // value read from button boolean buttonVal1 = HIGH; // value read from button
@ -181,7 +218,9 @@ boolean ignoreUp2 = false; // whether to ignore the button release because the c
boolean waitForUp2 = false; // when held, whether to wait for the up event boolean waitForUp2 = false; // when held, whether to wait for the up event
boolean holdEventPast2 = false; // whether or not the hold event happened already boolean holdEventPast2 = false; // whether or not the hold event happened already
boolean longholdEventPast2 = false;// whether or not the long hold event happened already boolean longholdEventPast2 = false;// whether or not the long hold event happened already
#else #endif
#ifdef enable_serial
// For incoming serial data // For incoming serial data
int incomingByte; int incomingByte;
#endif #endif
@ -437,7 +476,9 @@ static const char* const addonsOptions[] PROGMEM = {addonsItem1, addonsItem2, ad
void aboutScreen() { void aboutScreen() {
display_Clear(); display_Clear();
// Draw the Logo // Draw the Logo
#ifdef enable_OLED
display.drawBitmap(0, 0, sig, 128, 64, 1); display.drawBitmap(0, 0, sig, 128, 64, 1);
#endif
println_Msg(F("Cartridge Reader")); println_Msg(F("Cartridge Reader"));
println_Msg(F("github.com/sanni")); println_Msg(F("github.com/sanni"));
print_Msg(F("2021 Version ")); print_Msg(F("2021 Version "));
@ -450,7 +491,7 @@ void aboutScreen() {
display_Update(); display_Update();
while (1) { while (1) {
#ifdef enable_OLED #if defined(enable_OLED) || defined(enable_LCD)
// get input button // get input button
int b = checkButton(); int b = checkButton();
@ -474,11 +515,12 @@ void aboutScreen() {
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);
resetArduino(); resetArduino();
} }
#else #endif
#ifdef enable_serial
wait_serial(); wait_serial();
resetArduino(); resetArduino();
#endif #endif
rgb.setColor(random(0, 255), random(0, 255), random(0, 255)); setColor_RGB(random(0, 255), random(0, 255), random(0, 255));
delay(random(50, 100)); delay(random(50, 100));
} }
} }
@ -643,6 +685,20 @@ void setup() {
// Read current folder number out of eeprom // Read current folder number out of eeprom
EEPROM_readAnything(0, foldern); EEPROM_readAnything(0, foldern);
#ifdef enable_LCD
display.begin();
display.setFont(u8g2_font_haxrcorp4089_tr);
#endif
#ifdef enable_neopixel
pixels.begin();
pixels.clear();
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
pixels.setPixelColor(1, pixels.Color(0, 0, 255));
pixels.setPixelColor(2, pixels.Color(0, 0, 255));
pixels.show();
#endif
#ifdef enable_OLED #ifdef enable_OLED
// GLCD // GLCD
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
@ -661,7 +717,7 @@ void setup() {
delay(100); delay(100);
// Initialize LED // Initialize LED
rgb.setColor(0, 0, 0); setColor_RGB(0, 0, 0);
// Clear the screen. // Clear the screen.
display_Clear(); display_Clear();
@ -693,31 +749,24 @@ void setup() {
display_Update(); display_Update();
delay(200); delay(200);
#endif #endif
#endif
#else #ifdef enable_serial
// Serial Begin // Serial Begin
Serial.begin(9600); Serial.begin(9600);
Serial.println(F("Cartridge Reader")); Serial.println(F("Cartridge Reader"));
Serial.println(F("2021 sanni")); Serial.println(F("2021 sanni"));
Serial.println(""); Serial.println("");
// LED Error // LED Error
rgb.setColor(0, 0, 255); setColor_RGB(0, 0, 255);
#endif #endif
// Init SD card // Init SD card
if (!sd.begin(SdSpiConfig(SS, DEDICATED_SPI))) { if (!sd.begin(SS)) {
display_Clear(); display_Clear();
print_Error(F("SD Error"), true); print_Error(F("SD Error"), true);
} }
#ifndef enable_OLED
// Print SD Info
Serial.print(F("SD Card: "));
Serial.print(sd.card()->cardSize() * 512E-9);
Serial.print(F("GB FAT"));
Serial.println(int(sd.vol()->fatType()));
#endif
#ifdef RTC_installed #ifdef RTC_installed
// Start RTC // Start RTC
RTCStart(); RTCStart();
@ -748,6 +797,19 @@ void dataIn() {
/****************************************** /******************************************
Helper Functions Helper Functions
*****************************************/ *****************************************/
// Set RGB color
void setColor_RGB(byte r, byte g, byte b) {
#ifdef enable_neopixel
pixels.clear();
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
pixels.setPixelColor(1, pixels.Color(g, r, b));
pixels.setPixelColor(2, pixels.Color(g, r, b));
pixels.show();
#else
rgb.setColor(r, g, b);
#endif
}
// Converts a progmem array into a ram array // Converts a progmem array into a ram array
void convertPgm(const char* const pgmOptions[], byte numArrays) { void convertPgm(const char* const pgmOptions[], byte numArrays) {
for (int i = 0; i < numArrays; i++) { for (int i = 0; i < numArrays; i++) {
@ -757,12 +819,12 @@ void convertPgm(const char* const pgmOptions[], byte numArrays) {
void print_Error(const __FlashStringHelper *errorMessage, boolean forceReset) { void print_Error(const __FlashStringHelper *errorMessage, boolean forceReset) {
errorLvl = 1; errorLvl = 1;
rgb.setColor(255, 0, 0); setColor_RGB(255, 0, 0);
println_Msg(errorMessage); println_Msg(errorMessage);
display_Update(); display_Update();
if (forceReset) { if (forceReset) {
#ifdef enable_OLED #if defined(enable_OLED) || defined(enable_LCD)
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("Press Button...")); println_Msg(F("Press Button..."));
display_Update(); display_Update();
@ -780,7 +842,8 @@ void print_Error(const __FlashStringHelper *errorMessage, boolean forceReset) {
display_Update(); display_Update();
delay(2000); delay(2000);
} }
#else #endif
#ifdef enable_serial
println_Msg(F("Fatal Error, please reset")); println_Msg(F("Fatal Error, please reset"));
while (1); while (1);
#endif #endif
@ -788,49 +851,73 @@ void print_Error(const __FlashStringHelper *errorMessage, boolean forceReset) {
} }
void wait() { void wait() {
#ifdef enable_LCD
wait_encoder();
#endif
#ifdef enable_OLED #ifdef enable_OLED
wait_btn(); wait_btn();
#else #endif
#ifdef enable_serial
wait_serial(); wait_serial();
#endif #endif
} }
void print_Msg(const __FlashStringHelper *string) { void print_Msg(const __FlashStringHelper *string) {
#ifdef enable_LCD
display.print(string);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.print(string); display.print(string);
#else #endif
#ifdef enable_serial
Serial.print(string); Serial.print(string);
#endif #endif
} }
void print_Msg(const char string[]) { void print_Msg(const char string[]) {
#ifdef enable_LCD
display.print(string);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.print(string); display.print(string);
#else #endif
#ifdef enable_serial
Serial.print(string); Serial.print(string);
#endif #endif
} }
void print_Msg(long unsigned int message) { void print_Msg(long unsigned int message) {
#ifdef enable_LCD
display.print(message);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.print(message); display.print(message);
#else #endif
#ifdef enable_serial
Serial.print(message); Serial.print(message);
#endif #endif
} }
void print_Msg(byte message, int outputFormat) { void print_Msg(byte message, int outputFormat) {
#ifdef enable_LCD
display.print(message, outputFormat);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.print(message, outputFormat); display.print(message, outputFormat);
#else #endif
#ifdef enable_serial
Serial.print(message, outputFormat); Serial.print(message, outputFormat);
#endif #endif
} }
void print_Msg(String string) { void print_Msg(String string) {
#ifdef enable_LCD
display.print(string);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.print(string); display.print(string);
#else #endif
#ifdef enable_serial
Serial.print(string); Serial.print(string);
#endif #endif
} }
@ -852,56 +939,88 @@ void print_Msg_PaddedHex32(unsigned long message) {
print_Msg_PaddedHexByte((message >> 0) & 0xFF); print_Msg_PaddedHexByte((message >> 0) & 0xFF);
} }
void println_Msg(String string) { void println_Msg(String string) {
#ifdef enable_LCD
display.println(string);
display.setCursor(0, display.ty + 8);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.println(string); display.println(string);
#else #endif
#ifdef enable_serial
Serial.println(string); Serial.println(string);
#endif #endif
} }
void println_Msg(byte message, int outputFormat) { void println_Msg(byte message, int outputFormat) {
#ifdef enable_LCD
display.println(message, outputFormat);
display.setCursor(0, display.ty + 8);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.println(message, outputFormat); display.println(message, outputFormat);
#else #endif
#ifdef enable_serial
Serial.println(message, outputFormat); Serial.println(message, outputFormat);
#endif #endif
} }
void println_Msg(const char message[]) { void println_Msg(const char message[]) {
#ifdef enable_LCD
display.println(message);
display.setCursor(0, display.ty + 8);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.println(message); display.println(message);
#else #endif
#ifdef enable_serial
Serial.println(message); Serial.println(message);
#endif #endif
} }
void println_Msg(const __FlashStringHelper *string) { void println_Msg(const __FlashStringHelper *string) {
#ifdef enable_LCD
display.println(string);
display.setCursor(0, display.ty + 8);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.println(string); display.println(string);
#else #endif
#ifdef enable_serial
Serial.println(string); Serial.println(string);
#endif #endif
} }
void println_Msg(long unsigned int message) { void println_Msg(long unsigned int message) {
#ifdef enable_LCD
display.print(message);
display.setCursor(0, display.ty + 8);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.println(message); display.println(message);
#else #endif
#ifdef enable_serial
Serial.println(message); Serial.println(message);
#endif #endif
} }
void display_Update() { void display_Update() {
#ifdef enable_LCD
display.updateDisplay();
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.display(); display.display();
#else #endif
#ifdef enable_serial
delay(100); delay(100);
#endif #endif
} }
void display_Clear() { void display_Clear() {
#ifdef enable_LCD
display.clearDisplay();
display.setCursor(0, 8);
#endif
#ifdef enable_OLED #ifdef enable_OLED
display.clearDisplay(); display.clearDisplay();
display.setCursor(0, 0); display.setCursor(0, 0);
@ -909,9 +1028,13 @@ void display_Clear() {
} }
unsigned char question_box(const __FlashStringHelper* question, char answers[7][20], int num_answers, int default_choice) { unsigned char question_box(const __FlashStringHelper* question, char answers[7][20], int num_answers, int default_choice) {
#ifdef enable_LCD
return questionBox_LCD(question, answers, num_answers, default_choice);
#endif
#ifdef enable_OLED #ifdef enable_OLED
return questionBox_OLED(question, answers, num_answers, default_choice); return questionBox_OLED(question, answers, num_answers, default_choice);
#else #endif
#ifdef enable_serial
return questionBox_Serial(question, answers, num_answers, default_choice); return questionBox_Serial(question, answers, num_answers, default_choice);
#endif #endif
} }
@ -919,7 +1042,7 @@ unsigned char question_box(const __FlashStringHelper* question, char answers[7][
/****************************************** /******************************************
Serial Out Serial Out
*****************************************/ *****************************************/
#ifndef enable_OLED #ifdef enable_serial
void wait_serial() { void wait_serial() {
while (Serial.available() == 0) { while (Serial.available() == 0) {
} }
@ -1045,29 +1168,248 @@ byte questionBox_Serial(const __FlashStringHelper* question, char answers[7][20]
void rgbLed(byte Color) { void rgbLed(byte Color) {
switch (Color) { switch (Color) {
case blue_color: case blue_color:
rgb.setColor(0, 0, 255); setColor_RGB(0, 0, 255);
break; break;
case red_color: case red_color:
rgb.setColor(255, 0, 0); setColor_RGB(255, 0, 0);
break; break;
case purple_color: case purple_color:
rgb.setColor(255, 0, 255); setColor_RGB(255, 0, 255);
break; break;
case green_color: case green_color:
rgb.setColor(0, 255, 0); setColor_RGB(0, 255, 0);
break; break;
case turquoise_color: case turquoise_color:
rgb.setColor(0, 255, 255); setColor_RGB(0, 255, 255);
break; break;
case yellow_color: case yellow_color:
rgb.setColor(255, 255, 0); setColor_RGB(255, 255, 0);
break; break;
case white_color: case white_color:
rgb.setColor(255, 255, 255); setColor_RGB(255, 255, 255);
break; break;
} }
} }
/******************************************
LCD Menu Module
*****************************************/
#if defined(enable_LCD) && defined(enable_rotary)
// Read encoder state
int checkButton() {
// Read rotary encoder
encoder.tick();
int newPos = encoder.getPosition();
// Read button
boolean reading = (PING & (1 << PING2)) >> PING2;
// Check if rotary encoder has changed
if (rotaryPos != newPos) {
int rotaryDir = (int)encoder.getDirection();
if (rotaryDir == 1) {
rotaryPos = newPos;
return 1;
}
else if (rotaryDir == -1) {
rotaryPos = newPos;
return 2;
}
else {
return 0;
}
}
// Check if button has changed
else {
if (reading != lastButtonState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (reading != buttonState) {
buttonState = reading;
if (buttonState == 0) {
while ((PING & (1 << PING2)) >> PING2 == 0);
lastButtonState = reading;
return 3;
}
}
else {
lastButtonState = reading;
return 0;
}
}
else {
lastButtonState = reading;
return 0;
}
}
}
// Wait for user to push button
void wait_encoder() {
// Change led to green
if (errorLvl == 0)
rgbLed(green_color);
while (1)
{
// Get rotary encoder
encoder.tick();
int newPos = encoder.getPosition();
#ifdef enable_N64
#ifndef clockgen_installed
// Send some clock pulses to the Eeprom in case it locked up
if ((mode == mode_N64_Cart) && ((saveType == 5) || (saveType == 6))) {
pulseClock_N64(1);
}
#endif
#endif
if (rotaryPos != newPos) {
rotaryPos = newPos;
errorLvl = 0;
break;
}
}
}
#endif
#ifdef enable_LCD
// Display a question box with selectable answers. Make sure default choice is in (0, num_answers]
unsigned char questionBox_LCD(const __FlashStringHelper * question, char answers[7][20], int num_answers, int default_choice) {
//clear the screen
display.clearDisplay();
display.updateDisplay();
display.setCursor(0, 8);
// change the rgb led to the start menu color
rgbLed(default_choice);
// print menu
display.println(question);
display.setCursor(0, display.ty + 8);
for (unsigned char i = 0; i < num_answers; i++) {
// Add space for the selection dot
display.print(" ");
// Print menu item
display.println(answers[i]);
display.setCursor(0, display.ty + 8);
}
display.updateDisplay();
// start with the default choice
choice = default_choice;
// draw selection box
display.setDrawColor(1);
display.drawPixel(0, 8 * choice + 12);
display.updateDisplay();
unsigned long idleTime = millis();
byte currentColor = 0;
// wait until user makes his choice
while (1) {
// Attract Mode
if (millis() - idleTime > 300000) {
if ((millis() - idleTime) % 4000 == 0) {
if (currentColor < 7) {
currentColor++;
if (currentColor == 1) {
currentColor = 2; // skip red as that signifies an error to the user
}
}
else {
currentColor = 0;
}
}
rgbLed(currentColor);
}
/* Check Button
1 click
2 doubleClick
3 hold
4 longHold */
int b = checkButton();
if (b == 2) {
idleTime = millis();
// remove selection box
display.setDrawColor(0);
display.drawPixel(0, 8 * choice + 12);
display.updateDisplay();
if ((choice == 0) && (filebrowse == 1)) {
if (currPage > 1) {
lastPage = currPage;
currPage--;
break;
}
else {
root = 1;
break;
}
}
else if (choice > 0) {
choice--;
}
else {
choice = num_answers - 1;
}
// draw selection box
display.setDrawColor(1);
display.drawPixel(0, 8 * choice + 12);
display.updateDisplay();
// change RGB led to the color of the current menu option
rgbLed(choice);
}
// go one down in the menu if the Cart Dumpers button is clicked shortly
if (b == 1) {
idleTime = millis();
// remove selection box
display.setDrawColor(0);
display.drawPixel(0, 8 * choice + 12);
display.updateDisplay();
if ((choice == num_answers - 1 ) && (numPages > currPage) && (filebrowse == 1)) {
lastPage = currPage;
currPage++;
break;
}
else
choice = (choice + 1) % num_answers;
// draw selection box
display.setDrawColor(1);
display.drawPixel(0, 8 * choice + 12);
display.updateDisplay();
// change RGB led to the color of the current menu option
rgbLed(choice);
}
// if the Cart Dumpers button is hold continiously leave the menu
// so the currently highlighted action can be executed
if (b == 3) {
idleTime = millis();
break;
}
}
// pass on user choice
setColor_RGB(0, 0, 0);
return choice;
}
#endif
/****************************************** /******************************************
OLED Menu Module OLED Menu Module
*****************************************/ *****************************************/
@ -1365,7 +1707,7 @@ unsigned char questionBox_OLED(const __FlashStringHelper* question, char answers
} }
// pass on user choice // pass on user choice
rgb.setColor(0, 0, 0); setColor_RGB(0, 0, 0);
return choice; return choice;
} }
#endif #endif

View File

@ -182,7 +182,9 @@ void n64ControllerMenu() {
case 0: case 0:
display_Clear(); display_Clear();
display_Update(); display_Update();
controllerTest(); #ifdef enable_OLED
controllerTest_OLED();
#endif
quit = 1; quit = 1;
break; break;
@ -903,6 +905,7 @@ void get_button()
/****************************************** /******************************************
N64 Controller Test N64 Controller Test
*****************************************/ *****************************************/
#ifdef enable_OLED
#define CENTER 64 #define CENTER 64
void oledPrint(const char string[], int x, int y) { void oledPrint(const char string[], int x, int y) {
@ -926,7 +929,7 @@ void printSTR(String st, int x, int y)
oledPrint(buf, x, y); oledPrint(buf, x, y);
} }
void controllerTest() { void controllerTest_OLED() {
// on which screens do we start // on which screens do we start
int startscreen = 1; int startscreen = 1;
int mode = 0; int mode = 0;
@ -1426,6 +1429,8 @@ void controllerTest() {
} }
} }
} }
#endif
/****************************************** /******************************************
N64 Controller Pak Functions N64 Controller Pak Functions
(connected via Controller) (connected via Controller)
@ -3069,7 +3074,7 @@ redumpsamefolder:
else { else {
// Dump was bad or unknown // Dump was bad or unknown
errorLvl = 1; errorLvl = 1;
rgb.setColor(255, 0, 0); setColor_RGB(255, 0, 0);
println_Msg(F("Checksum not found")); println_Msg(F("Checksum not found"));
println_Msg(F("in N64.txt")); println_Msg(F("in N64.txt"));
println_Msg(F("")); println_Msg(F(""));
@ -3099,7 +3104,7 @@ redumpsamefolder:
case 1: case 1:
// Dump again into new folder // Dump again into new folder
display_Clear(); display_Clear();
rgb.setColor(0, 0, 0); setColor_RGB(0, 0, 0);
goto redumpnewfolder; goto redumpnewfolder;
break; break;
@ -3118,7 +3123,7 @@ redumpsamefolder:
display_Clear(); display_Clear();
println_Msg(F("Reading Rom...")); println_Msg(F("Reading Rom..."));
display_Update(); display_Update();
rgb.setColor(0, 0, 0); setColor_RGB(0, 0, 0);
goto redumpsamefolder; goto redumpsamefolder;
break; break;

View File

@ -1253,10 +1253,11 @@ chooseMapper:
errorLvl = 1; errorLvl = 1;
display.println("Mapper not supported"); display.println("Mapper not supported");
display.display(); display.display();
wait_btn(); wait();
goto chooseMapper; goto chooseMapper;
} }
#else #endif
#ifdef enable_serial
setmapper: setmapper:
String newmap; String newmap;
mapfound = false; mapfound = false;
@ -1356,7 +1357,8 @@ void setPRGSize() {
println_Msg(F("K")); println_Msg(F("K"));
display_Update(); display_Update();
delay(1000); delay(1000);
#else #endif
#ifdef enable_serial
if (prglo == prghi) if (prglo == prghi)
newprgsize = prglo; newprgsize = prglo;
else { else {
@ -1429,7 +1431,8 @@ void setCHRSize() {
println_Msg(F("K")); println_Msg(F("K"));
display_Update(); display_Update();
delay(1000); delay(1000);
#else #endif
#ifdef enable_serial
if (chrlo == chrhi) if (chrlo == chrhi)
newchrsize = chrlo; newchrsize = chrlo;
else { else {
@ -1549,7 +1552,8 @@ void setRAMSize() {
} }
display_Update(); display_Update();
delay(1000); delay(1000);
#else #endif
#ifdef enable_serial
if (ramlo == ramhi) if (ramlo == ramhi)
newramsize = ramlo; newramsize = ramlo;
else { else {

View File

@ -717,7 +717,7 @@ void getCartInfo_SFM() {
if (checkcart_SFM() == 0) { if (checkcart_SFM() == 0) {
// Checksum either corrupt or 0000 // Checksum either corrupt or 0000
errorLvl = 1; errorLvl = 1;
rgb.setColor(255, 0, 0); setColor_RGB(255, 0, 0);
display_Clear(); display_Clear();
println_Msg(F("ERROR")); println_Msg(F("ERROR"));
println_Msg(F("Rom header corrupt")); println_Msg(F("Rom header corrupt"));

View File

@ -58,9 +58,12 @@ To compile and upload the code please have a look at [this wiki article](https:/
Needed libraries(already included in the portable Arduino IDE under Releases) Needed libraries(already included in the portable Arduino IDE under Releases)
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/adafruit/Adafruit_SSD1306 OLED lib: https://github.com/adafruit/Adafruit_SSD1306
GFX Lib: https://github.com/adafruit/Adafruit-GFX-Library GFX Lib: https://github.com/adafruit/Adafruit-GFX-Library
BusIO: https://github.com/adafruit/Adafruit_BusIO BusIO: https://github.com/adafruit/Adafruit_BusIO
LCD lib: https://github.com/olikraus/u8g2
RGB Tools lib: https://github.com/joushx/Arduino-RGB-Tools RGB Tools lib: https://github.com/joushx/Arduino-RGB-Tools
Neopixel lib: https://github.com/adafruit/Adafruit_NeoPixel
Rotary Enc lib: https://github.com/mathertel/RotaryEncoder
SI5351 lib: https://github.com/etherkit/Si5351Arduino SI5351 lib: https://github.com/etherkit/Si5351Arduino
RTC lib: https://github.com/adafruit/RTClib (If you include an RTC) RTC lib: https://github.com/adafruit/RTClib

View File

@ -1,3 +1,6 @@
#include "options.h"
#ifdef RTC_installed
#include "RTC.h" #include "RTC.h"
#include "SdFat.h" #include "SdFat.h"
@ -49,3 +52,5 @@ String RTCStamp() {
// Print results // Print results
return dts; return dts;
} }
#endif

View File

@ -1,3 +1,6 @@
#include "options.h"
#ifdef RTC_installed
// RTC Library // RTC Library
#ifndef _RTC_H #ifndef _RTC_H
#define _RTC_H #define _RTC_H
@ -11,3 +14,4 @@ void dateTime(uint16_t* date, uint16_t* time);
String RTCStamp(); String RTCStamp();
#endif #endif
#endif

View File

@ -319,7 +319,7 @@ void getCartInfo_SMS() {
default: default:
cartSize = 48 * 1024UL; cartSize = 48 * 1024UL;
// LED Error // LED Error
rgb.setColor(0, 0, 255); setColor_RGB(0, 0, 255);
break; break;
} }
@ -382,7 +382,7 @@ void getCartInfo_SMS() {
wait(); wait();
#endif #endif
// Turn off LED // Turn off LED
rgb.setColor(0, 0, 0); setColor_RGB(0, 0, 0);
} }
// Read rom and save to the SD card // Read rom and save to the SD card

View File

@ -665,7 +665,7 @@ void getCartInfo_SNES() {
// Checksum either corrupt or 0000 // Checksum either corrupt or 0000
manualConfig = 1; manualConfig = 1;
errorLvl = 1; errorLvl = 1;
rgb.setColor(255, 0, 0); setColor_RGB(255, 0, 0);
display_Clear(); display_Clear();
println_Msg(F("ERROR")); println_Msg(F("ERROR"));
@ -775,7 +775,8 @@ void getCartInfo_SNES() {
println_Msg(F("Press Button...")); println_Msg(F("Press Button..."));
display_Update(); display_Update();
wait(); wait();
#else #endif
#ifdef enable_serial
println_Msg(F(" ")); println_Msg(F(" "));
#endif #endif

View File

@ -1,3 +1,31 @@
//******************************************
// CHOOSE HARDWARE VERSION
//******************************************
//#define HW4
#define HW3
//#define HW2
//#define HW1
//#define SERIAL
#if defined(HW4)
#define enable_LCD
#define enable_neopixel
#define enable_rotary
#endif
#if defined(HW2) || defined(HW3)
#define enable_OLED
#define enable_Button2
#endif
#if defined(HW1)
#define enable_OLED
#endif
#if defined(SERIAL)
#define enable_serial
#endif
//****************************************** //******************************************
// GLOBAL OPTIONS // GLOBAL OPTIONS
//****************************************** //******************************************
@ -5,15 +33,9 @@
// flashMenu, nesMenu or smsMenu for single slot Cart Readers // flashMenu, nesMenu or smsMenu for single slot Cart Readers
#define startMenu mainMenu #define startMenu mainMenu
// Comment out to change to Serial Output // Skip start-up animation
// be sure to change the Arduino Serial Monitor to no line ending
#define enable_OLED
// Skip OLED start-up animation
// #define fast_start // #define fast_start
// Enable the second button
#define enable_Button2
// Setup RTC if installed. // Setup RTC if installed.
// remove // if you have an RTC installed // remove // if you have an RTC installed
// #define RTC_installed // #define RTC_installed

Binary file not shown.