replace NES defines with rgbLed function calls

This commit is contained in:
smesgr9000 2024-05-26 22:43:41 +02:00
parent 363d18b542
commit cb111077f8
5 changed files with 34 additions and 44 deletions

View File

@ -113,6 +113,7 @@ typedef enum COLOR_T {
turquoise_color,
yellow_color,
white_color,
black_color,
} color_t;
// Graphic I2C OLED
@ -1450,7 +1451,7 @@ void selfTest() {
display_Update();
if (!digitalRead(7)) {
setColor_RGB(255, 0, 0);
rgbLed(red_color);
errorLvl = 1;
println_Msg(F("Error"));
println_Msg(FS(FSTRING_EMPTY));
@ -1474,7 +1475,7 @@ void selfTest() {
for (byte pinNumber = 2; pinNumber <= 69; pinNumber++) {
if (isPin_2t9_14t17_22t37_42t49_54t69(pinNumber)) {
if (!digitalRead(pinNumber)) {
setColor_RGB(255, 0, 0);
rgbLed(red_color);
errorLvl = 1;
print_Msg(F("Error: Pin "));
if ((54 <= pinNumber) && (pinNumber <= 69)) {
@ -1505,7 +1506,7 @@ void selfTest() {
if (isPin_2t9_14t17_22t37_42t49_54t69(pinNumber2) && (pinNumber != pinNumber2)) {
pinMode(pinNumber2, INPUT_PULLUP);
if (!digitalRead(pinNumber2)) {
setColor_RGB(255, 0, 0);
rgbLed(red_color);
errorLvl = 1;
print_Msg(F("Error: Pin "));
if ((54 <= pinNumber) && (pinNumber <= 69)) {
@ -1538,7 +1539,7 @@ void selfTest() {
println_Msg(F("Testing Clock Generator"));
initializeClockOffset();
if (!i2c_found) {
setColor_RGB(255, 0, 0);
rgbLed(red_color);
errorLvl = 1;
println_Msg(F("Error: Clock Generator"));
println_Msg(F("not found"));
@ -2095,7 +2096,7 @@ void setup() {
Serial.println(F("Cartridge Reader"));
Serial.println(F("2024 github.com/sanni"));
// LED Error
setColor_RGB(0, 0, 255);
rgbLed(blue_color);
# endif /* ENABLE_SERIAL */
// Init SD card
@ -2262,7 +2263,7 @@ void convertPgm(const char* const pgmOptions[], byte numArrays) {
void _print_Error(void) {
errorLvl = 1;
setColor_RGB(255, 0, 0);
rgbLed(red_color);
display_Update();
}
@ -2663,6 +2664,9 @@ void rgbLed(byte Color) {
case white_color:
setColor_RGB(255, 255, 255);
break;
case black_color:
setColor_RGB(0, 0, 0);
break;
}
}
@ -2895,7 +2899,7 @@ unsigned char questionBox_Display(const __FlashStringHelper* question, char answ
}
// pass on user choice
setColor_RGB(0, 0, 0);
rgbLed(black_color);
#ifdef ENABLE_GLOBAL_LOG
println_Msg(FS(FSTRING_EMPTY));
@ -3222,7 +3226,7 @@ uint8_t checkButton() {
buttonState = reading;
// Button was pressed down
if (buttonState == 0) {
setColor_RGB(0, 0, 0);
rgbLed(black_color);
unsigned long pushTime = millis();
// Wait until button was let go again
while ((PING & (1 << PING2)) >> PING2 == 0) {

View File

@ -194,14 +194,6 @@ const char _file_name_with_number_fmt[] PROGMEM = "%s.%02d.%s";
#define CHR_WRITE_HI PORTF |= (1 << 2)
#define CHR_WRITE_LOW PORTF &= ~(1 << 2)
// RGB LED COMMON ANODE
#define LED_RED_OFF setColor_RGB(0, 0, 0)
#define LED_RED_ON setColor_RGB(255, 0, 0)
#define LED_GREEN_OFF setColor_RGB(0, 0, 0)
#define LED_GREEN_ON setColor_RGB(0, 255, 0)
#define LED_BLUE_OFF setColor_RGB(0, 0, 0)
#define LED_BLUE_ON setColor_RGB(0, 0, 255)
#define MODE_READ \
{ \
PORTK = 0xFF; \
@ -436,9 +428,7 @@ void setup_NES() {
DDRK = 0;
set_address(0);
LED_RED_OFF;
LED_GREEN_OFF;
LED_BLUE_OFF;
rgbLed(black_color);
}
/******************************************
@ -948,7 +938,7 @@ FsFile createNewFile(const char* prefix, const char* extension) {
// Could not find an available name, recompose the original name and error out.
snprintf_P(filename, sizeof(filename), _file_name_no_number_fmt, prefix, extension);
LED_RED_ON;
rgbLed(red_color);
display_Clear();
print_Msg(filename);
@ -956,7 +946,7 @@ FsFile createNewFile(const char* prefix, const char* extension) {
display_Update();
print_FatalError(sd_error_STR);
LED_RED_OFF;
rgbLed(black_color);
}
void CreatePRGFileInSD() {
@ -987,14 +977,14 @@ void CreateRAMFileInSD() {
strcat(fileName, ".bin");
}
if (!myFile) {
LED_RED_ON;
rgbLed(red_color);
display_Clear();
println_Msg(F("RAM FILE FAILED!"));
display_Update();
//print_Error(F("SD Error"), true);
LED_RED_OFF;
rgbLed(black_color);
}
}
@ -1676,7 +1666,7 @@ void readPRG(bool readrom) {
display_Clear();
display_Update();
LED_BLUE_ON;
rgbLed(blue_color);
set_address(0);
_delay_us(1);
CreatePRGFileInSD();
@ -2692,7 +2682,7 @@ void readPRG(bool readrom) {
set_address(0);
PHI2_HI;
ROMSEL_HI;
LED_BLUE_OFF;
rgbLed(black_color);
}
void readCHR(bool readrom) {
@ -2703,7 +2693,7 @@ void readCHR(bool readrom) {
uint16_t banks;
LED_GREEN_ON;
rgbLed(green_color);
set_address(0);
_delay_us(1);
if (chrsize == 0) {
@ -3533,7 +3523,7 @@ void readCHR(bool readrom) {
set_address(0);
PHI2_HI;
ROMSEL_HI;
LED_GREEN_OFF;
rgbLed(black_color);
}
/******************************************
@ -3545,8 +3535,7 @@ void readRAM() {
uint16_t banks;
LED_BLUE_ON;
LED_GREEN_ON;
rgbLed(turquoise_color);
set_address(0);
_delay_us(1);
if (ramsize == 0) {
@ -3715,8 +3704,7 @@ void readRAM() {
set_address(0);
PHI2_HI;
ROMSEL_HI;
LED_BLUE_OFF;
LED_GREEN_OFF;
rgbLed(black_color);
}
void writeBankPRG(const size_t from, const size_t to, const size_t base) {
@ -3920,7 +3908,7 @@ void writeRAM() {
break;
}
myFile.close();
LED_GREEN_ON;
rgbLed(green_color);
println_Msg(FS(FSTRING_EMPTY));
println_Msg(F("RAM FILE WRITTEN!"));
@ -3931,8 +3919,7 @@ void writeRAM() {
}
}
LED_RED_OFF;
LED_GREEN_OFF;
rgbLed(black_color);
sd.chdir(); // root
filePath[0] = '\0'; // Reset filePath
}
@ -4203,7 +4190,7 @@ void NESmaker_ChipErase() { // Typical 70ms
void writeFLASH() {
display_Clear();
if (!flashfound) {
LED_RED_ON;
rgbLed(red_color);
println_Msg(F("FLASH NOT DETECTED"));
display_Update();
} else {
@ -4221,7 +4208,7 @@ void writeFLASH() {
sd.chdir();
sprintf(filePath, "%s/%s", filePath, fileName);
LED_RED_ON;
rgbLed(red_color);
display_Clear();
println_Msg(F("Writing File: "));
println_Msg(filePath);
@ -4272,20 +4259,19 @@ void writeFLASH() {
#endif
}
myFile.close();
LED_GREEN_ON;
rgbLed(green_color);
println_Msg(FS(FSTRING_EMPTY));
println_Msg(F("FLASH FILE WRITTEN!"));
display_Update();
} else {
LED_RED_ON;
rgbLed(red_color);
println_Msg(F("SD ERROR"));
display_Update();
}
}
display_Clear();
LED_RED_OFF;
LED_GREEN_OFF;
rgbLed(black_color);
sd.chdir(); // root
filePath[0] = '\0'; // Reset filePath
}

View File

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

View File

@ -391,7 +391,7 @@ void getCartInfo_SMS() {
default:
cartSize = 48 * 1024UL;
// LED Error
setColor_RGB(0, 0, 255);
rgbLed(blue_color);
break;
}
@ -542,7 +542,7 @@ void getCartInfo_SMS() {
#endif
// Turn off LED
setColor_RGB(0, 0, 0);
rgbLed(black_color);
}
//******************************************

View File

@ -740,7 +740,7 @@ void getCartInfo_SNES() {
// Checksum either corrupt or 0000
manualConfig = 1;
errorLvl = 1;
setColor_RGB(255, 0, 0);
rgbLed(red_color);
display_Clear();
println_Msg(F("ERROR"));