Hi! I’m trying to control a ledstrip(ws2812) from my openHAB colorpicker
I followed this tutorial:https://tutorials-raspberrypi.de/raspberry-pi-openhab-2-ws2801-ws2812-rgb-led-streifen-steuern/
When I test the strip with the example script, it works perfect, but the original code dont
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time, sys, inspect, ast
import RPi.GPIO as GPIO
# Import the WS2801 module.
import Adafruit_WS2801
import Adafruit_GPIO.SPI as SPI
# Configure the count of pixels:
PIXEL_COUNT = 32
# other settings
SPI_PORT = 0
SPI_DEVICE = 0
pixels = Adafruit_WS2801.WS2801Pixels(PIXEL_COUNT, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE), gpio=GPIO)
################################################################################
# DEFINE YOUR FUNCTIONS HERE
################################################################################
def setRGBColor(pixels, r=255, g=255, b=255):
# cast from string to int
r, g, b = int(float(r)), int(float(g)), int(float(b))
pixels.set_pixels( Adafruit_WS2801.RGB_to_color( r, g, b ) )
pixels.show()
if __name__ == "__main__":
if len(sys.argv) < 4:
sys.exit(1)
cmdargs = sys.argv[1:]
setRGBColor(pixels, cmdargs[0], cmdargs[1], cmdargs[2])
Thats the code to send the colorpick values to the WS2801 but I want it working on my WS2812
I assume i have to modify and should look like that code
#!/usr/bin/env python3
from neopixel import *
# LED strip configuration:
LED_COUNT = 16 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN = 10 # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 10 # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
# Define functions
# Here is where i should "translate" the ws2801 code to ws2812(?)
And there is the openhab log, where its correctly reading the colorpicker value and sending it to the script
[ome.event.ItemCommandEvent] - Item 'WS28xx_Strip' received command 67,54,100
[vent.ItemStateChangedEvent] - WS28xx_Strip changed from 0,0,100 to 67,54,100
[INFO ] [pse.smarthome.model.script.WS Status] - 238.93499999541000,255.00,117.3000
[INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/usr/bin/python3 /etc/openhab2/scripts/ws28xx.py 238.93499999541000 255.00 117.3000'
Any help? I’m really stuck