first commit
This commit is contained in:
commit
a5a0434432
1126 changed files with 439481 additions and 0 deletions
47
Software/Python/grove_rgb_lcd/example.py
Normal file
47
Software/Python/grove_rgb_lcd/example.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# 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
|
||||
#
|
||||
'''
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi.
|
||||
Copyright (C) 2017 Dexter Industries
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
'''
|
||||
|
||||
from grove_rgb_lcd import *
|
||||
|
||||
setText("Hello world\nLCD test")
|
||||
setRGB(0,128,64)
|
||||
|
||||
# Slowly change the colors every 0.01 seconds.
|
||||
for c in range(0,255):
|
||||
setRGB(c,255-c,0)
|
||||
time.sleep(0.01)
|
||||
|
||||
setRGB(0,255,0)
|
||||
setText("Bye bye, this should wrap")
|
||||
194
Software/Python/grove_rgb_lcd/example2.py
Normal file
194
Software/Python/grove_rgb_lcd/example2.py
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# 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
|
||||
#
|
||||
'''
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi.
|
||||
Copyright (C) 2017 Dexter Industries
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
'''
|
||||
|
||||
from grove_rgb_lcd import *
|
||||
|
||||
import random
|
||||
|
||||
try:
|
||||
setRGB(0,255,0)
|
||||
|
||||
setText("Grove - LCD RGB Backlight")
|
||||
time.sleep(2)
|
||||
|
||||
setText("Hello World")
|
||||
time.sleep(2)
|
||||
|
||||
setText("Random colors")
|
||||
for i in range(0,51):
|
||||
setRGB(random.randint(0,255),random.randint(0,255),random.randint(0,255))
|
||||
time.sleep(.1)
|
||||
time.sleep(1)
|
||||
|
||||
# ascii char 255 is the cursor character
|
||||
setRGB(255,255,255)
|
||||
setText(chr(255)*32)
|
||||
time.sleep(2)
|
||||
|
||||
# typewriter
|
||||
setRGB(255,127,0)
|
||||
str = "Hello World"
|
||||
for i in range(0,12):
|
||||
setText(str[:i])
|
||||
time.sleep(.2)
|
||||
time.sleep(2)
|
||||
|
||||
setRGB(255,0,255)
|
||||
setText("1234567890ABCDEF1234567890ABCDEF")
|
||||
time.sleep(2)
|
||||
|
||||
setText("Long strings will be truncated at 32 chars")
|
||||
time.sleep(2)
|
||||
|
||||
setRGB(0,255,0)
|
||||
setText("Automatic word wrapping")
|
||||
time.sleep(2)
|
||||
|
||||
setText("Manual\nword wrapping")
|
||||
time.sleep(2)
|
||||
|
||||
setRGB(0,255,255)
|
||||
setText("ASCII printable and extended")
|
||||
time.sleep(2)
|
||||
|
||||
chars = ""
|
||||
for a in range(32,256):
|
||||
chars += chr(a)
|
||||
if len(chars) == 32:
|
||||
setText(chars)
|
||||
chars = ""
|
||||
time.sleep(2)
|
||||
|
||||
setRGB(0,255,0)
|
||||
setText("Solid colors")
|
||||
time.sleep(2)
|
||||
|
||||
setText("Red")
|
||||
setRGB(255,0,0)
|
||||
time.sleep(.5)
|
||||
|
||||
setText("Green")
|
||||
setRGB(0,255,0)
|
||||
time.sleep(.5)
|
||||
|
||||
setText("Blue")
|
||||
setRGB(0,0,255)
|
||||
time.sleep(.5)
|
||||
|
||||
setText("Yellow")
|
||||
setRGB(255,255,0)
|
||||
time.sleep(.5)
|
||||
|
||||
setText("Magenta")
|
||||
setRGB(255,0,255)
|
||||
time.sleep(.5)
|
||||
|
||||
setText("Cyan")
|
||||
setRGB(0,255,255)
|
||||
time.sleep(.5)
|
||||
|
||||
setText("White")
|
||||
setRGB(255,255,255)
|
||||
time.sleep(.5)
|
||||
|
||||
setText("Black")
|
||||
setRGB(0,0,0)
|
||||
time.sleep(.5)
|
||||
|
||||
setText("Grey")
|
||||
setRGB(127,127,127)
|
||||
time.sleep(.5)
|
||||
|
||||
setRGB(255,255,255)
|
||||
setText("Alphanumeric characters")
|
||||
time.sleep(2)
|
||||
|
||||
setText("1234567890ABCDEF1234567890ABCDEF")
|
||||
time.sleep(2)
|
||||
|
||||
setText("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
time.sleep(2)
|
||||
|
||||
setText("abcdefghijklmnopqrstuvwxyz")
|
||||
time.sleep(2)
|
||||
|
||||
setText("1234567890")
|
||||
time.sleep(2)
|
||||
|
||||
setText("Shades of red")
|
||||
for c in range(0,255):
|
||||
setRGB(255,255-c,255-c)
|
||||
time.sleep(.01)
|
||||
|
||||
setText("Shades of green")
|
||||
for c in range(0,255):
|
||||
setRGB(255-c,255,255-c)
|
||||
time.sleep(.01)
|
||||
|
||||
setText("Shades of blue")
|
||||
for c in range(0,255):
|
||||
setRGB(255-c,255-c,255)
|
||||
time.sleep(.01)
|
||||
|
||||
setText("Shades of yellow")
|
||||
for c in range(0,255):
|
||||
setRGB(255,255,255-c)
|
||||
time.sleep(.01)
|
||||
|
||||
setText("Shades of magenta")
|
||||
for c in range(0,255):
|
||||
setRGB(255,255-c,255)
|
||||
time.sleep(.01)
|
||||
|
||||
setText("Shades of cyan")
|
||||
for c in range(0,255):
|
||||
setRGB(255-c,255,255)
|
||||
time.sleep(.01)
|
||||
|
||||
setText("Shades of grey")
|
||||
for c in range(0,255):
|
||||
setRGB(c,c,c)
|
||||
time.sleep(.01)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
setText("KeyboardInterrupt")
|
||||
setRGB(255,0,0)
|
||||
except IOError:
|
||||
setText("IOError")
|
||||
setRGB(255,0,0)
|
||||
|
||||
time.sleep(1)
|
||||
setText("All done")
|
||||
setRGB(0,255,0)
|
||||
46
Software/Python/grove_rgb_lcd/example3.py
Normal file
46
Software/Python/grove_rgb_lcd/example3.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# GrovePi Example for using the Grove - LCD RGB Backlight without erasing the screen(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
|
||||
#
|
||||
'''
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi.
|
||||
Copyright (C) 2017 Dexter Industries
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
'''
|
||||
from grove_rgb_lcd import *
|
||||
import time
|
||||
|
||||
setRGB(0,255,0)
|
||||
buf=list("Grove -Update without erase")
|
||||
setText("".join(buf))
|
||||
time.sleep(1)
|
||||
|
||||
for i in range(len(buf)):
|
||||
buf[i]="."
|
||||
setText_norefresh("".join(buf))
|
||||
time.sleep(.1)
|
||||
122
Software/Python/grove_rgb_lcd/grove_rgb_lcd.py
Normal file
122
Software/Python/grove_rgb_lcd/grove_rgb_lcd.py
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# 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':
|
||||
import winrt_smbus as smbus
|
||||
bus = smbus.SMBus(1)
|
||||
else:
|
||||
import smbus
|
||||
import RPi.GPIO as GPIO
|
||||
rev = GPIO.RPI_REVISION
|
||||
if rev == 2 or rev == 3:
|
||||
bus = smbus.SMBus(1)
|
||||
else:
|
||||
bus = smbus.SMBus(0)
|
||||
|
||||
# this device has two I2C addresses
|
||||
DISPLAY_RGB_ADDR = 0x62
|
||||
DISPLAY_TEXT_ADDR = 0x3e
|
||||
|
||||
# set backlight to (R,G,B) (values from 0..255 for each)
|
||||
def setRGB(r,g,b):
|
||||
bus.write_byte_data(DISPLAY_RGB_ADDR,0,0)
|
||||
bus.write_byte_data(DISPLAY_RGB_ADDR,1,0)
|
||||
bus.write_byte_data(DISPLAY_RGB_ADDR,0x08,0xaa)
|
||||
bus.write_byte_data(DISPLAY_RGB_ADDR,4,r)
|
||||
bus.write_byte_data(DISPLAY_RGB_ADDR,3,g)
|
||||
bus.write_byte_data(DISPLAY_RGB_ADDR,2,b)
|
||||
|
||||
# send command to display (no need for external use)
|
||||
def textCommand(cmd):
|
||||
bus.write_byte_data(DISPLAY_TEXT_ADDR,0x80,cmd)
|
||||
|
||||
# set display text \n for second line(or auto wrap)
|
||||
def setText(text):
|
||||
textCommand(0x01) # clear display
|
||||
time.sleep(.05)
|
||||
textCommand(0x08 | 0x04) # display on, no cursor
|
||||
textCommand(0x28) # 2 lines
|
||||
time.sleep(.05)
|
||||
count = 0
|
||||
row = 0
|
||||
for c in text:
|
||||
if c == '\n' or count == 16:
|
||||
count = 0
|
||||
row += 1
|
||||
if row == 2:
|
||||
break
|
||||
textCommand(0xc0)
|
||||
if c == '\n':
|
||||
continue
|
||||
count += 1
|
||||
bus.write_byte_data(DISPLAY_TEXT_ADDR,0x40,ord(c))
|
||||
|
||||
#Update the display without erasing the display
|
||||
def setText_norefresh(text):
|
||||
textCommand(0x02) # return home
|
||||
time.sleep(.05)
|
||||
textCommand(0x08 | 0x04) # display on, no cursor
|
||||
textCommand(0x28) # 2 lines
|
||||
time.sleep(.05)
|
||||
count = 0
|
||||
row = 0
|
||||
while len(text) < 32: #clears the rest of the screen
|
||||
text += ' '
|
||||
for c in text:
|
||||
if c == '\n' or count == 16:
|
||||
count = 0
|
||||
row += 1
|
||||
if row == 2:
|
||||
break
|
||||
textCommand(0xc0)
|
||||
if c == '\n':
|
||||
continue
|
||||
count += 1
|
||||
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
|
||||
if __name__=="__main__":
|
||||
setText("Hello world\nThis is an LCD test")
|
||||
setRGB(0,128,64)
|
||||
time.sleep(2)
|
||||
for c in range(0,255):
|
||||
setText_norefresh("Going to sleep in {}...".format(str(c)))
|
||||
setRGB(c,255-c,0)
|
||||
time.sleep(0.1)
|
||||
setRGB(0,255,0)
|
||||
setText("Bye bye, this should wrap onto next line")
|
||||
Loading…
Add table
Add a link
Reference in a new issue