Fix lib
This commit is contained in:
@@ -1,6 +1,26 @@
|
|||||||
import time,sys
|
#!/usr/bin/env python
|
||||||
from grove_rgb_lcd import lcd
|
#
|
||||||
|
# GrovePi Example for using the Grove - LCD RGB Backlight (http://www.seeedstudio.com/wiki/Grove_-_LCD_RGB_Backlight)
|
||||||
|
#
|
||||||
|
# The GrovePi connects the Raspberry Pi and Grove sensors. You can learn more about GrovePi here: http://www.dexterindustries.com/GrovePi
|
||||||
|
#
|
||||||
|
# Have a question about this example? Ask on the forums here: http://forum.dexterindustries.com/c/grovepi
|
||||||
|
#
|
||||||
|
# History
|
||||||
|
# ------------------------------------------------
|
||||||
|
# Author Date Comments
|
||||||
|
# Initial Authoring
|
||||||
|
# Karan 7 Jan 16 Library updated to add a function to update the text without erasing the screen
|
||||||
|
# Released under the MIT license (http://choosealicense.com/licenses/mit/).
|
||||||
|
# For more information see https://github.com/DexterInd/GrovePi/blob/master/LICENSE
|
||||||
|
|
||||||
|
#
|
||||||
|
# NOTE:
|
||||||
|
# Just supports setting the backlight colour, and
|
||||||
|
# putting a single string of text onto the display
|
||||||
|
# Doesn't support anything clever, cursors or anything
|
||||||
|
|
||||||
|
import time,sys
|
||||||
|
|
||||||
if sys.platform == 'uwp':
|
if sys.platform == 'uwp':
|
||||||
import winrt_smbus as smbus
|
import winrt_smbus as smbus
|
||||||
@@ -75,15 +95,28 @@ def setText_norefresh(text):
|
|||||||
count += 1
|
count += 1
|
||||||
bus.write_byte_data(DISPLAY_TEXT_ADDR,0x40,ord(c))
|
bus.write_byte_data(DISPLAY_TEXT_ADDR,0x40,ord(c))
|
||||||
|
|
||||||
|
# Create a custom character (from array of row patterns)
|
||||||
|
def create_char(location, pattern):
|
||||||
|
"""
|
||||||
|
Writes a bit pattern to LCD CGRAM
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
location -- integer, one of 8 slots (0-7)
|
||||||
|
pattern -- byte array containing the bit pattern, like as found at
|
||||||
|
https://omerk.github.io/lcdchargen/
|
||||||
|
"""
|
||||||
|
location &= 0x07 # Make sure location is 0-7
|
||||||
|
textCommand(0x40 | (location << 3))
|
||||||
|
bus.write_i2c_block_data(DISPLAY_TEXT_ADDR, 0x40, pattern)
|
||||||
|
|
||||||
# example code
|
# example code
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
setRGB(255, 255, 255)
|
setText("Hello world\nThis is an LCD test")
|
||||||
# Total time in seconds
|
setRGB(0,128,64)
|
||||||
total_seconds = 5 * 60
|
time.sleep(2)
|
||||||
|
for c in range(0,255):
|
||||||
while total_seconds >= 0:
|
setText_norefresh("Going to sleep in {}...".format(str(c)))
|
||||||
minutes = total_seconds // 60
|
setRGB(c,255-c,0)
|
||||||
seconds = total_seconds % 60
|
time.sleep(0.1)
|
||||||
setText(f"{minutes:02d}:{seconds:02d}")
|
setRGB(0,255,0)
|
||||||
time.sleep(1)
|
setText("Bye bye, this should wrap onto next line")
|
||||||
total_seconds -= 1
|
|
||||||
Reference in New Issue
Block a user