YahboomTechnology / Raspberry-Pi-RGB-Cooling-HAT

Raspberry Pi RGB Cooling HAT with adjustable fan and OLED display for Pi5/4B/3B+/3B
https://category.yahboom.net/products/rgb-cooling-hat
38 stars 17 forks source link

RGB control #3

Open stutteringp0et opened 3 years ago

stutteringp0et commented 3 years ago

What the heck is wrong with the RGB control?

Using the supplied rgb.py script, it turns on random LEDs to random colors every time I run it.

The last line of the script is:

setRGB(Max_LED, 0, 0, 255)

As I read it, Max_LED sets all 3 lights, no red or green, and 100% blue - so this line says turn all 3 lights blue (0,0,255)....but that isn't what happens. I may or may not get all 3 lights, the lights that do turn on may or may not be blue. It seems completely random.

When I write a script to control a single LED, turning LED0 white (255,255,255) - it's a toss up as to which LED comes on, and what color it is when it does.

import smbus
import time
bus = smbus.SMBus(1)

addr = 0x0d
rgb_off_reg = 0x07

def setRGB0(r, g, b):
    bus.write_byte_data(addr, rgb_off_reg, 0x00)
    #time.sleep(2)
    bus.write_byte_data(addr, 0x00, 0&0xff)
    bus.write_byte_data(addr, 0x01, r&0xff)
    bus.write_byte_data(addr, 0x02, g&0xff)
    bus.write_byte_data(addr, 0x03, b&0xff)

setRGB0(255,255,255)
stutteringp0et commented 3 years ago

Even the command to turn the LEDs off isn't consistent.

If I run this from the python shell, it occasionally turns the LEDs on!

bus.write_byte_data(addr, rgb_off_reg, 0x00)