Jump to content

Recommended Posts

Posted

Hello

Ones again I need Your advice for steering RGB LED APA106.

I try to search for any program to control this Led but most of them is for RPI and it`s not work for My OPI.

2446293100_1577806970_thumb.jpg

 

Is this connection for DIN should by for any SPI1?:

5420831300_1577806995_thumb.jpg

 

Do You have idea how to for example set change color of led ?

 

Regards

 

 

 

Posted
1 hour ago, djmcg said:

Do You have idea how to for example set change color of led ?

You need some NeoPixel library ...

Here are some info extracted from https://gist.github.com/probonopd/97f6826cc5aa3c0c0950682b0bc266bc

WS2812B Neopixels driven by Python

Connect the data line of the WS2812B Neopixels to pin SPI1_MOSI/PA15. In /boot/armbianEnv.txt we need:

overlays=spi-spidev
param_spidev_spi_bus=1
param_spidev_max_freq=100000000

We can successfully compile the needed Python libraries on the device itself:

git clone https://github.com/doceme/py-spidev.git
cd py-spidev
make -j4
make install
cd ..
git clone https://github.com/joosteto/ws2812-spi.git
find ws2812-spi/ -type f -name '*.py' -exec sed -i -e 's|spi.open(0,0)|spi.open(1,0)|g' {} \;
find ws2812-spi/ -type f -name '*.py' -exec sed -i -e 's|tx=\[\]|tx=\[0x00\]|g' {} \;

Make sure to use spi.open(1,0); we need to use SPI bus 1 since the internal SPI Flash is connected to SPI bus 0.

# Make 16 LEDs red
./ws2812-spi/ws2812.py -c "[[0,255,0]]" -n 16

# Make 16 LEDs white
./ws2812-spi/ws2812.py -c "[[255,255,255]]" -n 16

# Switch 16 LEDs off
./ws2812-spi/ws2812.py -c "[[0,0,0]]" -n 16

 

Posted

Hello thank for reply:

16 hours ago, martinayotte said:

Connect the data line of the WS2812B Neopixels to pin SPI1_MOSI/PA15

I Have the OPI WIN not Zero so I connect to SPI1_MOSI/PD2 hope it`s good.

 

Next I edit the /boot/armbianEnv.txt file like below :

7226695300_1577872340_thumb.jpg

and saved.

Next steps like You wrote please check:

5631425300_1577872422_thumb.jpg

Unfortunately I have error:

9246514600_1577872514_thumb.jpg

 

Could You advice what I`m doing wrong?

 

 


 

Posted
4 hours ago, djmcg said:

Could You advice what I`m doing wrong?

It seems not finding the /dev/spi1.0 ...

Did you rebooted after having edited the /boot/armbianEnv.txt to add the overlay ?

Posted
Just now, djmcg said:

What You mean "overlay"

This is loading an overlay :

overlays=spi-spidev
param_spidev_spi_bus=1

It should make /dev/spi1.0 appearing ...

 

Which Armbian image are you using ?

 

Posted

The system image: https://dl.armbian.com/_old/orangepiwin/archive/Armbian_19.11.4_Orangepiwin_bionic_current_5.3.13_desktop.img.gz

