Anyone Used Nextion Displays?

techElder

Well-known member
That's great. Hopefully these displays will withstand the test of time and market conditions.

I'm a little reticent about offloading too much to the display processor, but hopefully we'll be blessed with more and better of these types of displays.
 

lbenson

Senior Member
Nextion Editor Overview

Ok, I make no claim for the aesthetics of layout, image choice, or colors, but this is lightning round work.

I now have three pages, and navigation between them in the simulator is smooth. This first image shows the Nextion Editor/Simulator. In the center is the project being simulated, the first page.
i1.jpg

The window on the upper left shows the objects which you can place on a page. So far I've used Text, Button, and Radio Button. Below that is the window of images, sized for my screen, 320x240 pixels. On the bottom is a window where you can put the commands which your picaxe would send to the Nextion. Partially contracted to the right of that are windows which show the messages sent to your picaxe.

The top window on the left shows the pages which are in your project. You write code, either on the Nextion or with the picaxe, or both, to navigate between the pages.

The lower right window shows what attributes are available to be set for the page object. For Page1 I've set the background to be an image, and the image to be the 4th one in the project. Most of the other objects have many more attributes, like x and y coordinates, in pixels, and width and height.

This shows the three pages.
3pages.jpg

Only the third page connects to the picaxe at present.

I've included details about the Nextion editor to give some idea of how easy and fun it is to work with. Real what-you-see-is-what-you-get screen building, and imminently picaxeable.
 

cachomachine

Senior Member
You can make your text transparent by choosing crop image (and choosing the same immage as your background) in your text attribute window
Example.jpg
 

lbenson

Senior Member
Ah, so that's what that "crop image" object is for. Thanks cachomachine. I wonder why the Nextion forum thread about the need for a transparent background didn't mention that--maybe they figured it had been well covered in other discussions (or perhaps I missed it).

You just saved me a good bit of time--I was going to look for a program which could easily crop a (for instance) 320x240 pixel image given x & y coordinates and width and height.
 

lbenson

Senior Member
Ah, so that's what that "crop image" object is for
Or rather, that's what the "crop image" value for the "sta" attribute in the text object is for--making the object background an image cropped from the image you select.
Page1off.jpg
That means that if you change the background image (for instance, in my case, by clicking HEAT), you need to change the image the cropped background is from also. For instance

"t6.picc=2"
Page1x4.jpg
 
Last edited:

techElder

Well-known member
Got the editor to see how much I can learn, too.

One thing I've found in trying this "transparency" trick is that it doesn't work on a solid background; and only on pictures that are "full-screen."

Since it doesn't work on solid background colored screens, it means that if you change color of the background you would have to go to each "transparent" component and change the background color there as well.
 

techElder

Well-known member
Also, be careful in your programming that if you reference a component "ID", be aware that if you delete a component the display will renumber all the rest of the components so they are all again in sequence.

Your ID reference might just be pointing to a different component.

This editor is not very mature, yet.
 

lbenson

Senior Member
... if you delete a component the display will renumber all the rest of the components so they are all again in sequence.
It renumbers the object IDs, but doesn't change the component name, so if you refer to the objects by name instead of object number, you will be OK.
 

lbenson

Senior Member
... the x and y positions of the button could be changed by the picaxe or MCU (or by code running on the Nextion)
What I said above is apparently not true. I found this in a Feature Request thread: "an HMI object can not be moved across the screen, its x, y, w, and h are permanent once defined in the HMI and no attempt at changing this during runtime will succeed. Hard coded"
 

techElder

Well-known member
I've learned that you can hide/unhide and set values from the MCU (PICAXE.)

So, you could toggle overlapping button's visibility with "vis b0,1" and "vis b1,0" and vice versa to get button's in the same space that perform different tasks.

Maybe the button's perform the same action, but you wanted to move their x,y positions. Hide and unhide different buttons in different x,y locations.
 

lbenson

Senior Member
@cachomachine,

I see that on the Nextion forum "Example Keyboard" thread you got some, uhh, less than generous replies. Did you find a good Nextion keyboard object (if "object" it is)?
 

