Skip to content

Commit c0a4ee7

Browse files
author
Pete Lewis
committed
created serial splash example code
1 parent 4c1bfc1 commit c0a4ee7

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
OpenLCD is an LCD with serial/I2C/SPI interfaces.
3+
By: Nathan Seidle, Pete Lewis
4+
SparkFun Electronics
5+
Date: 7/26/2018
6+
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
7+
8+
OpenLCD gives the user multiple interfaces (serial, I2C, and SPI) to control an LCD. SerLCD was the original
9+
serial LCD from SparkFun that ran on the PIC 16F88 with only a serial interface and limited feature set.
10+
This is an updated serial LCD.
11+
12+
This example shows how to change the Splash Screen contents. We assume the module is currently at default 9600bps.
13+
14+
We use software serial because if OpenLCD is attached to an Arduino's hardware serial port during bootloading
15+
it can cause problems for both devices.
16+
17+
Note: If OpenLCD gets into an unknown state or you otherwise can't communicate with it send 18 (0x12 or ctrl+r)
18+
at 9600 baud while the splash screen is active and the unit will reset to 9600 baud.
19+
20+
Emergency reset: If you get OpenLCD stuck into an unknown baud rate, unknown I2C address, etc, there is a
21+
safety mechanism built-in. Tie the RX pin to ground and power up OpenLCD. You should see the splash screen
22+
then "System reset Power cycle me" and the backlight will begin to blink. Now power down OpenLCD and remove
23+
the RX/GND jumper. OpenLCD is now reset to 9600bps with a I2C address of 0x72. Note: This feature can be
24+
disabled if necessary. See *Ignore Emergency Reset* for more information.
25+
26+
To get this code to work, attached an OpenLCD to an Arduino Uno using the following pins:
27+
RX (OpenLCD) to Pin 7 (Arduino)
28+
VIN to 5V
29+
GND to GND
30+
31+
Command cheat sheet:
32+
ASCII / DEC / HEX
33+
'|' / 124 / 0x7C - Put into setting mode
34+
Ctrl+c / 3 / 0x03 - Change width to 20
35+
Ctrl+d / 4 / 0x04 - Change width to 16
36+
Ctrl+e / 5 / 0x05 - Change lines to 4
37+
Ctrl+f / 6 / 0x06 - Change lines to 2
38+
Ctrl+g / 7 / 0x07 - Change lines to 1
39+
Ctrl+h / 8 / 0x08 - Software reset of the system
40+
Ctrl+i / 9 / 0x09 - Enable/disable splash screen
41+
Ctrl+j / 10 / 0x0A - Save currently displayed text as splash
42+
Ctrl+k / 11 / 0x0B - Change baud to 2400bps
43+
Ctrl+l / 12 / 0x0C - Change baud to 4800bps
44+
Ctrl+m / 13 / 0x0D - Change baud to 9600bps
45+
Ctrl+n / 14 / 0x0E - Change baud to 14400bps
46+
Ctrl+o / 15 / 0x0F - Change baud to 19200bps
47+
Ctrl+p / 16 / 0x10 - Change baud to 38400bps
48+
Ctrl+q / 17 / 0x11 - Change baud to 57600bps
49+
Ctrl+r / 18 / 0x12 - Change baud to 115200bps
50+
Ctrl+s / 19 / 0x13 - Change baud to 230400bps
51+
Ctrl+t / 20 / 0x14 - Change baud to 460800bps
52+
Ctrl+u / 21 / 0x15 - Change baud to 921600bps
53+
Ctrl+v / 22 / 0x16 - Change baud to 1000000bps
54+
Ctrl+w / 23 / 0x17 - Change baud to 1200bps
55+
Ctrl+x / 24 / 0x18 - Change the contrast. Follow Ctrl+x with number 0 to 255. 120 is default.
56+
Ctrl+y / 25 / 0x19 - Change the TWI address. Follow Ctrl+x with number 0 to 255. 114 (0x72) is default.
57+
Ctrl+z / 26 / 0x1A - Enable/disable ignore RX pin on startup (ignore emergency reset)
58+
'-' / 45 / 0x2D - Clear display. Move cursor to home position.
59+
/ 128-157 / 0x80-0x9D - Set the primary backlight brightness. 128 = Off, 157 = 100%.
60+
/ 158-187 / 0x9E-0xBB - Set the green backlight brightness. 158 = Off, 187 = 100%.
61+
/ 188-217 / 0xBC-0xD9 - Set the blue backlight brightness. 188 = Off, 217 = 100%.
62+
63+
For example, to change the baud rate to 115200 send 124 followed by 18.
64+
65+
*/
66+
67+
#include <SoftwareSerial.h>
68+
69+
SoftwareSerial OpenLCD(6, 7); //RX (not used), TX
70+
71+
void setup()
72+
{
73+
Serial.begin(9600); //Begin local communication for debug statements
74+
75+
OpenLCD.begin(9600); //Begin communication with OpenLCD
76+
77+
delay(1000);
78+
79+
OpenLCD.write('|'); //Put LCD into setting mode
80+
OpenLCD.write('-'); // clear screen
81+
82+
delay(1000);
83+
84+
OpenLCD.print("Custom Splash Looking good!"); // Send our new content to display - this will soon become our new splash screen.
85+
86+
OpenLCD.write('|'); //Put LCD into setting mode
87+
OpenLCD.write(10); //Set current contents to splash screen memory (this is also a "ctrl-j", if you are doing it manually)
88+
89+
}
90+
91+
void loop()
92+
{
93+
// nothing here, just doing this example in setup()
94+
}
95+

0 commit comments

Comments
 (0)