Rushtp #101.1 - Nextion Notes - Demonstration of Local Vs Global Attribute Variables

by Rushtp in Circuits > Microcontrollers

25 Views, 0 Favorites, 0 Comments

Rushtp #101.1 - Nextion Notes - Demonstration of Local Vs Global Attribute Variables

0a. Untitled-1.jpg
0a. IMG_0723.JPG

Background

Before we get into programming in Nextion Editor it is important to understand

how Local and Global settings affect the values of object variables when displayed pages

are changed or refreshed. So let’s set up a quick demonstration…


For the Nextion display case build: Rushtp #1 - Nextion 7” Display DIY Enclosure/Case : 12 Steps (with Pictures)

Supplies

  1. Nextion Editor (Download)
  2. Nextion Editor Guide
  3. Nextion Instruction set

Nextion Editor - Objects and Coding

2a. Untitled-2.jpg
1. Untitled-1.jpg

Create a new project "Demonstration of Local vs Global Attribute Variables.HMI" and add the following objects with the attributes and code listed below.

Running in Debug tap the Nr ++ button. Both the Local and Global values will increment by 1.

Now tap the Refresh page 0 button.

  1. The Local value will return to its default state (the one set by Attribute val = 0).
  2. The Global value will not change and will continue to be incremented when the Nr ++ button is tapped.

This is important because it ensures object values are retained when a display page is changed or refreshed. Without the Global setting object values would revert to their default values.

Note: The objects with yellow tags (n0) have a vscope set to local, while black tagged (n1) vscope are global.

b0

 Toolbox, Button, Attribute

	objname		b0
	vscope 		local
	font   		1
	txt    		Nr ++
	x      		250
	y      		125
	w      		80
	h      		30

 Event, Touch Release Event

 n0.val++

 n1.val++

t0

 Toolbox, Text, Attribute

	objname		t0
	vscope 		local
	font   		1
	txt    		Local
	x      		160
	y      		180
	w      		100
	h      		30
n0

 Toolbox, Number, Attribute

	objname		n0
	vscope 		local
	font   		1
	x      		263
	y      		180
	w      		60
	h      		30
t1

 Toolbox, Text, Attribute

	objname		t1
	vscope 		local
	font   		1
	txt    		Global
	x      		160
	y      		240
	w      		100
	h      		30

Note: object n1 has it’s vscope set to global

n1

 Toolbox, Number, Attribute

	objname		n1
	vscope 		global
	font   		1
	x      		263
	y      		240
	w      		60
	h      		30
b1

 Toolbox, Button, Attribute

	objname		b1
	vscope 		local
	font   		1
	txt    		Refresh page0
	txt_maxl	15
	x      		250
	y      		300
	w      		80
	h      		50

 Event, Touch Release Event

 page 0