Quantcast
Viewing all articles
Browse latest Browse all 5091

Troubleshooting • Re: Did anyone get the screen blanking to work properly?

Ah... I think I may have found the source of the problem for me, but that has raised a secondary question....

I have a set of USB connected APA-102 LED's running a Cheerlights colour feed via a Python script as a service. I've found that after killing this task, the screen blanks and stays blanked.... So... What do I need to check and try and avoid to prevent this script from awakening the screen blanking or is it a service configuration I need to be aware of?

Kind regards,

Jon.

Soft-cheerlights.py

Code:

#!/usr/bin/env python#Based on original cheerlights.py from Pimoroniimport timefrom colorsys import hsv_to_rgbfrom colorsys import rgb_to_hsvfrom copy import copyfrom sys import exittry:    import requestsexcept ImportError:    exit("This script requires the requests module\nInstall with: sudo pip install requests")from mote import Motemote = Mote()num_pixels = 16transition_time = 1 # secondstransition_step = 100mote.configure_channel(1, num_pixels, False)mote.configure_channel(2, num_pixels, False)mote.configure_channel(3, num_pixels, False)mote.configure_channel(4, num_pixels, False)def is_cnx_active(timeout):  try:    requests.head("http://www.google.com/", timeout=timeout)    return True  except:    return Falsewhile True:  if is_cnx_active(2) is True:    # Do something    print("The internet connection is active")    break  else:    print("Waiting for internet")    passtry:    channels_colour_rgb = [[0,0,0], [0,0,0], [0,0,0], [0,0,0]]    channels_colour = [[0,0,0], [0,0,0], [0,0,0], [0,0,0]]    channels_colour_delta = [[0,0,0], [0,0,0], [0,0,0], [0,0,0]]    old_channels_colour = [[0,1,0], [0,1,0], [0,1,0], [0,1,0]]    while True:        r = requests.get('http://api.thingspeak.com/channels/1417/feed.json')        j = r.json()        f = j['feeds'][-4:]        f = [element for index, element in enumerate(f) if index%1==0]        print(f)        # get the new colours        channel = 1        for col in f:            col = col['field2']            r, g, b = bytearray.fromhex(col.lstrip('#'))            h,s,v = rgb_to_hsv(r,g,b)            channels_colour_rgb[channel - 1][0] = r            channels_colour_rgb[channel - 1][1] = g            channels_colour_rgb[channel - 1][2] = b            channels_colour[channel - 1][0] = h            channels_colour[channel - 1][1] = s            channels_colour[channel - 1][2] = v            #calculate the count for each            for idx in range(0,3):                channels_colour_delta[channel - 1][idx] = (channels_colour[channel - 1][idx] - old_channels_colour[channel - 1][idx]) / float(transition_step)            channel += 1             print(channels_colour_rgb)        if old_channels_colour != channels_colour:            # Do the transition            for step in range(0, transition_step):                for channel in range(1, 5):                    for idx in range(0,3):                        old_channels_colour[channel - 1][idx] += channels_colour_delta[channel - 1][idx]                        r,g,b = hsv_to_rgb(old_channels_colour[channel - 1][0],                                           old_channels_colour[channel - 1][1],                                           old_channels_colour[channel - 1][2]);                        for pixel in range(mote.get_pixel_count(channel)):                            mote.set_pixel(channel, pixel, int(r), int(g), int(b))                        mote.show()                time.sleep(transition_time / transition_step)        for channel in range(0, 4):            for idx in range(0,3):                old_channels_colour[channel][idx] = channels_colour[channel][idx]        time.sleep(45)except KeyboardInterrupt:    mote.clear()    mote.show()    time.sleep(0.1)

Statistics: Posted by Jonovich — Fri Dec 29, 2023 11:08 pm



Viewing all articles
Browse latest Browse all 5091

Trending Articles