diff --git a/oled/Dockerfile b/oled/Dockerfile new file mode 100644 index 0000000..2acf4a4 --- /dev/null +++ b/oled/Dockerfile @@ -0,0 +1,27 @@ +# +# Dockerfile for oled +# + +FROM easypi/alpine-arm +MAINTAINER EasyPi Software Foundation + +RUN set -xe \ + && apk add --no-cache build-base \ + curl \ + linux-headers \ + python \ + python-dev \ + freetype \ + freetype-dev \ + jpeg \ + jpeg-dev \ + && curl https://bootstrap.pypa.io/get-pip.py | python \ + && pip install luma.oled \ + && apk del --purge build-base \ + curl \ + linux-headers \ + python-dev \ + freetype-dev \ + jpeg-dev + +ENTRYPOINT ["python"] diff --git a/oled/README.md b/oled/README.md new file mode 100644 index 0000000..d41c57d --- /dev/null +++ b/oled/README.md @@ -0,0 +1,22 @@ +oled +==== + +## Demo + +``` +OLED Pin | Name | Remarks | RPi Pin | RPi Function +---------+------+---------+---------+-------------- +1 | GND | Ground | P01-6 | GND +2 | VCC | +3.3V | P01-1 | 3V3 +3 | SCL | Clock | P01-5 | GPIO 3 (SCL) +4 | SDA | Data | P01-3 | GPIO 2 (SDA) +``` + +```bash +# Show "hello world" on oled display module +$ cat demo.py | docker-compose run --rm oled +``` + +## Todo + +- [ ] Implement RESTful API diff --git a/oled/demo.py b/oled/demo.py new file mode 100644 index 0000000..8de28ed --- /dev/null +++ b/oled/demo.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +from luma.core.interface.serial import i2c +from luma.core.render import canvas +from luma.oled.device import ssd1306 + +serial = i2c(port=1, address=0x3C) +device = ssd1306(serial) +device.cleanup = lambda _: None + +with canvas(device) as draw: + draw.rectangle(device.bounding_box, outline="white", fill="black") + draw.text((30, 40), "Hello World", fill="white") diff --git a/oled/docker-compose.yml b/oled/docker-compose.yml new file mode 100644 index 0000000..1100aa9 --- /dev/null +++ b/oled/docker-compose.yml @@ -0,0 +1,4 @@ +oled: + image: easypi/oled-arm + devices: + - /dev/i2c-1