-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestNeoPixel24.py
133 lines (100 loc) · 4.42 KB
/
TestNeoPixel24.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# rpi_ws281x library example
import time
from rpi_ws281x import *
import argparse
# LED strip configuration:
LED_COUNT = 60 # Anazahl NeoPixel
LED_PIN = 18 # Gewaehlter GPIO pin
LED_FREQ_HZ = 800000 # LED signal Frequenz in Hertz (800khz)
LED_DMA = 10 # DMA (Direkt Memory Acces) channel (10 vom Hersteller empfohlen)
LED_BRIGHTNESS = 255 # Helligkeit von 0 bis max. 255
LED_INVERT = False # Invertiertes Signal für Transistorschaltung
LED_CHANNEL = 0 # auf '1' setzten wenn GPIOs 13, 19, 41, 45 oder 53 genutzt werden sollen
def colorWipe(strip, color, wait_ms=50):
i = 0
for i in range(15): #Angabe wie viele Neopixel angesteuert werden sollen
i = i+1 #Position für den Ersten NeoPixel der angestuert werden soll
strip.setPixelColor(i, color) #den Anzusteuernden Pixeln die Farbwerte übergeben
strip.show() #Pixel Ansteuern
def colorWipe1(strip, color, wait_ms=50):
i = 0
for i in range(15):
i = i+16
strip.setPixelColor(i, color)
strip.show()
def colorWipe2(strip, color, wait_ms=50):
i = 0
for i in range(15):
i = i+31
strip.setPixelColor(i, color)
strip.show()
def colorWipe3(strip, color, wait_ms=50):
i = 0
for i in range(15):
i = i+46
strip.setPixelColor(0, color)
strip.setPixelColor(i, color)
strip.show()
def left(strip, color, wait_ms=50):
i = 0
for i in range(30):
i=i+1
strip.setPixelColor(i, color)
strip.show()
def right(strip, color, wait_ms=50):
i = 0
for i in range(30):
i= i+31
strip.setPixelColor(0, color)
strip.setPixelColor(i, color)
strip.show()
def all(strip, color, wait_ms=50):
i = 0
for i in range(60):
strip.setPixelColor(i, color)
strip.show()
# Main program logic follows:
if __name__ == '__main__':
# Process arguments
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
args = parser.parse_args()
# Create NeoPixel object with appropriate configuration.
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
# Intialize the library (must be called once before other functions).
strip.begin()
print ('Press Ctrl-C to quit.')
if not args.clear:
print('Use "-c" argument to clear LEDs on exit')
try:
x=1
while x<9: #Nur Eingaben kleiner 9 werden verarbeitet
print ('Dom Beleuchtung')
x=int(input("Position waehlen : ")) #Aufforderung im Terminal ausgeben
if x == 1: #Eingabe vergleichen
print("Bereich 1 gewaehlt") #Konsolenausgabe welcher Bereich gaehlt wurde
colorWipe(strip, Color(127, 127, 127)) #Farbwerte Vergeben
if x == 2:
print("Bereich 2 gewaehlt")
colorWipe1(strip, Color(127, 127, 127))
if x == 3:
print("Bereich 3 gewaehlt")
colorWipe2(strip, Color(127, 127, 127))
if x == 4:
print("Bereich 4 gewaehlt")
colorWipe3(strip, Color(127, 127, 127))
if x == 5:
print("Bereich 5 gewaehlt")
left(strip, Color(127, 127, 127))
if x == 6:
print("Bereich 6 gewaehlt")
right(strip, Color(127, 127, 127))
if x == 7:
print("Bereich 7 gewaehlt")
all(strip, Color(127, 127, 127))
if x == 8:
print("Ausschalten ")
all(strip, Color(0,0,0))
except KeyboardInterrupt:
if args.clear:
colorWipe(strip, Color(0,0,0), 10)