Skip to content

Commit 3a2485d

Browse files
committed
rename main.ts to OLED12864_I2C.ts, and add "PARTS" to block
1 parent c3cc3d7 commit 3a2485d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

main.ts renamed to OLED12864_I2C.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* http://www.micropython.org.cn
55
*/
66

7-
//% weight=100 color=#0855AA icon="O" block="OLED12864 I2C"
7+
//% weight=20 color=#0855AA icon="O" block="OLED12864_I2C"
88
namespace OLED12864_I2C {
99
let font: number[] = [];
1010
font[0] = 0x0022d422;
@@ -185,6 +185,7 @@ namespace OLED12864_I2C {
185185
*/
186186
//% blockId="OLED12864_I2C_PIXEL" block="set pixel at x %x|y %y|color %color"
187187
//% weight=70 blockGap=8
188+
//% parts=OLED12864_I2C trackArgs=0
188189
export function pixel(x: number, y: number, color: number = 1) {
189190
let page = y >> 3
190191
let shift_page = y % 8
@@ -214,6 +215,7 @@ namespace OLED12864_I2C {
214215
*/
215216
//% blockId="OLED12864_I2C_SHOWSTRING" block="show string at x %x|y %y|text %s|color %color"
216217
//% weight=80 blockGap=8
218+
//% parts=OLED12864_I2C trackArgs=0
217219
export function showString(x: number, y: number, s: string, color: number = 1) {
218220
let col = 0
219221
let p = 0
@@ -250,6 +252,7 @@ namespace OLED12864_I2C {
250252
*/
251253
//% blockId="OLED12864_I2C_NUMBER" block="show a Number at x %x|y %y|number %num|color %color"
252254
//% weight=80 blockGap=8
255+
//% parts=OLED12864_I2C trackArgs=0
253256
export function showNumber(x: number, y: number, num: number, color: number = 1) {
254257
showString(x, y, num.toString(), color)
255258
}
@@ -263,6 +266,7 @@ namespace OLED12864_I2C {
263266
*/
264267
//% blockId="OLED12864_I2C_HLINE" block="draw a horizontal line at x %x|y %y|number %len|color %color"
265268
//% weight=71 blockGap=8
269+
//% parts=OLED12864_I2C trackArgs=0
266270
export function hline(x: number, y: number, len: number, color: number = 1) {
267271
for (let i = x; i < (x + len); i++)
268272
pixel(i, y, color)
@@ -277,6 +281,7 @@ namespace OLED12864_I2C {
277281
*/
278282
//% blockId="OLED12864_I2C_VLINE" block="draw a vertical line at x %x|y %y|number %len|color %color"
279283
//% weight=72 blockGap=8
284+
//% parts=OLED12864_I2C trackArgs=0
280285
export function vline(x: number, y: number, len: number, color: number = 1) {
281286
for (let i = y; i < (y + len); i++)
282287
pixel(x, i, color)
@@ -292,6 +297,7 @@ namespace OLED12864_I2C {
292297
*/
293298
//% blockId="OLED12864_I2C_RECT" block="draw a rectangle at x1 %x1|y1 %y1|x2 %x2|y2 %y2|color %color"
294299
//% weight=73 blockGap=8
300+
//% parts=OLED12864_I2C trackArgs=0
295301
export function rect(x1: number, y1: number, x2: number, y2: number, color: number = 1) {
296302
if (x1 > x2)
297303
x1 = [x2, x2 = x1][0];
@@ -309,6 +315,7 @@ namespace OLED12864_I2C {
309315
*/
310316
//% blockId="OLED12864_I2C_INVERT" block="invert display %d"
311317
//% weight=65 blockGap=8
318+
//% parts=OLED12864_I2C trackArgs=0
312319
export function invert(d: boolean = true) {
313320
let n = (d) ? 0xA7 : 0xA6
314321
cmd1(n)
@@ -319,6 +326,7 @@ namespace OLED12864_I2C {
319326
*/
320327
//% blockId="OLED12864_I2C_DRAW" block="draw"
321328
//% weight=64 blockGap=8
329+
//% parts=OLED12864_I2C trackArgs=0
322330
export function draw() {
323331
set_pos()
324332
pins.i2cWriteBuffer(_I2CAddr, _screen)
@@ -329,6 +337,7 @@ namespace OLED12864_I2C {
329337
*/
330338
//% blockId="OLED12864_I2C_CLEAR" block="clear"
331339
//% weight=63 blockGap=8
340+
//% parts=OLED12864_I2C trackArgs=0
332341
export function clear() {
333342
_screen.fill(0)
334343
_screen[0] = 0x40
@@ -340,6 +349,7 @@ namespace OLED12864_I2C {
340349
*/
341350
//% blockId="OLED12864_I2C_ON" block="turn on"
342351
//% weight=62 blockGap=8
352+
//% parts=OLED12864_I2C trackArgs=0
343353
export function on() {
344354
cmd1(0xAF)
345355
}
@@ -349,6 +359,7 @@ namespace OLED12864_I2C {
349359
*/
350360
//% blockId="OLED12864_I2C_OFF" block="turn off"
351361
//% weight=61 blockGap=8
362+
//% parts=OLED12864_I2C trackArgs=0
352363
export function off() {
353364
cmd1(0xAE)
354365
}
@@ -359,6 +370,7 @@ namespace OLED12864_I2C {
359370
*/
360371
//% blockId="OLED12864_I2C_ZOOM" block="zoom %d"
361372
//% weight=60 blockGap=8
373+
//% parts=OLED12864_I2C trackArgs=0
362374
export function zoom(d: boolean = true) {
363375
_ZOOM = (d) ? 1 : 0
364376
cmd2(0xd6, _ZOOM)
@@ -370,6 +382,7 @@ namespace OLED12864_I2C {
370382
*/
371383
//% blockId="OLED12864_I2C_init" block="init OLED with addr %addr"
372384
//% weight=100 blockGap=8
385+
//% parts=OLED12864_I2C trackArgs=0
373386
export function init(addr: number) {
374387
_I2CAddr = addr;
375388
cmd1(0xAE) // SSD1306_DISPLAYOFF

0 commit comments

Comments
 (0)