Start a new topic

Send command from basic

I have a 320x480 Nextion programmed with just a black blank screen from the editor and sd card.It does turn black.

From basic I used.

hserprint "cls"

hsersend 255

hsersend 255

hsersend 255

hserprint "draw 10,10,100,100,RED"

hsersend 255

hsersend 255

hsersend 255

What must I do in the editor to make the above work.ie draw a box or line or circle? There are no libraries for microchip pics.


GUI Commands are independent from component design

Not familiar with your PIC basic, but appears it should work.

Did you not upload to your MCU to test?

Thanks for replying.I flashed the pic with Great Cow Basic.standard serial setup-9600. . Nothing happened.I just set page 0 to black background/white foreground. RED is upper case but not a command? You say it should work. Is it as simple as my code or am I not doing something in the editor? Would the equivalent c or python code work? Is anything missing from the code like screen init or do I use debug and write rest and com_star then download to display through usb-ttl adaptor and maybe change default screen baud? Cheers.

Okay I found error in cls command

- requires 565 color number to clear screen to

- so use cls 0 for black

RED is defined in Nextion Instruction Set

All can be tested in Debug Simulator as

   cls 0

   draw 10,10,100,100,RED


Arduino C++ equiv assume Serial2 for Nextion RX/TX

-----------------------

void setup(void) {

   Serial2.begin(9600);

   Serial2.print("cls 0ÿÿÿ");

   Serial2.print("draw 10,10,100,100,REDÿÿÿ");

}


void loop() {

 

}

-------------------------


I think you forgot the ";"
I use Bascom basic compiler
'---------------macro--------------------------------------------------------
Macro Fin 'to end a tx sequence--------------------------
  Printbin &HFF ; &HFF ; &HFF
End Macro

Macro H22 ' to send " before or after a sentence---------
  Printbin &H22
End Macro

Macro Comma  'to send a , after a numeric value-----  '
  Printbin &H2C
End Macro

' draw a solid circle---------------------------------------------------------
Xw = 300
Yw = 100
Radius = 50
Print "cirs ";
Print Xw;
comma
Print Yw;
comma
Print Radius;
comma
Print "BLUE";
Fin

' draw a solid rectangle-----------------------------------------------------
Xw = 350
Yw = 250
Width = 50
Height = 50
Print "fill ";
Print Xw;
comma
Print Yw;
comma
Print Width;
comma
Print Height;
comma
Print Darkviolet;
Fin
'draw a  rectangle----------------------------------------------------------
Xw = 30
Yw = 35
X2w = 120
Y2w = 280
Print "draw ";
Print Xw;
comma
Print Yw;
comma
Print X2w;
comma
Print Y2w;
comma
Print "BLACK";
Fin

------------------------------------------

works well and fast !

Login or Signup to post a comment