This repository has been archived by the owner on Feb 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
167 lines (134 loc) · 4.7 KB
/
main.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
from led_controller.led_objects import *
from led_controller.led_world import LEDWorldBuilder, ObjectLocation
import opc
import time
from datetime import datetime
import argparse
FC_SERVER = '172.16.20.233:7890'
FC_SERVER = '192.168.2.1:7890'
client = opc.Client(FC_SERVER)
def all_leds_on():
world = LEDWorldBuilder().add_octa_circle().build()
color = (255, 0, 0)
led_all = LEDAll(color)
pixels = world.draw([led_all], None)
client.put_pixels(pixels)
client.put_pixels(pixels)
def working_light():
world = LEDWorldBuilder().add_octa_circle().build()
color = (237, 183, 21)
location = ObjectLocation(-45, 90)
led_spot = LEDSpot(color, location, 120)
pixels = world.draw([led_spot], datetime.now())
client.put_pixels(pixels)
client.put_pixels(pixels)
def all_leds_off():
world = LEDWorldBuilder().add_octa_circle().build()
color = (0, 0, 0)
led_all = LEDAll(color)
pixels = world.draw([led_all], None)
client.put_pixels(pixels)
client.put_pixels(pixels)
def show_spot():
world = LEDWorldBuilder().add_octa_circle().build()
color = (255, 0, 0)
location = ObjectLocation(0, 1.414213562)
led_spot = LEDSpot(color, location, 1.0/60 * 20)
pixels = world.draw([led_spot], 0)
client.put_pixels(pixels)
client.put_pixels(pixels)
angle_inc = 1
while True:
led_spot.location.angle += angle_inc
if led_spot.location.angle > 45 or led_spot.location.angle < (-45-45):
angle_inc *= -1
pixels = world.draw([led_spot], 0)
client.put_pixels(pixels)
time.sleep(0.02)
def show_spot_round():
world = LEDWorldBuilder().add_octa_circle().build()
color = (255, 255, 255)
location = ObjectLocation(0, 1.414213562)
led_spot = LEDSpot(color, location, 1.0/60 * 20)
pixels = world.draw([led_spot], datetime.now())
client.put_pixels(pixels)
client.put_pixels(pixels)
angle_inc = 1
while True:
led_spot.location.angle += angle_inc
if led_spot.location.angle > 360:
led_spot.location.angle
pixels = world.draw([led_spot], datetime.now())
client.put_pixels(pixels)
time.sleep(0.01)
def show_animated_spot():
world = LEDWorldBuilder().add_octa_circle().build()
color = (237, 183, 21)
location = ObjectLocation(0, 1.5)
led_spot = LEDSpot(color, location, 1.0/60 * 30, 0.25, 0.3)
symbols = [led_spot]
while symbols:
now = datetime.now()
pixels = world.draw(symbols, now)
client.put_pixels(pixels)
symbols = [s for s in symbols if not s.dead]
time.sleep(0.02)
def show_wave():
world = LEDWorldBuilder().add_octa_circle().build()
color = (150, 0, 0)
led_wave = LEDWave(color, 1, 15)
while True:
now = datetime.now()
pixels = world.draw([led_wave], now)
client.put_pixels(pixels)
time.sleep(0.02)
def show_drop():
world = LEDWorldBuilder().add_octa_circle().build()
location = ObjectLocation(0, 0.5)
color = (52, 141, 151)
led_drop = LEDContinuousDrop(color, location, 0.75, decrease=0.05, end_after=1)
symbols = [led_drop]
while symbols:
now = datetime.now()
pixels = world.draw(symbols, now)
client.put_pixels(pixels)
symbols = [s for s in symbols if not s.dead]
time.sleep(0.02)
def show_continuous_drop():
world = LEDWorldBuilder().add_octa_circle().build()
location = ObjectLocation(0, 0.5)
color = (255, 255, 255)#(52, 141, 151)
led_drop = LEDContinuousDrop(color, location, 1.0)
symbols = [led_drop]
while symbols:
now = datetime.now()
pixels = world.draw(symbols, now)
client.put_pixels(pixels)
client.put_pixels(pixels)
symbols = [s for s in symbols if not s.dead]
time.sleep(0.02)
def show_pulsing():
world = LEDWorldBuilder().add_octa_circle().build()
color = (255, 0, 0)
led_puls = LEDAllPulsing(color, 0.1)
while True:
now = datetime.now()
pixels = world.draw([led_puls], now)
client.put_pixels(pixels)
time.sleep(0.02)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Interior LED art for ME310 Audi')
parser.add_argument('pattern', choices=['off', 'all', 'spot', 'spotRound', 'wave', 'drop', 'conDrop', 'puls', 'workingLight', 'aniSpot'])
args = parser.parse_args()
{
'all': all_leds_on,
'off': all_leds_off,
'spot': show_spot,
'spotRound': show_spot_round,
'wave': show_wave,
'drop': show_drop,
'conDrop': show_continuous_drop,
'puls': show_pulsing,
'workingLight': working_light,
'aniSpot': show_animated_spot,
}[args.pattern]()