-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrgb.lua
More file actions
77 lines (64 loc) · 1.94 KB
/
Copy pathrgb.lua
File metadata and controls
77 lines (64 loc) · 1.94 KB
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
local module = {}
ws2812.init()
g = 230
r = 230
b = 230
brightness = 255
local i, buffer = 0, ws2812.newBuffer(config.LEDNUM, 3)
ws2812_effects.init(buffer)
buffer:fill(0, 0, 0)
ws2812.write(buffer)
function module.white()
buffer:fill(230, 230, 230)
ws2812.write(buffer)
end
function module.change_color(g, r, b)
ws2812_effects.set_brightness(brightness)
ws2812_effects.set_color(g,r,b)
ws2812_effects.set_mode("static")
ws2812_effects.start()
end
function module.close()
buffer:fill(0, 0, 0)
ws2812.write(buffer)
ws2812_effects.stop()
end
function module.set_brightness(brightness)
ws2812_effects.set_brightness(brightness)
ws2812_effects.set_color(g,r,b)
ws2812_effects.set_mode("static")
ws2812_effects.start()
end
function module.change_effects(effect)
ws2812_effects.set_brightness(brightness)
ws2812_effects.set_color(g,r,b)
if effect == "blink" then
ws2812_effects.set_mode("blink")
elseif effect == "rainbow_cycle" then
ws2812_effects.set_mode("rainbow_cycle", 3)
elseif effect == "static" then
ws2812_effects.set_mode("static")
elseif effect == "fire" then
ws2812_effects.set_mode("fire")
elseif effect == "fire_soft" then
ws2812_effects.set_mode("fire_soft")
elseif effect == "fire_intense" then
ws2812_effects.set_mode("fire_intense")
elseif effect == "halloween" then
ws2812_effects.set_mode("halloween")
elseif effect == "circus_combustus" then
ws2812_effects.set_mode("circus_combustus")
elseif effect == "larson_scanner" then
ws2812_effects.set_mode("larson_scanner")
elseif effect == "random_dot" then
ws2812_effects.set_mode("random_dot", 3)
end
ws2812_effects.start()
end
function module.close_effect()
ws2812_effects.set_brightness(brightness)
ws2812_effects.set_color(g,r,b)
ws2812_effects.set_mode("static")
ws2812_effects.start()
end
return module