Skip to content

trevorwslee/MicroPython-DumbDisplay

Repository files navigation

DumbDisplay MicroPython Library (v0.5.0)

DumbDisplay MicroPython Library -- workable with Python 3 -- is a port of the DumbDisplay Arduino Library to Micro-Python / Python 3 for the DumbDisplay Android app

For a video introduction, please watch the YouTube video: Introducing DumbDisplay MicroPython Library -- with ESP32, Raspberry Pi Pico, and Raspberry Pi Zero

Although the porting is work in progress, nevertheless, a large portion of DumbDisplay functionalities have been ported. Hopefully, this should already be helpful for friends that develop programs for microcontroller boards in Micro-Python.

As hinted previously, even it is originally targeted for MicroPython, it should be useful with regular Python 3, like in Raspberry Pi environment or even with desktop / laptop. As a result, it can be an alternative way to prototype Android app driven remotely with Python 3 from desktop / laptop.

Enjoy

Installation

For Micro-Python, please refer to the above-mentioned YouTube video for examples of using DumbDisplay MicroPython Library for microcontroller programming.

If your targeted is desktop / laptop, you can install the package like:

pip install git+https://github.com/trevorwslee/MicroPython-DumbDisplay

If you would like to try out the development version (for desktop / laptop), you can install the development version like:

pip install --upgrade --force-reinstall git+https://github.com/trevorwslee/MicroPython-DumbDisplay@develop

Getting Started

The basic script setup is:

  1. import core, for creating DumbDisplay object
  2. import IO mechanism, for creating IO object, like
  • io4Inet(the default) -- Python networking support (not available for Micro-Python)
  • io4Wifi -- Micro-Python WiFi support (for Raspberry Pi Pico W, ESP32, etc.)
  1. import layers, for creating layer objects

For example (using Python networking support with io4Inet as io )

from dumbdisplay.core import *
from dumbdisplay.io_inet import *
from dumbdisplay.layer_ledgrid import *
dd = DumbDisplay()  # default io is io4Inet()
l = LayerLedGrid(dd)
l.turnOn()

A simple sample that explicitly makes use of WiFi io4Wifi as io, can be like

from dumbdisplay.core import *
from dumbdisplay.io_wifi import *
from dumbdisplay.layer_ledgrid import *
import time
dd = DumbDisplay(io4Wifi("ssid", "password"))
l = LayerLedGrid(dd, 2, 1)
l.offColor("green")
l.turnOn()
for _ in range(10):
    time.sleep(1)
    l.toggle(0, 0)
    l.toggle(1, 0)
dd.writeComment("DONE")    

A simple sample that polls for feedbacks, can be like

from dumbdisplay.core import *
from dumbdisplay.io_inet import *
from dumbdisplay.layer_ledgrid import *
dd = DumbDisplay()  # default io is io4Inet()
l = LayerLedGrid(dd, 20, 20)
l.enableFeedback("fa")
l.offColor(RGB_COLOR(0xcc, 0xcc, 0xcc))
while True:
    feedback = l.getFeedback()
    if feedback is not None:
        print("l FB: {}: {},{}".format(feedback.type, feedback.x, feedback.y))
        l.toggle(feedback.x, feedback.y)

A more complete simple sample that also shows "auto pin" as well, can be like

from dumbdisplay.core import *
from dumbdisplay.io_inet import *
from dumbdisplay.layer_lcd import *
from dumbdisplay.layer_graphical import *

_last_x = -1
_color = "red"
def feedback_handler(layer, type, x, y):
    global _last_x, _last_y, _color
    if layer == l:
        if _last_x != -1:
            l.drawLine(_last_x, _last_y, x, y, _color)
        _last_x = x
        _last_y = y
    else:    
        if layer == l_r:
            _color = "red"
        elif layer == l_g:
            _color = "green"
        elif layer == l_b:
            _color = "blue"            
        _last_x = -1   


dd = DumbDisplay()  # default io is io4Inet()
l_r = LayerLcd(dd)
l_g = LayerLcd(dd)
l_b = LayerLcd(dd)
l = LayerGraphical(dd, 150, 100)
l_r.backgroundColor("red")
l_g.backgroundColor("green")
l_b.backgroundColor("blue")
l.backgroundColor("white")
l.border(3, "black")
l_r.enableFeedback("f", feedback_handler=feedback_handler)
l_g.enableFeedback("f", feedback_handler=feedback_handler)
l_b.enableFeedback("f", feedback_handler=feedback_handler)
l.enableFeedback("fs:rpt50", feedback_handler=feedback_handler)
AutoPin('V', AutoPin('H', l_r, l_g, l_b), l).pin(dd)
while True:
    dd.timeslice()

Notes:

  • If seeing ESP32 brownout detection issue, try
    import machine
    machine.reset_cause()
    
  • If DumbDisplay Android app fails to make connection to desktop / laptop, check your desktop firewall settings; try switching desktop WIFI to use 2.4 GHz.

Selected Demos

Here is a few Raspberry Pi Pico PIO demos that might interested you

Respberry Pi Pico W Generating Tones With Programmable I/O (PIO) Using MicroPython Respberry Pi Pico W NeoPixels Experiments With Programmable I/O (PIO) Using MicroPython

Thank You!

Greeting from the author Trevor Lee:

Peace be with you! May God bless you! Jesus loves you! Amazing Grace!

License

MIT

Change History

v0.5.0

  • ported "level options" for LayerGraphical
  • ported LayerSelection
  • added dumbdisplay_examples package
  • bug fixes

v0.3.1

  • ported LayerJoystick

v0.3.0

  • checked Raspberry Pi Pico W WIFI support
  • ported more options from Arduino DumbDisplay library
  • bug fixes

v0.2.1

  • ported LayerPlotter
  • ported "layer margin"
  • bug fixes

About

DumbDisplay MicroPython Library is a port of the Arduino DumbDisplay Library (https://github.com/trevorwslee/Arduino-DumbDisplay) for the DumbDisplay Android app -- https://play.google.com/store/apps/details?id=nobody.trevorlee.dumbdisplay

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published