Code Monkey home page Code Monkey logo

Comments (5)

nickehallgren avatar nickehallgren commented on September 27, 2024 1

So I got it to work as I wanted, this how I solved it

import atexit, time
from luma.core.render import canvas
from luma.core.interface.serial import spi, gpio_cs_spi
from luma.oled.device import ssd1306
import RPi.GPIO as GPIO


cs_pins = [16, 26, 19, 13, 12]
serials = [gpio_cs_spi(device=0, port=0, gpio_CS=cs) for cs in cs_pins]
devices = [ssd1306(serials[i], height=32, rotate=0) for i, _ in enumerate(cs_pins)]

def cleanup():
  for device in devices:
    device.clear()
  GPIO.cleanup()

atexit.register(cleanup)

for i, device in enumerate(devices, start=1):
  with canvas(device) as draw:
    draw.rectangle(device.bounding_box, outline="white", fill="black")
    draw.text((10, 10), f"DISPLAY {i}", fill="white")

while True:
  time.sleep(0.1)

from luma.oled.

thijstriemstra avatar thijstriemstra commented on September 27, 2024

Why do you use GPIO.output(pin, GPIO.LOW if j == i else GPIO.HIGH)?

from luma.oled.

nickehallgren avatar nickehallgren commented on September 27, 2024

@thijstriemstra Without that all the displays are looping "Display 1", "Display 2" etc all the time (they are all showing the same text)... But without it I get text on the first four displays after a restart of the program...

from luma.oled.

thijstriemstra avatar thijstriemstra commented on September 27, 2024

I wouldn't 'manually' try to change the gpio pins that luma.oled manages, unless there's a really good reason (e.g bugfix). This sounds to me like it's a coding issue (I want to show X) rather than an issue with luma.oled?

But without it I get text on the first four displays after a restart of the program...

Maybe do the cleear of the screens in the cleanup instead, e.g.

def cleanup():
  for device in devices:
    device.clear()
  GPIO.cleanup()

atexit.register(cleanup)

Or do a cleanup of the CS pins manually instead of using GPIO.cleanup()?

Also: try different/default SPI bus speeds..

from luma.oled.

nickehallgren avatar nickehallgren commented on September 27, 2024

I agree, I'm pretty sure the problem is my code. The change to the cleanup fixed the restart issue. Removed the bus_speed but still have same text on all displays (or actually only on four out of five).

I have also experimented with code from here #311 but didn't get the gpio_cs_spi to work

All help is greatly appreciated

from luma.oled.

Related Issues (20)

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.