Forked from https://github.com/Tinkertanker/pxt-oled-ssd1306
- Translate into Chinese Simplified
- Add more functions:
"OLED.drawCircle|block": "画圆 x %x|y %y|r %r",
"OLED.fillCircle|block": "填充圆 x %x|y %y|r %r",
"OLED.drawLine|block": "画线 x0 %x0|y0 %y0|x1 %x1|y1 %y1",
"OLED.drawRect|block": "画矩形 x %x|y %y|w %w|h %h",
"OLED.fillRect|block": "填充矩形 x %x|y %y|w %w|h %h",
"OLED.drawRoundRect|block": "画带圆角的矩形 x %x|y %y|w %w|h %h|r %r",
"OLED.fillRoundRect|block": "填充带圆角的矩形 x %x|y %y|w %w|h %h|r %r",
"OLED.drawTriangle|block": "画三角形 x0 %x0|y0 %y0|x1 %x1|y1 %y1|x2 %x2|y2 %y2",
"OLED.fillTriangle|block": "填充三角形 x0 %x0|y0 %y0|x1 %x1|y1 %y1|x2 %x2|y2 %y2"
1.打开https://makecode.microbit.org/
2.积木块列表中点击“高级”,拉到最下面有个“添加软件包”
3.搜索框中输入https://github.com/xuefengedu/pxt-oled-ssd1306_CN ,点击搜索按钮,点击下面显示的软件包“SSD1306_OLED 用户提供的软件包,非微软维护。SSD1306 OLED液晶micro:bit pxt扩展包”
SSD1306 makecode picture:
sample 1 hex download 点击链接后,页面上有3个按钮:“Raw”按钮,“Blame”按钮,“History”按钮,在“Raw”按钮上右键,另存为,进行下载。
sample 2 hex download 比sample 1多加了开始时设置画图显示为关闭,结束时再一次性显示画图的结果。而不是像第一次那样每次画图都显示,第一次每画一笔都发送数据去显示一次,那样效率有点低。
点击上面的链接后,页面上有3个按钮:“Raw”按钮,“Blame”按钮,“History”按钮,在“Raw”按钮上右键,另存为,进行下载。
This is the MakeCode Package for SSD1306 OLED controller, based on the Adafruit Arduino library available here.
- Insert the OLED display into the I2C ports on the break out board.
Initializes the OLED display.
Sets up the OLED display and prepares it for use by the micro:bit.
OLED.init(64, 128);
This block must be placed before any of the show
blocks.
Displays a string on the OLED module.
OLED.showString("hello, micro:bit!")
The init
block must be placed before this.
Displays a number on the OLED module.
OLED.showNumber(123)
The init
block must be placed before this.
Clears the display.
OLED.clear()
The init
block must be placed before this.
The following code is a simple counter that displays an increasing number every second.
OLED.init(64, 128)
let item = 0
basic.forever(() => {
basic.pause(1000)
item += 1
OLED.showNumber(item)
})
- for PXT/microbit