/*
Voltaje de Operación: 3.3 VDC
Controlador gráfico: IC ILI9431
Controlador de pantalla con buffer de video incluido
Controlador de táctil: XPT2046
Interface: SPI (CS, RS, SCL, SDA, RST)
Nivel lógico de SPI: 3.3V
Tamaño de la pantalla: 55 mm x 89,30 mm
Resolución: 240x320 píxeles
Profundidad de color: 65K
Cantidad de colores: 262144 colores (18-bit: R6G6B6)
*Puede trabajar opcionalmente a RGB 16-bit: R5G6B5
Socket para memoria externa SD
El adaptador SD card utiliza SPI, es necesario soldar los pines previamente (CS / MOSI / MISO / SCK)
Direccion MAC de este dispositivo Receptor: A8:42:E3:C9:43:8C
COLORES PARA EL TFT DISPLAY
=============================
#define NEGRO 0x0000
#define GRIS 0x8410
#define BLANCO 0xFFFF
#define ROJO 0xF800
#define NARANJA 0xFA60
#define AMARILLO 0xFFE0
#define VERDE1 0x07FF
#define VERDE2 0x07E0
#define CELESTE 0x07FF
#define XXX 0x04FF
#define AZUL 0x001F
#define XXX 0xF81F
#define ROSADO 0xF8FF
*/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>// biblioteca de gráficos principal
#include <Adafruit_ILI9341.h>// biblioteca específica del hardware
#include "WiFi.h"
#include "LogoEscuela.h"
#include "TanquePrueba.h"
#include <esp_now.h>
#define TFT_SCK 18
#define TFT_MOSI 23
#define TFT_MISO 19
#define TFT_CS 22
#define TFT_DC 21
#define TFT_RESET 17
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
const int potPin = 35;
int selected = 0;
int selected2 = -1;
int entered = -1;
int entered2 = -1;
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;
int a1 = 0;
int b1 = 0;
int c1 = 0;
int d1 = 0;
int e1 = 0;
//Codigo para graduar o calibrar la exactitud del sensor, colocarlo en el menu 2
float Ancho=16;
float Largo=22.5;
float Alto=34;
//======================================================
float NivelTanque;
float Volumencc;
float VolumenLtrs;
float VolumenGal;
float VolumenOz;
int potValue = 0;
float VolumenCC=0;
int Z=330;
int Estado=0;
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated
// constants won't change:
const long interval = 200; // interval at which to blink (milliseconds)
#define ColorN 0x0000 //Black Negro, puntero Primario de la barra grafica
#define ColorR 0xFFFF //BLANCO, Puntero Secundario de la barra grafica
#define ColorLleno 0x0000 //Black Negro, puntero Primario de la barra grafica
#define ColorVacio 0xFFFF //BLANCO, Puntero Secundario de la barra grafica
//*************************************************
typedef struct TxStruct
{
float MedidaSensor;
} TxStruct;
TxStruct sentData;
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len)
{//Comienzo void OnDataRecv
if (Estado==1){
memcpy(&sentData, incomingData, sizeof(sentData));
NivelTanque=Alto-sentData.MedidaSensor;
ImpreData();BarraGrafica();
//Tiempo de actualizacion
delay(10000);tft.fillScreen(ILI9341_BLACK);//Fin void ImpreData
tft.fillRect(0,200,300,20, ILI9341_BLACK);//Rectangulo para borrar la barra
}
else if (Estado==2) {
memcpy(&sentData, incomingData, sizeof(sentData));
NivelTanque=Alto-sentData.MedidaSensor;
ImpreData2();BarraGrafica();
//Tiempo de actualizacion
delay(10000);tft.fillScreen(ILI9341_BLACK);//Fin void ImpreData
tft.fillRect(0,200,300,20, ILI9341_BLACK);//Rectangulo para borrar la barra
}
else{}
} //Fin void OnDataRecv
void IRAM_ATTR menu() {
int enter = digitalRead(4);
//Código selección de menú de acuerdo a la resistencia del potenciomentro
if (potValue < 800 && entered == -1) {
selected = 0;
} else if (potValue < 800 && entered2 == -1) {
selected2 = 0;
}
if (potValue > 800 && potValue < 1600 && entered == -1) {
selected = 1;
} else if (potValue > 800 && potValue < 1600 && entered2 == -1) {
selected2 = 1;
}
if (potValue > 1600 && potValue < 2454 && entered == -1) {
selected = 2;
} else if (potValue > 1600 && potValue < 2454 && entered2 == -1) {
selected2 = 2;
}
if (potValue > 2454 && potValue < 3270 && entered == -1) {
selected = 3;
} else if (potValue > 2454 && potValue < 3270 && entered2 == -1) {
selected2 = 3;
}
if (potValue > 3270 && potValue <= 4095 && entered == -1) {
selected = 4;
} else if (potValue > 3270 && potValue <= 4095 && entered2 == -1) {
selected2 = 4;
}
if (enter == LOW && entered == -1) {
entered = selected;
tft.fillScreen(ILI9341_BLACK);
}
if (enter == LOW && entered2 == -1) {
entered2 = selected2;
tft.fillScreen(ILI9341_BLACK);
}
//Condicion para usa ENTER como BACK
if (enter == LOW && a > 1) {
a = 0;
entered = -1;
tft.fillScreen(ILI9341_BLACK);
} else if (enter == LOW && a1 > 1) {
a1 = 0;
entered2 = -1;
tft.fillScreen(ILI9341_BLACK);
digitalWrite(27, LOW);
};
if (enter == LOW && b > 1) {
b = 0;
entered = -1;
tft.fillScreen(ILI9341_BLACK);
} else if (enter == LOW && b1 > 1) {
b1 = 0;
entered2 = -1;
tft.fillScreen(ILI9341_BLACK);
digitalWrite(26, LOW);
};
if (enter == LOW && c > 1) {
c = 0;
entered = -1;
tft.fillScreen(ILI9341_BLACK);
} else if (enter == LOW && c1 > 1) {
c1 = 0;
entered2 = -1;
tft.fillScreen(ILI9341_BLACK);
};
if (enter == LOW && d > 1) {
d = 0;
entered = -1;
tft.fillScreen(ILI9341_BLACK);
} else if (enter == LOW && d1 > 1) {
d1 = 0;
entered2 = -1;
tft.fillScreen(ILI9341_BLACK);
};
if (enter == LOW && e > 1) {
e = 0;
entered = -1;
tft.fillScreen(ILI9341_BLACK);
} else if (enter == LOW && e1 > 1) {
e1 = 0;
entered2 = -1;
tft.fillScreen(ILI9341_BLACK);
};
//Configuración estructura del menú 1,2
const char *options[5] = {
" Volume",
" Graphics",
" Weight/QtyItem",
" Availability",
" Tools >>>",
};
//Sustitur un dato para colocar en el menú: Adjust sensor
const char *options2[5] = {
" Focus/Light",
" Laser pointer",
" Adjust sensor",
" Reset",
" <<< Return",
};
//Seleccionando primer bloque del menu (principal-monitor)
if (entered == -1) {
unsigned long currentMillis = millis();
tft.setTextSize(3);
//tft.fillScreen(BLACK);;
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_YELLOW);
tft.println(F(" M O N I T O R"));
tft.println("");
for (int i = 0; i < 5; i++) {
if (i == selected) {
tft.setTextColor(ILI9341_BLACK, ILI9341_YELLOW);
tft.println(options[i]);
} else if (i != selected) {
tft.setTextColor(ILI9341_WHITE,ILI9341_BLACK);
tft.println(options[i]);
}
}
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
AvisoDesliz(); //Aviso deslizante
}else{}
//Código o rutina para leer los datos del tanque
} else if (entered == 0) {
if (enter == LOW) {a = a + 1;}
if (a % 2 == 0) {
Estado=0;
}
else
{
Estado=1;OnDataRecv;
} //Final else que engloba los punteros
} else if (entered == 1) {
// tft.fillScreen(BLACK);
tft.setTextSize(3);
tft.setTextColor(ILI9341_GREEN);
tft.setCursor(0, 0);
tft.println(" G R A P H I C");
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(1);
tft.println("");
tft.setTextSize(2);
tft.println("En proceso...");
BarraGrafica();
if (enter == LOW) {b = b + 1;}
if (Volumencc>=0 && Volumencc<=250)
{tft.fillTriangle(8,200,3,215,13,215, ColorR);
tft.setCursor(0, 115);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.println("Empty container");
}//Mensaje container vacio
if (Volumencc >=833.33 && Volumencc<1666.66)
{tft.fillTriangle(37,200,32,215,42,215, ColorN);}//
if (Volumencc >=1666.66 && Volumencc<2499.99)
{tft.fillTriangle(62,200,57,215,67,215, ColorN);}//
if (Volumencc >=2499.99 && Volumencc<3333.32)
{tft.fillTriangle(87,200,82,215,92,215, ColorN);}
if (Volumencc >=3333.32 && Volumencc<4166.65)
{tft.fillTriangle(112,200,108,215,117,215, ColorN);}//
if (Volumencc >=4166.65 && Volumencc<4999.99)
{tft.fillTriangle(142,200,133,215,147,215, ColorN);
tft.setCursor(35, 115);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(3);
tft.println("Half container");
}//Mensaje Capacidad mitad del container
if (Volumencc >=4999.99 && Volumencc<5833.32)
{tft.fillTriangle(167,200,158,215,172,215, ColorN);}//
if(Volumencc >=5833.31 && Volumencc<6666.64)
{tft.fillTriangle(192,200,183,215,197,215, ColorN);}//
if(Volumencc >=6666.64 && Volumencc<7499.97)
{tft.fillTriangle(217,200,208,215,222,215, ColorN);}//
if(Volumencc >=7499.97 && Volumencc<8333.3)
{tft.fillTriangle(242,200,233,215,247,215, ColorN);}//
if(Volumencc >=8333.3 && Volumencc<9166.63)
{tft.fillTriangle(267,200,258,215,272,215, ColorN);}//
if(Volumencc >=9166.63 && Volumencc<9999.96)
{tft.fillTriangle(292,200,283,215,297,215, ColorN);
tft.setCursor(35, 115);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(0);
tft.println("Full container");}//Mensaje container lleno
tft.drawRGBBitmap(195, 50, TanquePrueba, 128, 130);//Dibuja Tanque Prueba
} else if (entered == 2) {
// Weight/QtyItem
if (enter == LOW) {c = c + 1;}
if (c % 2 == 0) {
Estado=0;
}
else
{
Estado=2;OnDataRecv;
}
} else if (entered == 3) {
//tft.fillScreen(BLACK);
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(0, 0);
tft.println(" M A T E R I A L");
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("");
tft.println("En proceso...");
if (enter == LOW) {d = d + 1;}
} else if (entered == 4) {
//Seleccionando segundo menú (Utilerias)
if (entered2 == -1) {
tft.setTextSize(3);
// tft.fillScreen(BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_GREEN);
tft.println(" T O O L S");
tft.println("");
for (int j = 0; j < 5; j++) {
if (j == selected2) {
tft.setTextColor(ILI9341_BLACK, ILI9341_GREEN);
tft.println(options2[j]);
} else if (j != selected2) {
tft.setTextColor(ILI9341_WHITE,ILI9341_BLACK);
tft.println(options2[j]);
}
}
} else if (entered2 == 0) {
tft.setTextSize(3);
//tft.fillScreen(BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_WHITE);
tft.println(" L I N T E R N A");
tft.println("");
tft.setCursor(115, 100);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(5);
tft.println("O N");
digitalWrite(27, HIGH);
if (enter == LOW) {a1 = a1 + 1;}
} else if (entered2 == 1) {
tft.setTextSize(3);
// tft.fillScreen(BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_WHITE);
tft.println(" LASER POINT");
tft.println("");
tft.setCursor(115, 100);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(5);
tft.println("O N");
digitalWrite(26, HIGH);
if (enter == LOW) {b1 = b1 + 1;}
//Buscar redes wifi
} else if (entered2 == 2) {
//Aqui codigo Adjuste sensor
tft.setTextSize(3);
tft.setTextColor(ILI9341_ORANGE);
tft.setCursor(0, 0);
tft.println(" ADJUSTE SENSOR");
tft.println("");
tft.setTextColor(ILI9341_WHITE);
const char *options3[5] = {
" Parameter W",
" Parameter L",
" Parameter H",
" Config",
" >>>",
};
for (int z = 0; z < 5; z++) {
if (z == selected2) {
tft.setTextColor(ILI9341_BLACK, ILI9341_ORANGE);
tft.println(options3[z]);
} else if (z != selected2) {
tft.setTextColor(ILI9341_WHITE,ILI9341_BLACK);
tft.println(options3[z]);
}
}
tft.setTextSize(2);
tft.println("");
tft.println("En proceso...");
if (enter == LOW) {c1 = c1 + 1;}
} else if (entered2 == 3) {
Reset();
if (enter == LOW) {d1 = d1 + 1;}
//regresar al principal
} else if (entered2 == 4) {
if (enter == LOW) {e = e + 1;}
e = e + 1;
regresar();
} //fin entereD2 4
} //CIERRE ENTERED4
}//Fin del Loop **void IRAM_ATTR menu** (Ciclo Principal)
void regresar() {
tft.fillScreen(ILI9341_BLACK);
entered = -1;
selected = 4;
selected2 = -1;
entered2 = -1;}
void presentacion() {
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(0, 0); //Agregado
tft.setTextSize(2);
tft.setTextColor(ILI9341_BLUE);
tft.println(" SCHOOL PROJECT");
tft.println("==========================");
tft.setTextColor(ILI9341_WHITE);
tft.println(" 5th Grade");
tft.println("");
tft.setTextSize(3);
tft.println("");
tft.println("");
tft.println("Matthiuss Garcia");
tft.setTextSize(2);
tft.println("");
tft.println("");
tft.println("");
tft.println("");
tft.println(" Period: 2023-2024");
tft.println(" Version 1.0");
delay(2000); } // Pause for 2 seconds
void hora() {
//tft.fillScreen(BLACK);
tft.setTextSize(3);
tft.setCursor(15, 50);
tft.setTextColor(ILI9341_WHITE);
tft.println("Time:");
tft.println("");
//tft.setCursor(15,25);
tft.println(__TIME__);
//tft.setCursor(56, 50);
tft.println(__DATE__);
tft.drawRect(0, 35, 300, 100, ILI9341_WHITE);}
//***************************************************************************************************************************
//*********************************************A D V E R T E N C I A*********************************************************
//***************************************************************************************************************************
//ADVERTENCIA NOTA IMPORTANTE!!!! : En ImpreData() y ImpreData2() cambiar de (if Volummnecc==0) a (if sentData.MedidaSensor==0)
void ImpreData(){
Volumencc=Ancho*Largo*NivelTanque;// Cambiar según ancho y largo del contenedor (en este caso 16cmx21.5cm)
if (Volumencc<=0){
Volumencc=0;NivelTanque=0;tft.fillRect(5,200,10,20, ILI9341_BLACK);}//Puntero + evitar los valores negativos
if (sentData.MedidaSensor==0){
delay(2000);
//ir a un procedimiento que indique que no hay trasmision de datos
NoTrasData();}
VolumenLtrs=Volumencc/1000;
VolumenGal= VolumenLtrs/3.79; //0.033814 (Galón Americano)
VolumenOz=Volumencc*0.033814;
tft.setCursor(0, 0);
tft.setTextSize(3);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.println(" S T A T U S ");
tft.setTextSize(2);
tft.println("");
tft.print("Sensor Measurement:");
tft.setTextColor(ILI9341_BLUE);
tft.println(sentData.MedidaSensor);
tft.setTextSize(3);
tft.setTextColor(ILI9341_GREEN);
tft.print("Volcc/ml:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(Volumencc);
tft.setTextColor(ILI9341_GREEN);
tft.print("VolLtrs:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(VolumenLtrs);
tft.setTextColor(ILI9341_GREEN);
tft.print("VolGal:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(VolumenGal);
tft.setTextColor(ILI9341_GREEN);
tft.print("VolOz:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(VolumenOz);
tft.print("LevelCm:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(NivelTanque);
}//Cierre de void impredata
void ImpreData2(){
Volumencc=Ancho*Largo*NivelTanque;// Cambiar según ancho y largo del contenedor (en este caso 16cmx21.5cm)
if (Volumencc<=0){
Volumencc=0;NivelTanque=0;tft.fillRect(5,200,10,20, ILI9341_BLACK);}//Puntero + evitar los valores negativos
if (sentData.MedidaSensor==0){
delay(2000);
//ir a un procedimiento que indique que no hay trasmision de datos
NoTrasData();}
VolumenLtrs=Volumencc/1000;
VolumenGal= VolumenLtrs/3.79; //0.033814 (Galón Americano)
tft.setCursor(0, 0);
tft.setTextSize(3);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.println(" WEIGHT/ITEMQTTY");
//sería de unos 998 kg/m3 a 20ºC, o 0,998 g/cc
tft.setTextSize(2);
tft.println("");
tft.print("Sensor Measurement:");
tft.setTextColor(ILI9341_BLUE);
tft.println(sentData.MedidaSensor);
tft.setTextSize(3);
//Peso en gramos del producto en el container
tft.setTextColor(ILI9341_GREEN);
tft.print("Weightgrs:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(Volumencc*0.998);
//Peso en Kilogramos de producto en el container
tft.setTextColor(ILI9341_GREEN);
tft.print("WeightKgs:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(VolumenLtrs*0.000998);
//Cantidad de piezas por centimetro cubicos o mililitro (supuesto 120) de item dentro del container
tft.setTextColor(ILI9341_GREEN);
tft.print("QttyItemcc:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(Volumencc/120);
//Cantidad de piezas por gramos (ejemplo 56) de item dentro del container
tft.setTextColor(ILI9341_GREEN);
tft.print("QttyItemgr:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(Volumencc*0.998/56);
//Nvel del liquido en el recipiente
tft.setTextColor(ILI9341_GREEN);
tft.print("LevelCm:");
tft.setTextColor(ILI9341_YELLOW);
tft.println(NivelTanque);
}//Cierre de void impreData2
void BarraGrafica(){
//tft.fillRect(x,y,Largo,Ancho,ILI9341_COLOR)
tft.fillRect(0,200,100,20, ILI9341_RED);
tft.drawRect(50,217,0,7, ILI9341_WHITE);
tft.setCursor(0, 225);tft.setTextColor(ILI9341_WHITE);tft.setTextSize(1);
tft.println("E");
tft.setCursor(0, 190);tft.setTextColor(ILI9341_ORANGE);tft.setTextSize(1);
tft.println("0 L");
tft.setCursor(43, 225);tft.setTextColor(ILI9341_WHITE);tft.setTextSize(1);
tft.println("1/6");
tft.setCursor(36, 190);tft.setTextColor(ILI9341_ORANGE);tft.setTextSize(1);
tft.println("1.6 L");
tft.setCursor(90, 225);tft.setTextColor(ILI9341_WHITE);tft.setTextSize(1);
tft.println("1/3");
tft.setCursor(88, 190);tft.setTextColor(ILI9341_ORANGE);tft.setTextSize(1);
tft.println("3.3 L");
tft.fillRect(100,200,100,20, ILI9341_YELLOW);
tft.drawRect(150,217,0,7, ILI9341_WHITE);
tft.setCursor(143, 225);tft.setTextColor(ILI9341_WHITE);tft.setTextSize(1);
tft.println("1/2");
tft.setCursor(140, 190);tft.setTextColor(ILI9341_ORANGE);tft.setTextSize(1);
tft.println("5 L");
tft.setCursor(193, 225);tft.setTextColor(ILI9341_WHITE);tft.setTextSize(1);
tft.println("2/3");
tft.setCursor(190, 190);tft.setTextColor(ILI9341_ORANGE);tft.setTextSize(1);
tft.println("6.6 L");
tft.fillRect(200,200,100,20, ILI9341_GREEN);
tft.drawRect(250,217,0,7, ILI9341_WHITE);
tft.setCursor(243, 225);tft.setTextColor(ILI9341_WHITE);tft.setTextSize(1);
tft.println("5/6");
tft.setCursor(240, 190);tft.setTextColor(ILI9341_ORANGE);tft.setTextSize(1);
tft.println("8.3 L");
tft.setCursor(295, 225);tft.setTextColor(ILI9341_WHITE);tft.setTextSize(1);
tft.println("F");
tft.setCursor(286, 190);tft.setTextColor(ILI9341_ORANGE);tft.setTextSize(1);
tft.println("10 L");
//Puntero y mensajes del volumen en el recipiente
//tft.fillRect(x, y ,Largo,Ancho,ILI9341_COLOR) plantilla rectangulo grafico
if (Volumencc>=0 && Volumencc<=250)
{tft.fillTriangle(8,200,3,215,13,215, ColorR);
tft.setCursor(1, 182);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(0);
tft.println("Empty");
}//Mensaje container vacio
if (Volumencc >=833.33 && Volumencc<1666.66)
{tft.fillTriangle(37,200,32,215,42,215, ColorN);}//
if (Volumencc >=1666.66 && Volumencc<2499.99)
{tft.fillTriangle(62,200,57,215,67,215, ColorN);}//
if (Volumencc >=2499.99 && Volumencc<3333.32)
{tft.fillTriangle(87,200,82,215,92,215, ColorN);}
if (Volumencc >=3333.32 && Volumencc<4166.65)
{tft.fillTriangle(112,200,108,215,117,215, ColorN);}//
if (Volumencc >=4166.65 && Volumencc<4999.99)
{tft.fillTriangle(142,200,133,215,147,215, ColorN);
tft.setCursor(140, 182);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(0);
tft.println("Half");
}//Mensaje Capacidad mitad del container
if (Volumencc >=4999.99 && Volumencc<5833.32)
{tft.fillTriangle(167,200,158,215,172,215, ColorN);}//
if(Volumencc >=5833.31 && Volumencc<6666.64)
{tft.fillTriangle(192,200,183,215,197,215, ColorN);}//
if(Volumencc >=6666.64 && Volumencc<7499.97)
{tft.fillTriangle(217,200,208,215,222,215, ColorN);}//
if(Volumencc >=7499.97 && Volumencc<8333.3)
{tft.fillTriangle(242,200,233,215,247,215, ColorN);}//
if(Volumencc >=8333.3 && Volumencc<9166.63)
{tft.fillTriangle(267,200,258,215,272,215, ColorN);}//
if(Volumencc >=9166.63 && Volumencc<9999.96)
{tft.fillTriangle(292,200,283,215,297,215, ColorN);
tft.setCursor(278, 182);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(0);
tft.println("Full");}//Mensaje container lleno
}//Cierre del void BarraGrafica y rutina (if) para el puntero
void MensajeAct(){
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(20, 115);
tft.setTextColor(ILI9341_ORANGE);
tft.setTextSize(3);
tft.println("Updating data...");
}
//***************************************************************************************************************************
//*********************************************A D V E R T E N C I A*********************************************************
//***************************************************************************************************************************
//Anexar texto en las recomendaciones que sugiera que pilas con poca energia tambien podrian afectar las comunicaciones
void NoTrasData(){
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(0, 0);
tft.setTextSize(3);
tft.setTextColor(ILI9341_RED);
tft.print(" W a r n i n g");
tft.setCursor(0, 80);
tft.setTextColor(ILI9341_GREEN);
//tft.print(delay(12000));
tft.println("Not sending data");
tft.setTextSize(2);
tft.setCursor(0, 130);
tft.setTextColor(ILI9341_YELLOW);
tft.println("***A t t e n t i o n***");
tft.println("");
tft.setTextColor(ILI9341_WHITE);
tft.println("The transmitting device");
tft.println("may have stopped to send");
tft.println("data to the receiver...,");
tft.println("check the connections or");
tft.println("reset the transmitter");
delay(12000);
}
void AvisoDesliz(){
tft.fillRect(0,223,320,20, ILI9341_ORANGE);
tft.setTextSize(2);
tft.setCursor(Z, 224);
Z=Z-10;
tft.setTextColor(ILI9341_BLACK);
tft.print("School: Esperanza Elementary Student: Matthiuss Garcia 5th Grade ");
if (Z==-750){Z=330;}
} //Cierre del vois AvisoDesliz()
void Reset(){
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(0, 0);
tft.println("The unit restarts in ");
tft.print("3 seconds...");
delay(3000);
tft.fillScreen(ILI9341_BLACK);
ESP.restart();
}//Cierre void reset
void setup(void) {
pinMode(27, OUTPUT); //Luz Foco Blanca
pinMode(26, OUTPUT); //Puntero Laser
pinMode(4, INPUT_PULLUP); //Seleccionador-Enter
selected = 0;
potValue = 0;
tft.begin();
Serial.begin(921600);
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
tft.drawRGBBitmap(0, 0, Logo_Escuela320x240, 316, 240);//Dibuja imagen
delay(5000);
tft.fillScreen(ILI9341_BLACK);
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) {
Serial.println("Error al inicial ESP-NOW");
return;
}
esp_now_register_recv_cb(OnDataRecv);
} //Cierre Setup
void loop() {
potValue = analogRead(potPin);
//Serial.println(potValue);
Serial.print("entered2:");
Serial.println(entered2);
Serial.print("entered:");
Serial.println(entered);
Serial.print("selected2:");
Serial.println(selected2);
Serial.print("selected:");
Serial.println(selected);
menu();}