Now I have problem with connection to internet :(

Posted

Hello

I just reinstall Armbian and RGB led start work

However after update

sudo apt install python-numpy

My LED colors is change now off is red and other colors is diffrent

Could You advice why?

?

 

 

 

Posted

I just uninstall python-numpy an color back to normal.

 

I would like to wrote some short code for change colors in python

Could You advice how to implement this

commands for code

On 12/31/2019 at 6:13 PM, martinayotte said:

# Make 16 LEDs red ./ws2812-spi/ws2812.py -c "[[0,255,0]]" -n 16 # Make 16 LEDs white ./ws2812-spi/ws2812.py -c "[[255,255,255]]" -n 16 # Switch 16 LEDs off ./ws2812-spi/ws2812.py -c "[[0,0,0]]" -n 16

 

Posted
1 hour ago, djmcg said:

Could You advice how to implement this

commands for code

What do you mean ?

Do you mean alternating colors within the same script ?

Simply add sleep command between each calls to ws2812.py ...

Posted
13 hours ago, martinayotte said:

What do you mean ?

Do you mean alternating colors within the same script ?

Simply add sleep command between each calls to ws2812.py ...

Yes I know how to generate colors

But won`t work

I don`t know where to paste this script of different colors.

 

Snap1.jpg

Posted
4 hours ago, djmcg said:

But won`t work

You seems to add calls within the script itself, which is bad technique, resulting to such python error ...

Leave the script unmodified and use a bash script as the master script such as :

 

#!/bin/bash

while true; do
	./ws2812-spi/ws2812.py -c "[[255,0,0]]" -n 16
	sleep 0.5
	./ws2812-spi/ws2812.py -c "[[0,255,0]]" -n 16
	sleep 0.5
	./ws2812-spi/ws2812.py -c "[[0,0,255]]" -n 16
	sleep 0.5
done

 

Posted

I`m really need update script in Python

 

Do You have idea how to update this script for example to kept the same effect what You wrote ?

 

 

Posted
1 hour ago, djmcg said:

I`m really need update script in Python

 

Do You have idea how to update this script for example to kept the same effect what You wrote ?

Then delete all those lines :

    if color!=None:
        write2812(spi, eval(color)*nLED)
    elif doTest:
        test_fixed(spi, nLED)
    else:
        usage()

and add those ones :

    while 1:
        write2812(spi, [[255,0,0])
        time.sleep(0.5)	
        write2812(spi, [[0,255,0])
        time.sleep(0.5)	
        write2812(spi, [[0,0,255])
        time.sleep(0.5)	

Be careful about indentation, python is strict about line alignements ...

Posted

I paste the code what You wrote and perform some updates

 

Unfortunately it`s not work

However

I make some short script like You mentioned before and it`s work but it`s something wrong the RGB LED sometime when should be "off" [(black) (0,0,0)] sometimes shines as RED.

 



 

 

 

Snap4.jpg

Posted
5 minutes ago, djmcg said:

Unfortunately it`s not work

You use parenthesis instead of brackets !!! :lol:

It should be "write2812(spi, [[0,0,255]])" instead of "write2812(spi, (0,0,255))"

Posted

Maybe due to the fact that you didn't provide color inside quotes ...

Try something like :

Green = "/root/Downloads/ws2812-spi/ws2812.py -c \"[[0,255,0]]\" -n 1"

 

Posted

Update code

But nothing chnage 

(however i just lern how to use "" twice  :) Thanks (\" did`t know\" )

import os
import time

White = "/root/Downloads/ws2812-spi/ws2812.py -c \"[[255,255,255]]\" -n 1"
Green = "/root/Downloads/ws2812-spi/ws2812.py -c \"[[0,255,0]]\" -n 1"
Blue =  "/root/Downloads/ws2812-spi/ws2812.py -c \"[[0,0,255]]\" -n 1"
Red = 	"/root/Downloads/ws2812-spi/ws2812.py -c \"[[255,0,0]]\" -n 1"
Off = 	"/root/Downloads/ws2812-spi/ws2812.py -c \"[[0,0,0]]\" -n 1"
y = 0.5

while True:
	
	os.system(White)
	print("white")
	time.sleep(y)
	os.system(Off)
	print("sleep")
	time.sleep(y)
	
	os.system(Blue)
	time.sleep(y)
	os.system(Off)
	time.sleep(y)
	
	os.system(Green)
	time.sleep(y)
	os.system(Off)
	time.sleep(y)

 

Posted
38 minutes ago, djmcg said:

But nothing chnage

But what are the color discripancies ?

White is white, right ?

Maybe bytes are swapped, for example, is red become blue ?

Posted
3 hours ago, djmcg said:

I`m observe that often [0,0,0] (turnoff) is RED.

If you only send [0,0,0] frequently, does it becomes RED sometimes ?

If Yes, maybe it is SPI speed issue ...

Posted
20 hours ago, martinayotte said:

If you only send [0,0,0] frequently, does it becomes RED sometimes ?

 

Yes.

It`s any possible to rework that? any resistor help?

Posted
1 hour ago, djmcg said:

It`s any possible to rework that?

I don't know, maybe by lowering the SPI speed ...

Try to change those lines, replacing the 1.05 by 5.05 :

    #print [hex(v) for v in tx]
    spi.xfer(tx, int(4/1.05e-6))
1 hour ago, djmcg said:

any resistor help?

Issue has nothing to do with resistor ...

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines