Guest User

Daft Punk Mask

a guest
Oct 21st, 2022
1,499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 31.65 KB | Source Code | 0 0
  1. from neopixel import Neopixel
  2. import random
  3. import utime
  4.  
  5. numpix = 256 #static value
  6.  
  7. strip = Neopixel(numpix, 0, 0, "GRB") #RGB Matrix settings (Num pixels, machine state, GPIO, arrangement)
  8. strip.fill((0,0,0)) #clear the board on startup
  9.  
  10. #setting up RGB settings
  11. red = (255, 0, 0)
  12. orange = (255, 50, 0)
  13. yellow = (255, 100, 0)
  14. pink = (255, 108, 210)
  15. green = (0, 255, 0)
  16. blue = (0, 0, 255)
  17. indigo = (100, 0, 90)
  18. violet = (200, 0, 100)
  19. blank = (0,0,0)
  20. white = (255, 255, 255)
  21. colors_rgb = [red, orange, yellow, green, blue, indigo, violet, pink]
  22.  
  23. delay = 0.03
  24. strip.brightness(50) #global value for LED brightness from 1-100
  25.  
  26. # lists of pixels in the side bars
  27. bar_1 = [14, 17, 18, 29, 30, 33, 34, 45, 46, 209, 210, 221, 222, 225, 226, 237, 238, 241]
  28. bar_2 = [19, 27, 28, 35, 36, 43, 44, 211, 212, 219, 220, 227, 228, 236]
  29. bar_3 = [26, 37, 42, 213, 218, 229]
  30. bar_4 = [38, 39, 40, 41, 216, 215, 214, 217]
  31.  
  32. hoz_index = [0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133] #index values for pix[] that represent the top most pixel of each column
  33.  
  34. # list of pixels not including sides and unused top and bottom rows and also put into a non stupid order
  35. pix = [49, 50, 51, 52, 53, 54, 55, 62, 61, 60, 59, 58, 57, 56, 65, 66, 67, 68, 69, 70, 71, 78, 77, 76, 75, 74, 73,
  36.        72, 81, 82, 83, 84, 85, 86, 87, 94, 93, 92, 91, 90, 89, 88, 97, 98, 99, 100, 101, 102, 103, 110, 109, 108,
  37.        107, 106, 105, 104, 113, 114, 115, 116, 117, 118, 119, 126, 125, 124, 123, 122, 121, 120, 129, 130, 131,
  38.        132, 133, 134, 135, 142, 141, 140, 139, 138, 137, 136, 145, 146, 147, 148, 149, 150, 151, 158, 157, 156,
  39.        155, 154, 153, 152, 161, 162, 163, 164, 165, 166, 167, 174, 173, 172, 171, 170, 169, 168, 177, 178, 179,
  40.        180, 181, 182, 183, 190, 189, 188, 187, 186, 185, 184, 193, 194, 195, 196, 197, 198, 199, 206, 205, 204,
  41.        203, 202, 201, 200]
  42.  
  43. def wipe(): #clears the board not including the side bars
  44.     x = 0
  45.     while x <= 215:
  46.         if x in pix:
  47.             strip.set_pixel(x, blank)
  48.         x += 1
  49.     strip.show()
  50.     x = 0
  51.     return
  52.  
  53. def sidebar():
  54.     # Side bar setup
  55.     for x in bar_1:
  56.         strip.set_pixel(x, red, 100)
  57.     for x in bar_2:
  58.         strip.set_pixel(x, yellow, 100)
  59.     for x in bar_3:
  60.         strip.set_pixel(x, blue, 100)
  61.     for x in bar_4:
  62.         strip.set_pixel(x, green, 100)
  63.     strip.show()
  64.     return
  65.  
  66.  
  67. def eq():
  68.     #Graphic Equalizer
  69.     count = 0
  70.     rand_options = [5, 5, 5, 5, 6, 4, 4, 3, 3, 2, 2, 1, 1, 0]
  71.     last_rand = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] #stores the last value for each column, so that the next loop can compare its last value. Initial values are placeholders.
  72.     while count < 300:
  73.         run_count = 0 #a number between 0-21 that tracks where we are in the loop
  74.         for x in pix[0:140:7]: #find position of top most pixel to draw from
  75.             if run_count == 19:
  76.                 run_count = 0
  77.             x = pix.index(x)
  78.             rand = random.choice(rand_options) #find a random choice from the list that determines the amplitude of the line drawn
  79.             if last_rand[run_count] < rand: #compares the random choice for this loop to the last one, to figure out if the line needs clearing
  80.                 strip.set_pixel(pix[x], blank)
  81.                 strip.set_pixel(pix[x+1], blank)
  82.                 strip.set_pixel(pix[x+2], blank)
  83.                 strip.set_pixel(pix[x+3], blank)
  84.                 strip.set_pixel(pix[x+4], blank)
  85.                 strip.set_pixel(pix[x+5], blank)
  86.                 strip.set_pixel(pix[x+6], blank)
  87.                
  88.             last_rand[run_count] = rand #stores the random choice value to a list for comparison
  89.  
  90.             if rand == 0: #bad hardcoding follows
  91.                 strip.set_pixel(pix[x], red)
  92.                 strip.set_pixel(pix[x+1], red)
  93.                 strip.set_pixel(pix[x+2], orange)
  94.                 strip.set_pixel(pix[x+3], green)
  95.                 strip.set_pixel(pix[x+4], green)
  96.                 strip.set_pixel(pix[x+5], green)
  97.                 strip.set_pixel(pix[x+6], green)
  98.             if rand == 1:
  99.                 strip.set_pixel(pix[x+1], red)
  100.                 strip.set_pixel(pix[x+2], orange)
  101.                 strip.set_pixel(pix[x+3], green)
  102.                 strip.set_pixel(pix[x+4], green)
  103.                 strip.set_pixel(pix[x+5], green)
  104.                 strip.set_pixel(pix[x+6], green)
  105.             if rand == 2:
  106.                 strip.set_pixel(pix[x+2], orange)
  107.                 strip.set_pixel(pix[x+3], green)
  108.                 strip.set_pixel(pix[x+4], green)
  109.                 strip.set_pixel(pix[x+5], green)
  110.                 strip.set_pixel(pix[x+6], green)
  111.             if rand == 3:
  112.                 strip.set_pixel(pix[x+3], green)
  113.                 strip.set_pixel(pix[x+4], green)
  114.                 strip.set_pixel(pix[x+5], green)
  115.                 strip.set_pixel(pix[x+6], green)
  116.             if rand == 4:
  117.                 strip.set_pixel(pix[x+4], green)
  118.                 strip.set_pixel(pix[x+5], green)
  119.                 strip.set_pixel(pix[x+6], green)
  120.             if rand == 5:
  121.                 strip.set_pixel(pix[x+5], green)
  122.                 strip.set_pixel(pix[x+6], green)
  123.             if rand == 6:
  124.                 strip.set_pixel(pix[x+6], green)
  125.                
  126.             run_count += 1
  127.         strip.show()
  128.         utime.sleep(0.04)
  129.         count += 1
  130.     return
  131.  
  132. def stars():
  133. #RGB Stars
  134.     count = 0
  135.     while count < 1000:
  136.         strip.set_pixel(random.choice(pix), colors_rgb[random.randint(0, len(colors_rgb)-1)])
  137.         strip.set_pixel(random.choice(pix), blank)
  138.         count += 1
  139.         strip.show()
  140.  
  141.     wipe()
  142.     return
  143.  
  144. def scanner():
  145. #Red scanner
  146.     count = 0
  147.     while count < 4:
  148.         for x in reversed(hoz_index):
  149.             if x == 0 or x == 133:
  150.                 pass
  151.             else:
  152.                 for i in range(-7, 7):
  153.                     strip.set_pixel(pix[x+i], red)
  154.                 strip.show()
  155.                 utime.sleep(delay)
  156.                 for i in range(-7, 7):
  157.                     strip.set_pixel(pix[x+i], blank)
  158.            
  159.         for x in hoz_index:
  160.             if x == 0 or x == 133:
  161.                 pass
  162.             else:
  163.                 for i in range(0, 14):
  164.                     strip.set_pixel(pix[x+i], red)
  165.                 strip.show()
  166.                 utime.sleep(delay)
  167.                 for i in range(0, 14):
  168.                     strip.set_pixel(pix[x+i], blank)
  169.         count += 1
  170.     count = 0
  171.     return
  172.  
  173.  
  174. def iloveDP(): #giggity
  175. #I Heart Daft Punk (This code is not efficent but the LEDs force me to with their shitty layout)
  176.     loop = 0
  177.     while loop < 1:
  178.         #I
  179.         for x in range(61, 79):
  180.             strip.set_pixel(pix[x],blue)
  181.         strip.set_pixel(pix[56],blue)
  182.         strip.set_pixel(pix[57],blue)
  183.         strip.set_pixel(pix[82],blue)
  184.         strip.set_pixel(pix[83],blue)
  185.         strip.show()
  186.         utime.sleep(1.5)
  187.     #clear
  188.         wipe()
  189.        
  190.     #full size heart draw
  191.         #Heart 1
  192.         count = 0
  193.         while count < 4:
  194.             for x in range(8, 11):
  195.                 strip.set_pixel(pix[x],red)
  196.             for x in range(14, 19):
  197.                 strip.set_pixel(pix[x],red)
  198.             for x in range(21, 27):
  199.                 strip.set_pixel(pix[x],red)
  200.             for x in range(29, 35):
  201.                 strip.set_pixel(pix[x],red)
  202.             for x in range(36, 42):
  203.                 strip.set_pixel(pix[x],red)
  204.             for x in range(42, 48):
  205.                 strip.set_pixel(pix[x],red)
  206.             for x in range(49, 54):
  207.                 strip.set_pixel(pix[x],red)
  208.             for x in range(57, 60):
  209.                 strip.set_pixel(pix[x],red)
  210.                
  211.             #Heart 2
  212.             for x in range(8, 11):
  213.                 strip.set_pixel(pix[x+70],red)
  214.             for x in range(14, 19):
  215.                 strip.set_pixel(pix[x+70],red)
  216.             for x in range(21, 27):
  217.                 strip.set_pixel(pix[x+70],red)
  218.             for x in range(29, 35):
  219.                 strip.set_pixel(pix[x+70],red)
  220.             for x in range(36, 42):
  221.                 strip.set_pixel(pix[x+70],red)
  222.             for x in range(42, 48):
  223.                 strip.set_pixel(pix[x+70],red)
  224.             for x in range(49, 54):
  225.                 strip.set_pixel(pix[x+70],red)
  226.             for x in range(57, 60):
  227.                 strip.set_pixel(pix[x+70],red)
  228.             strip.show()
  229.             utime.sleep(0.2)
  230.             wipe()
  231.  
  232.         #small heart draw
  233.             #Heart 1
  234.             for x in range(16, 18):
  235.                 strip.set_pixel(pix[x],red)
  236.             for x in range(22, 26):
  237.                 strip.set_pixel(pix[x],red)
  238.             for x in range(30, 34):
  239.                 strip.set_pixel(pix[x],red)
  240.             for x in range(37, 41):
  241.                 strip.set_pixel(pix[x],red)
  242.             for x in range(43, 47):
  243.                 strip.set_pixel(pix[x],red)
  244.             for x in range(51, 53):
  245.                 strip.set_pixel(pix[x],red)
  246.  
  247.                
  248.             #Heart 2
  249.             for x in range(16, 18):
  250.                 strip.set_pixel(pix[x+70],red)
  251.             for x in range(22, 26):
  252.                 strip.set_pixel(pix[x+70],red)
  253.             for x in range(30, 34):
  254.                 strip.set_pixel(pix[x+70],red)
  255.             for x in range(37, 41):
  256.                 strip.set_pixel(pix[x+70],red)
  257.             for x in range(43, 47):
  258.                 strip.set_pixel(pix[x+70],red)
  259.             for x in range(51, 53):
  260.                 strip.set_pixel(pix[x+70],red)
  261.             strip.show()
  262.             utime.sleep(0.2)
  263.             wipe()
  264.            
  265.             count += 1
  266.            
  267.         vert_pos = 133 #starting the text on the right
  268.         # Draw D
  269.         while vert_pos > -330:
  270.             # Draw D
  271.             for x in range(vert_pos, vert_pos+7): #I have to write one of these for every vertical draw, for the whole two words
  272.                 if x > 139 or x < 0: pass
  273.                 else:
  274.                     strip.set_pixel(pix[x],red)
  275.             for x in range(vert_pos+7, vert_pos+14, 6):
  276.                 if x > 139 or x < 0: pass
  277.                 else:
  278.                     strip.set_pixel(pix[x],red)
  279.             for x in range(vert_pos+15, vert_pos+20, 4):
  280.                 if x > 139 or x < 0: pass
  281.                 else:
  282.                     strip.set_pixel(pix[x],red)
  283.             for x in range(vert_pos+23, vert_pos+26):
  284.                 if x > 139 or x < 0: pass
  285.                 else:
  286.                     strip.set_pixel(pix[x],red)
  287.                    
  288.             #Draw A
  289.             for x in range(vert_pos+36, vert_pos+42):
  290.                 if x > 139 or x < 0: pass
  291.                 else:
  292.                     strip.set_pixel(pix[x],red)
  293.             for x in range(vert_pos+42, vert_pos+47,3):
  294.                 if x > 139 or x < 0: pass
  295.                 else:
  296.                     strip.set_pixel(pix[x],red)
  297.             for x in range(vert_pos+49, vert_pos+54,3):
  298.                 if x > 139 or x < 0: pass
  299.                 else:
  300.                     strip.set_pixel(pix[x],red)
  301.             for x in range(vert_pos+57, vert_pos+63):
  302.                 if x > 139 or x < 0: pass
  303.                 else:
  304.                     strip.set_pixel(pix[x],red)
  305.                    
  306.             #Draw F
  307.             for x in range(vert_pos+70, vert_pos+77):
  308.                 if x > 139 or x < 0: pass
  309.                 else:
  310.                     strip.set_pixel(pix[x],red)
  311.             for x in range(vert_pos+77, vert_pos+81, 3):
  312.                 if x > 139 or x < 0: pass
  313.                 else:
  314.                     strip.set_pixel(pix[x],red)
  315.             for x in range(vert_pos+84, vert_pos+88, 3):
  316.                 if x > 139 or x < 0: pass
  317.                 else:
  318.                     strip.set_pixel(pix[x],red)
  319.             for x in range(vert_pos+91, vert_pos+92):
  320.                 if x > 139 or x < 0: pass
  321.                 else:
  322.                     strip.set_pixel(pix[x],red)
  323.                    
  324.             #Draw T
  325.             for x in range(vert_pos+105, vert_pos+106):
  326.                 if x > 139 or x < 0: pass
  327.                 else:
  328.                     strip.set_pixel(pix[x],red)
  329.             for x in range(vert_pos+112, vert_pos+113):
  330.                 if x > 139 or x < 0: pass
  331.                 else:
  332.                     strip.set_pixel(pix[x],red)
  333.             for x in range(vert_pos+119, vert_pos+126):
  334.                 if x > 139 or x < 0: pass
  335.                 else:
  336.                     strip.set_pixel(pix[x],red)
  337.             for x in range(vert_pos+126, vert_pos+127):
  338.                 if x > 139 or x < 0: pass
  339.                 else:
  340.                     strip.set_pixel(pix[x],red)
  341.             for x in range(vert_pos+133, vert_pos+134):
  342.                 if x > 139 or x < 0: pass
  343.                 else:
  344.                     strip.set_pixel(pix[x],red)
  345.            
  346.             #Draw P
  347.             for x in range(vert_pos+168, vert_pos+175):
  348.                 if x > 139 or x < 0: pass
  349.                 else:
  350.                     strip.set_pixel(pix[x],red)
  351.             for x in range(vert_pos+175, vert_pos+180,3):
  352.                 if x > 139 or x < 0: pass
  353.                 else:
  354.                     strip.set_pixel(pix[x],red)
  355.             for x in range(vert_pos+182, vert_pos+187,3):
  356.                 if x > 139 or x < 0: pass
  357.                 else:
  358.                     strip.set_pixel(pix[x],red)
  359.             for x in range(vert_pos+190, vert_pos+192):
  360.                 if x > 139 or x < 0: pass
  361.                 else:
  362.                     strip.set_pixel(pix[x],red)
  363.            
  364.             #Draw U
  365.             for x in range(vert_pos+203, vert_pos+209):
  366.                 if x > 139 or x < 0: pass
  367.                 else:
  368.                     strip.set_pixel(pix[x],red)
  369.             for x in range(vert_pos+216, vert_pos+217):
  370.                 if x > 139 or x < 0: pass
  371.                 else:
  372.                     strip.set_pixel(pix[x],red)
  373.             for x in range(vert_pos+223, vert_pos+224):
  374.                 if x > 139 or x < 0: pass
  375.                 else:
  376.                     strip.set_pixel(pix[x],red)
  377.             for x in range(vert_pos+224, vert_pos+230):
  378.                 if x > 139 or x < 0: pass
  379.                 else:
  380.                     strip.set_pixel(pix[x],red)
  381.                    
  382.             #Draw N
  383.             for x in range(vert_pos+238, vert_pos+245):
  384.                 if x > 139 or x < 0: pass
  385.                 else:
  386.                     strip.set_pixel(pix[x],red)
  387.             for x in range(vert_pos+247, vert_pos+248):
  388.                 if x > 139 or x < 0: pass
  389.                 else:
  390.                     strip.set_pixel(pix[x],red)
  391.             for x in range(vert_pos+255, vert_pos+256):
  392.                 if x > 139 or x < 0: pass
  393.                 else:
  394.                     strip.set_pixel(pix[x],red)
  395.             for x in range(vert_pos+263, vert_pos+264):
  396.                 if x > 139 or x < 0: pass
  397.                 else:
  398.                     strip.set_pixel(pix[x],red)
  399.             for x in range(vert_pos+266, vert_pos+273):
  400.                 if x > 139 or x < 0: pass
  401.                 else:
  402.                     strip.set_pixel(pix[x],red)
  403.                    
  404.             #Draw K
  405.             for x in range(vert_pos+280, vert_pos+287):
  406.                 if x > 139 or x < 0: pass
  407.                 else:
  408.                     strip.set_pixel(pix[x],red)
  409.             for x in range(vert_pos+290, vert_pos+291):
  410.                 if x > 139 or x < 0: pass
  411.                 else:
  412.                     strip.set_pixel(pix[x],red)
  413.             for x in range(vert_pos+295, vert_pos+297):
  414.                 if x > 139 or x < 0: pass
  415.                 else:
  416.                     strip.set_pixel(pix[x],red)
  417.             for x in range(vert_pos+298, vert_pos+300):
  418.                 if x > 139 or x < 0: pass
  419.                 else:
  420.                     strip.set_pixel(pix[x],red)
  421.             for x in range(vert_pos+301, vert_pos+309,6):
  422.                 if x > 139 or x < 0: pass
  423.                 else:
  424.                     strip.set_pixel(pix[x],red)
  425.                    
  426.            
  427.             vert_pos = vert_pos - 7
  428.             strip.show()
  429.             wipe()
  430.         loop += 1
  431.     return
  432.  
  433. def expanding_heart():
  434.     count = 0
  435.     while count < 4:
  436.         #center heart
  437.         for x in range(43, 46):
  438.             strip.set_pixel(pix[x],red)
  439.         for x in range(49, 54):
  440.             strip.set_pixel(pix[x],red)
  441.         for x in range(56, 62):
  442.             strip.set_pixel(pix[x],red)
  443.         for x in range(64, 70):
  444.             strip.set_pixel(pix[x],red)
  445.         for x in range(71, 77):
  446.             strip.set_pixel(pix[x],red)
  447.         for x in range(77, 83):
  448.             strip.set_pixel(pix[x],red)
  449.         for x in range(84, 89):
  450.             strip.set_pixel(pix[x],red)
  451.         for x in range(92, 95):
  452.             strip.set_pixel(pix[x],red)
  453.         strip.show()
  454.         utime.sleep(0.05)
  455.         wipe()
  456.         #smaller heart
  457.         for x in range(50, 53):
  458.             strip.set_pixel(pix[x],red)
  459.         for x in range(57, 61):
  460.             strip.set_pixel(pix[x],red)
  461.         for x in range(65, 69):
  462.             strip.set_pixel(pix[x],red)
  463.         for x in range(72, 76):
  464.             strip.set_pixel(pix[x],red)
  465.         for x in range(78, 82):
  466.             strip.set_pixel(pix[x],red)
  467.         for x in range(85, 88):
  468.             strip.set_pixel(pix[x],red)
  469.         strip.show()
  470.         utime.sleep(0.05)
  471.         #back to full heart
  472.         for x in range(43, 46):
  473.             strip.set_pixel(pix[x],red)
  474.         for x in range(49, 54):
  475.             strip.set_pixel(pix[x],red)
  476.         for x in range(56, 62):
  477.             strip.set_pixel(pix[x],red)
  478.         for x in range(64, 70):
  479.             strip.set_pixel(pix[x],red)
  480.         for x in range(71, 77):
  481.             strip.set_pixel(pix[x],red)
  482.         for x in range(77, 83):
  483.             strip.set_pixel(pix[x],red)
  484.         for x in range(84, 89):
  485.             strip.set_pixel(pix[x],red)
  486.         for x in range(92, 95):
  487.             strip.set_pixel(pix[x],red)
  488.         strip.show()
  489.         utime.sleep(0.05)
  490.        
  491.         #expansion ring green
  492.         strip.set_pixel(pix[63], green)
  493.         strip.set_pixel(pix[70], green)
  494.         strip.set_pixel(pix[42], green)
  495.         strip.set_pixel(pix[91], green)
  496.         strip.set_pixel(pix[62], green)
  497.         strip.set_pixel(pix[83], green)
  498.         for x in range(46, 48):
  499.             strip.set_pixel(pix[x],green)
  500.         for x in range(95, 97):
  501.             strip.set_pixel(pix[x],green)
  502.         for x in range(46, 48):
  503.             strip.set_pixel(pix[x],green)
  504.         for x in range(54, 56):
  505.             strip.set_pixel(pix[x],green)
  506.         for x in range(89, 91):
  507.             strip.set_pixel(pix[x],green)
  508.         for x in range(98, 103):
  509.             strip.set_pixel(pix[x],green)
  510.         for x in range(35, 40):
  511.             strip.set_pixel(pix[x],green)
  512.         for x in range(29, 32):
  513.             strip.set_pixel(pix[x],green)
  514.         for x in range(106, 109):
  515.             strip.set_pixel(pix[x],green)
  516.         strip.show()
  517.         utime.sleep(0.05)
  518.        
  519.         #expansion ring blue
  520.         strip.set_pixel(pix[28], blue)
  521.         strip.set_pixel(pix[105], blue)
  522.         strip.set_pixel(pix[48], blue)
  523.         strip.set_pixel(pix[97], blue)
  524.         for x in range(40, 42):
  525.             strip.set_pixel(pix[x],blue)
  526.         for x in range(103, 105):
  527.             strip.set_pixel(pix[x],blue)
  528.         for x in range(32, 34):
  529.             strip.set_pixel(pix[x],blue)
  530.         for x in range(109, 111):
  531.             strip.set_pixel(pix[x],blue)
  532.         for x in range(21, 26):
  533.             strip.set_pixel(pix[x],blue)
  534.         for x in range(112, 117):
  535.             strip.set_pixel(pix[x],blue)
  536.         for x in range(15, 18):
  537.             strip.set_pixel(pix[x],blue)
  538.         for x in range(120, 123):
  539.             strip.set_pixel(pix[x],blue)
  540.         strip.show()
  541.         utime.sleep(0.05)
  542.        
  543.         #expansion ring violet
  544.         strip.set_pixel(pix[34], violet)
  545.         strip.set_pixel(pix[111], violet)
  546.         strip.set_pixel(pix[119], violet)
  547.         strip.set_pixel(pix[14], violet)
  548.         for x in range(117, 119):
  549.             strip.set_pixel(pix[x],violet)
  550.         for x in range(26, 28):
  551.             strip.set_pixel(pix[x],violet)
  552.         for x in range(18, 20):
  553.             strip.set_pixel(pix[x],violet)
  554.         for x in range(123, 125):
  555.             strip.set_pixel(pix[x],violet)
  556.         for x in range(126, 131):
  557.             strip.set_pixel(pix[x],violet)
  558.         for x in range(7, 12):
  559.             strip.set_pixel(pix[x],violet)
  560.         for x in range(1, 4):
  561.             strip.set_pixel(pix[x],violet)
  562.         for x in range(134, 137):
  563.             strip.set_pixel(pix[x],violet)
  564.         strip.show()
  565.         utime.sleep(0.05)
  566.        
  567.         #expansion ring white
  568.         strip.set_pixel(pix[0], white)
  569.         strip.set_pixel(pix[133], white)
  570.         strip.set_pixel(pix[125], white)
  571.         strip.set_pixel(pix[20], white)
  572.         for x in range(131, 133):
  573.             strip.set_pixel(pix[x],white)
  574.         for x in range(12, 14):
  575.             strip.set_pixel(pix[x],white)
  576.         for x in range(4, 6):
  577.             strip.set_pixel(pix[x],white)
  578.         for x in range(137, 139):
  579.             strip.set_pixel(pix[x],white)
  580.         strip.show()
  581.         utime.sleep(0.05)
  582.        
  583.         #expansion ring yellow
  584.         strip.set_pixel(pix[139], yellow)
  585.         strip.set_pixel(pix[6], yellow)
  586.         strip.show()
  587.         utime.sleep(0.8)
  588.        
  589.                                             #Reverse the expanding heart
  590.         #clear ring yellow
  591.         strip.set_pixel(pix[139], blank)
  592.         strip.set_pixel(pix[6], blank)
  593.         strip.show()
  594.         utime.sleep(0.05)
  595.        
  596.         #clear ring white
  597.         strip.set_pixel(pix[0], blank)
  598.         strip.set_pixel(pix[133], blank)
  599.         strip.set_pixel(pix[125], blank)
  600.         strip.set_pixel(pix[20], blank)
  601.         for x in range(131, 133):
  602.             strip.set_pixel(pix[x],blank)
  603.         for x in range(12, 14):
  604.             strip.set_pixel(pix[x],blank)
  605.         for x in range(4, 6):
  606.             strip.set_pixel(pix[x],blank)
  607.         for x in range(137, 139):
  608.             strip.set_pixel(pix[x],blank)
  609.         strip.show()
  610.         utime.sleep(0.05)
  611.        
  612.         #clear ring violet
  613.         strip.set_pixel(pix[34], blank)
  614.         strip.set_pixel(pix[111], blank)
  615.         strip.set_pixel(pix[119], blank)
  616.         strip.set_pixel(pix[14], blank)
  617.         for x in range(117, 119):
  618.             strip.set_pixel(pix[x],blank)
  619.         for x in range(26, 28):
  620.             strip.set_pixel(pix[x],blank)
  621.         for x in range(18, 20):
  622.             strip.set_pixel(pix[x],blank)
  623.         for x in range(123, 125):
  624.             strip.set_pixel(pix[x],blank)
  625.         for x in range(126, 131):
  626.             strip.set_pixel(pix[x],blank)
  627.         for x in range(7, 12):
  628.             strip.set_pixel(pix[x],blank)
  629.         for x in range(1, 4):
  630.             strip.set_pixel(pix[x],blank)
  631.         for x in range(134, 137):
  632.             strip.set_pixel(pix[x],blank)
  633.         strip.show()
  634.         utime.sleep(0.05)
  635.        
  636.         #clear ring blue
  637.         strip.set_pixel(pix[28], blank)
  638.         strip.set_pixel(pix[105], blank)
  639.         strip.set_pixel(pix[48], blank)
  640.         strip.set_pixel(pix[97], blank)
  641.         for x in range(40, 42):
  642.             strip.set_pixel(pix[x],blank)
  643.         for x in range(103, 105):
  644.             strip.set_pixel(pix[x],blank)
  645.         for x in range(32, 34):
  646.             strip.set_pixel(pix[x],blank)
  647.         for x in range(109, 111):
  648.             strip.set_pixel(pix[x],blank)
  649.         for x in range(21, 26):
  650.             strip.set_pixel(pix[x],blank)
  651.         for x in range(112, 117):
  652.             strip.set_pixel(pix[x],blank)
  653.         for x in range(15, 18):
  654.             strip.set_pixel(pix[x],blank)
  655.         for x in range(120, 123):
  656.             strip.set_pixel(pix[x],blank)
  657.         strip.show()
  658.         utime.sleep(0.05)
  659.        
  660.         #clear ring green
  661.         strip.set_pixel(pix[63], blank)
  662.         strip.set_pixel(pix[70], blank)
  663.         strip.set_pixel(pix[42], blank)
  664.         strip.set_pixel(pix[91], blank)
  665.         strip.set_pixel(pix[62], blank)
  666.         strip.set_pixel(pix[83], blank)
  667.         for x in range(46, 48):
  668.             strip.set_pixel(pix[x],blank)
  669.         for x in range(95, 97):
  670.             strip.set_pixel(pix[x],blank)
  671.         for x in range(46, 48):
  672.             strip.set_pixel(pix[x],blank)
  673.         for x in range(54, 56):
  674.             strip.set_pixel(pix[x],blank)
  675.         for x in range(89, 91):
  676.             strip.set_pixel(pix[x],blank)
  677.         for x in range(98, 103):
  678.             strip.set_pixel(pix[x],blank)
  679.         for x in range(35, 40):
  680.             strip.set_pixel(pix[x],blank)
  681.         for x in range(29, 32):
  682.             strip.set_pixel(pix[x],blank)
  683.         for x in range(106, 109):
  684.             strip.set_pixel(pix[x],blank)
  685.         strip.show()
  686.         utime.sleep(0.8)
  687.         count += 1
  688.     return
  689.  
  690. def eyes():
  691.     count = 0
  692.     shifty = 0
  693.     open_time = 0.3 #slow first open
  694.     while count < 5:
  695.         def blink(): #blink the eyes
  696.             strip.set_pixel(pix[8],blank)
  697.             strip.set_pixel(pix[43],blank)
  698.             strip.set_pixel(pix[19],blank)
  699.             strip.set_pixel(pix[26],blank)
  700.             strip.set_pixel(pix[33],blank)
  701.             strip.set_pixel(pix[40],blank)
  702.            
  703.             strip.set_pixel(pix[92],blank)
  704.             strip.set_pixel(pix[127],blank)
  705.             strip.set_pixel(pix[103],blank)
  706.             strip.set_pixel(pix[110],blank)
  707.             strip.set_pixel(pix[117],blank)
  708.             strip.set_pixel(pix[124],blank)
  709.             strip.show()
  710.             utime.sleep(0.001)
  711.            
  712.             for x in range(2, 5, 2):
  713.                 strip.set_pixel(pix[x],blank)
  714.             for x in range(9, 12, 2):
  715.                 strip.set_pixel(pix[x],blank)
  716.             strip.set_pixel(pix[18],blank)
  717.             strip.set_pixel(pix[23],blank)
  718.             strip.set_pixel(pix[30],blank)
  719.             strip.set_pixel(pix[39],blank)
  720.             for x in range(44, 47, 2):
  721.                 strip.set_pixel(pix[x],blank)
  722.             for x in range(51, 54, 2):
  723.                 strip.set_pixel(pix[x],blank)
  724.                
  725.             for x in range(86, 89, 2):
  726.                 strip.set_pixel(pix[x],blank)
  727.             for x in range(93, 96, 2):
  728.                 strip.set_pixel(pix[x],blank)
  729.             strip.set_pixel(pix[102],blank)
  730.             strip.set_pixel(pix[107],blank)
  731.             strip.set_pixel(pix[114],blank)
  732.             strip.set_pixel(pix[123],blank)
  733.             for x in range(128, 131, 2):
  734.                 strip.set_pixel(pix[x],blank)
  735.             for x in range(135, 138, 2):
  736.                 strip.set_pixel(pix[x],blank)
  737.             strip.show()
  738.             utime.sleep(0.001)
  739.             wipe()
  740.            
  741.            
  742.         #draw eyes opening
  743.         strip.set_pixel(pix[10],red)
  744.         strip.set_pixel(pix[17],red)
  745.         strip.set_pixel(pix[31],blue)
  746.         strip.set_pixel(pix[38],blue)
  747.         strip.set_pixel(pix[52],red)
  748.         strip.set_pixel(pix[59],red)
  749.        
  750.         strip.set_pixel(pix[80],red)
  751.         strip.set_pixel(pix[87],red)
  752.         strip.set_pixel(pix[101],blue)
  753.         strip.set_pixel(pix[108],blue)
  754.         strip.set_pixel(pix[122],red)
  755.         strip.set_pixel(pix[129],red)
  756.         strip.show()
  757.         utime.sleep(open_time)
  758.        
  759.         for x in range(9, 12, 2):
  760.             strip.set_pixel(pix[x],red)
  761.         for x in range(16, 19, 2):
  762.             strip.set_pixel(pix[x],red)
  763.         strip.set_pixel(pix[25],red)
  764.         strip.set_pixel(pix[30],blue)
  765.         strip.set_pixel(pix[37],blue)
  766.         strip.set_pixel(pix[46],red)
  767.         for x in range(51, 54, 2):
  768.             strip.set_pixel(pix[x],red)
  769.         for x in range(58, 61, 2):
  770.             strip.set_pixel(pix[x],red)
  771.        
  772.         for x in range(79, 82, 2):
  773.             strip.set_pixel(pix[x],red)
  774.         for x in range(86, 89, 2):
  775.             strip.set_pixel(pix[x],red)
  776.         strip.set_pixel(pix[95],red)
  777.         strip.set_pixel(pix[100],blue)
  778.         strip.set_pixel(pix[107],blue)
  779.         strip.set_pixel(pix[116],red)
  780.         for x in range(121, 124, 2):
  781.             strip.set_pixel(pix[x],red)
  782.         for x in range(128, 131, 2):
  783.             strip.set_pixel(pix[x],red)
  784.         strip.show()
  785.         utime.sleep(open_time)
  786.        
  787.         strip.set_pixel(pix[15],red)
  788.         strip.set_pixel(pix[50],red)
  789.         strip.set_pixel(pix[26],red)
  790.         strip.set_pixel(pix[33],red)
  791.         strip.set_pixel(pix[40],red)
  792.         strip.set_pixel(pix[47],red)
  793.        
  794.         strip.set_pixel(pix[85],red)
  795.         strip.set_pixel(pix[120],red)
  796.         strip.set_pixel(pix[96],red)
  797.         strip.set_pixel(pix[103],red)
  798.         strip.set_pixel(pix[110],red)
  799.         strip.set_pixel(pix[117],red)
  800.         strip.show()
  801.        
  802.         if shifty == 0:
  803.             utime.sleep(1.5)
  804.             strip.set_pixel(pix[30],blank)
  805.             strip.set_pixel(pix[31],blank)
  806.             strip.set_pixel(pix[100],blank)
  807.             strip.set_pixel(pix[101],blank)
  808.             strip.set_pixel(pix[44],blue)
  809.             strip.set_pixel(pix[45],blue)
  810.             strip.set_pixel(pix[114],blue)
  811.             strip.set_pixel(pix[115],blue)
  812.             strip.show()
  813.             utime.sleep(0.8)
  814.            
  815.             strip.set_pixel(pix[44],blank)
  816.             strip.set_pixel(pix[45],blank)
  817.             strip.set_pixel(pix[114],blank)
  818.             strip.set_pixel(pix[115],blank)
  819.             strip.set_pixel(pix[37],blank)
  820.             strip.set_pixel(pix[38],blank)
  821.             strip.set_pixel(pix[107],blank)
  822.             strip.set_pixel(pix[108],blank)
  823.             for x in range(23, 25):
  824.                 strip.set_pixel(pix[x],blue)
  825.             for x in range(30, 32):
  826.                 strip.set_pixel(pix[x],blue)
  827.             for x in range(93, 95):
  828.                 strip.set_pixel(pix[x],blue)
  829.             for x in range(100, 102):
  830.                 strip.set_pixel(pix[x],blue)
  831.             strip.show()
  832.             utime.sleep(1.5)
  833.            
  834.             strip.set_pixel(pix[30],blank)
  835.             strip.set_pixel(pix[31],blank)
  836.             strip.set_pixel(pix[100],blank)
  837.             strip.set_pixel(pix[101],blank)
  838.             strip.set_pixel(pix[23],blank)
  839.             strip.set_pixel(pix[24],blank)
  840.             strip.set_pixel(pix[93],blank)
  841.             strip.set_pixel(pix[94],blank)
  842.             strip.set_pixel(pix[37],blue)
  843.             strip.set_pixel(pix[38],blue)
  844.             strip.set_pixel(pix[44],blue)
  845.             strip.set_pixel(pix[45],blue)
  846.             strip.set_pixel(pix[107],blue)
  847.             strip.set_pixel(pix[108],blue)
  848.             strip.set_pixel(pix[114],blue)
  849.             strip.set_pixel(pix[115],blue)
  850.             strip.show()
  851.             utime.sleep(0.5)
  852.            
  853.             strip.set_pixel(pix[44],blank)
  854.             strip.set_pixel(pix[45],blank)
  855.             strip.set_pixel(pix[114],blank)
  856.             strip.set_pixel(pix[115],blank)
  857.             strip.set_pixel(pix[30],blue)
  858.             strip.set_pixel(pix[31],blue)
  859.             strip.set_pixel(pix[100],blue)
  860.             strip.set_pixel(pix[101],blue)
  861.             strip.show()
  862.             shifty = 1
  863.         utime.sleep(random.randint(2, 5))
  864.         blink()
  865.         open_time = 0.001
  866.         count += 1
  867.     return
  868.  
  869. #Main
  870. sidebar() #setup the bars on the side, they are static
  871. functions = [eq, stars, scanner, iloveDP, expanding_heart, eyes] #list of available functions to call on
  872.  
  873. while True:
  874.     wipe()
  875.     random.choice(functions)() #infinite loop of calling on the various functions
Advertisement
Add Comment
Please, Sign In to add comment