Coder Social home page Coder Social logo

mcauser / micropython-ssd1327 Goto Github PK

View Code? Open in Web Editor NEW
25.0 4.0 11.0 2.8 MB

MicroPython driver for SSD1327 128x128 4-bit greyscale OLED displays

License: MIT License

Python 100.00%
micropython ssd1327 oled-display grove-oled-display grove

micropython-ssd1327's Introduction

MicroPython SSD1327

A MicroPython library for SSD1327 128x128 4-bit greyscale OLED displays, over I2C.

For example, the Grove - OLED Display 1.12" which features a 96x96 display.

demo

Example

Copy the file to your device, using ampy, webrepl or compiling and deploying. eg.

$ ampy put ssd1327.py

Hello World

import ssd1327

# using Software I2C
from machine import SoftI2C, Pin
i2c = SoftI2C(sda=Pin(21), scl=Pin(22)) # TinyPICO
# i2c = SoftI2C(sda=Pin(0), scl=Pin(1)) # Raspberry Pi Pico
# i2c = SoftI2C(sda=Pin(4), scl=Pin(5)) # WeMos D1 Mini

# or using Hardware I2C
from machine import I2C, Pin
i2c = I2C(0) # TinyPICO sda=19, scl=18

display = ssd1327.SEEED_OLED_96X96(i2c)  # Grove OLED Display
# display = ssd1327.SSD1327_I2C(128, 128, i2c)  # WaveShare, Zio Qwiic

display.text('Hello World', 0, 0, 255)
display.show()

display.fill(0)
for y in range(0,12):
    display.text('Hello World', 0, y * 8, 15 - y)
display.show()

See /examples for more.

Parts

Connections

TinyPICO ESP32 Grove OLED
GPIO22 (SCL) SCL
GPIO21 (SDA) SDA
3V3 VCC
GND GND
Raspberry Pi Pico Grove OLED
GPIO1 (I2C0_SCL) SCL
GPIO0 (I2C0_SDA) SDA
3V3 VCC
GND GND
WeMos D1 Mini Grove OLED
D1 (GPIO5) SCL
D2 (GPIO4) SDA
3V3 (or 5V) VCC
G GND

Links

License

Licensed under the MIT License.

micropython-ssd1327's People

Contributors

mcauser avatar rodrigocmn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

micropython-ssd1327's Issues

Cannot run on Mac Mojave

I can't your helloworld on Thonny after copying ssd1327.py to my rasppi pico, I got this error

%Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "", line 13, in
File "ssd1327.py", line 191, in init
File "ssd1327.py", line 178, in init
File "ssd1327.py", line 77, in init
File "ssd1327.py", line 121, in poweron
File "ssd1327.py", line 182, in write_cmd
OSError: 5

Obtaining present state of a pixel

First of all, thanks for this awesome library. I am using it with an Adafruit 128x128 grayscale oled connected to a Pi Pico. It works great. Quick question: is there a way to interrogate the display, returning the present state of a specific pixel?(something akin to lcd.get(x,y)). Apologies if this is obvious, I am a noob to micropython.
Thanks again!

off-set shifted a bit

First of all Thanks a lot for this library .

I'm using a Chinese 1.5" OLED Module bought from taobao. It's not from seeed studio.

Now when I used this with my wemos D1 mini, I found an issue:
When I issue this command
display.text('Seeed Studio',0, 0, 15)
I get the offset moved down.
shifted off set on screen

to make my life easier, I started by creating a separate class in your ssd1327.py, for my display, which is 128x128

class OLED_128X128(SSD1327_I2C):
    def __init__(self, i2c):
        super().__init__(128, 128, i2c)

    def rotate(self, rotate):
        self.poweroff()
        self.write_cmd(SET_DISP_OFFSET)
        self.write_cmd(0x60 if rotate else 0x20) # 0x20=0 degrees, 0x60=180 degrees
        self.write_cmd(SET_SEG_REMAP)
        self.write_cmd(0x42 if rotate else 0x51) # 0x51=0 degrees, 0x42=180 degrees
        self.poweron()

    def lookup(self, table):
        # GS0 has no pre-charge and current drive
        self.write_cmd(SET_GRAYSCALE_TABLE)
        for i in range(0,15):
            self.write_cmd(table[i])

Then this line caught my eye:
self.write_cmd(SET_DISP_OFFSET)

Then I found, in the class SSD1327 under def init_display(self):
SET_DISP_OFFSET, 0x20, # Set vertical offset by COM from 0~127
I modified it to:

# SET_DISP_OFFSET, 0x20, # Set vertical offset by COM from 0~127
SET_DISP_OFFSET, 0x00, # Set vertical offset by COM from 0~127

Then I uploaded the modified lib to my wemos and upon testing with:

import ssd1327
from machine import I2C, Pin
i2c = I2C(sda=Pin(4), scl=Pin(5))
display = ssd1327.OLED_128X128(i2c)
display.fill(0)
display.text('Seeed Studio',0, 0, 15)
display.text('Seeed Studio',0, 120, 15)# to get the full range
display.show()

I get correct placements:
corrected off set on screen

May be you can make a scope for this in a better solution in your library and then we can all benefit from it.
This is the current modified version after I forked from you

Thank you again.

Rpi Pico HW i2c initialization problem

Hello Mike,

i am trying to initialize this with HS i2c in RPi Pico, but no success, only on SW...
i have 128x128 display, with SW it works ok, but slow
in samples and documentation i cannot see how to tell in code which i2c pins i am using.

import ssd1327
from machine import I2C, Pin
i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=400000)
display = ssd1327.SSD1327_I2C(128, 128, i2c)

with this it shows ->
Traceback (most recent call last):
File "", line 4, in
File "ssd1327.py", line 178, in init
File "ssd1327.py", line 78, in init
File "ssd1327.py", line 113, in init_display
File "ssd1327.py", line 186, in write_data
OSError: [Errno 110] ETIMEDOUT

is there error in library, or my code... ?

Suppport for Raspberry Pi Pico

The new Raspberry Pi Pico's MicroPython does not support start, write and stop operations for IC2. These operations are used in the write_data function.

The solution I've found was to identify the board via uos.uname() and use IC2.writeto() operation. This solution is included in my forked version, so I will create a pull request in case you want to merge the code.

BTW, I've also included a fix for chinese OLEDs offset problem in this pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.