Easy Nextion Library: Just want to draw a line

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

https://nextion.tech/instruction-set/

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.

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.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.