Hola Buenas a tod@s!
Estoy en un proyecto mas complejo y quería utilizar dos pantallas nextion de diferentes pulgadas..he empezado buscando información empezando por lo más sencillo y he encontrado este código al compilarlo me da error en “'Nextion' does not name a type” a mi entender creo que van los tiros por las librerías.. utilizo arduino mega 2560.
Tengo instaladas varias librerías que he encontrado por google…
1º ITEADLIB_Arduino_Nextion-master
2º nextion-master
3º ITEADLIB_Arduino_Nextion-0.7.0
#include <Nextion.h>
#include <SoftwareSerial.h>
SoftwareSerial nextion(10, 11);// Nextion TX to pin 10 and RX to pin 11 of Arduino
Nextion myNextion(nextion, 9600);
SoftwareSerial nextion_b(12, 13);// Nextion TX to pin 12 and RX to pin 13 of Arduino
Nextion myNextion_b(nextion_b, 9600);
char rx_message_A[25];
char rx_message_B[25];
void setup() {
Serial.begin(9600);
nextion.begin(9600);
nextion_b.begin(9600);
myNextion.init();
myNextion_b.init();
}
void loop() {
myNextion.listen().toCharArray(rx_message_A, 25);
myNextion_b.listen().toCharArray(rx_message_B, 25);
Serial.print(rx_message_A);
Serial.print(rx_message_B);
}
Alguien podría ayudarme..
Paralelamente Utilizando una solo pantalla Nextion consigo que funcione pero con el código de ejemplos que viene en las librerías por ejemplo “CompText.ino”… conectado a RX1 19 y TXI18, si sobre este código pudiera…”conectar” con la segunda pantalla Nextion me olvidaría del primer código…
#include "Nextion.h"
void t0PopCallback(void *ptr);
void b0PopCallback(void *ptr);
void b1PopCallback(void *ptr);
NexText t0 = NexText(0, 1, "t0");
NexButton b0 = NexButton(0, 2, "b0");
NexButton b1 = NexButton(0, 3, "b1");
char buffer[100] = {0};
NexTouch *nex_listen_list[] =
{
&t0,
&b0,
&b1,
NULL
};
void t0PopCallback(void *ptr)
{
dbSerialPrintln("t0PopCallback");
t0.setText("50");
}
void b0PopCallback(void *ptr)
{
uint16_t len;
uint16_t number;
dbSerialPrintln("b0PopCallback");
memset(buffer, 0, sizeof(buffer));
t0.getText(buffer, sizeof(buffer));
number = atoi(buffer);
number += 1;
memset(buffer, 0, sizeof(buffer));
itoa(number, buffer, 10);
t0.setText(buffer);
}
void b1PopCallback(void *ptr)
{
uint16_t len;
uint16_t number;
dbSerialPrintln("b1PopCallback");
memset(buffer, 0, sizeof(buffer));
t0.getText(buffer, sizeof(buffer));
number = atoi(buffer);
number -= 1;
memset(buffer, 0, sizeof(buffer));
itoa(number, buffer, 10);
t0.setText(buffer);
}
void setup(void)
{
nexInit();
t0.attachPop(t0PopCallback);
b0.attachPop(b0PopCallback);
b1.attachPop(b1PopCallback);
dbSerialPrintln("setup done");
}
void loop(void)
{
nexLoop(nex_listen_list);
}
Muchas gracias..
Omar