#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#include <EEPROM.h>
#include <RTClib.h>
DateTime now;
RTC_DS3231 rtc;
void displayDate(void);
void displayTime(void);
char t[32];
//================================================================================================================
#include "DFRobotDFPlayerMini.h"
DFRobotDFPlayerMini myDFPlayer;
//void printDetail(uint8_t type, int value);
//=============================================== COSTUM CHARACTERS =================================
byte hallow[] = {
B00000,
B11111,
B00000,
B00000,
B00000,
B00000,
B11111,
B00000
};
byte shadedL[] = {
B11110,
B10000,
B10111,
B10111,
B10111,
B10111,
B10000,
B11110
};
byte shadedR[] = {
B01111,
B00001,
B11101,
B11101,
B11101,
B11101,
B00001,
B01111
};
byte whole[] = {
B00000,
B11111,
B00000,
B11111,
B11111,
B00000,
B11111,
B00000
};
byte arrow[] = {
B00000,
B00100,
B00110,
B11111,
B11111,
B00110,
B00100,
B00000
};
byte note[] = {
B00010,
B00011,
B00010,
B00010,
B01110,
B11110,
B11110,
B01100
};
byte forw[] = {
B00000,
B10001,
B11001,
B11101,
B11111,
B11101,
B11001,
B10001
};
byte prev[] = {
B00000,
B10001,
B10011,
B10111,
B11111,
B10111,
B10011,
B10001
};
//================================================================================================================
#define underGlow 11
#define keyKnob 10
#define keyKnobLed 13
#define mdlStateL A2
#define mdlStateH A3
#define loudStock 12
#define rapid A1
#define busyPin 3
#define gripHeater 2
int comboLed = 1;
int lastStarterState = 0;
int starterState = 0;
int mdlStateL_last = 1;
int mdlStateH_last = 1;
int onOff = 0;
#define vpin A0
unsigned long prevMillis = 0;
int w = 1;
int notifVol;
//===================================== music reference ==================================
unsigned long track;
int nMode = 0;
int screenMode = 0;
int menu = 1;
unsigned long songCount;
boolean randomAll = false;
boolean isMp3Playing = false;
boolean isMp3Pause = false;
int folderNo;
int albumn = 1;
int spacing = 0;
const char *arrayAlbumn[] = {
"------ ALBUMN ------",
"ALL SONGS",
"NEW SONGS 2023",
"ALTERNATIVE",
"SLOW ROCK",
"MUSIC TRAVEL",
"PAROKYA ",
"AGSUNTA",
"OPM SONGS",
"PINOY RAP",
"SPLAN X LPARK",
"COUNTRY ",
"AVRIL LAVIGNE",
"URBAN DUB",
"RNB MUSIC",
"BOYCE AVENEU",
"URBAN DUB"
};
const char *arrayEQ[] = {
"----- EQUALIZER ----",
"NORMAL",
"POP",
"ROCK",
"JAZZ",
"CLASSIC",
"BASS",
"EQUALIZER",
"NOW PLAYING"
};
const char *tDate[] = {
"-- Time/Date Set ---",
"Time Format = [12]",
"Set Time",
"Set Date"
};
const int spacing1 = 4;
const int spacing2 = 5;
int eqMode;
int currentVol = 25;
boolean isActiveVol = false;
unsigned long previousVolTimer;
unsigned long previousPPTimer;
unsigned long prevSepMillis = 0;
unsigned long prevVoltTime;
int o = 1;
//==================================== NOTIFICATION REFERENCE ==================================
const char *arrayNotif[] = {
"====================",
"Activated",
"Deactivated",
"Switched On",
"Switched Off",
"--------------------"
};
const int dly = 50; //screen clear refresh value
const int dly1 = 2500; // how long it will stay on screen
//======================================== KEYKNOB ON STATE TIMER ======================================
const long startCount = 6200; // start countdown with 6 seconds
unsigned long previousMillisCounter;
bool counting = false;
unsigned long previousMillisUpdate;
const unsigned long intervalUpdate = 1000;
int count = 0;
//=============================================== time and date ========================================
int dLine = 1;
int dd;
int mmm;
int yyyy;
int hh;
int mn;
int np = 0;
int setPos = 1;
bool isAfternoon;
bool isSetTime;
bool isSetDate;
int timeFormat;
const char *sMonth[] = {
" ",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};
char dow[7][12] = {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
};
//================================================ return to home counting ======================================
unsigned long previousMenuTimer;
boolean isActiveMenu = false;
//================================================================================================================
static const int stockPassing = 4;
static const int button_1 = 8;
static const int button_2 = 6;
static const int button_3 = 7;
static const int button_4 = 5;
static const int button_5 = 9;
int buttonStatePrevious_aPass = HIGH;
int buttonStatePrevious_but1 = HIGH;
int buttonStatePrevious_but2 = HIGH;
int buttonStatePrevious_but3 = HIGH;
int buttonStatePrevious_but4 = HIGH;
int buttonStatePrevious_but5 = HIGH;
unsigned long minButtonLongPressDuration = 1000;
unsigned long buttonLongPressMillis;
bool buttonStateLongPress = false;
const int intervalButton = 50;
unsigned long previousButtonMillis;
unsigned long buttonPressDuration;
unsigned long currentButtonMillis;
void setup() {
//====================================================================================================
lcd.init(); // initialize the lcd
lcd.backlight();
//===========================================MP3 INITIALIZED==========================================
Serial.begin(9600);
myDFPlayer.begin(Serial);
//myDFPlayer.setTimeOut(100);
//myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
//myDFPlayer.enableDAC();
//====================================================================================================
lcd.createChar(0, hallow);
lcd.createChar(1, whole);
lcd.createChar(2, arrow);
lcd.createChar(3, note);
lcd.createChar(4, forw);
lcd.createChar(5, shadedL);
lcd.createChar(6, shadedR);
lcd.createChar(7, prev);
//=============================================================================================================
isMp3Playing = false;
Wire.begin();
rtc.begin();
//=============================================================================================================
if (!rtc.begin()) {
while (1)
;
}
if (rtc.lostPower()) {
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
int k;
isSetTime = false;
isSetDate = false;
//==============================================================================================================
int tmHour = now.hour();
if (tmHour > 19 && tmHour < 7) {
myDFPlayer.volume(10);
currentVol = 10;
} else {
myDFPlayer.volume(25);
currentVol = 25;
}
lcd.setCursor(2, 0);
lcd.print(F("Initializing...."));
myDFPlayer.playMp3Folder(1); //access granted
int j = 0;
while (j < 20) {
lcd.setCursor(j, 1);
lcd.write(byte(0));
delay(50);
j++;
}
j = 0;
while (j < 20) {
lcd.setCursor(j, 1);
lcd.write(byte(1));
delay(50);
j++;
}
//==============================================================================================================
delay(4000);
myDFPlayer.playMp3Folder(2); // welcome back
lcd.setCursor(4, 2);
lcd.print(F("Welcome Back"));
delay(3000);
if (tmHour > 7 && tmHour < 12) {
myDFPlayer.playMp3Folder(47); //goodmorning
} else if (tmHour > 12 && tmHour < 19) {
myDFPlayer.playMp3Folder(48); //goodafternoon
} else {
myDFPlayer.playMp3Folder(49); //goodevening
}
lcd.setCursor(0, 3);
lcd.print(F(" Master MARJUN "));
lcd.setCursor(1, 3);
delay(1000);
lcd.clear();
//==============================================================================================================
float voltage;
voltage = analogRead(vpin);
int m1 = 0;
const char *arrayWarn[] = { "WARNING!", " " };
int l = 0;
int l1 = 9;
if ((voltage * (5.0 / 1024) * ((38300.0 + 12300.0) / 12300.0)) < 12) {
myDFPlayer.playMp3Folder(11);
int l1 = 9;
while (l1 > 0) {
lcd.setCursor(0, 0);
lcd.print(arrayNotif[l]);
lcd.setCursor(6, 1);
lcd.print(arrayWarn[m1]);
lcd.setCursor(1, 2);
lcd.print(F("LOW VOLTAGE LEVEL!"));
lcd.setCursor(0, 3);
lcd.print(arrayNotif[l]);
l1--;
if (m1 == 0) {
m1 = 1;
l = 5;
} else {
m1 = 0;
l = 0;
}
delay(600);
}
delay(50);
lcd.clear();
}
if (rtc.getTemperature() < 15) {
myDFPlayer.playMp3Folder(21);
int l1 = 9;
while (l1 > 0) {
lcd.setCursor(0, 0);
lcd.print(arrayNotif[l]);
lcd.setCursor(6, 1);
lcd.print(arrayWarn[m1]);
lcd.setCursor(0, 2);
lcd.print(F("Current Temp is LOW"));
lcd.setCursor(0, 3);
lcd.print(arrayNotif[l]);
l1--;
if (m1 == 0) {
m1 = 1;
l = 5;
} else {
m1 = 0;
l = 0;
}
delay(600);
}
delay(50);
lcd.clear();
} else if (rtc.getTemperature() > 35) {
myDFPlayer.playMp3Folder(22);
int l1 = 9;
while (l1 > 0) {
lcd.setCursor(0, 0);
lcd.print(arrayNotif[l]);
lcd.setCursor(6, 1);
lcd.print(arrayWarn[m1]);
lcd.setCursor(0, 2);
lcd.print(F("Current Temp is HIGH"));
lcd.setCursor(0, 3);
lcd.print(arrayNotif[l]);
l1--;
if (m1 == 0) {
m1 = 1;
l = 5;
} else {
m1 = 0;
l = 0;
}
delay(600);
}
delay(50);
lcd.clear();
}
//==============================================================================================================
voltage = analogRead(vpin);
if ((voltage * (5.0 / 1024) * ((38300.0 + 12300.0) / 12300.0)) < 12) {
myDFPlayer.playMp3Folder(11);
lcd.setCursor(0, 0);
lcd.print(arrayNotif[0]);
lcd.setCursor(6, 1);
lcd.print(F("WARNING!"));
lcd.setCursor(1, 2);
lcd.print(F("LOW VOLTAGE LEVEL!"));
lcd.setCursor(0, 3);
lcd.print(arrayNotif[0]);
delay(10000);
lcd.clear();
}
timeFormat = EEPROM.read(2);
//===============================================================================================================
pinMode(A6, INPUT);
pinMode(A7, INPUT);
pinMode(underGlow, OUTPUT);
pinMode(keyKnob, OUTPUT);
pinMode(keyKnobLed, OUTPUT);
pinMode(mdlStateL, OUTPUT);
pinMode(mdlStateH, OUTPUT);
pinMode(loudStock, OUTPUT);
pinMode(rapid, OUTPUT);
pinMode(busyPin, INPUT);
pinMode(gripHeater, OUTPUT);
digitalWrite(mdlStateL, HIGH);
digitalWrite(mdlStateH, HIGH);
digitalWrite(underGlow, HIGH);
digitalWrite(keyKnob, LOW);
digitalWrite(loudStock, HIGH);
digitalWrite(rapid, HIGH);
digitalWrite(keyKnobLed, HIGH);
digitalWrite(gripHeater, HIGH);
//=============================================================================================================
pinMode(stockPassing, INPUT_PULLUP);
pinMode(button_1, INPUT_PULLUP);
pinMode(button_2, INPUT_PULLUP);
pinMode(button_3, INPUT_PULLUP);
pinMode(button_4, INPUT_PULLUP);
pinMode(button_5, INPUT_PULLUP);
eqMode = EEPROM.read(0);
switch (eqMode) {
case 0:
break;
case 1:
myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
break;
case 2:
myDFPlayer.EQ(DFPLAYER_EQ_POP);
break;
case 3:
myDFPlayer.EQ(DFPLAYER_EQ_ROCK);
break;
case 4:
myDFPlayer.EQ(DFPLAYER_EQ_JAZZ);
break;
case 5:
myDFPlayer.EQ(DFPLAYER_EQ_CLASSIC);
break;
case 6:
myDFPlayer.EQ(DFPLAYER_EQ_BASS);
break;
}
features();
}
void displayDate() {
int tmDay = now.day();
int tmMonth = now.month();
// int tmYear = now.year();
lcd.setCursor(10, 0);
lcd.print(dow[now.dayOfTheWeek()]);
lcd.setCursor(14, 0);
lcd.print(sMonth[tmMonth]);
if (tmDay < 10) {
lcd.setCursor(18, 0);
lcd.print(F("0"));
lcd.setCursor(19, 0);
lcd.print(tmDay);
} else {
lcd.setCursor(18, 0);
lcd.print(tmDay);
}
}
void displayTime() {
int tmHour = now.hour();
int tmMin = now.minute();
if (tmHour > 19 && tmHour < 7) {
notifVol = 0;
} else {
notifVol = 1;
}
if (tmHour > 12 && timeFormat > 1) {
if ((tmHour - 12) < 10) {
lcd.setCursor(0, 0);
lcd.print(F("0"));
lcd.setCursor(1, 0);
lcd.print(tmHour - 12);
} else {
lcd.setCursor(0, 0);
lcd.print(tmHour - 12);
}
} else {
if (tmHour < 10) {
lcd.setCursor(0, 0);
lcd.print(F("0"));
lcd.setCursor(1, 0);
lcd.print(tmHour);
} else {
lcd.setCursor(0, 0);
lcd.print(tmHour);
}
}
if (tmMin < 10) {
lcd.setCursor(3, 0);
lcd.print(F("0"));
lcd.setCursor(4, 0);
lcd.print(tmMin);
} else {
lcd.setCursor(3, 0);
lcd.print(tmMin);
}
if (timeFormat == 3) {
if (tmHour == 12 and tmMin > 0) {
lcd.setCursor(6, 0);
lcd.print(F("Pm"));
} else if (tmHour > 12) {
lcd.setCursor(6, 0);
lcd.print(F("Pm"));
} else {
lcd.setCursor(6, 0);
lcd.print(F("Am"));
}
}
}
void displayTrack() {
lcd.setCursor(10, 0);
lcd.print(" ");
if (randomAll){
lcd.setCursor(11, 0);
lcd.print("Folder");
lcd.setCursor(18, 0);
lcd.print(folderNo);
}else{
int tn;
if (track > 99) {
tn = 13;
} else {
tn = 14;
}
lcd.setCursor(tn, 0);
lcd.print(track);
lcd.setCursor(16, 0);
lcd.print(F("/"));
lcd.setCursor(17, 0);
lcd.print(songCount);
}
}
void readButtonState() {
//===============================================================================================================
if (currentButtonMillis - previousButtonMillis > intervalButton) {
int buttonState_aPass = digitalRead(stockPassing);
int buttonState_but1 = digitalRead(button_1);
int buttonState_but2 = digitalRead(button_2);
int buttonState_but3 = digitalRead(button_3);
int buttonState_but4 = digitalRead(button_4);
int buttonState_but5 = digitalRead(button_5);
if (buttonState_aPass == LOW && buttonStatePrevious_aPass == HIGH && !buttonStateLongPress) {
buttonLongPressMillis = currentButtonMillis;
buttonStatePrevious_aPass = LOW;
}
if (buttonState_but1 == LOW && buttonStatePrevious_but1 == HIGH && !buttonStateLongPress) {
buttonLongPressMillis = currentButtonMillis;
buttonStatePrevious_but1 = LOW;
}
if (buttonState_but2 == LOW && buttonStatePrevious_but2 == HIGH && !buttonStateLongPress) {
buttonLongPressMillis = currentButtonMillis;
buttonStatePrevious_but2 = LOW;
}
if (buttonState_but3 == LOW && buttonStatePrevious_but3 == HIGH && !buttonStateLongPress) {
buttonLongPressMillis = currentButtonMillis;
buttonStatePrevious_but3 = LOW;
}
if (buttonState_but4 == LOW && buttonStatePrevious_but4 == HIGH && !buttonStateLongPress) {
buttonLongPressMillis = currentButtonMillis;
buttonStatePrevious_but4 = LOW;
}
if (buttonState_but5 == LOW && buttonStatePrevious_but5 == HIGH && !buttonStateLongPress) {
buttonLongPressMillis = currentButtonMillis;
buttonStatePrevious_but5 = LOW;
}
//==============================================================================================================
buttonPressDuration = currentButtonMillis - buttonLongPressMillis;
if (buttonState_aPass == LOW && !buttonStateLongPress && buttonPressDuration >= minButtonLongPressDuration) {
buttonStateLongPress = true;
mdlTurnOn();
if (onOff < 2) {
onOff++;
} else {
onOff--;
}
}
if (buttonState_but1 == LOW && !buttonStateLongPress && buttonPressDuration >= minButtonLongPressDuration) {
buttonStateLongPress = true;
if (isMp3Playing && screenMode == 0) {
if (!isMp3Pause){
previousPPTimer = millis();
myDFPlayer.pause();
isMp3Pause = true;
dLine = 1;
nMode = 6;
lcd.clear();
delay(dly);
lcd.setCursor(4, 1);
lcd.print(F("MUSIC PLAYER"));
lcd.setCursor(7, 2);
lcd.print(F("PAUSED"));
notifications();
}else if (isMp3Pause){
myDFPlayer.start();
isMp3Pause = false;
dLine = 2;
nMode = 5;
lcd.clear();
delay(dly);
lcd.setCursor(3, 1);
lcd.print(F("RESUMED PLAYING"));
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[albumn]);
notifications();
}
}else if (onOff > 0 && screenMode == 0) {
mdlOff();
}
}
if (buttonState_but2 == LOW && !buttonStateLongPress && buttonPressDuration >= minButtonLongPressDuration) {
buttonStateLongPress = true;
if (isMp3Playing && screenMode == 0 ) {
if (!isMp3Pause){lcd.setCursor(2, 1);
lcd.print(F(" Next "));
lcd.setCursor(12, 1);
lcd.write(byte(4));
delay(1000);
lcd.setCursor(2, 2);
lcd.print(F(" "));
lcd.setCursor(spacing, 1);
lcd.print(arrayAlbumn[albumn]);
musicPlay();}else{
myDFPlayer.start();
isMp3Pause = false;
dLine = 2;
nMode = 5;
lcd.clear();
delay(dly);
lcd.setCursor(3, 1);
lcd.print(F("RESUMED PLAYING"));
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[albumn]);
notifications();
}
} else if (screenMode == 0) {
undeGlowMode();
}
}
if (buttonState_but3 == LOW && !buttonStateLongPress && buttonPressDuration >= minButtonLongPressDuration) {
buttonStateLongPress = true;
if (screenMode == 0 && !isMp3Playing) {
featureMode();
} else {
mdlOff();
}
}
if (buttonState_but4 == LOW && !buttonStateLongPress && buttonPressDuration >= minButtonLongPressDuration) {
buttonStateLongPress = true;
if (screenMode == 0) {
if (isMp3Playing) {
myDFPlayer.advertise(8);
} else {
myDFPlayer.playMp3Folder(8);
}
nMode = 5;
digitalWrite(keyKnobLed, HIGH);
digitalWrite(keyKnob, LOW);
lcd.clear();
delay(dly);
lcd.setCursor(3, 1);
lcd.print(F("KEY KNOB ACTIVE"));
lcd.setCursor(4, 2);
lcd.print(F("FOR 6 SECONDS"));
notifications();
}
}
if (buttonState_but5 == LOW && !buttonStateLongPress && buttonPressDuration >= minButtonLongPressDuration) {
buttonStateLongPress = true;
if (isMp3Playing && screenMode == 0) {
musicStop();
} else if (menu > 0 and menu < 7) {
isActiveMenu = false;
executeAction();
} else if (menu > 6) {
previousMenuTimer = millis();
executeAction();
}
}
//==============================================================================================================
if (buttonState_aPass == HIGH && buttonStatePrevious_aPass == LOW) {
buttonStatePrevious_aPass = HIGH;
buttonStateLongPress = false;
if (buttonPressDuration < minButtonLongPressDuration) {
passingNormal();
}
}
if (buttonState_but1 == HIGH && buttonStatePrevious_but1 == LOW) {
buttonStatePrevious_but1 = HIGH;
buttonStateLongPress = false;
if (buttonPressDuration < minButtonLongPressDuration) {
if (isSetTime) {
if (setPos == 1) {
if (hh < 24) {
hh++;
}
} else if (setPos == 2) {
if (mn < 60) {
mn++;
}
}
} else if (isSetDate) {
if (setPos == 1) {
if (dd < 31) {
dd++;
}
} else if (setPos == 2) {
if (mmm < 12) {
mmm++;
}
} else if (setPos == 3) {
yyyy++;
}
}
if (isMp3Playing && screenMode == 0 && !isSetTime && !isSetDate) {
if (currentVol>6){
currentVol --;
myDFPlayer.volumeDown();
}
previousVolTimer = millis();
isActiveVol = true;
onvOL();
}
if (screenMode == 1 && menu > 1) {
previousMenuTimer = millis();
isActiveMenu = true;
menu--;
updateMenu();
} else if (screenMode == 2 && menu > 16) {
previousMenuTimer = millis();
isActiveMenu = true;
menu--;
updateMenu();
} else if (screenMode == 3 && menu > 22) {
previousMenuTimer = millis();
isActiveMenu = true;
menu--;
updateMenu();
} else if (screenMode == 0 && !isMp3Playing && !isSetTime && !isSetDate) {
hornMode();
}
}
}
//-------------------------------------------------------------------------------------------------------------------
if (buttonState_but2 == HIGH && buttonStatePrevious_but2 == LOW) {
buttonStatePrevious_but2 = HIGH;
buttonStateLongPress = false;
if (buttonPressDuration < minButtonLongPressDuration) {
if (isSetTime) {
if (setPos == 1) {
if (hh < 24) {
hh++;
}
} else if (setPos == 2) {
if (mn < 60) {
mn++;
}
}
} else if (isSetDate) {
if (setPos == 1) {
if (dd < 31) {
dd++;
}
} else if (setPos == 2) {
if (mmm < 12) {
mmm++;
}
} else if (setPos == 3) {
yyyy++;
}
}
if (isMp3Playing && screenMode == 0 && !isSetTime && !isSetDate) {
myDFPlayer.volumeUp();
if (currentVol<30){
currentVol ++;
}
previousVolTimer = millis();
isActiveVol = true;
onvOL();
}
if (screenMode == 1 && menu > 1) {
previousMenuTimer = millis();
isActiveMenu = true;
menu--;
updateMenu();
} else if (screenMode == 2 && menu > 16) {
previousMenuTimer = millis();
isActiveMenu = true;
menu--;
updateMenu();
} else if (screenMode == 3 && menu > 22) {
previousMenuTimer = millis();
isActiveMenu = true;
menu--;
updateMenu();
} else if (screenMode == 0 && !isMp3Playing && !isSetTime && !isSetDate) {
cPassing();
}
}
}
//-------------------------------------------------------------------------------------------------------------------
if (buttonState_but3 == HIGH && buttonStatePrevious_but3 == LOW) {
buttonStatePrevious_but3 = HIGH;
buttonStateLongPress = false;
if (buttonPressDuration < minButtonLongPressDuration) {
if (isSetTime) {
if (setPos == 1) {
if (hh > 0) {
hh--;
}
} else if (setPos == 2) {
if (mn > 1) {
mn--;
}
}
} else if (isSetDate) {
if (setPos == 1) {
if (dd > 1) {
dd--;
}
} else if (setPos == 2) {
if (mmm > 1) {
mmm--;
}
} else if (setPos == 3) {
yyyy--;
}
}
if (isMp3Playing && screenMode == 0 && !isSetTime && !isSetDate) {
featureMode();
}
if (screenMode == 0 && !isMp3Playing && !isSetTime && !isSetDate) {
rapidMode();
} else if (screenMode == 1 && menu < 15) {
previousMenuTimer = millis();
isActiveMenu = true;
menu++;
updateMenu();
} else if (screenMode == 2 && menu < 21) {
previousMenuTimer = millis();
isActiveMenu = true;
menu++;
updateMenu();
} else if (screenMode == 3 && menu < 24) {
previousMenuTimer = millis();
isActiveMenu = true;
menu++;
updateMenu();
}
}
}
//-------------------------------------------------------------------------------------------------------------------
if (buttonState_but4 == HIGH && buttonStatePrevious_but4 == LOW) {
buttonStatePrevious_but4 = HIGH;
buttonStateLongPress = false;
if (buttonPressDuration < minButtonLongPressDuration) {
if (isSetTime) {
if (setPos == 1) {
if (hh > 0) {
hh--;
}
} else if (setPos == 2) {
if (mn > 1) {
mn--;
}
}
} else if (isSetDate) {
if (setPos == 1) {
if (dd > 1) {
dd--;
}
} else if (setPos == 2) {
if (mmm > 1) {
mmm--;
}
} else if (setPos == 3) {
yyyy--;
}
}
if (isMp3Playing && screenMode == 0 && !isSetTime && !isSetDate) {
undeGlowMode();
}
if (screenMode == 0 && !isMp3Playing && !isSetTime && !isSetDate) {
gripHeat();
} else if (screenMode == 1 && menu < 15) {
previousMenuTimer = millis();
isActiveMenu = true;
menu++;
updateMenu();
} else if (screenMode == 2 && menu < 21) {
previousMenuTimer = millis();
isActiveMenu = true;
menu++;
updateMenu();
} else if (screenMode == 3 && menu < 24) {
previousMenuTimer = millis();
isActiveMenu = true;
menu++;
updateMenu();
}
}
}
//===============================================================================================================
if (buttonState_but5 == HIGH && buttonStatePrevious_but5 == LOW) {
buttonStatePrevious_but5 = HIGH;
buttonStateLongPress = false;
if (buttonPressDuration < minButtonLongPressDuration) {
if (screenMode == 0 && isSetTime || isSetDate) {
if (isSetTime) {
if (setPos == 1) {
setPos = 2;
np = 1;
} else if (setPos == 2) {
isSetTime = false;
setPos = 1;
np = 0;
rtc.adjust(DateTime(now.year(), now.month(), now.day(), hh, mn, 0));
myDFPlayer.playMp3Folder(25);
nMode = 5;
screenMode = 4;
menu = 1;
lcd.clear();
lcd.setCursor(4, 1);
lcd.print(F("TIME SETTING"));
lcd.setCursor(7, 2);
lcd.print(F("SAVED!"));
notifications();
}
} else if (isSetDate) {
if (setPos == 1) {
setPos = 2;
np = 1;
} else if (setPos == 2) {
setPos = 3;
np = 1;
} else if (setPos == 3) {
isSetDate = false;
setPos = 1;
np = 0;
rtc.adjust(DateTime(yyyy, mmm, dd, now.hour(), now.minute(), now.second()));
myDFPlayer.playMp3Folder(26);
nMode = 5;
screenMode = 4;
menu = 1;
lcd.clear();
lcd.setCursor(4, 1);
lcd.print(F("DATE SETTING"));
lcd.setCursor(7, 2);
lcd.print(F("SAVED!"));
notifications();
}
}
}
if (screenMode == 0 && !isSetTime && !isSetDate) {
previousMenuTimer = millis();
isActiveMenu = true;
screenMode = 1;
menu = 1;
delay(dly);
updateMenu();
} else if (screenMode == 1 && !isSetTime && !isSetDate) {
previousMenuTimer = millis();
isActiveMenu = true;
screenMode = 2;
menu = 16;
delay(dly);
updateMenu();
} else if (screenMode == 2 && !isSetTime && !isSetDate) {
previousMenuTimer = millis();
isActiveMenu = true;
screenMode = 3;
menu = 22;
delay(dly);
updateMenu();
} else if (screenMode == 3 && !isSetTime && !isSetDate) {
screenMode = 0;
menu = 1;
isActiveMenu = false;
lcd.clear();
delay(dly);
features();
delay(dly);
}
}
}
//===============================================================================================================
previousButtonMillis = currentButtonMillis;
}
}
//=================================================================================================================
void loop() {
currentButtonMillis = millis();
readButtonState();
//===================================================================================================================
unsigned long currentMillis2 = millis();
if (!counting) {
if (digitalRead(keyKnob) == LOW && count == 0) {
previousMillisCounter = currentMillis2;
counting = true;
count = 1;
}
}
unsigned long countUpValue = currentMillis2 - previousMillisCounter;
long countDownValue = startCount - long(countUpValue);
if (countDownValue <= 0) {
countDownValue = 0;
digitalWrite(keyKnob, HIGH);
count = 0;
digitalWrite(keyKnobLed, LOW);
counting = false;
} else {
// Update the output.
if (currentMillis2 - previousMillisUpdate >= intervalUpdate) {
previousMillisUpdate = currentMillis2;
if (screenMode == 0 && !isActiveVol) {
lcd.setCursor(3, dLine);
lcd.print(F("KeyKnob ="));
lcd.setCursor(14, dLine);
lcd.print((countDownValue) / 1000);
}
}
}
//=================================================================================================================
if (isActiveMenu) {
unsigned long currentMenuTime = millis();
if (currentMenuTime - previousMenuTimer >= 6000UL) {
if (screenMode > 0) {
isActiveMenu = false;
screenMode = 0;
menu = 1;
lcd.clear();
delay(dly);
features();
delay(dly);
}
}
}
//=================================================================================================================
if (isActiveVol && screenMode == 0) {
unsigned long currentVolTime = millis();
if (currentVolTime - previousVolTimer >= 3000UL) {
isActiveVol = false;
lcd.clear();
delay(dly);
features();
delay(dly);
}
}
//================================================================================================================
if (isMp3Playing && !isMp3Pause) {
if (digitalRead(busyPin) == HIGH) {
if (myDFPlayer.readType() == DFPlayerPlayFinished){
musicPlay();
}
}
}
//================================================================================================================
if (isMp3Pause) {
unsigned long currentPPTime = millis();
if (currentPPTime - previousPPTimer >= 300000UL) {
musicStop();
}
}
//=================================================================================================================
starterState = analogRead(A6);
if (starterState != lastStarterState) {
if (starterState > 300) {
nMode = 5;
lcd.clear();
delay(dly);
lcd.setCursor(6, 1);
lcd.print(F("STARTING"));
lcd.setCursor(7, 2);
lcd.print(F("ENGINE"));
if (isMp3Playing) {
myDFPlayer.advertise(12);
} else {
myDFPlayer.playMp3Folder(12);
}
notifications();
}
lastStarterState = starterState;
}
//=====================================================================================================================================================
int hornTrigger = analogRead(A7);
if (hornTrigger > 300) {
if (comboLed == 1) {
if (onOff == 0) {
digitalWrite(mdlStateL, LOW);
digitalWrite(mdlStateH, LOW);
delay(dly);
} else if (onOff == 1) {
digitalWrite(mdlStateL, HIGH);
digitalWrite(mdlStateH, LOW);
} else if (onOff == 2) {
digitalWrite(mdlStateL, LOW);
digitalWrite(mdlStateH, HIGH);
delay(dly);
}
}
} else {
digitalWrite(mdlStateL, mdlStateL_last);
digitalWrite(mdlStateH, mdlStateH_last);
}
//=======================================================================================================
float volts;
float voltage;
voltage = analogRead(vpin);
volts = voltage * (5.0 / 1024) * ((38300.0 + 12300.0) / 12300.0);
if (screenMode == 0 && digitalRead(keyKnob) == LOW && !isActiveVol) {
lcd.setCursor(0, dLine);
lcd.print(F(""));
} else if (screenMode == 0 && !isActiveVol) {
float temp;
temp = rtc.getTemperature();
const long voltDelay = 500;
unsigned long currVoltTime = millis();
lcd.setCursor(4, dLine);
lcd.print(F(" "));
lcd.setCursor(11, dLine);
lcd.print(F("Tp"));
lcd.setCursor(13, dLine);
lcd.print(F(" "));
lcd.setCursor(14, dLine);
lcd.print(temp);
lcd.setCursor(18, dLine);
lcd.print(F("c"));
if (currVoltTime - prevVoltTime >= voltDelay) {
prevVoltTime = currVoltTime;
lcd.setCursor(5, dLine);
lcd.print(volts);
lcd.setCursor(9, dLine);
lcd.print(F(" "));
}
if (volts < 12 && !isActiveVol) {
const long indelay = 800;
unsigned long currMillis = millis();
if (currMillis - prevMillis >= indelay) {
prevMillis = currMillis;
if (w == 1) {
w = 0;
} else {
w = 1;
}
if (w == 1) {
lcd.setCursor(1, dLine);
lcd.print(F("Vlt"));
} else {
lcd.setCursor(1, dLine);
lcd.print(F(" "));
}
}
} else {
lcd.setCursor(1, dLine);
lcd.print(F("Vlt"));
}
}
//=============================================================================================================================
if (!isSetTime && screenMode == 0) {
now = rtc.now();
displayTime();
}
else if (isSetTime && screenMode == 0) {
if (hh < 10) {
lcd.setCursor(0, 0);
lcd.print(F("0"));
lcd.setCursor(1, 0);
lcd.print(hh);
} else {
lcd.setCursor(0, 0);
lcd.print(hh);
}
lcd.print(F(":"));
if (mn < 10) {
lcd.setCursor(3, 0);
lcd.print(F("0"));
lcd.setCursor(4, 0);
lcd.print(mn);
} else {
lcd.setCursor(3, 0);
lcd.print(mn);
}
delay(100);
if (setPos == 1) {
if (np == 1) {
delay(2000);
myDFPlayer.playMp3Folder(42);
delay(4000);
np = 0;
}
lcd.setCursor(0, 0);
lcd.print(F(" "));
} else if (setPos == 2) {
if (np == 1) {
myDFPlayer.playMp3Folder(43);
delay(4000);
np = 0;
}
lcd.setCursor(3, 0);
lcd.print(F(" "));
}
}
if (!isSetDate && screenMode == 0) {
if (!isMp3Playing){
now = rtc.now();
displayDate();}else{}
} else if (isSetDate && screenMode == 0) {
if (dd < 10) {
lcd.setCursor(10, 0);
lcd.print(F("0"));
lcd.setCursor(11, 0);
lcd.print(dd);
} else {
lcd.setCursor(10, 0);
lcd.print(dd);
}
lcd.print(F("/"));
if (mmm < 10) {
lcd.setCursor(13, 0);
lcd.print(F("0"));
lcd.setCursor(14, 0);
lcd.print(mmm);
} else {
lcd.setCursor(13, 0);
lcd.print(mmm);
}
lcd.print(F("/"));
lcd.print(yyyy);
delay(100);
if (screenMode == 0) {
lcd.setCursor(2, 0);
lcd.print(F(":"));
if (setPos == 1) {
if (np == 1) {
delay(2000);
myDFPlayer.playMp3Folder(44);
delay(4000);
np = 0;
}
lcd.setCursor(10, 0);
lcd.print(F(" "));
} else if (setPos == 2) {
if (np == 1) {
myDFPlayer.playMp3Folder(45);
delay(5000);
np = 0;
}
lcd.setCursor(13, 0);
lcd.print(F(" "));
} else if (setPos == 3) {
if (np == 1) {
myDFPlayer.playMp3Folder(46);
delay(6000);
np = 0;
}
lcd.setCursor(16, 0);
lcd.print(F(" "));
}
}
}
//========================================================================================================
if (screenMode == 0 && !isSetTime && !isSetDate) {
unsigned long currSepMillis = millis();
if (currSepMillis - prevSepMillis >= 1000) {
prevSepMillis = currSepMillis;
if (o == 1) {
o = 0;
} else {
o = 1;
}
if (o == 1) {
lcd.setCursor(2, 0);
lcd.print(F(" "));
} else {
lcd.setCursor(2, 0);
lcd.print(F(":"));
}
}
}
//========================================================================================================
}
void musicStop() {
myDFPlayer.stop();
randomAll = false;
isMp3Pause = false;
isMp3Playing = false;
if (notifVol == 0) {
myDFPlayer.volume(10);
currentVol = 10;
} else {
myDFPlayer.volume(25);
currentVol = 25;
}
myDFPlayer.playMp3Folder(35);
dLine = 1;
lcd.clear();
delay(dly);
lcd.setCursor(4, 1);
lcd.print(F("MUSIC PLAYER"));
lcd.setCursor(5, 2);
lcd.print(F("TERMINATED"));
notifications();
}
void musicPlay() {
if (randomAll){
folderNo = random(2,15);
}else{
folderNo = albumn;
}
delay(100);
switch (folderNo) {
case 2:
songCount = 247;
break;
case 3:
songCount = 157;
break;
case 4:
songCount = 90;
break;
case 5:
songCount = 85;
break;
case 6:
songCount = 93;
break;
case 7:
songCount = 163;
break;
case 8:
songCount = 113;
break;
case 9:
songCount = 166;
break;
case 10:
songCount = 84;
break;
case 11:
songCount = 209;
break;
case 12:
songCount = 80;
break;
case 13:
songCount = 47;
break;
case 14:
songCount = 141;
break;
case 15:
songCount = 92;
break;
}
delay(100);
track = random(songCount);
delay(100);
myDFPlayer.playFolder(folderNo, track);
displayTrack();
}
void notifications() {
int a;
int b;
if (nMode == 1) {
a = 0;
b = 1;
lcd.setCursor(5, 2);
lcd.print(arrayNotif[1]);
} else if (nMode == 2) {
a = 1;
b = 0;
lcd.setCursor(5, 2);
lcd.print(arrayNotif[2]);
} else if (nMode == 3) {
a = 0;
b = 1;
lcd.setCursor(5, 2);
lcd.print(arrayNotif[3]);
} else if (nMode == 4) {
a = 1;
b = 0;
lcd.setCursor(4, 2);
lcd.print(arrayNotif[4]);
} else if (nMode == 5) {
a = 1;
} else if (nMode == 6) {
a = 0;
}
int j = 0;
int d = 10; // delay of notification animation
int e = 0;
int g;
int h;
j = 19;
g = 0;
h = 19;
while (j > -1) {
lcd.setCursor(j, e);
lcd.write(byte(a));
delay(d);
if (e == 0) {
e = 3;
j = g;
g++;
} else {
e = 0;
j = h;
h--;
}
}
if (nMode > 4) {
delay(1000);
}
if (nMode < 5) {
delay(500);
e = 0;
j = 0;
g = 19;
h = 0;
while (j < 20) {
lcd.setCursor(j, e);
lcd.write(byte(b));
delay(d);
if (e == 0) {
e = 3;
j = g;
h++;
} else {
e = 0;
j = h;
g--;
}
}
}
delay(10);
delay(1500);
lcd.clear();
delay(dly);
if (menu == 1) {
features();
} else {
updateMenu();
}
}
void features() {
if (digitalRead(underGlow) == LOW) {
lcd.setCursor(19, 1);
lcd.print(F("*"));
}
if (digitalRead(mdlStateL) == LOW || digitalRead(mdlStateH) == LOW) {
lcd.setCursor(0, 1);
lcd.print(F("*"));
}
if (isMp3Playing) {
if (albumn > 1) {
lcd.setCursor(spacing, 1);
lcd.print(arrayAlbumn[albumn]);
lcd.setCursor(1, 1);
lcd.write(byte(3));
lcd.setCursor(18, 1);
lcd.write(byte(3));
} else if (albumn == 1) {
lcd.setCursor(1, 1);
lcd.write(byte(3));
lcd.setCursor(18, 1);
lcd.write(byte(3));
lcd.setCursor(spacing, 1);
lcd.print(arrayAlbumn[albumn]);
}
}
if (isMp3Pause) {
lcd.setCursor(4, 1);
lcd.print("Music Paused");
}
if (screenMode == 0 && !isMp3Playing) {
lcd.setCursor(0, 2);
lcd.print(F("LHORN: CPASS:"));
lcd.setCursor(0, 3);
lcd.print(F("RAPID: GRIPH:"));
} else {
lcd.setCursor(0, 3);
lcd.print(F("FMODE: UGLOW:"));
}
if (digitalRead(loudStock) == LOW && !isMp3Playing) {
lcd.setCursor(7, 2);
lcd.print(F("["));
lcd.print(F("]"));
} else if (!isMp3Playing) {
lcd.setCursor(7, 2);
lcd.write(byte(5));
lcd.write(byte(6));
}
if (comboLed == 0 && !isMp3Playing) {
lcd.setCursor(18, 2);
lcd.print(F("["));
lcd.print(F("]"));
} else if (!isMp3Playing) {
lcd.setCursor(18, 2);
lcd.write(byte(5));
lcd.write(byte(6));
}
if (!isMp3Playing) {
if (digitalRead(rapid) == LOW) {
lcd.setCursor(7, 3);
lcd.print(F("["));
lcd.print(F("]"));
} else {
lcd.setCursor(7, 3);
lcd.write(byte(5));
lcd.write(byte(6));
}
} else if (digitalRead(loudStock) == HIGH || digitalRead(rapid) == HIGH) {
lcd.setCursor(7, 3);
lcd.write(byte(5));
lcd.write(byte(6));
} else {
lcd.setCursor(7, 3);
lcd.print(F("["));
lcd.print(F("]"));
}
if (!isMp3Playing) {
if (digitalRead(gripHeater) == HIGH) {
lcd.setCursor(18, 3);
lcd.print(F("["));
lcd.print(F("]"));
} else {
lcd.setCursor(18, 3);
lcd.write(byte(5));
lcd.write(byte(6));
}
} else if (digitalRead(underGlow) == LOW) {
lcd.setCursor(18, 3);
lcd.write(byte(5));
lcd.write(byte(6));
} else {
lcd.setCursor(18, 3);
lcd.print(F("["));
lcd.print(F("]"));
}
}
void mdlTurnOn() {
int h = !digitalRead(mdlStateH);
int l = !digitalRead(mdlStateL);
if (digitalRead(mdlStateH) == HIGH && digitalRead(mdlStateL) == HIGH) {
digitalWrite(mdlStateL, LOW);
nMode = 3;
mdlStateL_last = l;
if (isMp3Playing) {
myDFPlayer.advertise(17);
} else {
myDFPlayer.playMp3Folder(17);
}
lcd.clear();
delay(dly);
lcd.setCursor(6, 1);
lcd.print(F("MDL LIGHT"));
notifications();
} else {
digitalWrite(mdlStateH, h);
digitalWrite(mdlStateL, l);
mdlStateH_last = h;
mdlStateL_last = l;
}
}
void passingNormal() {
int h = !digitalRead(mdlStateH);
int l = !digitalRead(mdlStateL);
if (digitalRead(mdlStateL) == HIGH && digitalRead(mdlStateH) == HIGH) {
digitalWrite(mdlStateL, LOW);
digitalWrite(mdlStateH, LOW);
delay(100);
} else {
digitalWrite(mdlStateH, h);
digitalWrite(mdlStateL, l);
delay(100);
digitalWrite(mdlStateL, mdlStateL_last);
digitalWrite(mdlStateH, mdlStateH_last);
}
}
void gripHeat() {
if (digitalRead(gripHeater) == 1) {
digitalWrite(gripHeater, LOW);
nMode = 1;
if (isMp3Playing) {
myDFPlayer.advertise(3);
} else {
myDFPlayer.playMp3Folder(3);
}
lcd.clear();
delay(dly);
lcd.setCursor(4, 1);
lcd.print(F("GRIP HEATER"));
notifications();
} else {
digitalWrite(gripHeater, HIGH);
nMode = 2;
if (isMp3Playing) {
myDFPlayer.advertise(4);
} else {
myDFPlayer.playMp3Folder(4);
}
lcd.clear();
delay(dly);
lcd.setCursor(4, 1);
lcd.print(F("GRIP HEATER"));
notifications();
}
}
void undeGlowMode() {
if (digitalRead(underGlow) == HIGH) {
digitalWrite(underGlow, LOW);
nMode = 3;
if (isMp3Playing) {
myDFPlayer.advertise(19);
} else {
myDFPlayer.playMp3Folder(19);
}
lcd.clear();
delay(dly);
lcd.setCursor(5, 1);
lcd.print(F("UNDER GLOW"));
notifications();
} else {
digitalWrite(underGlow, HIGH);
nMode = 4;
if (isMp3Playing) {
myDFPlayer.advertise(20);
} else {
myDFPlayer.playMp3Folder(20);
}
lcd.clear();
delay(dly);
lcd.setCursor(5, 1);
lcd.print(F("UNDER GLOW"));
notifications();
}
}
void featureMode() {
if (digitalRead(loudStock) == HIGH || comboLed == 1 || digitalRead(rapid) == HIGH) {
nMode = 2;
comboLed = 0;
screenMode = 0;
digitalWrite(loudStock, LOW);
digitalWrite(rapid, LOW);
if (isMp3Playing) {
myDFPlayer.advertise(16);
} else {
myDFPlayer.playMp3Folder(16);
}
lcd.clear();
delay(dly);
lcd.setCursor(4, 1);
lcd.print(F("ALL FEATURE'S"));
notifications();
} else {
nMode = 1;
screenMode = 0;
digitalWrite(loudStock, HIGH);
comboLed = 1;
digitalWrite(rapid, HIGH);
if (isMp3Playing) {
myDFPlayer.advertise(5);
} else {
myDFPlayer.playMp3Folder(5);
}
lcd.clear();
delay(dly);
lcd.setCursor(4, 1);
lcd.print(F("ALL FEATURE'S"));
notifications();
}
}
void rapidMode() {
if (digitalRead(rapid) == LOW) {
digitalWrite(rapid, HIGH);
nMode = 1;
if (isMp3Playing) {
myDFPlayer.advertise(13);
} else {
myDFPlayer.playMp3Folder(13);
}
lcd.clear();
delay(dly);
lcd.setCursor(5, 1);
lcd.print(F("RAPID HORN"));
notifications();
} else {
digitalWrite(rapid, LOW);
nMode = 2;
if (isMp3Playing) {
myDFPlayer.advertise(14);
} else {
myDFPlayer.playMp3Folder(14);
}
lcd.clear();
delay(dly);
lcd.setCursor(5, 1);
lcd.print(F("RAPID HORN"));
notifications();
}
}
void mdlOff() {
digitalWrite(mdlStateL, HIGH);
digitalWrite(mdlStateH, HIGH);
mdlStateH_last = 1;
mdlStateL_last = 1;
onOff = 0;
nMode = 4;
if (isMp3Playing) {
myDFPlayer.advertise(18);
} else {
myDFPlayer.playMp3Folder(18);
}
lcd.clear();
delay(dly);
lcd.setCursor(5, 1);
lcd.print(F("MDL LIGHT"));
notifications();
}
void hornMode() {
if (digitalRead(loudStock) == LOW) {
digitalWrite(loudStock, HIGH);
nMode = 1;
if (isMp3Playing) {
myDFPlayer.advertise(9);
} else {
myDFPlayer.playMp3Folder(9);
}
lcd.clear();
delay(dly);
lcd.setCursor(5, 1);
lcd.print(F("LOUD HORN "));
notifications();
} else {
nMode = 2;
digitalWrite(loudStock, LOW);
if (isMp3Playing) {
myDFPlayer.advertise(10);
} else {
myDFPlayer.playMp3Folder(10);
}
lcd.clear();
delay(dly);
lcd.setCursor(6, 1);
lcd.print(F("LOUD HORN"));
notifications();
}
}
void cPassing() {
if (comboLed == 0) {
comboLed = 1;
nMode = 1;
if (isMp3Playing) {
myDFPlayer.advertise(6);
} else {
myDFPlayer.playMp3Folder(6);
}
lcd.clear();
delay(dly);
lcd.setCursor(4, 1);
lcd.print(F("COMBO PASSING"));
notifications();
} else {
comboLed = 0;
nMode = 2;
if (isMp3Playing) {
myDFPlayer.advertise(7);
} else {
myDFPlayer.playMp3Folder(7);
}
lcd.clear();
delay(dly);
lcd.setCursor(4, 1);
lcd.print(F("COMBO PASSING"));
notifications();
}
}
void onvOL()
{
lcd.setCursor(1, 2);
lcd.print(F(" Vol = "));
lcd.setCursor(18, 2);
lcd.print(F(" "));
int x = 8;
while (x< 18)
{
lcd.setCursor(x, 2);
lcd.write(byte(0));
x ++;
}
x = 8;
while (x< 7+((currentVol-4)/2.5))
{
lcd.setCursor(x, 2);
lcd.write(byte(1));
x ++;
}
}
void timeFormatSet() {
if (timeFormat == 1) {
timeFormat = 2;
EEPROM.write(2, 2);
lcd.setCursor(6, 2);
lcd.print(F("12 HOUR"));
myDFPlayer.playMp3Folder(38);
} else if (timeFormat == 2) {
timeFormat = 3;
EEPROM.write(2, 3);
lcd.setCursor(5, 2);
lcd.print(F("12H AM/PM"));
myDFPlayer.playMp3Folder(39);
} else if (timeFormat == 3) {
timeFormat = 1;
EEPROM.write(2, 1);
lcd.setCursor(6, 2);
lcd.print(F("24 HOUR"));
myDFPlayer.playMp3Folder(37);
}
notifications();
}
//====================================================
void updateMenu() {
switch (menu) {
case 0:
menu = 1;
break;
case 1:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(0, 1);
lcd.write(2);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[1]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[2]);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[3]);
break;
case 2:
lcd.setCursor(0, 1);
lcd.print(F(" "));
lcd.setCursor(0, 2);
lcd.write(2);
lcd.setCursor(0, 3);
lcd.print(F(" "));
break;
case 3:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[1]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[2]);
lcd.setCursor(0, 3);
lcd.write(2);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[3]);
break;
case 4:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(0, 1);
lcd.write(2);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[4]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[5]);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[6]);
break;
case 5:
lcd.setCursor(0, 1);
lcd.print(F(" "));
lcd.setCursor(0, 2);
lcd.write(2);
lcd.setCursor(0, 3);
lcd.print(F(" "));
break;
case 6:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[4]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[5]);
lcd.setCursor(0, 3);
lcd.write(2);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[6]);
break;
case 7:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(0, 1);
lcd.write(2);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[7]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[8]);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[9]);
break;
case 8:
lcd.setCursor(0, 1);
lcd.print(F(" "));
lcd.setCursor(0, 2);
lcd.write(2);
lcd.setCursor(0, 3);
lcd.print(F(" "));
break;
case 9:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[7]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[8]);
lcd.setCursor(0, 3);
lcd.write(2);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[9]);
break;
case 10:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(0, 1);
lcd.write(2);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[10]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[11]);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[12]);
break;
case 11:
lcd.setCursor(0, 1);
lcd.print(F(" "));
lcd.setCursor(0, 2);
lcd.write(2);
lcd.setCursor(0, 3);
lcd.print(F(" "));
break;
case 12:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[10]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[11]);
lcd.setCursor(0, 3);
lcd.write(2);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[12]);
break;
case 13:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(0, 1);
lcd.write(2);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[13]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[14]);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[15]);
break;
case 14:
lcd.setCursor(0, 1);
lcd.print(F(" "));
lcd.setCursor(0, 2);
lcd.write(2);
lcd.setCursor(0, 3);
lcd.print(F(" "));
break;
case 15:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayAlbumn[0]);
lcd.setCursor(2, 1);
lcd.print(arrayAlbumn[13]);
lcd.setCursor(2, 2);
lcd.print(arrayAlbumn[14]);
lcd.setCursor(0, 3);
lcd.write(2);
lcd.setCursor(2, 3);
lcd.print(arrayAlbumn[15]);
break;
case 16:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayEQ[0]);
lcd.setCursor(0, 1);
lcd.write(2);
lcd.setCursor(2, 1);
lcd.print(arrayEQ[1]);
lcd.setCursor(2, 2);
lcd.print(arrayEQ[2]);
lcd.setCursor(2, 3);
lcd.print(arrayEQ[3]);
break;
case 17:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayEQ[0]);
lcd.setCursor(2, 1);
lcd.print(arrayEQ[1]);
lcd.setCursor(0, 2);
lcd.write(2);
lcd.setCursor(2, 2);
lcd.print(arrayEQ[2]);
lcd.setCursor(0, 3);
lcd.setCursor(2, 3);
lcd.print(arrayEQ[3]);
break;
case 18:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayEQ[0]);
lcd.setCursor(2, 1);
lcd.print(arrayEQ[1]);
lcd.setCursor(2, 2);
lcd.print(arrayEQ[2]);
lcd.setCursor(0, 3);
lcd.write(2);
lcd.setCursor(2, 3);
lcd.print(arrayEQ[3]);
break;
case 19:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayEQ[0]);
lcd.setCursor(0, 1);
lcd.write(2);
lcd.setCursor(2, 1);
lcd.print(arrayEQ[4]);
lcd.setCursor(2, 2);
lcd.print(arrayEQ[5]);
lcd.setCursor(2, 3);
lcd.print(arrayEQ[6]);
break;
case 20:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayEQ[0]);
lcd.setCursor(2, 1);
lcd.print(arrayEQ[4]);
lcd.setCursor(0, 2);
lcd.write(2);
lcd.setCursor(2, 2);
lcd.print(arrayEQ[5]);
lcd.setCursor(2, 3);
lcd.print(arrayEQ[6]);
break;
case 21:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(arrayEQ[0]);
lcd.setCursor(2, 1);
lcd.print(arrayEQ[4]);
lcd.setCursor(2, 2);
lcd.print(arrayEQ[5]);
lcd.setCursor(0, 3);
lcd.write(2);
lcd.setCursor(2, 3);
lcd.print(arrayEQ[6]);
break;
case 22:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(tDate[0]);
lcd.setCursor(2, 1);
lcd.print(tDate[1]);
lcd.setCursor(17, 1);
if (timeFormat == 1) {
lcd.print(F("24"));
} else if (timeFormat == 2) {
lcd.print(F("12"));
} else if (timeFormat == 3) {
lcd.print(F("in"));
}
lcd.setCursor(0, 1);
lcd.write(2);
lcd.setCursor(2, 2);
lcd.print(tDate[2]);
lcd.setCursor(2, 3);
lcd.print(tDate[3]);
break;
case 23:
lcd.setCursor(0, 1);
lcd.print(F(" "));
lcd.setCursor(0, 2);
lcd.write(2);
lcd.setCursor(0, 3);
lcd.print(F(" "));
break;
case 24:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(tDate[0]);
lcd.setCursor(2, 1);
lcd.print(tDate[1]);
lcd.setCursor(17, 1);
if (timeFormat == 1) {
lcd.print(F("24"));
} else if (timeFormat == 2) {
lcd.print(F("12"));
} else if (timeFormat == 3) {
lcd.print(F("in"));
}
lcd.setCursor(2, 2);
lcd.print(tDate[2]);
lcd.setCursor(2, 3);
lcd.print(tDate[3]);
lcd.setCursor(0, 3);
lcd.write(2);
case 25:
menu = 24;
break;
}
if (eqMode < 4 && menu > 15 && menu < 19) {
lcd.setCursor(18, eqMode);
lcd.write(byte(5));
lcd.write(byte(6));
} else if (eqMode > 3 && menu > 18 && menu < 22) {
lcd.setCursor(18, (eqMode - 3));
lcd.write(byte(5));
lcd.write(byte(6));
}
// void loop();
}
void executeAction() {
switch (menu) {
case 1:
action1();
break;
case 2:
action2();
break;
case 3:
action3();
break;
case 4:
action4();
break;
case 5:
action5();
break;
case 6:
action6();
break;
case 7:
action7();
break;
case 8:
action8();
break;
case 9:
action9();
break;
case 10:
action10();
break;
case 11:
action11();
break;
case 12:
action12();
break;
case 13:
action13();
break;
case 14:
action14();
break;
case 15:
action15();
break;
case 16:
action16();
break;
case 17:
action17();
break;
case 18:
action18();
break;
case 19:
action19();
break;
case 20:
action20();
break;
case 21:
action21();
break;
case 22:
action22();
break;
case 23:
action23();
break;
case 24:
action24();
break;
}
}
void action1() {
isMp3Pause = false;
albumn = 1;
spacing = 5;
nMode = 5;
isMp3Playing = true;
randomAll = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[1]);
screenMode = 0;
menu = 1;
notifications();
}
void action2() {
isMp3Pause = false;
albumn = 2;
spacing = 3;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[2]);
screenMode = 0;
menu = 1;
notifications();
}
void action3() {
isMp3Pause = false;
albumn = 3;
spacing = 4;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[3]);
screenMode = 0;
menu = 1;
notifications();
}
void action4() {
isMp3Pause = false;
albumn = 4;
spacing = 5;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[4]);
screenMode = 0;
menu = 1;
notifications();
}
void action5() {
isMp3Pause = false;
albumn = 5;
spacing = 4;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[5]);
screenMode = 0;
menu = 1;
notifications();
}
void action6() {
isMp3Pause = false;
albumn = 6;
spacing = 6;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[6]);
screenMode = 0;
menu = 1;
notifications();
}
void action7() {
isMp3Pause = false;
albumn = 7;
spacing = 6;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[7]);
screenMode = 0;
menu = 1;
notifications();
}
void action8() {
isMp3Pause = false;
albumn = 8;
spacing = 5;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[8]);
screenMode = 0;
menu = 1;
notifications();
}
void action9() {
isMp3Pause = false;
albumn = 9;
spacing = 5;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[9]);
screenMode = 0;
menu = 1;
notifications();
}
void action10() {
isMp3Pause = false;
albumn = 10;
spacing = 3;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[10]);
screenMode = 0;
menu = 1;
notifications();
}
void action11() {
isMp3Pause = false;
albumn = 11;
spacing = 6;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[11]);
screenMode = 0;
menu = 1;
notifications();
}
void action12() {
isMp3Pause = false;
albumn = 12;
spacing = 3;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[12]);
screenMode = 0;
menu = 1;
notifications();
}
void action13() {
isMp3Pause = false;
albumn = 13;
spacing = 5;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[13]);
screenMode = 0;
menu = 1;
notifications();
}
void action14() {
isMp3Pause = false;
albumn = 14;
spacing = 5;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[14]);
screenMode = 0;
menu = 1;
notifications();
}
void action15() {
isMp3Pause = false;
albumn = 15;
spacing = 4;
nMode = 5;
isMp3Playing = true;
dLine = 2;
musicPlay();
delay(dly);
lcd.clear();
lcd.setCursor(spacing1, 1);
lcd.print(arrayEQ[8]);
lcd.setCursor(spacing, 2);
lcd.print(arrayAlbumn[15]);
screenMode = 0;
menu = 1;
notifications();
}
void action16() {
EEPROM.write(0, 1);
eqMode = 1;
nMode = 5;
lcd.clear();
lcd.setCursor(spacing2, 1);
lcd.print(arrayEQ[7]);
lcd.setCursor(7, 2);
lcd.print(F("NORMAL"));
myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
notifications();
}
void action17() {
EEPROM.write(0, 2);
eqMode = 2;
nMode = 5;
lcd.clear();
lcd.setCursor(spacing2, 1);
lcd.print(arrayEQ[7]);
lcd.setCursor(8, 2);
lcd.print(F("POP"));
myDFPlayer.EQ(DFPLAYER_EQ_POP);
notifications();
}
void action18() {
EEPROM.write(0, 3);
eqMode = 3;
nMode = 5;
lcd.clear();
lcd.setCursor(spacing2, 1);
lcd.print(arrayEQ[7]);
lcd.setCursor(7, 2);
lcd.print(F("ROCK"));
myDFPlayer.EQ(DFPLAYER_EQ_ROCK);
notifications();
}
void action19() {
EEPROM.write(0, 4);
eqMode = 4;
nMode = 5;
lcd.clear();
lcd.setCursor(spacing2, 1);
lcd.print(arrayEQ[7]);
lcd.setCursor(7, 2);
lcd.print(F("JAZZ"));
myDFPlayer.EQ(DFPLAYER_EQ_JAZZ);
notifications();
}
void action20() {
EEPROM.write(0, 5);
eqMode = 5;
nMode = 5;
lcd.clear();
lcd.setCursor(spacing2, 1);
lcd.print(arrayEQ[7]);
lcd.setCursor(6, 2);
lcd.print(F("CLASSIC"));
myDFPlayer.EQ(DFPLAYER_EQ_CLASSIC);
notifications();
}
void action21() {
EEPROM.write(0, 6);
eqMode = 6;
nMode = 5;
lcd.clear();
lcd.setCursor(spacing2, 1);
lcd.print(arrayEQ[7]);
lcd.setCursor(8, 2);
lcd.print(F("BASS"));
myDFPlayer.EQ(DFPLAYER_EQ_BASS);
notifications();
}
void action22() {
myDFPlayer.stop();
myDFPlayer.volume(25);
currentVol = 25;
isMp3Pause = false;
isMp3Playing = false;
dLine = 1;
nMode = 5;
lcd.clear();
lcd.setCursor(4, 1);
lcd.print(F("TIME FORMAT"));
timeFormatSet();
}
void action23() {
myDFPlayer.stop();
myDFPlayer.volume(25);
currentVol = 25;
isMp3Pause = false;
isMp3Playing = false;
dLine = 1;
randomAll = false;
isSetTime = true;
hh = now.hour();
mn = now.minute();
nMode = 5;
screenMode = 0;
menu = 1;
lcd.clear();
np = 1;
lcd.setCursor(7, 1);
lcd.print(F("SETTING"));
lcd.setCursor(8, 2);
lcd.print(F("TIME"));
myDFPlayer.playMp3Folder(31);
notifications();
}
void action24() {
myDFPlayer.stop();
myDFPlayer.volume(25);
currentVol = 25;
isMp3Pause = false;
isMp3Playing = false;
dLine = 1;
randomAll = false;
isSetDate = true;
dd = now.day();
mmm = now.month();
yyyy = now.year();
nMode = 5;
screenMode = 0;
menu = 1;
np = 1;
lcd.clear();
lcd.setCursor(7, 1);
lcd.print(F("SETTING"));
lcd.setCursor(8, 2);
lcd.print(F("DATE"));
myDFPlayer.playMp3Folder(30);
notifications();
}