You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/community/p1/All/nextion_ez/README.md
+26-21
Original file line number
Diff line number
Diff line change
@@ -13,57 +13,63 @@ Full documentation on the Arduino Easy Nextion Library and protocol, as well as
13
13
14
14
If you find this library useful, please consider supporting the author of the original Easy Nextion Library, Thanasis Seitanis at: [[email protected]](https://paypal.me/seithan)
15
15
16
-
17
16
**NOTE**: `.HMI` files for Nextion Editor are also included in the demo folder.
18
17
19
18
## The public methods
20
19
-`start()`
21
20
-`writeNum()`
22
21
-`writeStr()`
22
+
-`writeByte()`
23
+
-`pushCmdArg()`
23
24
-`sendCmd()`
24
25
-`addWave()`
25
26
-`readNum()`
26
27
-`readStr()`
28
+
-`readByte()`
27
29
-`cmdAvail()`
28
30
-`getCmd()`
29
-
-`getSubCmd()`
30
-
-`readByte()`
31
+
-`getCmdLen()`
31
32
-`getCurrentPage()`
32
33
-`getLastPage()`
34
+
-`setCurrentPage()`
35
+
-`setLastPage()`
36
+
37
+
**NOTE** previous version had a `getSubCmd` method that exactly duplicated the functionality of `readByte`, it has been removed. If you used `getSubCmd` in your code, just replace it with `readByte`
33
38
34
39
In order for the object to update the Id of the current page, you must write the Preinitialize Event of every page: `printh 23 02 50 XX` , where `XX` the id of the page in HEX.
35
40
Your code can then read the current page and previous page using the `getCurrentPage()` and `getLastPage()` methods.
36
41
37
42
Standard Easy Nextion Library commands are sent from the Nextion display with `printh 23 02 54 XX` , where `XX` is the id for the command in HEX.
38
-
Your code should call the `listen()` method frequently to check for new commands from the display. You can then use the `getAvail`, `getCmd()` and `getSubCmd` methods to parse any commands.
43
+
Your code should call the `listen()` method frequently to check for new commands from the display. You can then use the `cmdAvail`, `getCmd()` and `readByte()` methods to parse any commands.
39
44
40
45
example:
41
-
```
42
-
PRI callCommand(_cmd) 'parse the 1st command byte and decide how to proceed
46
+
```spin
47
+
PUB main()
48
+
nextion.listen ' need to run this to check for incoming data from the Nextion
49
+
if nextion.cmdAvail > 0 ' has the nextion sent a command?
50
+
callCommand(nextion.getCmd) ' get the command byte and see parse it
51
+
52
+
PRI callCommand(_cmd) ' parse the 1st command byte and decide how to proceed
43
53
case _cmd
44
-
"T" : 'standard Easy Nextion Library commands start with "T"
45
-
nx_sub := nextion.getSubCmd ' so we need the second byte to know what function to call
46
-
callTrigger(nx_sub)
54
+
"T" : ' standard Easy Nextion Library commands start with "T"
55
+
callTrigger(readByte) ' so we need the second byte to know what function to call
56
+
' custom commands can be added by expanding this case statement
47
57
48
-
PRI callTrigger(_triggerId) 'use the 2nd command byte from nextion and call associated function
58
+
PRI callTrigger(_triggerId) ' use the 2nd command byte from nextion and call associated function
49
59
case _triggerId
50
60
$00 :
51
-
trigger00
61
+
trigger00 ' the orginal Arduino library uses numbered trigger functions
52
62
$01 :
53
63
trigger01
54
64
$02 :
55
-
trigger02
56
-
$03 :
57
-
trigger03
58
-
$04 :
59
-
trigger04
65
+
runCount ' but since we are parsing ourselves, we can call any method we want
60
66
```
61
67
62
68
**NOTE**: This Spin object requires the use of a custom version of FullDuplexSerial.spin called FullDuplexSerialAvail.spin that adds a function to return the number of bytes in the rx_buffer
63
69
64
70
**NOTE**: Spin on the Proppeller 1 chip has a limit of 64 of items in a case statement. For complexe Nextion systems use of custom commands in addition to the "T" command can be used to avoid this limit. Alternatively case statements can be nested inside another structure.
65
71
Example:
66
-
```
72
+
```spin
67
73
PRI callTrigger(_triggerId) 'use the 2nd command byte from nextion and call associated function
68
74
if _triggerId < $40
69
75
case _triggerId
@@ -116,10 +122,9 @@ A local Number component n0 on page1 can be accessed by page1.n0 or n0, but ther
116
122
117
123
118
124
## Compatibility
119
-
* Propeller (spin version in P1 folder)
120
-
* Propeller2 (spin2 version in P2 folder)
121
-
122
-
## Releases:
125
+
* Propeller (https://github.com/parallaxinc/propeller spin version in P1 folder)
126
+
* Propeller2 (https://github.com/parallaxinc/propeller spin2 version in P2 folder)
0 commit comments