Skip to content

Commit 58820c8

Browse files
committed
add shr() and shl() function, fixed backlight on/off bug
* fixed bug on backlight on/off + add shr() and shl() function
1 parent 3700b2a commit 58820c8

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ turn on LCD backlight
5454
- BacklightOff()
5555
turn off LCD backlight
5656

57+
- shl()
58+
shift left screen
59+
60+
- shr()
61+
shift right screen
62+
63+
5764
## Demo
5865

5966
![](https://raw.githubusercontent.com/microbit-makecode-packages/i2cLCD1602/master/demo.jpg)

main.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace I2C_LCD1602 {
108108
* turn on LCD
109109
*/
110110
//% blockId="I2C_LCD1620_ON" block="turn on LCD"
111-
//% weight=80 blockGap=8
111+
//% weight=81 blockGap=8
112112
export function on(): void {
113113
cmd(0x0C)
114114
}
@@ -126,7 +126,7 @@ namespace I2C_LCD1602 {
126126
* clear all display content
127127
*/
128128
//% blockId="I2C_LCD1620_CLEAR" block="clear LCD"
129-
//% weight=75 blockGap=8
129+
//% weight=85 blockGap=8
130130
export function clear(): void {
131131
cmd(0x01)
132132
}
@@ -135,10 +135,10 @@ namespace I2C_LCD1602 {
135135
* turn on LCD backlight
136136
*/
137137
//% blockId="I2C_LCD1620_BACKLIGHT_ON" block="turn on backlight"
138-
//% weight=70 blockGap=8
138+
//% weight=71 blockGap=8
139139
export function BacklightOn(): void {
140140
BK = 8
141-
dat(0)
141+
cmd(0)
142142
}
143143

144144
/**
@@ -148,7 +148,24 @@ namespace I2C_LCD1602 {
148148
//% weight=70 blockGap=8
149149
export function BacklightOff(): void {
150150
BK = 0
151-
dat(0)
151+
cmd(0)
152152
}
153153

154+
/**
155+
* shift left
156+
*/
157+
//% blockId="I2C_LCD1620_SHL" block="Shift Left"
158+
//% weight=61 blockGap=8
159+
export function shl(): void {
160+
cmd(0x18)
161+
}
162+
163+
/**
164+
* shift right
165+
*/
166+
//% blockId="I2C_LCD1620_SHR" block="Shift Right"
167+
//% weight=60 blockGap=8
168+
export function shr(): void {
169+
cmd(0x1C)
170+
}
154171
}

pxt.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "i2cLCD1602",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "makecode I2C LCD1602 package for micro:bit",
55
"license": "MIT",
66
"dependencies": {

0 commit comments

Comments
 (0)