Difference between revisions of "Grove LCD RGB Backlight 16x2"

From Teknologisk videncenter
Jump to: navigation, search
m
m (Eksempel på funktionalitet)
 
Line 5: Line 5:
 
*[[Media:AiP31068.pdf| LCD Display control chip]]
 
*[[Media:AiP31068.pdf| LCD Display control chip]]
 
=Eksempel på funktionalitet=
 
=Eksempel på funktionalitet=
 +
==Display chip==
 
<source lang=bash>
 
<source lang=bash>
 
#!/bin/bash
 
#!/bin/bash
Line 50: Line 51:
 
i2cset -y 2 0x3e 0x40 0x67
 
i2cset -y 2 0x3e 0x40 0x67
 
</source>
 
</source>
 
+
==RGB chip==
 +
<source lang=bash>
 +
#!/bin/bash
 +
#LED chip adresse 0x62
 +
#LEDOT register 0x08
 +
#to bit pr. LED
 +
#00 00 00 00
 +
#Set 00 00 00 01
 +
#Sleep mode off
 +
i2cset -y 2 0x62 0x0 0x0
 +
i2cset -y 2 0x62 0x8 0x10 # RED
 +
sleep 1
 +
i2cset -y 2 0x62 0x8 0x01 # BLUE
 +
sleep 1
 +
i2cset -y 2 0x62 0x8 0x04 # GREEN
 +
sleep 1
 +
i2cset -y 2 0x62 0x8 0x15 # RGB = White (Sort of)
 +
</source>
 
[[category:Grove]][[Category:I2C]]
 
[[category:Grove]][[Category:I2C]]

Latest revision as of 07:33, 11 April 2024

LCD with RGB Backlight

Links

Eksempel på funktionalitet

Display chip

#!/bin/bash
# Hex codes found with
#  echo Viborg | od -x --endian=big
#  0000000 5669 626f 7267 0a00


# i2cset -y <i2cBUS> <i2cADDRESS> <Control Byte> <Data byte>
#  Control byte bits Co RS 0 0   0 0 0 0 ( 0x80 = Co, 0x40 = RS, 0xc0 = Co and RS)
#    Co:  0 = Last Control Byte - 1 = Another Control Byte follows
#    RS:  0 = Following data byte is a command - 1 = following data byte is data
#Function set 0010 1000 // 2 line mode and 5x8
i2cset -y 2 0x3e 0x00 0x28
#Display on/off control 0000 1110 // Diplay on cursor on blink off
i2cset -y 2 0x3e 0x00 0x0D
#Display clear
i2cset -y 2 0x3e 0x00 0x01
#Entry mode set 0000 0110
i2cset -y 2 0x3e 0x00 0x06
#i2cset -y 2 0x3e 0x20 0x06
#i2cset -y 2 0x3e 0x8 0x06
i2cset -y 2 0x3e 0x00 0x02
# 1xxx xxxx = set DDRAM adress = 1000 0000 to 1011 1111
#  first line (1000 0000 to 1000 1111 possible on 16 characters line) = 0x80 to 0x8f
#  second  line (1100 0000 to 1100 1111 possible on 16 characters line) = 0xC0 to 0xCf
i2cset -y 2 0x3e 0x00 0x84 # 5th character on line 1
#Display Mercantec
i2cset -y 2 0x3e 0x40 0x4d
i2cset -y 2 0x3e 0x40 0x65
i2cset -y 2 0x3e 0x40 0x72
i2cset -y 2 0x3e 0x40 0x63
i2cset -y 2 0x3e 0x40 0x61
i2cset -y 2 0x3e 0x40 0x6e
i2cset -y 2 0x3e 0x40 0x74
i2cset -y 2 0x3e 0x40 0x65
i2cset -y 2 0x3e 0x40 0x63
#Display Viborg in middle of second line
i2cset -y 2 0x3e 0x00 0xC5 # 5th character on line 2
i2cset -y 2 0x3e 0x40 0x56
i2cset -y 2 0x3e 0x40 0x69
i2cset -y 2 0x3e 0x40 0x62
i2cset -y 2 0x3e 0x40 0x6f
i2cset -y 2 0x3e 0x40 0x72
i2cset -y 2 0x3e 0x40 0x67

RGB chip

#!/bin/bash
 #LED chip adresse 0x62
 #LEDOT register 0x08
 #to bit pr. LED
 #00 00 00 00
 #Set 00 00 00 01
 #Sleep mode off
i2cset -y 2 0x62 0x0 0x0
i2cset -y 2 0x62 0x8 0x10 # RED
sleep 1
i2cset -y 2 0x62 0x8 0x01 # BLUE
sleep 1
i2cset -y 2 0x62 0x8 0x04 # GREEN
sleep 1
i2cset -y 2 0x62 0x8 0x15 # RGB = White (Sort of)