10000 ex16 working · sparkfun/qwiic_serlcd_py@b58e76f · GitHub
[go: up one dir, main page]

Skip to content

Commit b58e76f

Browse files
author
Pete Lewis
committed
ex16 working
1 parent f93fb64 commit b58e76f

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env python
2+
#-----------------------------------------------------------------------------
3+
# ex16_qwiic_serlcd_set_splash.py
4+
#
5+
# This sketch demonstrates how to create your own custom splash screen.
6+
#
7+
# This is done by first writing the text you want as your splash to the display,
8+
# then 'saving' it as a splash screen.
9+
#
10+
# You can also disable or enable the displaying of the splash screen.
11+
#
12+
# Note - The disableSplash() and enableSplash() commands
13+
# are only supported on SerLCD v1.2 and above. But you can still use the
14+
# toggle splash command (Ctrl+i) to enable/disable the splash.
15+
#
16+
#------------------------------------------------------------------------
17+
#
18+
# Written by SparkFun Electronics, August 2020
19+
#
20+
# Originally written for the Arduino Library by Nathan Seidle 2/16/2019
21+
#
22+
# Ported to this python example by Pete Lewis 8/18/2020
23+
#
24+
# Ported from Arduino Library code with many contributions from
25+
# Gaston Williams - August 29, 2018
26+
#
27+
# This python library supports the SparkFun Electroncis qwiic
28+
# qwiic sensor/board ecosystem on a Raspberry Pi (and compatable) single
29+
# board computers.
30+
#
31+
# More information on qwiic is at https://www.sparkfun.com/qwiic
32+
#
33+
# Do you like this library? Help support SparkFun. Buy a board!
34+
#
35+
#==================================================================================
36+
# Copyright (c) 2020 SparkFun Electronics
37+
#
38+
# Permission is hereby granted, free of charge, to any person obtaining a copy
39+
# of this software and associated documentation files (the "Software"), to deal
40+
# in the Software without restriction, including without limitation the rights
41+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
42+
# copies of the Software, and to permit persons to whom the Software is
43+
# furnished to do so, subject to the following conditions:
44+
#
45+
# The above copyright notice and this permission notice shall be included in all
46+
# copies or substantial portions of the Software.
47+
#
48+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
49+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
50+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
51+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
52+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
53+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54+
# SOFTWARE.
55+
#==================================================================================
56+
# Example 16
57+
#
58+
59+
from __future__ import print_function
60+
import qwiic_serlcd
61+
import time
62+
import sys
63+
64+
def runExample():
65+
66+
print("\nSparkFun Qwiic SerLCD Example 16\n")
67+
print("\nType CTRL+C to end.\n")
68+
myLCD = qwiic_serlcd.QwiicSerlcd()
69+
70+
if myLCD.connected == False:
71+
print("The Qwiic SerLCD device isn't connected to the system. Please check your connection", \
72+
file=sys.stderr)
73+
return
74+
75+
myLCD.setBacklight(255, 255, 255) # bright white
76+
myLCD.setContrast(5) # set contrast. Lower to 0 for higher contrast.
77+
myLCD.begin() # call this for default settings (no
78+
myLCD.leftToRight()
79+
myLCD.noCursor()
80+
time.sleep(1) # give a sec for system messages to complete
81+
82+
myLCD.clearScreen()
83+
myLCD.print("Tea-O-Matic")
84+
time.sleep(1)
85+
86+
myLCD.saveSplash() # save this current text as the splash screen at next power up
87+
88+
myLCD.enableSplash() # This will cause the splash to be displayed at power on
89+
#myLCD.disableSplash() # This will supress the splash from being displayed at power on
90+
91+
counter = 0
92+
93+
myLCD.clearScreen()
94+
myLCD.print("Cups of tea: ")
95+
96+
while True:
97+
print("counter: %d" % counter)
98+
myLCD.setCursor(0,1)
99+
myLCD.print(str(counter))
100+
counter = counter + 1
101+
time.sleep(1)
102+
103+
if __name__ == '__main__':
104+
try:
105+
runExample()
106+
except (KeyboardInterrupt, SystemExit) as exErr:
107+
print("\nEnding Example 16")
108+
sys.exit(0)
109+
110+

0 commit comments

Comments
 (0)
0