lbenson

Senior Member
SHE LIVES!

FirstLight1.jpg

Ok, the picaxe is a kludge--14M2 plugged into an 08M2 board because I didn't have a 14M2 board free.

The 2.4 inch OLED looks sharp--better than the photo. Background image changes in about a second (no picaxe involvement). Changing the min/max settings is near-instantaneous with the touch screen--plus and minus results appear in less than a second, and the same with moving from one min/max variable to the next--this involves a message from the Nextion to the picaxe, and a command from the picaxe to the Nextion. Even with this small size oled, the buttons are useable.

All in all, performs as advertised, giving the picaxe a snappy, visually pleasing touch screen interface with a editor/simulator which makes development a breeze.

Obviously, there is tedious work to be done to set up a complex interface, but it is satisfying to see it come together bit by bit, and the result is highly satisfactory.
 
Last edited:

cachomachine

Senior Member
Well, the Itead studio moderator did not liked the fact that i asked twice for the keyboard HMI but they gave me enough to build mine.
Keyboard.jpg
Again the HMI size is too big ( 4mo) for the forum so i will have to find another way to make it available.
 

johnlong

Senior Member
Hi Ibenson, cachomachine
Just a quick question at the begining of both your codes
you both have a block of data for the eeprom can you let me know
what it is for
Is it for the display to function correctly
Have created 5 pages and uploaded them to the display opening and closing looping from 1to the other
nicely
Having probs uploading the images at the mo
Just another quick question can the display cause an interupt on the picaxe
ie press button picaxe picks it up on say A.5 (40x2) in slot 1
inacts on it and goes to slot0 (as I have at the moment via push button)
regards
john
 

cachomachine

Senior Member
The block of data at in my program is not for the Nextion display but for the onboard ds3231 real time clock.
Not sure about your second question. Nextion display communicates with the Picaxe with serout and serin on 2 different pins so it should create an interrupt everytime.
 

lbenson

Senior Member
In my case, the "Table" command provides the names of the variables which I want the Nextion to be able to update. The eeprom/data statement provides the initial values of those variables.

The "enhanced" nextion displays have i/o pins available, so in theory you could run a separate wire to a picaxe interrupt pin. I would question the need to do this, though--in a tight loop with no pauses, you can look for "commands" generated by the Nextion at the rate of a good many times a second (depending on what else you are doing, of course). Where this is important you need to design your program so that it gives the attention needed to the demands of responsive interaction with a human.
 

stan74

Senior Member
I bought a nextion 320x480,flashed a sd card demo and that was it. Has any one tried using plot to plot say read adc and display on the screen with for x=o to screen width:plot adcval:next or out like that.NOT the graph/scroll which looks slow. I bin too busy to bother with it. If I was a multi tasking octopus I wouldn't have enough tentacles or time to try all the stuff I buy from ebay. Any info would be interesting for me. I only got 1 cos I thought the graphics would be fast but now I program normal displays faster
 

johnlong

Senior Member
Morning
Stan74 Cachomachine in post #55 code shows the connection of the nextion via the 14m2 attached to a rtc clock and reading and displaying a temp sensor and Ibenson code shows the button press capture look at his section under the lable main
I myself have just started playing with it and I am very impressed with the screens image
web.jpgweb2.jpg

The images are 2 of the 5 that are loaded onto the display so will be looking at the retrival of the generated data side of things in the next couple of days
I like the look of using a select case like Ibenson has used (just need to cleem from him what "!") as I have seperated the diffrent attachments to diffrent pages.
The images where produced using Inkscape
My approch to the nextion is the up and dwn keys update the nextion variables then the enter key sends the information of the variable to the Picaxe (hopefully)
To do this the the number boxes are nextion tool number123 on your left hand side of the editor in the attributes on the right handside click the sta button and select crop image just use the same image as your back ground (via the green picc) this works for number and text fields however it does not for the buttons you need to create buttons the size you want (as the editor trys to fill the button with the whole pic)
then add them as pic
here is the my test code running on the picaxe
Code:
dirsC=%00000010
symbol nxout=C.1
symbol nxin=C.0
symbol nxbaud=T9600_8
symbol vT=b3
symbol vH=b4
symbol hour =b5
symbol mins=b6
symbol heaton=b7
symbol fan=b8
symbol dehumon=b9
symbol humon=b10
symbol date=b11
symbol month=w10
symbol day=b13
symbol year=w23
symbol AM=b15
symbol td=b16
symbol sd=b17
symbol vtd=b18
debug

