module main
author 'Turgut Guneysu'
version 2 1
description 'Demonstrates the 128x64OLED(1306-09) Library use.'
variables S1 S2 _msg1 _msg2 _msg3 _picNo
spec ' ' 'OLEDDemo' 'OLEDDemo'
spec ' ' 'dataLoop' 'dataLoop _ _ _ _' 'auto auto auto auto' '10' '10' '10' '10'
spec ' ' 'CTRLPanel' 'CTRLPanel'
spec ' ' 'Contrast1-4' 'Contrast1-4'
spec ' ' 'MBLogo and Title' 'MBLogo and Title'
spec ' ' 'OLEDCharset' 'OLEDCharset'
spec ' ' 'animatedSprites' 'animatedSprites'
spec ' ' 'drawCircles' 'drawCircles'
spec ' ' 'drawCirclesMatrix' 'drawCirclesMatrix'
spec ' ' 'drawLines' 'drawLines'
spec ' ' 'drawRectangles' 'drawRectangles'
spec ' ' 'linedraw framed Text' 'linedraw framed Text'
spec ' ' 'mbitCharSet' 'mbitCharSet'
spec ' ' 'textInGDBuffer' 'textInGDBuffer'
spec ' ' 'lineDrawBT' 'lineDrawBT'
spec ' ' 'lineDrawLR' 'lineDrawLR'
spec ' ' 'lineDrawRL' 'lineDrawRL'
spec ' ' 'lineDrawTB' 'lineDrawTB'
spec ' ' 'MPFrame' 'MPFrame'
to CTRLPanel {
comment 'Demo of Control Panel with 3 live values updated
Touch value is updated as an icon.'
OLEDClear
local 'Toff1' ('[data:split]' '3C,42,81,81,81,81,81,81' ',')
for i (size Toff1) {
atPut i Toff1 (hexToInt (at i Toff1))
}
local 'Toff2' ('[data:split]' '81,81,81,81,81,81,42,3C' ',')
for i (size Toff2) {
atPut i Toff2 (hexToInt (at i Toff2))
}
local 'Ton1' ('[data:split]' '3C,42,81,99,99,81,81,81' ',')
for i (size Ton1) {
atPut i Ton1 (hexToInt (at i Ton1))
}
local 'Ton2' ('[data:split]' '81,81,81,99,99,81,42,3C' ',')
for i (size Ton2) {
atPut i Ton2 (hexToInt (at i Ton2))
}
OLEDDrawString ' Control Panel ' 1 1 false
OLEDDrawString 'Light:' 3 1 false
OLEDDrawString 'Temp:' 5 1 false
OLEDDrawString 'Touch:' 7 1 false
OLEDShowGDBuffer
dataLoop Toff1 Toff2 Ton1 Ton2
}
to 'Contrast1-4' {
comment 'Adjust CONTRAST 1 - 4'
for i 4 {
OLEDDispString ('[data:join]' ' ' i ' ') false 4 7
OLEDContrast i
waitMillis 1000
OLEDContrast 1
}
}
to 'MBLogo and Title' {
comment 'MicroBlocks Logo & Title'
OLEDClear
BunnyPIC
OLEDDrawPic _imgBMPTbl 'Display'
OLEDMode 'Horizontal'
OLEDCursorReset
OLEDDispString 'Micro
Blocks' true 3 8
OLEDDispString 'Is
GREAT!!!' false 5 8
}
to MPFrame {
OLEDDrawRect 0 2 127 44 true false 3
OLEDDrawRect 2 4 83 42 true false 3
OLEDDrawRect 85 4 125 42 true false 3
OLEDShowGDBuffer
}
to OLEDCharset {
OLEDClear
OLEDContrast 1
OLEDDispString '_CHARACTER SET_' false
OLEDDispString _cTABLE false 3 1
waitMillis 2000
OLEDClear
OLEDDispString ' _LINEDRAW SET_ ' false
OLEDDispString ('[data:copyFromTo]' _lineTABLE 1 14) false 3 1
OLEDDispString ('[data:copyFromTo]' _lineTABLE 15 28) false 5 1
OLEDDispString ('[data:copyFromTo]' _lineTABLE 29 40) false 7 1
}
to OLEDDemo {
comment 'Demo program to show various display features.'
'_initCheck'
'_OLEDStopScroll'
OLEDMode 'Horizontal'
OLEDClear
OLEDDispString 'Micro
Blocks' true 3 7
OLEDDispString 'Is
GREAT!!!' false 5 7
waitMillis 1000
if (_displayType == 9) {
'_OLEDScroll-VRL' 'Vert-Right' 1 8 0 1 1 128
waitMillis 2500
'_OLEDStopScroll'
waitMillis 1000
} else {
waitMillis 1000
repeat 2 {
OLEDZoomMode 'On'
waitMillis 500
OLEDZoomMode 'Off'
waitMillis 500
}
}
OLEDCursorReset
BunnyPIC
OLEDDrawPic _imgBMPTbl 'Display'
comment 'Scroll image right and left'
OLEDCursorReset
OLEDColMode 1 5
'_OLEDScroll-RL' 'Right' 1 8 1 47
waitMillis 690
'_OLEDStopScroll'
OLEDCursorReset
'_OLEDScroll-RL' 'Left' 1 8 1 47
waitMillis 690
'_OLEDStopScroll'
waitMillis 1000
OLEDMode 'Horizontal'
OLEDClear
'_initGDBuffer'
}
to animatedSprites {
comment 'Make 2 Sprites and Loop them on display in horizontal and vertical directions.
Upon collision, display explosion pattern.'
OLEDClear
local '_clearSprite' (newList 5)
S1 = (OLEDMakeSprite 23068334)
S2 = (OLEDMakeSprite 15166916)
forever {
for c 120 {
local 'r' (c % 9)
local 's2R' (maximum r 1)
local 's2C' (random 56 64)
OLEDDrawSprite S1 1 c
OLEDDrawSprite S2 ((8 - s2R) + 1) s2C
OLEDShowGDBuffer
if (and (s2R == 1) (and (c > (s2C - 2)) (c < (s2C + 2)))) {
repeat 3 {
OLEDDrawSprite (OLEDMakeSprite 22506965) 1 s2C
OLEDShowGDBuffer
waitMillis 200
OLEDDrawSprite _clearSprite 1 (s2C - 2)
OLEDDrawSprite _clearSprite 1 (s2C + 2)
OLEDShowGDBuffer
waitMillis 200
}
} else {
OLEDDrawSprite _clearSprite 1 c
OLEDDrawSprite _clearSprite ((8 - s2R) + 1) s2C
}
}
}
}
to dataLoop t1 t2 t3 t4 {
forever {
OLEDDrawString ('[data:join]' '' ('[display:lightLevel]') ' ') 3 64 false
OLEDDrawString ('[data:join]' '' ('[sensors:temperature]') ' ') 5 64 false
if ('logo touched') {
OLEDDrawSprite t3 7 64
OLEDDrawSprite t4 7 72
} else {
OLEDDrawSprite t1 7 64
OLEDDrawSprite t2 7 72
}
OLEDShowGDBuffer
waitMillis 250
}
}
to drawCircles {
comment 'Concentric circles, out, in'
OLEDClear
OLEDContrast 1
for i 64 {
if ((i % 2) == 0) {OLEDDrawCircle 64 32 i true}
}
for i 64 {
if (((65 - i) % 2) == 0) {OLEDDrawCircle 64 32 (65 - i) false}
}
}
to drawCirclesMatrix {
comment 'Draw Circles across the display
Center every 10 pixels,
Radius = 3'
OLEDClear
OLEDContrast 1
_delayGDUpd = (booleanConstant false)
for y 63 {
if ((y % 8) == 0) {for x 127 {
if ((x % 10) == 0) {OLEDDrawCircle x y 3 true}
}
}
}
OLEDShowGDBuffer
}
to drawLines {
comment 'Lines from 0,0 to opposite y-range
Place OLEDShowGDBuffer into loops (slow)
or at the end (fast)'
OLEDClear
OLEDContrast 1
_delayGDUpd = (booleanConstant false)
for i 64 {
if ((i % 2) == 1) {OLEDDrawLine 0 0 127 (i - 1) true}
}
comment 'Lines from 127,0 to origin y-range'
for i 64 {
if ((i % 2) == 1) {OLEDDrawLine 127 0 0 (i - 1) true}
}
comment 'Draw two circles inside the right & left triangles'
OLEDCursorReset
OLEDShowGDBuffer
}
to drawRectangles {
comment 'Concentric Rectangles, in, in'
OLEDClear
OLEDContrast 1
for i 28 {
if (((i - 1) % 2) == 0) {OLEDDrawRect (i - 1) (i - 1) (127 - (i - 1)) (63 - (i - 1)) true true 3}
OLEDShowGDBuffer
}
for i 28 {
if (((i - 1) % 2) == 0) {OLEDDrawRect (i - 1) (i - 1) (127 - (i - 1)) (63 - (i - 1)) false true 3}
OLEDShowGDBuffer
}
}
to lineDrawBT {
for r 5 {
OLEDDispString _msg1 false (6 - r) 3
OLEDDispString _msg2 false (7 - r) 3
OLEDDispString _msg3 false (8 - r) 3
OLEDDispString ' ' false (9 - r) 3
waitMillis delay
}
}
to lineDrawLR {
for c 2 {
OLEDDispString _msg1 false 6 (1 + c)
OLEDDispString _msg2 false 7 (1 + c)
OLEDDispString _msg3 false 8 (1 + c)
OLEDDispString ('[data:unicodeString]' 32) false 6 c
OLEDDispString ('[data:unicodeString]' 32) false 7 c
OLEDDispString ('[data:unicodeString]' 32) false 8 c
waitMillis delay
}
}
to lineDrawRL {
OLEDDispString _msg1 false 1 2
OLEDDispString _msg2 false 2 2
OLEDDispString _msg3 false 3 2
waitMillis 100
OLEDClear
OLEDDispString _msg1 false 1 1
OLEDDispString _msg2 false 2 1
OLEDDispString _msg3 false 3 1
waitMillis 1000
OLEDClear
}
to lineDrawTB {
for r 6 {
OLEDDispString _msg1 false r 1
OLEDDispString _msg2 false (r + 1) 1
OLEDDispString _msg3 false (r + 2) 1
OLEDDispString ' ' false (maximum 1 (r - 1)) 1
waitMillis delay
}
}
to 'linedraw framed Text' {
comment 'Text with LineDraw characters'
_msg1 = ''
_msg2 = 'MicroBlocks'
_msg3 = ''
local 'delay' 100
OLEDClear
lineDrawTB
waitMillis 150
lineDrawLR
waitMillis 150
lineDrawBT
waitMillis 150
lineDrawRL
}
to mbitCharSet {
comment 'Using Sprite capability to draw the micro:bit character set
of the LED Library Uses 5x5 matrix of letter instead of 8x8.'
OLEDClear
local 'c#' 1
local 'r#' 1
local 'string' 'Using Sprite capability to draw the micro:bit character set.'
for c string {
OLEDDrawSprite (OLEDMakeSprite 15237440 ('[display:mbShapeForLetter]' ('[data:unicodeAt]' 1 c))) r# c#
c# += 5
if (c# >= 125) {
r# += 1
c# = 1
}
}
OLEDShowGDBuffer
local 'c#' 1
local 'r#' 5
for c _cTABLE {
OLEDDrawSprite (OLEDMakeSprite 15237440 ('[display:mbShapeForLetter]' ('[data:unicodeAt]' 1 c))) r# c#
c# += 5
if (c# >= 125) {
r# += 1
c# = 1
}
}
OLEDShowGDBuffer
}
to textInGDBuffer {
comment 'Treats character bitmaps as Sprite and draws them on GDBuffer
Drawn text is surrounded by a rectangle.
You can either OLEDShowGDBuffer after every character (slower)
or at the end (much faster).'
OLEDClear
OLEDContrast 1
local 'C' 24
for CHAR 'Text w Line' {
OLEDDrawSprite ('_cBMP' CHAR false) 3 C
C += 8
OLEDShowGDBuffer
}
waitMillis 2000
OLEDDrawRect 20 12 112 28 true true 3
OLEDShowGDBuffer
waitMillis 3000
OLEDDrawRect 20 12 112 28 false true 3
OLEDShowGDBuffer
}
script 67 50 {
comment 'Please make sure to modify the OLEDInit blocks according to your display type and connectivity,
as well as provide the I2C address, and other pin info as it pertains to your environment.'
}
script 67 131 {
whenStarted
comment 'SPI '
OLEDInit_SPI 'OLED_2.42in' 16 8
OLEDContrast 1
OLEDDemo
}
script 439 145 {
comment 'I2C'
OLEDInit_I2C 'OLED_2.42in' '3C' 1
OLEDContrast 1
OLEDDispString 'Hello!' false
}
script 442 299 {
whenButtonPressed 'B'
comment 'Using Sprite capability to draw the micro:bit character set
of the LED Library Uses 5x5 matrix of letter instead of 8x8.'
mbitCharSet
}
script 63 323 {
whenButtonPressed 'A'
comment 'Display the character and linedraw set tables'
OLEDCharset
}
script 50 513 {
comment '====================== LIBRARY USE SAMPLES ARE PROVIDED BELOW ==========================
To run, click on each examples comment block.'
}
script 66 680 {
comment 'Full line of text'
OLEDClear
OLEDDispString '0123456789ABCDEF' false
}
script 67 839 {
comment 'Adjust CONTRAST 1 - 4'
'Contrast1-4'
}
script 67 909 {
comment 'MicroBlocks Logo & Title'
'MBLogo and Title'
}
script 67 979 {
comment 'REVERSE VIDEO Test'
OLEDClear
OLEDDispString '
TESTING
INVERSE
VIDEO
' true
}
script 67 1170 {
comment 'Text framed with LineDraw characters'
'linedraw framed Text'
}
script 67 1240 {
comment 'In the examples below, you can set the _delayGDUpd field to TRUE and delay updating the display until alll image composition is complete.
Try it both ways to see the difference.'
}
script 67 1337 {
comment 'Lines from 0,0 to opposite y-range
Place OLEDShowGDBuffer into loops (slow)
or at the end (fast)'
drawLines
}
script 67 1438 {
comment 'Draw Circles across the display
Center every 10 pixels,
Radius = 3'
drawCirclesMatrix
}
script 67 1539 {
comment 'Concentric circles, out, in'
drawCircles
}
script 67 1609 {
comment 'Concentric Rectangles, in, in'
drawRectangles
}
script 67 1679 {
comment '====================== SPRITE SPECIFIC EXAMPLES PROVIDED BELOW (Make use of the GDBuffer) =========================='
}
script 67 1745 {
comment 'Make 2 Sprites and Loop them on display in horizontal and vertical directions.
Upon collision, display explosion pattern.'
animatedSprites
}
script 67 1865 {
comment 'Treats character bitmaps as Sprite and draws them on GDBuffer
Drawn text is surrounded by a rectangle.
You can either OLEDShowGDBuffer after every character (slower)
or at the end (much faster).'
textInGDBuffer
}
script 67 2000 {
comment 'Demo of Control Panel with 3 live values updated
Touch value is updated as an icon.'
CTRLPanel
}
script 67 2085 {
comment 'Picture of Jens & John
Reveals GDBuffer onto Display by random pixels.'
OLEDClear
OLEDContrast 1
JJPIC
OLEDDrawPic _imgBMPTbl 'GDBuffer'
OLEDShowGDBuffer
waitMillis 2000
'_clearDisplay'
waitMillis 2000
'_OLEDReveal' 0
waitMillis 4000
'_clearDisplay'
}
script 67 2403 {
comment 'AV Control Panel
Displays equalizer bars with a picture show of MB team.
On SPI displays, adjust speed 1000 - 10000000.'
'[sensors:spiSetup]' 10000000
local 'picBMPs' ('[data:makeList]')
JMPIC
'[data:addLast]' _imgBMPTbl picBMPs
BRPIC
'[data:addLast]' _imgBMPTbl picBMPs
JMoPIC
'[data:addLast]' _imgBMPTbl picBMPs
KGPIC
'[data:addLast]' _imgBMPTbl picBMPs
OLEDClear
OLEDContrast 4
MPPIC
OLEDDrawPic _imgBMPTbl 'GDBuffer'
for i 200 {
if ((i % 25) == 0) {
_begRow = 1
_begCol = 90
_picNo = (random 1 4)
'_toGDBuffer' (at _picNo picBMPs)
}
local 'c' 0
repeat 9 {
c += 8
r = 5
repeat (random 1 4) {
OLEDDrawSprite (newList 7 119) r c
r += -1
}
}
OLEDShowGDBuffer
for i 4 {
OLEDDrawSprite (newList 72 0) (1 + i) 8
}
}
}
module '32BR'
author unknown
version 1 0
description ''
variables _imgBMPTbl _imgBMPTbl2
spec ' ' 'BR1' 'BR1'
spec ' ' 'BRPIC' 'BRPIC'
to BR1 {
comment 'Make this custom block P1'
local '_img1' ('[data:join]' '' '3C,DE,80,01/1F,00,81,02/1F,00,80,00/07,1C,80,00/1B,F0,C0,00/1B,C8,03,00/1F,F8,0F,00/1B,F8,1D,00/07,F8,3D,00/07,F8,79,00/07,F8,F8,00/07,FC,F0,01/07,FC,F8,01/07,FC,DD,30/01,FE,7F,22/01,FE,7F,03/01,FE,7F,06/01,FF,BC,04/01,7E,3C,08/03,7F,34,00/03,3F,84,00/03,3F,2C,02/07,3E,BC,00/03,7E,3E,01/03,7C,3F,01/07,78,FF,01/0B,F8,FF,81/0D,F0,BF,C0/1D,C0,7F,E0/15,00,00,F0/71,00,00,7C/71,A9,11,3')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img1 '/'))
}
to BRPIC {
comment 'Make this custom block PIC.
Assembles a user PICTURE into the
global _imgBMPTbl
Delimiter is "comma" uni(44)
Picture lines are "/" terminated.'
_imgBMPTbl = ('[data:makeList]')
BR1
}
module '32JM'
author unknown
version 1 0
description ''
variables _imgBMPTbl _imgBMPTbl2
spec ' ' 'JM1' 'JM1'
spec ' ' 'JMPIC' 'JMPIC'
to JM1 {
comment 'Make this custom block P1'
local '_img1' ('[data:join]' '' '7F,E0,D4,FF/FF,3F,C0,FF/DF,BF,80,FF/0F,03,E0,F1/8F,00,00,C0/03,00,00,00/09,38,00,00/1C,40,01,00/0F,B1,02,00/8F,E8,55,00/DF,C8,EA,00/CF,28,01,00/CF,14,00,00/9F,04,00,00/1F,00,00,00/7F,04,03,08/FF,0F,03,35/FF,9F,83,2A/9F,DF,03,5D/DF,9C,87,3F/DF,FC,87,7F/DF,BC,8F,7F/FF,7C,DE,FF/FF,FD,FB,FF/FF,FF,FF,FF/FF,FF,FF,FF/FF,FF,FF,7F/FF,FF,FF,1F/FE,FF,FF,BF/F8,FF,FF,33/F0,FF,7F,00/E0,FF,1F,0')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img1 '/'))
}
to JMPIC {
comment 'Make this custom block PIC.
Assembles a user PICTURE into the
global _imgBMPTbl
Delimiter is "comma" uni(44)
Picture lines are "/" terminated.'
_imgBMPTbl = ('[data:makeList]')
JM1
}
module '32JMo'
author unknown
version 1 0
description ''
variables _imgBMPTbl _imgBMPTbl2
spec ' ' 'JMo1' 'JMo1'
spec ' ' 'JMoPIC' 'JMoPIC'
to JMo1 {
comment 'Make this custom block P1'
local '_img1' ('[data:join]' '' '00,F8,FF,FF/00,00,FE,FF/00,80,F8,FF/00,00,E0,FF/00,00,DE,FF/00,00,F8,FF/00,00,00,FC/00,00,00,B0/00,06,3C,E0/80,03,FF,08/9E,0B,FD,03/FF,8B,3E,07/FF,5B,0C,0F/FF,0F,0C,0E/FF,0F,82,1C/FF,07,88,38/FF,0F,80,F9/FF,3F,E0,F9/FF,FF,FD,FF/FF,FF,9F,FF/FF,FF,9F,FF/FF,EF,FF,FF/FF,FB,EF,FF/FF,FF,7F,FF/FF,FF,FF,FF/FE,FF,FF,FF/FB,FF,FF,FF/FF,FF,FF,FF/FF,FF,FF,FF/FF,FF,FF,03/FF,1F,80,FF/FF,1F,80,F')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img1 '/'))
}
to JMoPIC {
comment 'Make this custom block PIC.
Assembles a user PICTURE into the
global _imgBMPTbl
Delimiter is "comma" uni(44)
Picture lines are "/" terminated.'
_imgBMPTbl = ('[data:makeList]')
JMo1
}
module '32KG'
author unknown
version 1 0
description ''
variables _imgBMPTbl _imgBMPTbl2
spec ' ' 'KG1' 'KG1'
spec ' ' 'KGPIC' 'KGPIC'
to KG1 {
comment 'Make this custom block P1'
local '_img1' ('[data:join]' '' 'FF,0F,00,FC/FF,FF,FF,FF/3F,24,01,FE/3F,E0,7F,70/1F,FE,FF,01/FF,FF,FF,AF/FB,FF,FF,FF/FF,FF,FF,FF/FF,FB,FF,FF/FF,FB,FF,BF/FF,F1,BF,7F/FF,FB,BF,7F/FF,FB,3B,3F/FF,FF,3F,7D/FF,FF,3B,0D/FF,7F,92,1E/FF,0F,70,0B/FF,03,50,0D/FF,7B,3B,06/FF,FF,FF,07/FE,DF,3F,00/F1,C6,3F,00/80,CC,07,00/00,8E,0B,00/00,00,00,00/00,00,00,00/00,00,00,00/00,00,00,00/00,00,00,00/03,00,00,00/0E,00,00,00/15,00,00,0')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img1 '/'))
}
to KGPIC {
comment 'Make this custom block PIC.
Assembles a user PICTURE into the
global _imgBMPTbl
Delimiter is "comma" uni(44)
Picture lines are "/" terminated.'
_imgBMPTbl = ('[data:makeList]')
KG1
}
module 'Basic Sensors' Input
author MicroBlocks
version 1 1
tags tilt acceleration light sensor
choices accelerometerRange '1' '2' '4' '8'
description 'Provides blocks to read tilt in the three axes, acceleration, temperature and light level. Many boards come with this particular set of sensors, such as the micro:bit, the Circuit Playground Express, the Calliope or the Citilab ED1.'
spec 'r' '[sensors:tiltX]' 'tilt x'
spec 'r' '[sensors:tiltY]' 'tilt y'
spec 'r' '[sensors:tiltZ]' 'tilt z'
spec 'r' '[sensors:acceleration]' 'acceleration'
spec 'r' '[display:lightLevel]' 'light level'
spec 'r' '[sensors:temperature]' 'temperature (C)'
spec ' ' '_setAccelRange' 'set acceleration range _ g = 100' 'menu.accelerometerRange' '1'
to '_setAccelRange' n {
'[sensors:setAccelerometerRange]' (0 + n)
}
module BunnyPic
author unknown
version 1 0
description ''
variables _imgBMPTbl
spec ' ' 'B1' 'B1'
spec ' ' 'B2' 'B2'
spec ' ' 'BunnyPIC' 'BunnyPIC'
to B1 {
comment 'Make this custom block P1'
local '_img1' ('[data:join]' '' '00,00,00,00,00,00,00,00/00,00,00,00,00,00,00,00/00,00,00,00,C0,FF,03,00/00,F8,07,00,F8,00,1E,00/00,FE,FF,00,1E,00,70,00/80,03,C0,8F,03,00,C0,00/E0,00,00,FC,00,00,80,01/30,00,00,60,00,00,00,03/18,00,00,00,00,00,00,06/0C,00,00,00,00,00,00,0C/04,00,00,06,00,00,00,18/06,00,F8,07,00,00,00,10/C2,FF,3F,06,00,00,00,30/FB,00,00,06,00,00,08,20/8F,FF,0F,02,00,00,08,60/E2,00,FF,03,00,00,10,40/30,00,80,03,00,00,20,40/18,00,00,00,00,E0,20,C0/0C,00,00,00,00,E0,40,C0/04,00,00,00,00,60,40,80/06,00,00,00,00,00,C0,81/02,00,80,03,00,00,C2,87/03,00,FE,03,00,00,86,86/C3,FF,1F,03,00,00,FE,C3/F9,00,00,02,00,00,FE,C3/0F,00,00,02,00,00,46,42/02,00,00,02,00,20,C0,43/00,00,00,06,00,70,40,60/00,00,00,06,00,70,40,60/00,00,00,04,00,00,20,20/00,00,00,0C,00,00,20,30/00,00,00,08,00,00,10,18')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img1 '/'))
}
to B2 {
comment 'Make this custom block P2'
local '_img2' ('[data:join]' '' '00,00,00,18,00,00,08,08/00,00,00,30,00,00,00,0C/00,00,00,60,00,00,00,06/00,00,00,C0,00,00,00,03/00,00,00,80,03,00,C0,01/00,00,00,00,0E,00,60,00/00,00,00,00,38,00,3C,00/00,00,00,00,E0,FF,0F,00/00,00,00,00,00,FE,00,00/00,00,00,00,00,00,00,00')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img2 '/'))
}
to BunnyPIC {
comment 'Make this custom block PIC.
Assembles a user PICTURE into the
global _imgBMPTbl
Delimiter is "comma" uni(44)
Picture lines are "comma + /" terminated.'
_imgBMPTbl = ('[data:makeList]')
B1
B2
}
module JensJohnPic
author unknown
version 1 0
description ''
variables _imgBMPTbl
spec ' ' 'JJ1' 'JJ1'
spec ' ' 'JJ2' 'JJ2'
spec ' ' 'JJ3' 'JJ3'
spec ' ' 'JJ4' 'JJ4'
spec ' ' 'JJPIC' 'JJPIC'
to JJ1 {
comment 'Make this custom block P1'
local '_img1' ('[data:join]' '' 'FF,7F,00,FE,FF,FF,FF,FF/FF,1F,00,FC,FF,FF,FF,7F/FF,07,00,E0,FF,FF,FF,7F/FF,03,00,80,FF,FF,FF,7F/FF,01,00,00,E0,FF,FF,BF/FF,00,00,00,00,FF,FF,BF/7F,00,00,00,00,FC,FF,FF/1F,00,00,00,00,F0,FF,FF/0F,00,00,00,00,C0,FF,FF/0F,00,00,00,00,87,FF,FF/09,00,00,00,00,00,FF,1F/01,00,00,00,00,00,FC,E7/00,00,00,00,00,00,F0,E3/00,00,00,00,00,00,C0,F3/00,00,00,00,00,00,00,63/00,00,00,00,00,00,00,F8/01,00,00,00,00,00,00,C0/00,00,00,08,00,00,00,00/00,00,00,0C,00,00,00,00/00,00,0E,0E,00,00,0E,00/00,00,0F,4F,00,04,3C,00/00,80,FF,4F,00,00,3C,00/00,E0,FF,4F,00,00,18,00/00,F0,FF,1F,00,00,00,00/00,F8,FF,1F,00,00,00,00/00,FD,FF,3F,00,00,00,00/80,FF,FF,1F,00,00,02,00/C0,FF,FF,3F,00,00,06,00/C0,FF,FF,FF,00,80,06,07/C0,FF,FF,FF,03,40,C6,03/C0,FF,FF,FF,1F,0F,C7,3F/E0,FF,FF,FF,FF,0F,EF,7F')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img1 '/'))
}
to JJ2 {
comment 'Make this custom block P2'
local '_img2' ('[data:join]' '' 'C0,FF,FF,FF,FF,0F,EF,FF/81,FF,FF,3F,FE,87,F7,FF/01,FF,FF,1B,FE,E3,F7,FF/01,FE,FF,1B,FE,F3,FB,FF/01,FC,FF,9F,FF,E3,FC,FF/01,F8,FF,FF,FF,67,FE,FF/03,F0,FF,FF,FF,7F,FF,FF/07,C0,FF,DF,FF,7F,FF,FF/07,00,FE,FF,FF,77,FF,FF/0F,08,FC,FF,FF,EF,FF,FF/FF,FF,FF,FF,FF,FF,FF,FF/FF,FF,FF,FF,FF,FF,FF,FF/FF,FF,FF,FF,FF,FF,FF,7F/FF,FF,FF,FF,FF,FF,FF,07/FF,FF,FF,FF,FF,FF,07,E0/FF,FF,FF,FF,01,80,07,FE/00,00,00,00,00,00,00,00/D0,FF,FF,FF,FF,FF,FF,FF/90,FF,FF,FF,FF,FF,FF,FF/80,FF,3F,00,E0,F8,FF,FF/00,FF,1F,E0,00,F8,FF,FF/00,FF,FF,FF,00,F8,FF,FF/00,FF,FF,FF,00,F0,FF,FF/00,F6,03,0F,00,C0,FF,FF/00,FE,C1,01,00,BE,F8,FF/00,FB,00,00,00,00,E0,FF/80,FF,00,00,00,00,00,7F/C0,1F,00,00,00,00,00,7C/E0,0F,00,00,00,00,00,70/F0,07,00,00,00,00,00,38/F8,E7,00,00,00,00,00,00/FC,FF,01,E0,01,00,00,00')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img2 '/'))
}
to JJ3 {
comment 'Make this custom block P3'
local '_img3' ('[data:join]' '' 'FC,FF,71,F8,07,00,00,00/FE,FF,71,F8,0F,0E,00,00/FE,FF,71,F8,07,0C,00,00/FE,FF,71,EC,01,00,00,00/FF,FF,71,3C,00,00,00,00/FF,FF,71,34,00,00,00,00/FF,FF,23,02,00,00,00,00/FF,FF,03,00,00,00,00,00/FF,FF,0F,00,00,00,00,00/FF,FF,3F,04,18,00,00,00/FF,FF,7F,1E,1C,00,00,00/FF,FF,FF,1F,1E,00,3E,00/FF,FF,FF,FF,1E,C0,3F,00/FF,FF,FF,BF,1F,E0,3F,00/FF,FF,E3,1F,1F,E0,7F,00/FF,FF,73,3E,3F,E0,7F,00/FE,FF,33,7E,3F,E0,FF,00/FE,FF,33,FE,7F,F0,FF,80/FE,FF,33,FE,FF,F0,FF,81/FE,FF,73,FC,FF,FD,FF,C7/FC,FF,77,FE,FF,FF,FF,EF/FC,FF,77,FE,FF,FF,FF,FF/F8,FF,FF,FE,FF,FF,FF,FF/F8,FF,FF,FF,FF,FF,FF,FF/80,FF,FF,FF,FF,FF,FF,FF/00,FF,FF,FF,FF,FF,FF,9F/00,FE,FF,FF,FF,FF,7F,00/00,F8,FF,FF,FF,FF,1F,00/00,F8,FF,F5,FF,FF,0C,00/00,C0,FF,DF,FF,FF,FF,0F/00,80,FF,FF,FF,FF,20,F0/00,00,FF,FF,FF,0F,00,00')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img3 '/'))
}
to JJ4 {
comment 'Make this custom block P4'
local '_img4' ('[data:join]' '' '00,00,FE,FF,FF,03,00,00/00,00,FC,FF,FF,01,00,00/00,00,F8,FF,FF,03,00,00/00,00,E0,FF,FF,03,00,00/00,00,00,FF,FF,00,00,00/00,00,00,F8,1F,00,00,00/00,00,00,80,30,F4,3F,02/00,00,00,00,00,00,FF,FF')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img4 '/'))
}
to JJPIC {
comment 'Make this custom block PIC.
Assembles a user PICTURE into the
global _imgBMPTbl
Delimiter is "comma" uni(44)
Picture lines are "comma + /" terminated.'
_imgBMPTbl = ('[data:makeList]')
JJ1
JJ2
JJ3
JJ4
}
module 'LED Display' Output
author MicroBlocks
version 1 2
tags pixel matrix led tft
description 'Display primitives for the 5x5 LED display on the BBC micro:bit, Calliope mini and M5Atom Matrix. Boards with TFT displays (such as the Citilab ED1 or the M5Stack family) also support this primitives in a simulated "fat pixel" display.'
variables _stop_scrolling_text
spec ' ' '[display:mbDisplay]' 'display _' 'microbitDisplay' 15237440
spec ' ' '[display:mbDisplayOff]' 'clear display'
spec ' ' '[display:mbPlot]' 'plot x _ y _' 'num num' 3 3
spec ' ' '[display:mbUnplot]' 'unplot x _ y _' 'num num' 3 3
spec ' ' 'displayCharacter' 'display character _' 'str' 'A'
spec ' ' 'scroll_text' 'scroll text _ : pausing _ ms' 'str num' 'HELLO ROSA!' 100
spec ' ' 'stopScrollingText' 'stop scrolling'
to displayCharacter s {
s = ('[data:join]' '' s)
if ((size s) == 0) {
'[display:mbDisplayOff]'
return 0
}
'[display:mbDrawShape]' ('[display:mbShapeForLetter]' (at 1 s))
}
to scroll_text text optionalDelay {
text = ('[data:join]' text '')
delay = 100
if ((pushArgCount) > 1) {
delay = optionalDelay
}
_stop_scrolling_text = (booleanConstant false)
local 'length' (size text)
for position ((length * 6) + 6) {
if _stop_scrolling_text {return 0}
for i length {
'[display:mbDrawShape]' ('[display:mbShapeForLetter]' ('[data:unicodeAt]' i text)) (((i * 6) + 2) - position) 1
}
waitMillis delay
}
}
to stopScrollingText {
_stop_scrolling_text = (booleanConstant true)
waitMillis 10
'[display:mbDisplayOff]'
}
module 'Misc Primitives'
author MicroBlocks
version 1 1
description 'Miscellaneous system primitives.'
spec ' ' 'noop' 'no op'
spec ' ' 'ignoreArgs' 'ignore : _ : ...' 'auto' 0
spec 'r' 'pushArgCount' 'arg count'
spec 'r' 'getArg' 'arg _' 'num' 0
spec 'r' 'longMult' '( _ * _ ) >> _' 'num num num' 1024 2048 10
spec 'r' '[misc:sin]' 'fixed sine _' 'num' 9000
module MusicPanel
author unknown
version 1 0
description ''
variables _imgBMPTbl _imgBMPTbl2
spec ' ' 'MP1' 'MP1'
spec ' ' 'MP2' 'MP2'
spec ' ' 'MP3' 'MP3'
spec ' ' 'MP4' 'MP4'
spec ' ' 'MPPIC' 'MPPIC'
to MP1 {
comment 'Make this custom block P1'
local '_img1' ('[data:join]' '' 'FC,FF,FF,FF,FF,1F,00,00/04,00,00,00,00,10,00,00/F4,FF,FF,FF,FF,97,FF,3F/14,01,00,00,00,95,00,20/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,40,20/14,00,00,00,00,94,E0,20/14,00,00,00,00,94,F8,23/14,00,00,00,00,94,FC,27/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,E0,20/14,00,00,00,00,94,F8,23/14,00,00,00,00,94,FC,27/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/14,00,00,00,00,94,FF,3F/14,00,00,00,00,14,00,00/14,00,00,00,00,14,00,00/14,00,00,00,00,14,00,00/14,00,00,00,00,94,FF,3F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FC,27/14,00,00,00,00,94,FC,27/14,00,00,00,00,94,F8,23/14,00,00,00,00,94,F8,23/14,00,00,00,00,94,F8,23')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img1 '/'))
}
to MP2 {
comment 'Make this custom block P2'
local '_img2' ('[data:join]' '' '14,00,00,00,00,94,F0,21/14,00,00,00,00,94,F0,21/14,00,00,00,00,94,F0,21/14,00,00,00,00,94,E0,20/14,00,00,00,00,94,E0,20/14,00,00,00,00,94,40,20/14,00,00,00,00,94,40,20/14,00,00,00,00,94,00,20/14,00,00,00,00,94,FF,3F/14,00,00,00,00,14,00,00/14,00,00,00,00,14,00,00/14,00,00,00,00,14,00,00/14,00,00,00,00,94,FF,3F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/14,00,00,00,00,94,FF,3F/14,00,00,00,00,14,00,00/14,00,00,00,00,14,00,00')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img2 '/'))
}
to MP3 {
comment 'Make this custom block P3'
local '_img3' ('[data:join]' '' '14,00,00,00,00,14,00,00/14,00,00,00,00,14,00,00/14,00,00,00,00,94,FF,3F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/F4,FF,FF,FF,FF,97,FF,3F/04,00,00,00,00,10,00,00/F4,FF,FF,FF,FF,17,00,00/14,00,00,00,00,14,00,00/14,00,00,00,00,94,FF,3F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/14,01,00,00,80,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FC,27/14,00,00,00,00,94,F8,23/14,00,00,00,00,94,E0,20/14,00,00,00,00,94,FE,2F')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img3 '/'))
}
to MP4 {
comment 'Make this custom block P4'
local '_img4' ('[data:join]' '' '14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FC,27/14,00,00,00,00,94,F8,23/14,00,00,00,00,94,E0,20/14,00,00,00,00,94,40,20/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,FE,2F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,FF,3F/14,00,00,00,00,14,00,00/14,00,00,00,00,14,00,00/14,00,00,00,00,14,00,00/14,00,00,00,00,94,FF,3F/14,00,00,00,00,94,00,20/14,00,00,00,00,94,08,22/14,00,00,00,00,94,08,22/14,00,00,00,00,94,08,22/14,00,00,00,00,94,10,21/14,00,00,00,00,94,E0,20/14,00,00,00,00,94,C0,20/14,00,00,00,00,94,20,21/14,00,00,00,00,94,10,22/14,00,00,00,00,94,08,22/14,00,00,00,00,94,08,22/14,01,00,00,00,94,BE,2F/14,00,00,00,80,94,1C,27/14,00,00,00,00,94,08,22/14,00,00,00,00,94,00,20/14,00,00,00,00,94,00,20/F4,FF,FF,FF,FF,97,FF,3F/04,00,00,00,00,10,00,00/FC,FF,FF,FF,FF,1F,00,00')
_imgBMPTbl = ('[data:join]' _imgBMPTbl ('[data:split]' _img4 '/'))
}
to MPPIC {
comment 'Make this custom block PIC.
Assembles a user PICTURE into the
global _imgBMPTbl
Delimiter is "comma" uni(44)
Picture lines are "comma + /" terminated.'
_imgBMPTbl = ('[data:makeList]')
MP1
MP2
MP3
MP4
}
module 'OLED128x64(1306-09)'
author 'Turgut Guneysu'
version 2 3.5
depends Strings miscPrims
choices ModeMenu Horizontal Vertical
choices TargetMenu Display GDBuffer
choices OnOffMenu On Off
choices VideoMenu Inverse Normal
choices ScrollMenu1 Right Left
choices ScrollMenu2 'Vert-Right' 'Vert-Left'
choices LineMenu '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''
choices DispTypeMenu 'OLED_0.96in' 'OLED_2.42in'
description 'Supports 0.96in and 2.42in OLED Displays with SD1306 and SD1309 chipsets. Comm mode is I2C or SPI.
Changes:
- fix pixel off logic
- name change
'
variables OLEDReady OLEDi2cAddr _GDBufReady _GDBuffer _INITseq _begCol _begRow _cHexTBL _cLINEUniTBL _cList _comma _cStarts _cTABLE _clearSprite _col _comMode _dList _dcPin _delayGDUpd _displayType _endCol _endRow _hexTbl _imgBMPTbl _lineHexTBL _lineTABLE _resetPin _row char invFlag timer _cmdPrefix
spec ' ' 'OLEDInit_I2C' 'OLEDInit_I2C _ I2CAddr(hex) _ ResetPin# _' 'str.DispTypeMenu auto auto' 'OLED_0.96in' '3C' 0
spec ' ' 'OLEDInit_SPI' 'OLEDInit_SPI _ D/CPin# _ ResetPin# _' 'str.DispTypeMenu auto auto' 'OLED_2.42in' 16 8
spec ' ' 'OLEDClear' 'OLEDClear'
spec ' ' 'OLEDFlip' 'OLEDFlip'
spec ' ' 'OLEDColMode' 'OLEDColMode Beg (1-16) _ End (1-16) _' 'auto auto' 1 16
spec ' ' 'OLEDContrast' 'OLEDContrast (1-4) _' 'auto' 2
spec ' ' 'OLEDCursorReset' 'OLEDCursorReset'
spec ' ' 'OLEDDisplay' 'OLEDDisplay _' 'str.OnOffMenu' 'On'
spec ' ' 'OLEDDispString' 'OLEDDispString _ InvYN _ : Row (1-8) _ Col (1-16) _' 'auto bool auto auto' 'Hello!' false 1 1
spec ' ' 'OLEDDrawCircle' 'OLEDDrawCircle Cx (0-127) _ Cy (0-63) _ R _ Pix On _' 'auto auto auto bool' 64 32 '10' true
spec ' ' 'OLEDDrawLine' 'OLEDDrawLine x0 (0-127) _ y0 (0-63) _ x1 _ y1 _ pixOn _' 'auto auto auto auto bool' 0 0 127 63 true
spec ' ' 'OLEDDrawPic' 'OLEDDrawPic ImgList _ To _ : Row (0-7) _ Col (0-127) _' 'auto str.TargetMenu auto auto' '' 'Display' 0 0
spec ' ' 'OLEDDrawRect' 'OLEDDrawRect TLx (0-127) _ TLy (0-63) _ BRx _ BRy _ Pix On _ Rounded _ R(3-15) _' 'auto auto auto auto bool bool auto' 0 0 127 63 true false 3
spec ' ' 'OLEDDrawSprite' 'OLEDDrawSprite _ Row (1-8) _ Col (1-128) _' 'auto auto auto' 0 1 1
spec ' ' 'OLEDDrawString' 'OLEDDrawString _ Row (1-8) _ Col (1-128) _ InvYN _' 'auto auto auto bool' 'Hello!' 1 1 false
spec 'r' 'OLEDMakeSprite' 'OLEDMakeSprite _ : sprSeed(0-33554431) _' 'microbitDisplay auto' 15237440 0
spec ' ' 'OLEDMode' 'OLEDMode _' 'str.ModeMenu' 'Horizontal'
spec ' ' 'OLEDPixel' 'OLEDPixel Px (0-127) _ Py (0-63) _ Pix On _' 'auto auto bool' 0 0 true
spec ' ' 'OLEDSetVideo' 'OLEDSetVideo _' 'str.VideoMenu' 'Inverse'
spec ' ' 'OLEDShowGDBuffer' 'OLEDShowGDBuffer'
spec ' ' 'OLEDZoomMode' 'OLEDZoomMode _' 'str.OnOffMenu' 'On'
spec ' ' '_GDDRAMoff' '_GDDRAMoff'
spec ' ' '_GDDRAMon' '_GDDRAMon'
spec ' ' '_L1' '_L1'
spec ' ' '_L2' '_L2'
spec ' ' '_OLEDReset' '_OLEDReset Pin# _' 'auto' '0'
spec ' ' '_OLEDReveal' '_OLEDReveal Delay(ms) _' 'auto' 0
spec ' ' '_OLEDScroll-RL' '_OLEDScroll-RL _ BegRow (1-8) _ EndRow _ BegCol (1-128) _ EndCol _' 'str.ScrollMenu1 auto auto auto auto' 'Right' 1 8 1 128
spec ' ' '_OLEDScroll-VRL' '_OLEDScroll-VRL _ BegRow (1-8) _ EndRow _ #Hor (0-1) _ #Ver (0-63) _ BegCol (1-128) _ EndCol _' 'str.ScrollMenu2 auto auto auto auto auto auto' 'Vert-Right' 1 8 0 1 1 128
spec ' ' '_OLEDStopScroll' '_OLEDStopScroll'
spec ' ' '_SPIWriteCmd' '_SPIWriteCmd'
spec ' ' '_SPIWriteData' '_SPIWriteData'
spec ' ' '_T1' '_T1'
spec ' ' '_T2' '_T2'
spec ' ' '_T3' '_T3'
spec ' ' '_T4' '_T4'
spec 'r' '_bufPtr2rc' '_bufPtr2rc _' 'auto' '10'
spec ' ' '_buildHexTBL' '_buildHexTBL'
...
This file has been truncated, please download it to see its full contents.
Comments