I have been looking through the examples supplied with the 2.7 release.
Here is an extract from example 2
:
def runExample():
print("\nSparkFun Qwiic SerLCD Example 2\n")
myLCD = qwiic_serlcd.QwiicSerlcd()
if myLCD.connected == False:
print("The Qwiic SerLCD device isn't connected to the system. Please check your connection", \
file=sys.stderr)
return
myLCD.setBacklight(255, 255, 255) # Set backlight to bright white
myLCD.setContrast(5) # set contrast. Lower to 0 for higher contrast.
time.sleep(1) # give a sec for system messages to complete
while True:
myLCD.setBacklight(0, 0, 0) # black is off
myLCD.clearScreen() # Clear the display - this moves the cursor to home position as well
myLCD.print("Black (off)")
time.sleep(5)
myLCD.setBacklight(255, 0, 0) # bright red
myLCD.clearScreen()
myLCD.print("Red")
time.sleep(5)
myLCD.setBacklight(0xFF, 0x8C, 0x00) # orange
myLCD.clearScreen()
myLCD.print("Orange")
time.sleep(5)
Ok, nothing too nasty looking there.
But then when I run that… Eeeeew! The screen colours and the names!
Nothing to do with one another. Weird.
So. Let’s not dwell on that.
I’ll keep going through the examples:
Here’s a bit from example 13
:
def runExample():
print("\nSparkFun Qwiic SerLCD Example 13\n")
print("\nType CTRL+C to end.\n")
myLCD = qwiic_serlcd.QwiicSerlcd()
if myLCD.connected == False:
print("The Qwiic SerLCD device isn't connected to the system. Please check your connection", \
file=sys.stderr)
return
myLCD.setContrast(5) # set contrast. Lower to 0 for higher contrast.
myLCD.begin() # call this for default settings (no
myLCD.leftToRight()
myLCD.noCursor()
time.sleep(1) # give a sec for system messages to complete
while True:
myLCD.setFastBacklight(255, 0, 0) # bright red
myLCD.clearScreen()
myLCD.print("Red")
time.sleep(1)
myLCD.setFastBacklight(0xFF, 0x8C, 0x00) # orange
myLCD.clearScreen()
myLCD.print("Orange")
time.sleep(1)
When I run that, it works.
I get a RED screen and an ORANGE screen.
They alternate quite happily and the colours match the name on the screen.
(Of course I have skipped a few examples here this time around)
So, what’s going on I wonder?
How can I know the difference between the
myLCD.setBacklight(
and the myLCD.setFastBacklight(
commands?
It just seems weird that there is/are two examples of how to change the back light and one works, and the other … well. Kinda does, but doesn’t. (Opposite association to the names)
Ok. So I sit down and write a script in python. (EITHER VERSION)
Given the back light is … anything but red.
from __future__ import print_function
import qwiic_serlcd
import time
import sys
myLCD = qwiic_serlcd.QwiicSerlcd()
Then I enter:
myLCD.setBacklight(255, 0, 0)
All things being good
Anarchy! MULTIPLE colours.
Now, let’s dissect that part: I send a command to set the RGB values to 255,0,0. Yet! I see multiple - as in NOT singular - colours on the screen.
Bah! I don’t know. I’m not a rocket scientist.
Let’s try the other one.
(Getting the screen back to semblance of order)
I then type in:
myLCD.setFastBacklight(255, 0, 0)
MAGIC!
Wow! The screen is red.
ONE colour to another. ONE change.
No made colour changes.
Why?
What is this command and why is it not better documented?
Beats me, but I will search.
I have lost 3 days researching this and found it was obscured away in the THRITEENTH example file which was for the deprecated version of python, which I by accident installed.
Had I installed the version 3.7 originally I am sure I would still be lost.
It isn’t your fault or anything like that.
It is just - as I said earlier - a single / simple piece of paper with the display with a link to the python scripts would have made this whole thing non existent.
Or even on the web page a link: This is some python code to talk to this display.