Start a new topic
Implemented

line command in arduino

How can draw a line (rectangle/circle/...) on the nextion screen from the arduino ide /

by sending an arduino command?


Hi What is the syntax to send a command to next ion from arduino ? For example to force to display the page 1 ?

Hi,


I have written the following code that works 100%. Just change your header class name: I my case it is PodFunctionsClass::


void PodFunctionsClass::SendHeader()

{

 Serial1.write(0xff);

 Serial1.write(0xff);

 Serial1.write(0xff);

}

void PodFunctionsClass::TOut(String value, String icon_name) {

 Serial1.flush();

 SendHeader();

 Serial1.print(icon_name);

 Serial1.write(0x22);

 Serial1.print(value);

 Serial1.write(0x22);

 SendHeader();

 Serial1.flush();

}

void PodFunctionsClass::StrOut(String outstr) {

 SendHeader();

 Serial1.print(outstr);

 SendHeader();

}

// used for pic no updates

// and valaues to be passed to the screen

void PodFunctionsClass::VOut(int val, String icon_name) {

 Serial1.flush();

 SendHeader();

 Serial1.print(icon_name);

 Serial1.print(val);

 SendHeader();

 Serial1.flush();

}


So, if you want to change the page to say page0 you just have to use:


StrOut("page page0");


I hope it help.

Hi,


I have tried to add a line by using "line 0, 0, 100, 100, RED" from the Instruction Input Area in Debug mode.


I have also used the following code sent from Arduino Maga2560 using the previous post functions:


void PodFunctionsClass::drawLine()

{

StrOut("page Home");

StrOut("fill 0, 0, 100, 30, RED");

delay(1000);

StrOut("line 0, 0, 100, 100, RED");

delay(1000);

StrOut("draw 10, 10, 100, 100, RED");

delay(1000);

}



This does not work. What am I doing wrong?


Regards


did you manage it?
i need to draw a line but the command did not work...

 

draw the line without the space after the comma ,


line 0, 0, 100, 100, RED

should be

line 0,0,100,100,RED


this is wrong in the instruction set page ;)

hello,

Thats work, great i have tried without any space ;).
Great help.
Do you know a way to save the draw so next time i return to a page can see it again?
Thanks,
Timóteo

 

I would save the string in arduino and if you receive the page signal from the display that it is now on this page you want, you send the draw again.

or you just look at the button which enters the page. if you receive this button signal send the draw.

That is the ideia, the problem is that when i use the command sendxy=1 and draw something using the thdra=1 and thc=YELLOW it only send to serial the first point of touch and not all the sequence.
Do you have any ideia how to do it in order to have all the trace?

 

I remove the spaces and it now works 100%. The "cirs 100,100,30,RED" is not so sharp on the screen as I would have liked it to be. I'd rather draw the pic in Visio, Word or even Power Point. I looks much better that way.


The drawback with this is that the picture takes up the background and gauges has to to placed over that exact spot (crop image) for every gauge - Am I doing it wrong? 

@Will

The nextion displays are 16-bit 565 color displays.  Things like lines and fonts do not have any smoothing functions (additional pixels in another color/shade of) on the Nextion that are found in Visio, Word etc on a comparatively powerful desktop computer.  Using photos will indeed look better but will chew up more resources. When you HMI ends up with too many photos and not enough resources for other things, You will discover the balance you need.


I am now reviewing all of the Feature Requests, this will take some time, patience please.

This is not a feature request

Login or Signup to post a comment