I’m Sorry, little one…

We have MAJOR progress on the lightshow

###IMPORTS###

import board

import time

import random

from lib import neopixel #If you’re grabbing the “neopixel.mpy” file, GRAB THE LARGER ONE

sleep_time = 1

###DEF FUNCTIONS###

#This is what the code will initially do when it recieves a message, kinda like a notification

def static_gen(test_time_limit = False, test_time_max = 3):

    static_delay = 0

    static_time_total = 0

        #randomized logic to disperse time.sleeps

    if random.randint(0,8) == 0:

        pixels.fill((0,0,0))

        time.sleep(0.5)

    else:

        #pick random colors per random LED

        for i in range(random.randint(75, 150)): #loops over the code multiple times

            static_delay = .2*random.random()

            #test mode feature to cut off the remaining static loop time

            if test_time_limit:

                if static_time_total >= test_time_max:

                    break

            pixels[random.randint(0, num_pixels-1)] = random.choice(list(colors.values()))

            time.sleep(static_delay)

            pixels.fill((0,0,0))

            #test mode feature to count up the time used delaying

            if test_time_limit:

                static_time_total += static_delay

#This is what the program will do with the lights when nothing is happening

def idle_xmas(counter):

    print(counter)

    if counter == 0:

        #pixels.fill(colors[“RED”])

        for i in range(num_pixels):

            if i %2 ==0:

                pixels[i-1] = colors[“RED”]

            else:

                pixels[i-1] = colors[“GREEN”]

        time.sleep(sleep_time)

        counter += 1

    elif counter == 1:

        for i in range(num_pixels):

            if i %2 ==0:

                pixels[i-1] = colors[“GREEN”]

            else:

                pixels[i-1] = colors[“RED”]

        counter -= 1

        time.sleep(sleep_time)

    else:

        counter = 0

    return counter

def msg_display(message = “PLACEHOLDER”):

    time.sleep(sleep_time)

    for char in message:

        pixels.fill((0,0,0))

        time.sleep(.05)

        if char.isalpha():

            pixels[letters[char.upper()]] = random.choice(list(colors.values()))

            time.sleep(sleep_time)

        elif char.isdigit():

            char = int(char)

            if char< 1 or char > 26:

                pass

            else:

                for i in range(0, char):

                    pixels[i] = random.choice(list(colors.values()))

                    time.sleep(sleep_time)

                time.sleep(sleep_time)

        else:

            pixels.fill((0,0,0))

            time.sleep(sleep_time)

#def color dictionary

colors = {

    “RED” : (255,0,0),

    “ORANGE” : (255,105,0),

    “GOLD” : (255,215,0),

    “YELLOW” : (255,255,0),

    “YELLOW-GREEN” : (170,255,0),

    “GREEN” : (0,255,0),

    “TURQOISE” : (0,255,170),

    “CYAN” : (0,255,255),

    “SKY” : (0,170,255),

    “BLUE” : (0,0,255),

    “PURPLE” : (170,0,255),

    “UHH” : (255,0,255),

    “HOT PINK” : (255,0,170),

    “WHITE” : (255,255,255),

    “test brown” : (153,102,0)

}

#define alphabet to number dictionary

letters = {

    “A” : 0,

    “B” : 1,

    “C” : 2,

    “D” : 3,

    “E” : 4,

    “F” : 5,

    “G” : 6,

    “H” : 7,

    “I” : 8,

    “J” : 9,

    “K” : 10,

    “L” : 11,

    “M” : 12,

    “N” : 13,

    “O” : 14,

    “P” : 15,

    “Q” : 16,

    “R” : 17,

    “S” : 18,

    “T” : 19,

    “U” : 20,

    “V” : 21,

    “W” : 22,

    “X” : 23,

    “Y” : 24,

    “Z” : 25,

}

# Update this to match the number of NeoPixel LEDs connected to your board

num_pixels = 26 #need moar LEDs to get ALL letters

#define your NeoPixel object and its brightness

pixels = neopixel.NeoPixel(board.GP22, num_pixels)

pixels.brightness = 0.5

message_acquired = True

counter = 0

while True:

    counter = idle_xmas(counter)

    if random.random() < .1:

        message_acquired = True

    if message_acquired:

        static_gen(True, 2)

        msg_display(“Hi World 2”)

        message_acquired = False

|| No Time to explain, The Child beckons more ||


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *