99 */
1010//% weight=100 color=#0fbc11 icon="▀"
1111namespace I2C_LCD1602 {
12-
1312 let i2cAddr : number // 0x3F: PCF8574A, 0x27: PCF8574
1413 let BK : number // backlight control
1514 let RS : number // command/data
@@ -44,11 +43,11 @@ namespace I2C_LCD1602 {
4443 }
4544
4645 /**
47- * initial LCD, set I2C address. Default is 39/63 for PCF8574/PCF8574A
46+ * initial LCD, set I2C address. Address is 39/63 for PCF8574/PCF8574A
4847 * @param Addr is i2c address for LCD, eg: 39, 63
4948 */
50- //% help=functions/show-number
51- //% block
49+ //% blockId="I2C_LCD1620_SET_ADDRESS" block="LCD initialize with Address %addr"
50+ //% weight=100 blockGap=8
5251 export function LcdInit ( Addr : number ) {
5352 i2cAddr = Addr
5453 BK = 8
@@ -71,7 +70,8 @@ namespace I2C_LCD1602 {
7170 * @param x is LCD column position, eg: 0
7271 * @param y is LCD row position, eg: 0
7372 */
74- //% block
73+ //% blockId="I2C_LCD1620_SHOW_NUMBER" block="show number %n|at x %x|y %y"
74+ //% weight=90 blockGap=8
7575 export function ShowNumber ( n : number , x : number , y : number ) : void {
7676 let s = n . toString ( )
7777 ShowString ( s , x , y )
@@ -83,7 +83,8 @@ namespace I2C_LCD1602 {
8383 * @param x is LCD column position, [0 - 15], eg: 0
8484 * @param y is LCD row position, [0 - 1], eg: 0
8585 */
86- //% block
86+ //% blockId="I2C_LCD1620_SHOW_STRING" block="show string %s|at x %x|y %y"
87+ //% weight=90 blockGap=8
8788 export function ShowString ( s : string , x : number , y : number ) : void {
8889 let a : number
8990
@@ -102,31 +103,35 @@ namespace I2C_LCD1602 {
102103 /**
103104 * turn on LCD
104105 */
105- //% block
106- export function LcdOn ( ) : void {
106+ //% blockId="I2C_LCD1620_ON" block="turn on LCD"
107+ //% weight=80 blockGap=8
108+ export function on ( ) : void {
107109 cmd ( 0x0C )
108110 }
109111
110112 /**
111113 * turn off LCD
112114 */
113- //% block
114- export function LcdOff ( ) : void {
115+ //% blockId="I2C_LCD1620_OFF" block="turn off LCD"
116+ //% weight=80 blockGap=8
117+ export function off ( ) : void {
115118 cmd ( 0x08 )
116119 }
117120
118121 /**
119122 * clear all display content
120123 */
121- //% block
122- export function LcdClear ( ) : void {
124+ //% blockId="I2C_LCD1620_CLEAR" block="clear LCD"
125+ //% weight=75 blockGap=8
126+ export function clear ( ) : void {
123127 cmd ( 0x01 )
124128 }
125129
126130 /**
127131 * turn on LCD backlight
128132 */
129- //% block
133+ //% blockId="I2C_LCD1620_BACKLIGHT_ON" block="turn on backlight"
134+ //% weight=70 blockGap=8
130135 export function BacklightOn ( ) : void {
131136 BK = 8
132137 dat ( 0 )
@@ -135,7 +140,8 @@ namespace I2C_LCD1602 {
135140 /**
136141 * turn off LCD backlight
137142 */
138- //% block
143+ //% blockId="I2C_LCD1620_BACKLIGHT_OFF" block="turn off backlight"
144+ //% weight=70 blockGap=8
139145 export function BacklightOff ( ) : void {
140146 BK = 0
141147 dat ( 0 )
0 commit comments