Trying to get OLED SPI 1.2 in front port of large breakout garden working.
The garden is OK, as it’s fine with a BME280 sensor
Host is a Pi Zero 2W
SPI & I2C interfaces are enabled
python3 font_awesome.py --display sh1106 --height 128 --rotate 2 --interface spi --gpio-data-command 9 --spi-device 1
Says:
font_awesome.py: error: argument --display/-d: invalid choice: 'sh1106' (choose from 'max7219', 'ws2812', 'neopixel', 'neosegment', 'apa102', 'unicornhathd', 'linux_framebuffer')
Any ideas, please?
Thanks!
Shoe
December 2, 2023, 8:10pm
2
Can you link the screen and code you’re using? At a glance I can’t see any Pimoroni display with that size/driver chip, so if that’s a Pimoroni script it might not be built to support other displays and drivers.
ahnlak
December 3, 2023, 9:23am
4
Can’t spot that message anywhere obvious in that repo, so I’m guessing you’ve followed a link to something that doesn’t support a SH1106 display.
Tricky to say much more without knowing what it is that you’re running :-)
Shoe
December 3, 2023, 11:06am
5
It looks like that might be trying to run using luma.led_matrix
, rather than luma.oled
, as the matrix verison has a simlar list of supported devices.
As @ahnlak said, it’s really hard to know what’s going wrong here without the exact code.
Trying to use the examples provided, e.g., bounce.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2014-18 Richard Hull and contributors
# See LICENSE.rst for details.
# PYTHON_ARGCOMPLETE_OK
"""
Display a bouncing ball animation and frames per second.
Attribution: https://github.com/rogerdahl/ssd1306/blob/master/examples/bounce.py
"""
import sys
import random
from demo_opts import get_device
import luma.core.render
from luma.core.sprite_system import framerate_regulator
class Ball(object):
def __init__(self, w, h, radius, color):
self._w = w
self._h = h
self._radius = radius
self._color = color
self._x_speed = (random.random() - 0.5) * 10
self._y_speed = (random.random() - 0.5) * 10
self._x_pos = self._w / 2.0
self._y_pos = self._h / 2.0
def update_pos(self):
if self._x_pos + self._radius > self._w:
self._x_speed = -abs(self._x_speed)
elif self._x_pos - self._radius < 0.0:
self._x_speed = abs(self._x_speed)
if self._y_pos + self._radius > self._h:
self._y_speed = -abs(self._y_speed)
elif self._y_pos - self._radius < 0.0:
self._y_speed = abs(self._y_speed)
self._x_pos += self._x_speed
self._y_pos += self._y_speed
def draw(self, canvas):
canvas.ellipse((self._x_pos - self._radius, self._y_pos - self._radius,
self._x_pos + self._radius, self._y_pos + self._radius), fill=self._color)
def main(num_iterations=sys.maxsize):
colors = ["red", "orange", "yellow", "green", "blue", "magenta"]
balls = [Ball(device.width, device.height, i * 1.5, colors[i % 6]) for i in range(10)]
frame_count = 0
fps = ""
canvas = luma.core.render.canvas(device)
regulator = framerate_regulator(fps=0)
while num_iterations > 0:
with regulator:
num_iterations -= 1
frame_count += 1
with canvas as c:
c.rectangle(device.bounding_box, outline="white", fill="black")
for b in balls:
b.update_pos()
b.draw(c)
c.text((2, 0), fps, fill="white")
if frame_count % 20 == 0:
fps = "FPS: {0:0.3f}".format(regulator.effective_FPS())
if __name__ == '__main__':
try:
device = get_device()
main()
except KeyboardInterrupt:
pass
pi@raspberrypi:~/luma.examples/examples $ python3 bounce.py --display sh1106 --height 128 --rotate 2 --interface spi --gpio-data-command 9 --spi-device 1
usage: bounce.py [-h] [--config CONFIG] [--display DISPLAY] [--width WIDTH]
[--height HEIGHT] [--rotate ROTATION] [--interface INTERFACE]
[--i2c-port I2C_PORT] [--i2c-address I2C_ADDRESS]
[--spi-port SPI_PORT] [--spi-device SPI_DEVICE]
[--spi-bus-speed SPI_BUS_SPEED]
[--spi-transfer-size SPI_TRANSFER_SIZE]
[--spi-cs-high SPI_CS_HIGH] [--ftdi-device FTDI_DEVICE]
[--framebuffer-device FRAMEBUFFER_DEVICE] [--gpio GPIO]
[--gpio-mode GPIO_MODE]
[--gpio-data-command GPIO_DATA_COMMAND]
[--gpio-chip-select GPIO_CHIP_SELECT]
[--gpio-reset GPIO_RESET] [--gpio-backlight GPIO_BACKLIGHT]
[--gpio-reset-hold-time GPIO_RESET_HOLD_TIME]
[--gpio-reset-release-time GPIO_RESET_RELEASE_TIME]
[--block-orientation ORIENTATION] [--mode MODE]
[--framebuffer FRAMEBUFFER] [--num-segments NUM_SEGMENTS]
[--bgr] [--inverse] [--h-offset H_OFFSET]
[--v-offset V_OFFSET] [--backlight-active VALUE] [--debug]
bounce.py: error: argument --display/-d: invalid choice: 'sh1106' (choose from 'max7219', 'ws2812', 'neopixel', 'neosegment', 'apa102', 'unicornhathd', 'linux_framebuffer')
Or without the launch arguments/options,
pi@raspberrypi:~/luma.examples/examples $ python3 bounce.py
OSError: [Errno 121] Remote I/O error
Thank you.
ahnlak
December 4, 2023, 10:59am
7
Well yes, but that still doesn’t tell us what you’ve actually installed, so we’re still guessing.
As @Shoe says above, it looks like you have the led_matrix
drivers set up, which won’t drive a SH1106 display - you probably need oled
drivers instead, it being an oled screen and all…
No idea to be perfectly honest. Thanks for all the help, I’m going to re-image the SD card and start again.