]>
Commit | Line | Data |
---|---|---|
1 | /* vim:ts=4 sts=4 et tw=80 | |
2 | * | |
3 | * fnordlicht firmware | |
4 | * | |
5 | * for additional information please | |
6 | * see http://lochraster.org/fnordlichtmini | |
7 | * | |
8 | * (c) by Alexander Neumann <alexander@bumpern.de> | |
9 | * Lars Noschinski <lars@public.noschinski.de> | |
10 | * | |
11 | * This program is free software: you can redistribute it and/or modify it | |
12 | * under the terms of the GNU General Public License version 3 as published by | |
13 | * the Free Software Foundation. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
18 | * more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License along with | |
21 | * this program. If not, see <http://www.gnu.org/licenses/>. | |
22 | */ | |
23 | ||
24 | #ifndef PWM_H | |
25 | #define PWM_H | |
26 | ||
27 | #include "timer.h" | |
28 | #include "color.h" | |
29 | ||
30 | #if PWM_CHANNELS != 3 | |
31 | #error "PWM_CHANNELS is not 3, this is unsupported!" | |
32 | #endif | |
33 | ||
34 | #define PWM_HSV_SIZE sizeof(struct hsv_color_t) | |
35 | ||
36 | struct global_pwm_t | |
37 | { | |
38 | /* current color */ | |
39 | struct rgb_color_t current; | |
40 | ||
41 | /* target for fading engine */ | |
42 | struct dual_color_t target; | |
43 | ||
44 | /* delay and step for fading engine */ | |
45 | uint8_t fade_delay[PWM_CHANNELS]; | |
46 | uint8_t fade_step[PWM_CHANNELS]; | |
47 | }; | |
48 | ||
49 | extern struct global_pwm_t global_pwm; | |
50 | ||
51 | /* prototypes */ | |
52 | void pwm_init(void); | |
53 | void pwm_poll(void); | |
54 | void pwm_poll_fading(void); | |
55 | ||
56 | void pwm_fade_rgb(struct rgb_color_t *color, uint8_t step, uint8_t delay); | |
57 | void pwm_fade_hsv(struct hsv_color_t *color, uint8_t step, uint8_t delay); | |
58 | ||
59 | /* return true if fading process is complete */ | |
60 | bool pwm_target_reached(void); | |
61 | ||
62 | /* convert hsv to rgb color */ | |
63 | void pwm_hsv2rgb(struct dual_color_t *color); | |
64 | /* convert rgb to hsv color */ | |
65 | void pwm_rgb2hsv(struct dual_color_t *color); | |
66 | ||
67 | /* stop fading, hold current color */ | |
68 | void pwm_stop_fading(void); | |
69 | ||
70 | /* modify color */ | |
71 | void pwm_modify_rgb(struct rgb_color_offset_t *color, uint8_t step, uint8_t delay); | |
72 | void pwm_modify_hsv(struct hsv_color_offset_t *color, uint8_t step, uint8_t delay); | |
73 | ||
74 | #endif |