-
Notifications
You must be signed in to change notification settings - Fork 0
/
laborlicht.h
52 lines (43 loc) · 1.58 KB
/
laborlicht.h
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
#ifndef LABORLICHT_H
#define LABORLICHT_H
#include <stdlib.h>
#include "hw.h"
typedef enum color_preset_e {
color_black,
color_red,
color_yellow,
color_green,
color_cyan,
color_blue,
color_purple,
color_white,
color_MAX
} color_preset_t;
extern unsigned char const g_color_presets[color_MAX][channel_MAX];
inline static void set_color_preset(color_preset_t preset) {
g_color[channel_red] = PW(g_color_presets[preset][channel_red]);
g_color[channel_green] = PW(g_color_presets[preset][channel_green]);
g_color[channel_blue] = PW(g_color_presets[preset][channel_blue]);
}
void color_fade(unsigned char const *fade_color,
unsigned char const steps,
unsigned int delay);
inline static void color_fade_preset(color_preset_t const preset,
unsigned char const steps,
unsigned int delay) {
unsigned char preset_color[channel_MAX];
for (unsigned char channel = 0; channel < channel_MAX; ++channel) {
preset_color[channel] = PW(g_color_presets[preset][channel]);
}
color_fade(preset_color, steps, delay);
}
// fade to a random color (minimum brightness per channel is 64);
inline static void color_fade_random(unsigned char const steps,
unsigned int delay) {
unsigned char random_color[channel_MAX];
for (color_channel_t channel = 0; channel < channel_MAX; ++channel) {
random_color[channel] = (rand() % 192) + 64;
}
color_fade(random_color, steps, delay);
}
#endif // LABORLICHT_H