Sorry, new guy here. Could you let me know if I'm in the right forum
I have been coding for many years and have worked through numerous examples. I am really happy with the Easy Nextion Library. However, for the life of me, I can't seem to figure out how to draw a simple line using the library. I have been trying to find examples for a few days.
Nextion displays this command: "line 20,30,170,200,BLUE".
I don't want to use this (I know it works)
Serial1.print("line 20,37,270,300,BLUE");
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
Thanks for any help
xfpd
August 18, 2023, 4:38am
2
harleyguy:
Nextion displays this command: "line 20,30,170,200,BLUE"
https://nextion.tech/instruction-set/
Well, well, well....
Just send it as a s tring to Nextion (along with 0xFF 0xFF 0xFF) and it parses it does the job! Need to keep an eye which page you're on as it draws on the current one.
I now down vote the Nextion documentation. If it's there its too hard to find. If it isn't it should be.
Hello nibcorrea,
Welcome.
Please can you read How to get the most out of this forum before you make another post.
Try
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
Serial.println(__FILE__);
delay(2000);
Serial1.print("line 20,37,270,300,BLUE");
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
Serial.print("Done");
}
void loop() {
}
This is for the Nextion on serial port 1, please modify to suit the port you are using.
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
Serial.println(__FILE__);
delay(2000);
Serial1.print("line 20,37,270,300,BLUE");
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
Serial.print("Done");
}
void loop() {
}
Thanks but i have read the documentation. And the other threads. And that code works. But as i noted above i don't want to use Serial1.print.
My question is how do i use the Easy Nextion. Library to send the command.
Pseudo example:
myNex.writeStr("t0.txt", "line 20,30,170,200,BLUE");
The above only prints line 20,30,170,200,BLUE as text.
b707
August 18, 2023, 7:04am
4
But why?
It seems to me that it is a easiest way to do what you want.
1 Like
I prefer to avoid employing the Serial.print
method, as its implementation spans four lines of code.
Alternatively, a more refined approach could involve the creation of a dedicated function:
void Foo(String message);
Foo("line 20, 30, 170, 200, BLUE");
void Foo(String message)
{
Serial.print(message);
Serial.write(0xFF);
Serial.write(0xFF);
Serial.write(0xFF);
}
Nevertheless, it is worth noting that the Easy Nextion Library offers an integrated solution for this particular functionality:
myNex.writeStr("line 20, 30, 170, 200, BLUE");
Any way I found my answer note the one liner above.
Thanks for your help guys.
system
Closed
February 14, 2024, 7:42am
6
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.