main:
Vt=28:vH=73:hour=23:mins=55:date=23:year=2017:vtd=25

do


			Serout nxout, nxbaud, (" page main")
			Gosub ff
			Serout nxout, nxbaud, ("temp.val=",#vTd)
			gosub ff
			Serout nxout, nxbaud, ("setc.val=",#vT)
			gosub ff
			Serout nxout, nxbaud, ("rh.val=",#vH)
			gosub ff
			Serout nxout, nxbaud, ("dt.val=",#date)
			gosub ff
			Serout nxout, nxbaud, ("yr.val=",#year)
			gosub ff
			Serout nxout, nxbaud, ("setrh.val=",#vH)
			gosub ff
			Serout nxout, nxbaud, ("hr.val=",#hour)
			gosub ff
			Serout nxout, nxbaud, ("mn.val=",#mins)
			gosub ff
			Serout nxout, nxbaud, ("ht.txt=",34,"OFF",34)
			gosub ff
			Serout nxout, nxbaud, ("cf.txt=",34,"ON",34)
			gosub ff
			Serout nxout, nxbaud, ("dhm.txt=",34,"OFF",34)
			gosub ff
			Serout nxout, nxbaud, ("hm.txt=",34,"OFF",34)
			gosub ff
			Serout nxout, nxbaud, ("usb.txt=",34,"ON",34)
			gosub ff
			Serout nxout, nxbaud, ("mode.txt=",34,"Manual",34)
			gosub ff
			Serout nxout, nxbaud, ("dy.txt=",34,"Sunday",34)
			gosub ff
			Serout nxout, nxbaud, ("mth.txt=",34,"September",34)
			gosub ff
			Serout nxout, nxbaud, ("am.txt=",34,"AM",34)
			gosub ff
			Serout nxout, nxbaud, ("st.txt=",34,"rd",34)
			gosub ff
			inc vtd
			if vtd=101 then
				vtd=1
				endif
			pause 5000
			Serout nxout, nxbaud, ("am.txt=",34,"PM",34)
			gosub ff
		
			debug
loop


ff:			Serout nxout, nxbaud, ($FF,$FF,$FF)
			Return
hope this helps

regards
john
 

lbenson

Senior Member
Johnlong,

In my code posted above, and with my practice in general with the Nextion on M2 picaxes, the "!" character returned by the Nextion in response to a user action (e.g., button press) is purely arbitrary as the first character of a 2-charactor command, as is "#" as the first character of a 2-byte command advising of a page number change. I code this command sequence in the Button Release Event (or other appropriate place) on the Nextion side, (e.g., with 'print "!1"' or'print "!A"').

These commands are decoded with SELECT statements within SELECT statements.

I use the 2-byte commands because I was already comfortable using 2-byte serial background receive on the M2 devices for prior projects where asynchronous user input was expected. I ignore anything else which the Nextion sends (which could get me into trouble but hasn't so far).

In the case where the user needs to send more than 2 bytes (for instance, when a numeric value is entered), I program the Nextion to send a 2-byte code and then immediately the desired text (e.g., "!^", with 'print "!^"' and 'print tVal.txt'); the picaxe goes into serin upon receipt of "!^" and gets the sent text. The text must be of a known length for SERIN to work (and can be padded with spaces on the Nextion side to achieve this length). If there's a chance that the picaxe might be too busy to receive the text immediately, a timer could be set on the Nextion side and the text sent at its expiration). You could also code it so that whenever the picaxe receives the "!^" command, just before it goes into SERIN it sends the 'print tVal.txt' command to the Nextion--that might be safest.

It would also be possible to get text of arbitrary length by using hserin until a specified termination character is received.

Other than using images, I have not done anything with the Nextion's graphics capabilities.
 
Last edited:

johnlong

Senior Member
Hi Ibenson
If you have the time can you explain the serin and serout a bit more
I understand it as if I send a command to the nextion it will respond with a susiquent command
ie 0x70 as such
I coded the nextion as follows on pressing the enter key it coded as follows print page 3 print v0.val
this is just an example of 1 of the function.
So if I code the nextion with
print "!#" followed by
print page 2
print v1.val
I can then translate this as
serin nxpin,nxbaud b1,b2,b3
will this give me b1=!# (heyup incomming)
b2=2 (its from page 2 goto page 2 selection)
b3= v1's value (b12 val=v1 val)
Just another quick question the x2's have a hint setup function could this be used to create an interrupt
ie if B.3 quite no command sent and B.2 gets a tickle (hint2)
sets an interrupt goes to slot0 and wait commands
regards
john
 

lbenson

Senior Member
john, I ignore everything the Nextion sends except for the commands I am looking for (which I have coded on the nextion, in, for instance, the button release section). If my initial hserin receives a value which is not "!" or "#", I just loop around and try the next hserin (having done anything else the picaxe might want to do in the master loop).

I would not do 'print "page 2"' on the nextion side. Unless you have more than, say, 62 nextion actions which you want the picaxe to respond to ("!*", where "*" can be any upper case or lower case letter or "0"-"9") your program should be able to assume that the nextion is on the page where you coded the command which was sent (some exceptions are possible).

If you do have more than 62 commands, but less than 62 per page, keep track in the picaxe program of which page you are on (when a page is loaded, I have the nextion send, for instance, "#0" to tell the picaxe that it is now on page 0--the picaxe then responds to set up page 0 as necessary). Then you can respond with the appropriate code for the particular command for that page.

So for instance, if you know that the text which will be sent to you is six characters long, contained in v1.txt (so I would convert to ascii and pad any numeric values), your code would be something like this.
Code:
#picaxe 14m2
symbol pNextionIn  = C.1
symbol pNextionOut = C.2
symbol nextion_baud_rate  = T9600_16
Setfreq M16

main:
  do
    b1 = $ff ' invalid
    hserin b1 ' if no bytes ready, no change
    if b1 = "!" or b1 = "#" then ' valid command
      pause 50 ' allow 2nd character to arrive, if need be
      hserin b2 
    endif
    select b1
      case "#"   ' page change -- add a "select b2"
      case "!"   ' command
        select b2
          case "0"   ' respond somehow
          case "1"   ' respond somehow
          case "^"   ' nextion requesting to send 6 characters
            Serout pNextionOut, nextion_baud_rate, ("print v1.txt",$FF,$FF,$FF)
            serin  pNextionIn, nextion_baud_rate,b22,b23,b24,b25,b26,b27
            sertxd(b22,b23,b24,b25,b26,b27,cr,lf)
        end select
    end select
  loop
You can put the received text into upper ram by replacing the serin with this (m2)
bptr = 28 ' above m2 named variables
serin pNextionIn, nextion_baud_rate,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc

I haven't tested this specific code (it passes syntax), but this is how I would do it.
 
Last edited:

fernando_g

Senior Member
The product description on Amazon is a work of art;

". It is the best solution to replace the traditional LCD and LED Nixie tube.
"

.
Ouch! you touched a sensitive nerve.
There is something with the glow quality of a Nixie, that simply can't be replicated with an LCD display.
True, Nixies are fragile, expensive and require high voltages, but that is part of their appeal.
 

johnlong

Senior Member
Hi All
being having another look at the nextion and using the duel state button function but found that when I left the page
the setting selected prior to leaving would revert back to its original state tried alsort no head way so contacted the nextion forum
and Patrick responded with the following which adds a clear insite into the workings of the unit

Patricks response
a dual-state button can have two pictures associated with the button

- setting .sta to image gives the options for .pic0 and .pic1

- setting .pic0 in Editor and select image for 0 state

- setting .pic1 in Editor and select image for 1 state


In operation, press will turn on or off depending on previous state

- this is handled automatically and can be read by bt0.val


Now there is no Nextion side code required

- such is merely getting in your way. Remove.


The issue of changing pages and expecting all to be the same on re-entry

- this you need to understand


Each Nextion page in your HMI design is like a mini program

- when you change to an alternate page

the Preinitialization Event from new loading page is run

then the old page is dumped from memory to make room for new

then the new loading page is loaded into memory

(this is loaded static as per the way you designed it in HMI design)

then the Postinitialization Event from new loading page is run


When you want something to persist across page changes

- you must do with a global variable Nextion side

handle storing to temp location in Preinitialization Event

handle restoring from temp location in PostInitialization Event

- or you can have your MCU track which page user is on

sending bt0.val=1ÿÿÿ or bt0.val=0ÿÿÿ depending on actual MCU side value

- or you can even set .vscope of your dual-state button to global


Dual-states will present a challenge MCU side as

- is Nextion in control and therefore state of bt0.val is authority

- then on page change, your MCU must adjust to its value

(an example of Nextion in control is

bt0 toggles high/low of GPIO pins on enhanced models)

- if your MCU is in control, then regardless of the state of bt0.val

- your MCU must make change to bt0 to reflect actual state.

Sometimes dual-state maybe the wrong component for task


Regardless, you must choose for your design of which controls

and what method you will use for it to persist - then implement.


I am less certain that you are attempting to dynamically change

the picture set for the 0/1 state of the dual-state

But if you wanted to

bt0.pic0=4ÿÿÿ and bt0.pic1=5ÿÿÿ would select new pictures.

back to me
interesting that each page is like a mini program
So by writing in the postInisalize section of the page
the following
bt0.val=bt0.val
bt1.val=bt1.val
bt2.val=bt2.val
bt3.val=bt3.val
and making there respective vscopes global
the image on leaving and returning remains as you set them no need to reissue commands
tested and working with the 40x2 and the display
regards
john
 

lbenson

Senior Member
I don't understand how setting something equal to itself can change nextion behavior, but if it works for you ....

For the sake of clarity, I would be inclined to establish separate global variables, e.g., vBt0, vBt1, etc. Then when the state changes, vBt0.val=bt0.val.

Then upon page initialization (e.g., moving to a new page or returning), set the button state: bt0.val=vBt0.val, etc.

If what you are doing works, this would make no functional difference--it would just (to me) make clearer what you are doing.
 

oracacle

Senior Member
I have just gotten myself a couple of the 2.4" of these and have been seeing if I can move an older project menu display over to it. As I have been looking through some of the material I found that there are some mighty handy things that can be done.

I was having difficulties getting some information to display, so had a bit of reads here and noticed that ibenson had $22 between the comma and speech marks in a serial transmission which iirc = "", replacing $22 with "" does not have the same affect so was wondering if someone can enlighten me to there function - the code doesn't work without them and I cant find a reference else were.

This code changes the text in a button called light - it switches a torch on and off

#no_data
#no_table

Rich (BB code):
#no_data
#no_table

main:
      if b4 = $70 then
            inc b3
                  if bit0 = 0 then
                  let bit0 = 1
                  serout c.4, t9600, ("light.txt=",$22,"Light On",$22,$FF,$FF,$FF)
            else
                  let bit0 = 0
                  serout c.4, t9600, ("light.txt=",$22,"Light Off",$22,$FF,$FF,$FF)
            end if
            debug
      end if
      serin b.7, t9600,b4,b5,b6,b7,b8,b9,b10
      goto main
 
Last edited by a moderator:

MartinM57

Moderator
$22 is the hex code for a double quote character i.e. a single "

The complete Nextion command you want the Nextion to receive is:
light.txt="Light On" followed by three $FF characters
i.e the text value is surrounded by double quote characters

...which is exactly what your serout statement does...
Code:
serout c.4, t9600, ("light.txt=",$22,"Light On",$22,$FF,$FF,$FF)
If you used just..
Code:
serout c.4, t9600, ("light.txt=","Light On",$FF,$FF,$FF)
then the Nextion would receive
light.txt=Light On followed by three $FF characters
...which the Nextion would treat as invalid (and probably just do nothing) as there are no quotes around the text value
 

hippy

Senior Member
One option for handling quotes ($22), making it easier to specify what one wants to do without the complexity of remembering how to get it right, is to use macros, for example -

Code:
#Macro SetText( obj, txt )
  SerOut C.4, T9600, ( obj,".txt=",$22,txt,$22, $FF,$FF,$FF )
#EndMacro

SetText( "light", "Light On" )
If one selects Options, Diagnostics and ticks the Pre-processor, 'Display pre-processor output' option one can see what the actual code generated will be when the code is Syntax Checked.
 

oracacle

Senior Member
https://www.youtube.com/watch?v=_-R5tJMuRQA&feature=youtu.be

So have been making some progress. I have been looking at porting an older project over (maybe to a bigger variant when money allows).

displaying ADC values

Code:
#no_data
#no_table
'setfreq m16

symbol dis_in     	= c.7
symbol dis_out    	= c.6
symbol baud 		= T9600
#terminal 9600
init:
	pause 1000
	hsersetup b9600_8, %00000001
	hserout 0, ("page ","1",$FF,$FF,$FF)
	'hserin 0, 4
	hserptr = 0
	setintflags %00100000,%00100000

main:
	'serin c.7, t9600,b4,b5,b6,b7
	'sertxd (#b4,44,#b5,44,#b6,44,#b7,13,10)
	'need to look for page 10
	if b4 = 102 and b5 = 10 then
		high b.7

		readadc 0, b8
		hserout 0, ("sensor1.val=",#b8,$FF,$FF,$FF)
		let w6 = b8 *10 *4 /100
		let b8 = w6
		hserout 0, ("bar1.val=",#b8,$FF,$FF,$FF)
		
		readadc 1, b10
		hserout 0, ("sensor2.val=",#b10,$FF,$FF,$FF)
		let w6 = b10 *10 *4 /100
		let b10 = w6
		hserout 0, ("bar2.val=",#b10,$FF,$FF,$FF)
		low b.7
	end if
	
	goto main
	
interrupt:
      flags = 0
	setintflags off
	get 0, b4, b5, b6, b7
	sertxd (#b4,44,#b5,44,#b6,44,#b7,13,10)
	if b4 = 0X71 then
		sertxd ("value:",44,#b5,13,10)
		let b4 = 102
		let b5 = 10
	end if
	hserptr = 0
	setintflags %00100000,%00100000
	return
This work but could do with some more work, it could also cause issues down the line. The programme makes use of an interrupt so that the display can be update and the slider at the bottom be adjusted during update - not a problem in its self, but the project makes use of comparator interrupt. Think it maybe a case of trying to put them in different programme slots and setting the interrupt at the very top of each slot.

Now that I have most of the menus setup in the display I am going to start laying down some code to make it stick together and actually work.
 

johnlong

Senior Member
Hi oracale
as an interupt with my nextion connected to a 40x2 I use if hserptr<>0 then as an interupt across the 4 program slots
it works like a charm
If you intened to use pictures or images on your display a nice tip is when you creat a new page put your intended image for the page in the
pages picc then any image like buttons sliders you can use the crop image and your page image as its back drop
then when you add buttons so forth they then show the back ground through rather than a solid block covering the image
If using multiple like components like buttons set the first one up the copy paste if you do that. Then if you deside to delete
a button it will automatically renumber the whole lot saves loads of work
I have mine altering the settings of a 1307 to change the clock at will and alter the values of 4 set points and 4 pins on the chip
I used slot 0 as a menu for the settings and clock and determining which funtion to use auto or manual override slots 1 and 2
with slot 3 for sensor initilisation day file write and calander up date (time updated in running slot)
just because im a freek I terminate every nextion command with code_c in the nextion which clears the buffer
Just 1 more point look on there forum for the spellings correction error page as alot of the manual like the if statements are
wrong missing = signs ect
have fun with it stick in loads of images mines upto 5meg at the moment with the help and error pages
regards
john
 

oracacle

Senior Member
hmm, the hserptr trick is handy.
Although pictures look cool, they aren't really applicable. Part of the idea is to make things easier and pictures will just clutter things up.

While I'm here though I do have a question about the background serial receive, is the limit of the number of byte that can be received at one time the size of the scratch pad? I am looking at getting the display to do the basics of increasing and decreasing number and sending them back to the picaxe. The problem arises when you press accept it would send the number and then the page that is being loaded with all the stop byte etc. it will just receive then looking for the 3 stop bit would allow one to find the beginning of the next transmitted data, there would also be a requirement to determine when data was no longer being transmitted as well I think.

I hope that makes sense, it maybe the better part of week before I get to look at it again due to work

I haven't found anything that has stumped too much in the instruction set
this is run when the progress bar page is loaded so the slider returns to it previous value
Code:
if(slid.val==0)
{
  slid.val=h0.val*8
  n0.val=slid.val
}else
{
  h0.val=slid.val/8
  n0.val=slid.val
}
basic but does the job
 

johnlong

Senior Member
Hi
I would have thourght the size of the scratchpad is the limiting factor as its size is its size
but you are talking to a base 10 guy who struggles with the + - / * operators
I took Ibensons adivice in the earlier post in this thread and let the picaxe do the work
so all that comes from the nextion say for upping a value is (in the nextion pressed event)
print A+ (sent to picaxe) picaxe responds hserout ("nex.text="","#picval") loads of $ff,s
putting the termination in a gosub save the fingers plus I have found that that also means
that you dont need to employ any pauses
I just then used a bit of kidology when you hit the enter button on the the nextion alters the text fields colour (no action from pic)
making it look like you have done something
Like Ibenson said one master big stick
A good tip to help stopping getting confussed when dealing with multiple variables is give them all your chosen picaxe variable names
just stick an N in front then you know whats going where I think there is a limit to the size of the renaming in the Nextion but I only use
short abreviasions anyway being displexic long words are a drag anyway so in my code I use vT value tempreture in Nex nvt
I do fancy though having a play with your slider code above
regards
j
 

MartinM57

Moderator
Seems a good design (and many ways to skin a cat, allegedly) although personally, I would probably let the Nextion do all the variable incrementing locally, then send the final value to the PICAXE for storage/processing when the user selects "enter" and let the PICAXE send back the text field colour changes so that:
- I suspect the user interface will be slightly quicker
- even though the user won't realise, you will know that the round trip of the final value to the PICAXE worked OK if the colours change correctly
- the PICAXE doesn't get involved with local changes being done on the Nextion, and may be doing other stuff (or allow other stuff to be done) at the same time.

I suppose offloading the work to the PICAXE might have some advantages in that if you wanted to change to increment by 2 each time, then it's just a PICAXE code change rather than a Nextion update, which is a bit of a PITA and takes quite a long time for non-trivial Nextion-side setups ;)
 

johnlong

Senior Member
Hi
your right reprogramming the Nex is a pain if you have encapusated it in a project box or such an extension lead
into the sd card would be nice are they such things? I think I will Google that
I have found that when I come out of the slot thats running back to the main menu page has no effect on the on / off state
of the pins (the leds indicating pin state remain in current state) but what effect that has such things as reading the sensors
and updating the scratchpad soforth may well be effected . But I can except a lost data point as I only read the sensors once
every minute to the tempary store and when it returns from the menu it go's through the read before the time delay so worst case you lose 1 data write
or inc it by 1 the main data storeage is the result of 20 minute readings
so for this aplication a dip in or out effect is minimul
regards
john
 

techElder

Well-known member
You'll be better off in the long run to treat the Nextion like any other display that you would use. Use it for a display and not for a processor. It will be a much smarter display with many more ways to display your data, but when it comes to your data manipulation use the PICAXE.

Its tempting to be drawn into some of the features that they have programmed into it, but eventually you will find out that it is much easier to re-program changes in the PICAXE.

Now, having said that, there could possibly be some advantage in using the long integer capability. :D

Of course, IMHO and YMMV.
 
Top