View difference between Paste ID: 9fGHk7mH and Pr59MzBi
SHOW: | | - or go back to the newest paste.
1
from sense_hat import SenseHat
2
import time
3
4
s = SenseHat()
5
s.low_light = True
6
7
green = (0, 255, 0)
8
yellow = (255, 255, 0)
9
blue = (0, 0, 255)
10
red = (255, 0, 0)
11
white = (255,255,255)
12
nothing = (0,0,0)
13
pink = (255,105, 180)
14
15
def printRainbow():
16
  red=(255,0,0)
17
  green=(0,255,0)
18
  img=[]
19
  for x in range(1,9):
20
    for y in range(1,9):
21
      if ((x+y)%2==0):
22
        color=red
23
      else:
24
        color=green
25
#      color=(x*5,y*5, 200)
26
#      img[x*8+y]=color
27
      img.append(color)
28
  s.set_pixels(img)
29
  
30
def printStripes(seq):
31
  red=(255,0,0)
32
  green=(0,255,0)
33
  img=[]
34
  for x in range(1,9):
35
    for y in range(1,9):
36
      color=green
37
      if (seq==1):
38
        if (abs(x-y)==x-y):
39
          color=red;
40
      else:
41
         if (abs(x-y)==y-x):
42
          color=red;
43
      img.append(color)
44
  s.set_pixels(img)
45
46
47
48
def trinket_logo():
49
    G = green
50
    Y = yellow
51
    B = blue
52
    O = nothing
53
    logo = [
54
    O, O, O, O, O, O, O, O,
55
    O, Y, Y, Y, B, G, O, O,
56
    Y, Y, Y, Y, Y, B, G, O,
57
    Y, Y, Y, Y, Y, B, G, O,
58
    Y, Y, Y, Y, Y, B, G, O,
59
    Y, Y, Y, Y, Y, B, G, O,
60
    O, Y, Y, Y, B, G, O, O,
61
    O, O, O, O, O, O, O, O,
62
    ]
63
    return logo
64
65
def raspi_logo():
66
    G = green
67
    R = red
68
    O = nothing
69
    logo = [
70
    O, G, G, O, O, G, G, O, 
71
    O, O, G, G, G, G, O, O,
72
    O, O, R, R, R, R, O, O, 
73
    O, R, R, R, R, R, R, O,
74
    R, R, R, R, R, R, R, R,
75
    R, R, R, R, R, R, R, R,
76
    O, R, R, R, R, R, R, O,
77
    O, O, R, R, R, R, O, O,
78
    ]
79
    return logo
80
81
def plus():
82
    W = white
83
    O = nothing
84
    logo = [
85
    O, O, O, O, O, O, O, O, 
86
    O, O, O, W, W, O, O, O,
87
    O, O, O, W, W, O, O, O, 
88
    O, W, W, W, W, W, W, O,
89
    O, W, W, W, W, W, W, O,
90
    O, O, O, W, W, O, O, O,
91
    O, O, O, W, W, O, O, O,
92
    O, O, O, O, O, O, O, O,
93
    ]
94
    return logo
95
96
def equals():
97
    W = white
98
    O = nothing
99
    logo = [
100
    O, O, O, O, O, O, O, O, 
101
    O, W, W, W, W, W, W, O,
102
    O, W, W, W, W, W, W, O,
103
    O, O, O, O, O, O, O, O,
104
    O, O, O, O, O, O, O, O,
105
    O, W, W, W, W, W, W, O,
106
    O, W, W, W, W, W, W, O,
107
    O, O, O, O, O, O, O, O,
108
    ]
109
    return logo
110
111
def heart():
112
    P = pink
113
    O = nothing
114
    logo = [
115
    O, O, O, O, O, O, O, O,
116
    O, P, P, O, P, P, O, O,
117
    P, P, P, P, P, P, P, O,
118
    P, P, P, P, P, P, P, O,
119
    O, P, P, P, P, P, O, O,
120
    O, O, P, P, P, O, O, O,
121
    O, O, O, P, O, O, O, O,
122
    O, O, O, O, O, O, O, O,
123
    ]
124
    return logo
125
126
images = [trinket_logo, trinket_logo, plus, raspi_logo, raspi_logo, equals, heart, heart]
127
count = 0
128
129
#while True: 
130
131
sense=SenseHat()
132
printRainbow()
133
time.sleep(2)
134
for x in range(1,10):
135
  printStripes(x%2+1)
136
  temp=round(sense.get_temperature(),2)
137
  print(temp)
138
  time.sleep(1)
139
#printStripes(2)
140
#    s.set_pixels(images[count % len(images)]())
141
#    time.sleep(.75)
142
#    count += 1