Skip to content

Instantly share code, notes, and snippets.

@mwelling
Created August 29, 2018 03:23
Show Gist options
  • Save mwelling/3381aa45f3dcc4b76c8a7f930106cfb5 to your computer and use it in GitHub Desktop.
Save mwelling/3381aa45f3dcc4b76c8a7f930106cfb5 to your computer and use it in GitHub Desktop.
Epaper driver usage for OHSummit badge
The above code assumes that you have the driver code for the display and font built-in.
See pull request:
https://github.com/acamilo/micropython/pull/1
It also assumes that you have loaded the happy180.bmp onto the filesystem of the module.
The bitmap was taken from here:
https://github.com/ayoy/micropython-waveshare-epd/blob/master/epd/gfx/happy180.bmp
I loaded the file onto the badge using rshell.
michael@qwertyuiop:~/projects/ohs2018-badge/micropython-waveshare-epd/epd/gfx$ rshell --buffer-size=30 -p /dev/ttyUSB0 -a -e vi
Connecting to /dev/ttyUSB0 ...
Welcome to rshell. Use Control-D to exit.
/home/michael/projects/ohs2018-badge/micropython-waveshare-epd/epd/gfx> cp happy180.bmp /pyboard
/home/michael/projects/ohs2018-badge/micropython-waveshare-epd/epd/gfx>
from machine import Pin
import gxgde0213b1
import font12
import font20
reset = Pin(16, Pin.OUT)
dc = Pin(25, Pin.OUT)
busy = Pin(4, Pin.IN)
cs = Pin(5, Pin.OUT)
epd = gxgde0213b1.EPD(reset, dc, busy, cs)
epd.init()
fb_size = int(epd.width * epd.height / 8)
fb = bytearray(fb_size)
epd.clear_frame(fb)
epd.set_rotate(gxgde0213b1.ROTATE_90)
epd.display_string_at(fb, 0, 0, "Hello World!", font20, gxgde0213b1.COLORED)
epd.draw_bmp_at(fb, 10, 10, 'happy180.bmp', gxgde0213b1.COLORED)
epd.display_frame(fb)
@pdp7
Copy link

pdp7 commented Sep 19, 2018

import uos
from flashbdev import bdev
from machine import Pin
import gxgde0213b1
import font12
import font20
import font24

try:
    if bdev:
        uos.mount(bdev, '/')
except OSError:
    import inisetup
    vfs = inisetup.setup()

gc.collect()


reset = Pin(16, Pin.OUT)
dc = Pin(25, Pin.OUT)
busy = Pin(4, Pin.IN)
cs = Pin(5, Pin.OUT)
epd = gxgde0213b1.EPD(reset, dc, busy, cs)
epd.init()
fb_size = int(epd.width * epd.height / 8)
fb = bytearray(fb_size)
epd.clear_frame(fb)
epd.set_rotate(gxgde0213b1.ROTATE_90)
epd.display_string_at(fb, 0, 0, "Drew Fustini", font24, gxgde0213b1.COLORED)
epd.display_string_at(fb, 0, 24, "@pdp7", font24, gxgde0213b1.COLORED)
epd.display_frame(fb)
``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment