Start a new topic

Does "ref 0" mean "current page" or page #0 ?

This command "ref 0" was described (and still it is in nextion tutorials) as refreshing "current page"   whatever it is. I use it this way in my code.

Now I see the instruction page says that "ref 0" refreshes page #0

Now it does not imply "any current page" any more. Was this changed in subsequent versions?

If so, older tutorials are wrong now and I have to change code for a current version.

Please clarify.


It looks like ref 0 still refreshes the components on the current page.
Funny is that vis 255,0 hides the components on the current page.
vis 0,0 gives an error :)

 

vis 255,0 (where 255 is caught to branch to a segment of code for all components) versus

vis 0,0 (which is to hide ID 0 or the current page as all pages have ID of 0) renders a skipped component, and thus all following components (items on the page) do not have a need reference boundary of where on "the page" they are suppose to start.   Pages do not need to actually fill their screens, this is only a default setting, so knowing page left + offset of component on page - becomes critical and faults if the page component has been skipped.


As for the Ref 0, you are indeed correct, is the current page.  As pages have ID 0 then ref 0 is to refresh the actual Page Component with ID 0 (which its routine subsequently sequentially refreshes all other components until the end of Components is reached or until another page is encountered).

I am very sorry, my intention was to ask about "page 0" rather than "ref 0" . Not component's refreshment but page' . (that was for late night mess in mind...)
To correctly read my question: does "page 0" update "page #0" or whatever current page is ?
This command is described as "current page" in tutorials but now the instruction set man pages describe as "page #0" which means NOT any current page..
Please somebody clarify.
Sorry again

 

Sot instruction set saying
page 0         //Refresh page 0

should be saying "refresh whatever current page is" . It will be "0" page only in case if it is "currently active" - is it right?

Thank you Patrick - indeed now it is clear.
Now why did I need much of your time to explain this ? Because read Nextion Instruction set again:
page 0         //Refresh page 0
As wording goes, It unambiguously implies that "page 0" will refresh "page 0" (not a string name but ID number), "page 1" will refresh "page 1" , etc...... Yet, as per your explanation ALL pages have ID=0 therefore above comment should have read "refresh current page" whatever it is not necessarily page 0... This is creating  confusion through documentation and then you try hard to straighten it out as if the problem is a stupid user.
But I appreciate your efforts anyway, thank you

 

And the last point to help is who is creating the software, who is doing the technical translation and who is the one needing to use it.  And the software starts in Chinese, which needs to be understood well by the person doing the translations for documenting it into English.  This translator may not always have the most firmest grasp on the super technical side effects or implications of the command, maybe their weren't shown every aspect of its limited flexibility.  Then we as users need to actually use that information for doing our highly technical project - and the implications of the translations have side effects on our projects that we were not expecting.  Maybe if the documentation was being done by actual users that have used all of the possible iterations, who understand the importance that someone needs to rely on the information that is being written ... maybe then there would be less confusion surrounding commands and how to use them, or better explanations and less ambiguity.

You know what, for the sake of other people reading all of this.  It is noteworthy and my OCD is kicking in.


The Nextion Instruction Set should NOT read  page 0 //Refresh page 0  and maybe this is why my OCD is in overdrive.  Having not used these words previously, I will state:


  • The primary function of the page command is to change pages.  The Nextion Instruction Set fails to properly describe for the page command.  There is a slight difference between the page commands numeric and string arguments not addressed.  Changing pages to the current page MAY include calling PreInitialize and Post Initialize events that the ref command MIGHT NOT.
  • The primary function of the ref command is to refresh components.  A page is also a component.  There is no mention in the Ref 0 section that item 0 is always the current page, but that item 1 is the first component added to that current page and may be completely different.  While the primary purpose of ref is to update a value that is not always auto-updated (these are green attributes in the Editor that need updating, where bold green attributes are auto-updating)
  • there has never been a technical spec that stated that ref will call PreInitialize or PostInitialize Events and but the page command most definitely does.  But calling the page command calls and runs the contents of PreInitialize Events, then sets all components back to their HMI designed state, and then runs the contents of the Postinitialize Events.  It is here that globals have to be addressed with so much effort or the contents are lost -- and that is why page should NOT BE being referred to as a refresh and implying the same as ref.


