Screen bitmaps
Use the eink module to display multiple bitmaps on the screen, in a single draw.
Code
toit
import lightbug.devices as devices
import lightbug.services as services
import lightbug.messages.messages_gen as messages
import lightbug.util.bitmaps show lightbug-20-20 lightbug-30-30 lightbug-40-40
/**
A simple application that demonstrates drawing bitmaps on the E-ink display.
This example shows how to display a Lightbug logo.
*/
main:
device := devices.I2C --background=false
screen-width := 250
screen-height := 122
bitmap-dimension := 40
positions := [
[messages.DrawElement.REDRAW-TYPE_CLEARDONTDRAW, 0, 0], // Top left
[messages.DrawElement.REDRAW-TYPE_BUFFERONLY, (screen-width - 1 - bitmap-dimension), 0], // Top right
[messages.DrawElement.REDRAW-TYPE_BUFFERONLY, 0, (screen-height - 1 - bitmap-dimension)], // Bottom left
[messages.DrawElement.REDRAW-TYPE_FULLREDRAWWITHOUTCLEAR, (screen-width - 1 - bitmap-dimension), (screen-height - 1 - bitmap-dimension)], // Bottom right
]
print "💬 Sending bitmap logos to device screen"
positions.do: | p |
device.eink.draw-bitmap --status-bar-enable=false --redraw-type=p[0] --x=p[1] --y=p[2] --width=bitmap-dimension --height=bitmap-dimension --bitmap=lightbug-40-40Bitmaps
The bitmaps used, are the Lightbug logo, which are included in the project, as byte arrays.
toit
// 20x20 Lightbug logo
lightbug-20-20 := #[
0X0F,0XFF,0X00,0X3F,0XFF,0XC0,0X7F,0XFF,0XE0,0X7F,0XFF,0XE0,0XFF,0X0F,0XF0,0XFE,
0X07,0XF0,0XFF,0XFF,0XF0,0XFE,0X07,0XF0,0XFE,0X07,0XF0,0XFE,0X07,0XF0,0XFE,0X07,
0XF0,0XFE,0X07,0XF0,0XFE,0X07,0XF0,0XFE,0X07,0XF0,0XFE,0X07,0XF0,0XFE,0X07,0XF0,
0X7F,0XFF,0XE0,0X7F,0XFF,0XE0,0X3F,0XFF,0XC0,0X0F,0XFF,0X00
]
// 30x30 Lightbug logo
lightbug-30-30 := #[
0X00,0X00,0X00,0X00,0X0F,0XFF,0XFF,0XC0,0X3F,0XFF,0XF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F,0XFC,0X18,0X3F,0XFE,0X7F,
0XFC,0X18,0X3F,0XFE,0X7F,0XFC,0X18,0X3F,0XFE,0X7F,0XFC,0X18,0X3F,0XFE,0X7F,0XFC,
0X18,0X3F,0XFE,0X7F,0XFC,0X18,0X3F,0XFE,0X7F,0XFC,0X18,0X3F,0XFE,0X7F,0XFC,0X18,
0X3F,0XFE,0X7F,0XFC,0X18,0X3F,0XFE,0X7F,0XFC,0X18,0X3F,0XFE,0X7F,0XFC,0X18,0X3F,
0XFE,0X7F,0XFC,0X18,0X3F,0XFE,0X7F,0XFC,0X18,0X3F,0XFE,0X7F,0XFF,0XFF,0XFF,0XFE,
0X7F,0XFF,0XFF,0XFF,0XFE,0X7F,0XFF,0XFF,0XFF,0XFE,0X3F,0XFF,0XFF,0XFF,0XFC,0X3F,
0XFF,0XFF,0XFF,0XFC,0X1F,0XFF,0XFF,0XFF,0XF8,0X0F,0XFF,0XFF,0XFF,0XF0,0X03,0XFF,
0XFF,0XFF,0XC0,0X00,0X00,0X00,0X00,0X00
]Output
[jaguar] INFO: program e3e5e232-7e31-0dbc-ce54-d994d415033a started
💬 Sending bitmap logos to device screen
[jaguar] INFO: program e3e5e232-7e31-0dbc-ce54-d994d415033a stoppedResult
You should see four bitmaps drawn, one in each corner.
