Skip to content

Instantly share code, notes, and snippets.

@mwelling
Created August 29, 2018 03:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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

--0000000000002db27c05761bee74
Content-Type: text/plain; charset="UTF-8"

michael@qwertyuiop:~/projects/ohs2018-badge-firmware/micropython/ports/esp32$
git diff
diff --git a/ports/esp32/modules/_boot.py b/ports/esp32/modules/_boot.py
index bf40ea3a..24a55b07 100644
--- a/ports/esp32/modules/_boot.py
+++ b/ports/esp32/modules/_boot.py
@@ -1,5 +1,10 @@
 import gc
 import uos
+from machine import Pin
+import gxgde0213b1
+import font12
+import font20
+
 from flashbdev import bdev

 try:
@@ -10,3 +15,16 @@ except OSError:
     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, "Hello World! - OHS", font20,
gxgde0213b1.COLORED)
+epd.display_frame(fb)

@pdp7
Copy link

pdp7 commented Sep 19, 2018

@pdp7
Copy link

pdp7 commented Sep 19, 2018

note: need to install rshell from pip:

pdp7@sp3:~/ohs2018-badge-firmware/micropython-waveshare-epd/epd/gfx$ sudo pip3 install rshell
The directory '/home/pdp7/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/pdp7/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting rshell
  Downloading https://files.pythonhosted.org/packages/1e/75/c3b2cdc23fb1bb36c90980e7887bdfe6b27e39fb1cbb0cd88a7a3eefe925/rshell-0.0.15.tar.gz (41kB)
    100% |████████████████████████████████| 51kB 1.7MB/s 
Collecting pyserial (from rshell)
  Downloading https://files.pythonhosted.org/packages/0d/e4/2a744dd9e3be04a0c0907414e2a01a7c88bb3915cbe3c8cc06e209f59c30/pyserial-3.4-py2.py3-none-any.whl (193kB)
    100% |████████████████████████████████| 194kB 2.0MB/s 
Collecting pyudev>=0.16 (from rshell)
  Downloading https://files.pythonhosted.org/packages/bc/a2/31a07829acea8e70a28c247f43fa5d981229ae0f9edfeddedf52de00709b/pyudev-0.21.0.tar.gz (89kB)
    100% |████████████████████████████████| 92kB 3.6MB/s 
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from pyudev>=0.16->rshell)
Installing collected packages: pyserial, pyudev, rshell
  Running setup.py install for pyudev ... done
  Running setup.py install for rshell ... done
Successfully installed pyserial-3.4 pyudev-0.21.0 rshell-0.0.15
pdp7@sp3:~/ohs2018-badge-firmware/micropython-waveshare-epd/epd/gfx$ rshell --buffer-size=30 -p /dev/ttyUSB0 -a -e vi
Connecting to /dev/ttyUSB0 ...

@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