So while this has little bearing on a simple project, it will definitely screw up a more detailed project, and leave the users either wondering why it fails, or it crimps the user from using the commands for what the translator did not properly describe or include.  The description of the page command most definitely negated to mention anything surrounding the order of loading and its consequences when calling page 0.


If I had a slider, and I make a change not auto-updated, I want to be specific to ref h0 and not having my  globals interfered with by what was in the HMI defaults before the program was running.


Does this make sense.  Thumbs are fingers, but not all fingers are thumbs. Therefore page does some ref  but not all ref are page.




@Patrick, are you sure about that? On my device and in my debugger the command page 0 works exactly as the command page PageName It exchange the current page for page 0, it does not update the current page. It looks like page Id's are different then component Id's.

I'm using this as when you reset the Arduino the Arduino does not know the state the Nextion is in. So I sent the command page 0 to get it back in the splash screen. Maybe the next generation of Nextions should be equipped with a reset connection. To remotely reset the Nextion is either by a relay or mosfet or by using the reset on the programming interface J2 (yuck) 

Thank you Edwin.  =)  So for certain the Nextion Instruction Set currently does not properly describe the page command and should not be introducing ambiguity.  So there was indeed a reason the OCD was kicking in last night and my insanity wasn't groundless without cause and for naught.


I certainly reserve using page for the purposes of changing pages, and ref for the purposes of refreshing an individual component.  In the interest of accuracy for now, I have removed the posts that are in question and I will hunt down the version of the Editor for which it had held true.  Perhaps it was the introduced behaviour of a bug that has since been changed.


The forum certainly could use an edit function to fix a small erroneous part rather than having to redo the entire post and there really needs to be a section that can contain more detailed and accurate information rather than skimming a million pages for what may be correct and not.  Thank again

Patrick, all your sophistication into "why instruction set must not be understood according to it's face value" is not needed... you could simply responded to my question in 3rd post "yes" - that my understanding is correct but instruction page is wrong... keep it simple...
 I personally don;t care about how mess happens - don;t waste your time on "who is to blame"... we are not judging here but learning to use good tool... drop the ego and be constructive.
Thank you

 

I'll be clear on why I try and spend the time to write longer more detailed answers, and it most certainly wasn't to waste my time on ego. I found it harder to learn what I needed from threads with short responses but no explanation, I am certainly not the only one.  The net is filled with short responses and no answers, so when I try to give back here, it is for the 100 users that arrive later looking for an answer because they may have a similar problem.  So am I perfect, hell no - I am only human.


1 person likes this
@Edwin  Now after overhaul of my 2,000 lines code I run test and found out that you are right - my old way to refresh current page using "page 0" (as Patrick explain it should work ) does not work any more - as you say - it switches to page #0 !
I need to refresh whole screen at the end of the loop...I tried to make refresh with statically maintained current page # like "page current-page-ID"  - also does not work pages are flipping unpredictably ... hard to debug as my code is large and many calls to Nextion... something was changed in this last version...
Please Let me know if you find how to refresh current page
Thanks
Vlad

 

> Please Let me know if you find how to refresh current page


REF 0


From the MCU you can get the current page with the sendme command that returns: 0X66+Page ID+End
From within the Nextion I think that you need a global variable to keep track of the page it's on (by setting it to the page Id in the page initialize event) as there is no system variable that contains that value.
I think that a system variable that returns the current page is a candidate for a feature request,so that page currentPage would have the same effect from the MCU as from within the Nextion.

 

Login or Signup to post a comment