Skip to content

MakeCode extension for controlling SSD1306 OLED display 128×64 using BBC micro:bit.

License

Notifications You must be signed in to change notification settings

Pythom1234/pxt-oled

Repository files navigation

Extension for control SSD1306 OLED display 128×64.

Blocks

argument is the color of pixel on the OLED display. The true means that the pixel will be on, false means that the pixel will be off.

and arguments are the x and y positions. Point 0,0 is in the upper left corner of the display. The display is 128 pixels wide (x) and 64 pixels high (y). This means that can be from 0 to 127 and can be from 0 to 63.

argument sets whether pixel inversion is used instead of pixel redrawing.

oled.init()

Initalize OLED display connected at address 60 (0x3C) on I2C. Must be called when the program starts.

oled.setContrast(255)

Sets contrast of display (0 to 255).

oled.clear(false)

Fills the display with .

oled.draw()

Sends data to the OLED display. You have to call it whenever you want to update the display.

oled.setPx(0, 0, true)

Sets the pixel color at position to .

oled.togglePx(0, 0)

Toggles the pixel color at position .

oled.px(0, 0)

Returns the pixel color at position .

oled.drawText("text", 0, 0, true, false)

Draws the text , which has the upper left corner at position . The color of the text is determined by .

oled.drawRect(0, 0, 10, 10, true, false, false)

Draws a rectangle with the upper left vertex at position and the lower right vertex at position . The option specifies whether the rectangle will be filled with the color. If false, then only the outline is drawn.

oled.drawLine(0, 0, 10, 10, true, false)

Draws a line from position to position

oled.drawImage(images.createImage(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`), 0, 0, true, false, false)

Show of type Image at position . Fields filled in white in the image are drawn in on the OLED display. The determines whether fields that are not filled with white are also drawn. You can add image from the Images category or import Imageio library: https://github.com/Pythom1234/pxt-imageio

oled.addChar(oled.charImage(`
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
`), "c")

oled.addChar: Add character for function oled.drawText(). The character is specified by .

oled.charImage: Make image for oled.addChar(). It's 8 pixels wide and 11 pixels high.

Examples

I also made a extension that uses OLED display (it's is still in development): https://github.com/Pythom1234/pxt-games

License

MIT

Supported targets

  • for PXT/microbit
<script src="https://makecode.com/gh-pages-embed.js"></script><script>makeCodeRender("{{ site.makecode.home_url }}", "{{ site.github.owner_name }}/{{ site.github.repository_name }}");</script>

About

MakeCode extension for controlling SSD1306 OLED display 128×64 using BBC micro:bit.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages