Skip to content

Commit 87e81c1

Browse files
author
Pete Lewis
committed
cursor example update - baud to 9600 and more comments at top
The line numbers are a little strange, so I added in a few more examples showing how to do various cursor controls to line 2, 3 and 4.
1 parent 4160d4a commit 87e81c1

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

firmware/Examples/Serial/Example6_Serial_CursorPosition/Example6_Serial_CursorPosition.ino

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,54 @@
6666
6767
For example, to change the baud rate to 115200 send 124 followed by 18.
6868
69+
70+
*********************************************
71+
*****************Cursor position cheat sheet:
72+
*********************************************
73+
74+
For the most part, it is pretty straight forward on how to control the cursor.
75+
Be warned though, the "line" numbers are a little strange (0, 64, 20, 84).
76+
There are four "parts" to the two commands needed.
77+
78+
First, the command character (254), simply write this with:
79+
80+
OpenLCD.write(254);
81+
82+
Second, a single write that consists of adding up three important numbers.
83+
84+
OpenLCD.write(changePosition + line + position);
85+
86+
changePosition never changes (haha), it is the command for the serLCD to know we want to change position. It is always 128.
87+
88+
Then the "line" number is either 0, 64, 20 or 84.
89+
90+
These correspond to each line like so:
91+
92+
Line 1 = 0
93+
Line 2 = 64
94+
Line 3 = 20
95+
Line 4 = 84
96+
97+
Then the "position" is a number from 0-15 or 0-19 (depending on which screen you are using).
98+
99+
For the 16x2 models, you will only need to set line 1 or line 2, so here's an example:
100+
101+
Jump to line 1, position 9
102+
OpenLCD.write(254); //Send command character
103+
OpenLCD.write(128 + 64 + 9); //Change the position (128) of the cursor to 2nd row (64), position 9 (9)
104+
105+
On a 20x4 model, you can try all four lines. For example:
106+
107+
Jump to line 3, position 4
108+
OpenLCD.write(254); //Send command character
109+
OpenLCD.write(128 + 20 + 4); //Change the position (128) of the cursor to 3rd row (20), position 4 (4)
110+
111+
And another 20x4 example:
112+
113+
Jump to line 4, position 18
114+
OpenLCD.write(254); //Send command character
115+
OpenLCD.write(128 + 84 + 18); //Change the position (128) of the cursor to 4th line (84), position 18 (18)
116+
69117
*/
70118

71119
#include <SoftwareSerial.h>
@@ -79,7 +127,7 @@ void setup()
79127
Serial.begin(9600); //Start serial communication at 9600 for debug statements
80128
Serial.println("OpenLCD Example Code");
81129

82-
OpenLCD.begin(115200); //Begin communication with OpenLCD
130+
OpenLCD.begin(9600); //Begin communication with OpenLCD
83131

84132
//Send the reset command to the display - this forces the cursor to return to the beginning of the display
85133
OpenLCD.write('|'); //Send setting character

0 commit comments

Comments
 (0)