4
4
* http://www.micropython.org.cn
5
5
*/
6
6
7
- //% weight=100 color=#0855AA icon="O" block="OLED12864 I2C "
7
+ //% weight=20 color=#0855AA icon="O" block="OLED12864_I2C "
8
8
namespace OLED12864_I2C {
9
9
let font : number [ ] = [ ] ;
10
10
font [ 0 ] = 0x0022d422 ;
@@ -185,6 +185,7 @@ namespace OLED12864_I2C {
185
185
*/
186
186
//% blockId="OLED12864_I2C_PIXEL" block="set pixel at x %x|y %y|color %color"
187
187
//% weight=70 blockGap=8
188
+ //% parts=OLED12864_I2C trackArgs=0
188
189
export function pixel ( x : number , y : number , color : number = 1 ) {
189
190
let page = y >> 3
190
191
let shift_page = y % 8
@@ -214,6 +215,7 @@ namespace OLED12864_I2C {
214
215
*/
215
216
//% blockId="OLED12864_I2C_SHOWSTRING" block="show string at x %x|y %y|text %s|color %color"
216
217
//% weight=80 blockGap=8
218
+ //% parts=OLED12864_I2C trackArgs=0
217
219
export function showString ( x : number , y : number , s : string , color : number = 1 ) {
218
220
let col = 0
219
221
let p = 0
@@ -250,6 +252,7 @@ namespace OLED12864_I2C {
250
252
*/
251
253
//% blockId="OLED12864_I2C_NUMBER" block="show a Number at x %x|y %y|number %num|color %color"
252
254
//% weight=80 blockGap=8
255
+ //% parts=OLED12864_I2C trackArgs=0
253
256
export function showNumber ( x : number , y : number , num : number , color : number = 1 ) {
254
257
showString ( x , y , num . toString ( ) , color )
255
258
}
@@ -263,6 +266,7 @@ namespace OLED12864_I2C {
263
266
*/
264
267
//% blockId="OLED12864_I2C_HLINE" block="draw a horizontal line at x %x|y %y|number %len|color %color"
265
268
//% weight=71 blockGap=8
269
+ //% parts=OLED12864_I2C trackArgs=0
266
270
export function hline ( x : number , y : number , len : number , color : number = 1 ) {
267
271
for ( let i = x ; i < ( x + len ) ; i ++ )
268
272
pixel ( i , y , color )
@@ -277,6 +281,7 @@ namespace OLED12864_I2C {
277
281
*/
278
282
//% blockId="OLED12864_I2C_VLINE" block="draw a vertical line at x %x|y %y|number %len|color %color"
279
283
//% weight=72 blockGap=8
284
+ //% parts=OLED12864_I2C trackArgs=0
280
285
export function vline ( x : number , y : number , len : number , color : number = 1 ) {
281
286
for ( let i = y ; i < ( y + len ) ; i ++ )
282
287
pixel ( x , i , color )
@@ -292,6 +297,7 @@ namespace OLED12864_I2C {
292
297
*/
293
298
//% blockId="OLED12864_I2C_RECT" block="draw a rectangle at x1 %x1|y1 %y1|x2 %x2|y2 %y2|color %color"
294
299
//% weight=73 blockGap=8
300
+ //% parts=OLED12864_I2C trackArgs=0
295
301
export function rect ( x1 : number , y1 : number , x2 : number , y2 : number , color : number = 1 ) {
296
302
if ( x1 > x2 )
297
303
x1 = [ x2 , x2 = x1 ] [ 0 ] ;
@@ -309,6 +315,7 @@ namespace OLED12864_I2C {
309
315
*/
310
316
//% blockId="OLED12864_I2C_INVERT" block="invert display %d"
311
317
//% weight=65 blockGap=8
318
+ //% parts=OLED12864_I2C trackArgs=0
312
319
export function invert ( d : boolean = true ) {
313
320
let n = ( d ) ? 0xA7 : 0xA6
314
321
cmd1 ( n )
@@ -319,6 +326,7 @@ namespace OLED12864_I2C {
319
326
*/
320
327
//% blockId="OLED12864_I2C_DRAW" block="draw"
321
328
//% weight=64 blockGap=8
329
+ //% parts=OLED12864_I2C trackArgs=0
322
330
export function draw ( ) {
323
331
set_pos ( )
324
332
pins . i2cWriteBuffer ( _I2CAddr , _screen )
@@ -329,6 +337,7 @@ namespace OLED12864_I2C {
329
337
*/
330
338
//% blockId="OLED12864_I2C_CLEAR" block="clear"
331
339
//% weight=63 blockGap=8
340
+ //% parts=OLED12864_I2C trackArgs=0
332
341
export function clear ( ) {
333
342
_screen . fill ( 0 )
334
343
_screen [ 0 ] = 0x40
@@ -340,6 +349,7 @@ namespace OLED12864_I2C {
340
349
*/
341
350
//% blockId="OLED12864_I2C_ON" block="turn on"
342
351
//% weight=62 blockGap=8
352
+ //% parts=OLED12864_I2C trackArgs=0
343
353
export function on ( ) {
344
354
cmd1 ( 0xAF )
345
355
}
@@ -349,6 +359,7 @@ namespace OLED12864_I2C {
349
359
*/
350
360
//% blockId="OLED12864_I2C_OFF" block="turn off"
351
361
//% weight=61 blockGap=8
362
+ //% parts=OLED12864_I2C trackArgs=0
352
363
export function off ( ) {
353
364
cmd1 ( 0xAE )
354
365
}
@@ -359,6 +370,7 @@ namespace OLED12864_I2C {
359
370
*/
360
371
//% blockId="OLED12864_I2C_ZOOM" block="zoom %d"
361
372
//% weight=60 blockGap=8
373
+ //% parts=OLED12864_I2C trackArgs=0
362
374
export function zoom ( d : boolean = true ) {
363
375
_ZOOM = ( d ) ? 1 : 0
364
376
cmd2 ( 0xd6 , _ZOOM )
@@ -370,6 +382,7 @@ namespace OLED12864_I2C {
370
382
*/
371
383
//% blockId="OLED12864_I2C_init" block="init OLED with addr %addr"
372
384
//% weight=100 blockGap=8
385
+ //% parts=OLED12864_I2C trackArgs=0
373
386
export function init ( addr : number ) {
374
387
_I2CAddr = addr ;
375
388
cmd1 ( 0xAE ) // SSD1306_DISPLAYOFF
0 commit comments