Hey guys,
I have problems with the page.show(); command for the Nextion.h library to switch the page.
Down here you can see my code, every time it comes to the command it prints in to the serial Monitor:
page page3⸮⸮⸮recvRetCommandFinished err
I cant find the problem. I hope someone else can ;D
#include <doxygen.h>
#include <NexButton.h>
#include <NexCheckbox.h>
#include <NexConfig.h>
#include <NexCrop.h>
#include <NexDualStateButton.h>
#include <NexGauge.h>
#include <NexGpio.h>
#include <NexHardware.h>
#include <NexHotspot.h>
#include <NexNumber.h>
#include <NexObject.h>
#include <NexPage.h>
#include <NexPicture.h>
#include <NexProgressBar.h>
#include <NexRadio.h>
#include <NexRtc.h>
#include <NexScrolltext.h>
#include <NexSlider.h>
#include <NexText.h>
#include <NexTimer.h>
#include <Nextion.h>
#include <NexTouch.h>
#include <NexUpload.h>
#include <NexVariable.h>
#include <NexWaveform.h>
NexPage page0 = NexPage(0, 0, "page0");
NexPage page1 = NexPage(1, 0, "page1");
NexPage page2 = NexPage(2, 0, "page2");
NexPage page3 = NexPage(3, 0, "page3");
/*
Ricardo Mena C
ricardo@crcibernetica.com
http://crcibernetica.com
This example code is in public domain
*/
#include <SoftwareSerial.h>
#include <NEXTIONmaster.h>
SoftwareSerial nextion(2, 3);// Nextion TX to pin 2 and RX to pin 3 of Arduino
NEXTIONmaster myNextion(nextion, 9600); //create a Nextion object named myNextion using the nextion serial port @ 9600bps
unsigned char Richtig = 0;
void setup() {
Serial.begin(9600);
myNextion.init();
}
void loop() {
/*Abfrage Themenauswahl*/
for (int i = 0; i < 1000; i++)
{
String message = myNextion.listen(); //check for message
if (message == "65 1 1 1 ffff ffff ffff")
{
goto Question1;
}
else
{
String message = myNextion.listen(); //check for message
if (message == "2")
{
goto Question1;
}
else
{
}
}
delay(90);
}
Question1:
dbSerialPrintln("page2PopCallback");
myNextion.setComponentText("t0", "Question1");
myNextion.setComponentText("b0", "A1");
myNextion.setComponentText("b1", "A2");
myNextion.setComponentText("b2", "A3");
myNextion.setComponentText("b3", "A4");
for (int i = 0; i < 10000; i++)
{
delay(10);
String message = myNextion.listen(); //check for message
if (message == "65 2 2 1 ffff ffff ffff")
{
Richtig ++;
goto Question2;
}
else
{ if (message == "65 2 3 1 ffff ffff ffff" || message == "65 2 4 1 ffff ffff ffff" || message == "65 2 5 1 ffff ffff ffff") /*65 2 4 1 ffff ffff ffff
65 2 3 1 ffff ffff ffff
65 2 5 1 ffff ffff fff */
{
goto Question2;
}
else
{
}
}
delay (90);
}
Question2:
myNextion.setComponentText("t0", "Question2");
myNextion.setComponentText("b0", "A1");
myNextion.setComponentText("b1", "A2");
myNextion.setComponentText("b2", "A3");
myNextion.setComponentText("b3", "A4");
for (int i = 0; i < 10000; i++)
{
delay(10);
String message = myNextion.listen(); //check for message
if (message == "65 2 4 1 ffff ffff ffff")
{
Richtig ++;
goto Question3;
}
else
{ if (message == "65 2 3 1 ffff ffff ffff" || message == "65 2 2 1 ffff ffff ffff" || message == "65 2 5 1 ffff ffff ffff") /*65 2 4 1 ffff ffff ffff
65 2 3 1 ffff ffff ffff
65 2 5 1 ffff ffff fff */
{
goto Question3;
}
else
{
}
}
delay (90);
}
Question3:
page3.show();
myNextion.setComponentText("t0", "Question3");
myNextion.setComponentText("b0", "A1");
myNextion.setComponentText("b1", "A2");
}