feat: remove 'Cargar imagen de fondo' from configuration menu
This commit is contained in:
parent
06a07091e3
commit
08ed6cad06
1 changed files with 17 additions and 86 deletions
|
|
@ -33,14 +33,13 @@ void clickSound() {
|
||||||
casioBeep(2048, 20);
|
casioBeep(2048, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration menu list (4 options)
|
// Configuration menu list (3 options)
|
||||||
const String menuList[4] = {
|
const String menuList[3] = {
|
||||||
"Ajuste de Alarmas", // 0
|
"Ajuste de Alarmas", // 0
|
||||||
"Volumen de Bip", // 1
|
"Volumen de Bip", // 1
|
||||||
"Cargar imagen de fondo", // 2
|
"Salir" // 2
|
||||||
"Salir" // 3
|
|
||||||
};
|
};
|
||||||
const uint8_t maxMenu = 4;
|
const uint8_t maxMenu = 3;
|
||||||
|
|
||||||
// Menu list for warning setting (4 vehicle gauges)
|
// Menu list for warning setting (4 vehicle gauges)
|
||||||
const String parameterList[4][2] = {
|
const String parameterList[4][2] = {
|
||||||
|
|
@ -317,53 +316,6 @@ void volumeMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
// Sub-screen 2: Cargar imagen de fondo desde SD
|
|
||||||
// -------------------------------------------------------------
|
|
||||||
void loadMyPic() {
|
|
||||||
if (!SD.begin()) {
|
|
||||||
tft.pushImage(129, 44, 60, 60, sdcard);
|
|
||||||
Serial.println(F("Micro SD Card not mounted!"));
|
|
||||||
tft.setTextColor(TFT_WHITE, TFT_RED);
|
|
||||||
tft.drawCentreString("Please insert Micro SD Card", 159, 120, 4);
|
|
||||||
} else {
|
|
||||||
Serial.println(F("Micro SD Card..OK"));
|
|
||||||
uint8_t cardType = SD.cardType();
|
|
||||||
if (cardType == CARD_NONE) {
|
|
||||||
Serial.println(F("Micro SD Card Error!"));
|
|
||||||
tft.setTextColor(TFT_WHITE, TFT_RED);
|
|
||||||
tft.drawCentreString("Micro SD Card Error!", 159, 120, 4);
|
|
||||||
} else {
|
|
||||||
if (!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) {
|
|
||||||
Serial.println(F("Error: SPIFFS failed!"));
|
|
||||||
tft.setTextColor(TFT_WHITE, TFT_RED);
|
|
||||||
tft.drawCentreString("Error: SPIFFS failed!", 159, 120, 4);
|
|
||||||
} else {
|
|
||||||
File sourceFile = SD.open(mypic_filename);
|
|
||||||
if (sourceFile) {
|
|
||||||
File destFile = SPIFFS.open(mypic_filename, FILE_WRITE);
|
|
||||||
Serial.println(F("Copying...\"mypic.jpg\""));
|
|
||||||
tft.setTextColor(TFT_BLACK, TFT_GREEN);
|
|
||||||
static uint8_t buf[512];
|
|
||||||
while (sourceFile.read(buf, 512)) {
|
|
||||||
destFile.write(buf, 512);
|
|
||||||
}
|
|
||||||
sourceFile.close();
|
|
||||||
destFile.close();
|
|
||||||
show_spiffs_jpeg_image(mypic_filename, 0, 0);
|
|
||||||
} else {
|
|
||||||
Serial.println(F("\"mypic.jpg\" not found!"));
|
|
||||||
tft.pushImage(130, 44, 60, 60, nofile);
|
|
||||||
tft.setTextColor(TFT_WHITE, TFT_RED);
|
|
||||||
tft.drawCentreString("\"mypic.jpg\" not found!", 159, 120, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SD.end();
|
|
||||||
SPIFFS.end();
|
|
||||||
casioBeep(4096, 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
// Menu Principal
|
// Menu Principal
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|
@ -371,19 +323,19 @@ void listMenu(uint8_t choice) {
|
||||||
tft.fillRect(0, 30, 320, 180, TFT_BLACK);
|
tft.fillRect(0, 30, 320, 180, TFT_BLACK);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < maxMenu; i++) {
|
for (uint8_t i = 0; i < maxMenu; i++) {
|
||||||
int y = 36 + i * 42;
|
int y = 42 + i * 52;
|
||||||
if (choice == i) {
|
if (choice == i) {
|
||||||
tft.fillRoundRect(10, y, 300, 38, 5, TFT_BLUE);
|
tft.fillRoundRect(10, y, 300, 44, 5, TFT_BLUE);
|
||||||
tft.drawRoundRect(10, y, 300, 38, 5, TFT_CYAN);
|
tft.drawRoundRect(10, y, 300, 44, 5, TFT_CYAN);
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLUE);
|
tft.setTextColor(TFT_WHITE, TFT_BLUE);
|
||||||
} else {
|
} else {
|
||||||
tft.fillRoundRect(10, y, 300, 38, 5, 0x18E3); // subtle dark card
|
tft.fillRoundRect(10, y, 300, 44, 5, 0x18E3); // subtle dark card
|
||||||
tft.setTextColor(TFT_WHITE, 0x18E3);
|
tft.setTextColor(TFT_WHITE, 0x18E3);
|
||||||
}
|
}
|
||||||
tft.drawString(menuList[i], 25, y + 7, 4);
|
tft.drawString(menuList[i], 25, y + 10, 4);
|
||||||
}
|
}
|
||||||
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||||
tft.drawCentreString("Toque una opcion para configurar", 160, 215, 2);
|
tft.drawCentreString("Toque una opcion para configurar", 160, 212, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void configMenu() {
|
void configMenu() {
|
||||||
|
|
@ -406,10 +358,9 @@ void configMenu() {
|
||||||
|
|
||||||
if (getTouch(&tx, &ty)) {
|
if (getTouch(&tx, &ty)) {
|
||||||
int8_t touchedOpt = -1;
|
int8_t touchedOpt = -1;
|
||||||
if (ty >= 34 && ty < 76) touchedOpt = 0;
|
if (ty >= 36 && ty < 90) touchedOpt = 0;
|
||||||
else if (ty >= 76 && ty < 118) touchedOpt = 1;
|
else if (ty >= 90 && ty < 144) touchedOpt = 1;
|
||||||
else if (ty >= 118 && ty < 160) touchedOpt = 2;
|
else if (ty >= 144 && ty <= 205) touchedOpt = 2;
|
||||||
else if (ty >= 160 && ty < 205) touchedOpt = 3;
|
|
||||||
|
|
||||||
if (touchedOpt >= 0) {
|
if (touchedOpt >= 0) {
|
||||||
select = touchedOpt;
|
select = touchedOpt;
|
||||||
|
|
@ -455,7 +406,7 @@ void configMenu() {
|
||||||
tft.drawCentreString("[--- Configuration Menu ---]", 159, 0, 4);
|
tft.drawCentreString("[--- Configuration Menu ---]", 159, 0, 4);
|
||||||
listMenu(select);
|
listMenu(select);
|
||||||
}
|
}
|
||||||
// Option 1: Volume setting (Buzzer level & live test)
|
// Option 1: Volume setting (Buzzer level & live touch)
|
||||||
else if (select == 1) {
|
else if (select == 1) {
|
||||||
volumeMenu();
|
volumeMenu();
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
@ -464,28 +415,8 @@ void configMenu() {
|
||||||
tft.drawCentreString("[--- Configuration Menu ---]", 159, 0, 4);
|
tft.drawCentreString("[--- Configuration Menu ---]", 159, 0, 4);
|
||||||
listMenu(select);
|
listMenu(select);
|
||||||
}
|
}
|
||||||
// Option 2: Load pic
|
// Option 2: Exit
|
||||||
else if (select == 2) {
|
else if (select == 2) {
|
||||||
clickSound();
|
|
||||||
tft.fillRect(0, 30, 320, 239, TFT_BLACK);
|
|
||||||
loadMyPic();
|
|
||||||
tft.setTextColor(TFT_BLACK, TFT_WHITE);
|
|
||||||
tft.drawCentreString("[- Tap screen or press button to exit -]", 159, 215, 4);
|
|
||||||
delay(400);
|
|
||||||
while (digitalRead(SELECTOR_PIN) == HIGH && !isScreenPressed()) {
|
|
||||||
autoDim();
|
|
||||||
yield();
|
|
||||||
}
|
|
||||||
while (isScreenPressed()) { delay(10); yield(); }
|
|
||||||
clickSound();
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
|
||||||
tft.fillRectVGradient(0, 0, 320, 26, TFT_ORANGE, 0xfc00);
|
|
||||||
tft.setTextColor(TFT_BLACK);
|
|
||||||
tft.drawCentreString("[--- Configuration Menu ---]", 159, 0, 4);
|
|
||||||
listMenu(select);
|
|
||||||
}
|
|
||||||
// Option 3: Exit
|
|
||||||
else if (select == 3) {
|
|
||||||
clickSound();
|
clickSound();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue