spectrum
This commit is contained in:
parent
dd224fc223
commit
f6a63d8c5a
@ -15,6 +15,7 @@
|
|||||||
#define END_LAMP_IDX 2
|
#define END_LAMP_IDX 2
|
||||||
#define COLOR_AMOUNT 3
|
#define COLOR_AMOUNT 3
|
||||||
enum color_pin {RED, GREEN, BLUE};
|
enum color_pin {RED, GREEN, BLUE};
|
||||||
|
enum color_spectrum {pr, pg, mr, pb, mg};
|
||||||
|
|
||||||
static unsigned long cur_time;
|
static unsigned long cur_time;
|
||||||
static unsigned long prev_time;
|
static unsigned long prev_time;
|
||||||
@ -23,7 +24,7 @@ short green_state;
|
|||||||
short red_state;
|
short red_state;
|
||||||
short blue_state;
|
short blue_state;
|
||||||
enum color_pin pin;
|
enum color_pin pin;
|
||||||
enum color_pin spectrum_state;
|
enum color_spectrum spectrum_state;
|
||||||
static int lamp_idx;
|
static int lamp_idx;
|
||||||
static int n_loops;
|
static int n_loops;
|
||||||
|
|
||||||
@ -65,9 +66,10 @@ int PrgTic
|
|||||||
// }
|
// }
|
||||||
if(cur_time-prev_time>=wait)
|
if(cur_time-prev_time>=wait)
|
||||||
{
|
{
|
||||||
|
prev_time = cur_time;
|
||||||
|
update_lights(p_ta_array);
|
||||||
spectrum();
|
spectrum();
|
||||||
}
|
}
|
||||||
update_lights(p_ta_array);
|
|
||||||
return RC;
|
return RC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,17 +77,20 @@ void spectrum()
|
|||||||
{
|
{
|
||||||
switch(spectrum_state)
|
switch(spectrum_state)
|
||||||
{
|
{
|
||||||
case RED:
|
case pr:
|
||||||
--blue_state;
|
|
||||||
if(++red_state>LIGHT_MAX) {++spectrum_state;}
|
if(++red_state>LIGHT_MAX) {++spectrum_state;}
|
||||||
break;
|
break;
|
||||||
case GREEN:
|
case pg:
|
||||||
--red_state;
|
|
||||||
if(++green_state>LIGHT_MAX) {++spectrum_state;}
|
if(++green_state>LIGHT_MAX) {++spectrum_state;}
|
||||||
break;
|
break;
|
||||||
case BLUE:
|
case mr:
|
||||||
--green_state;
|
if(--red_state<LIGHT_MIN) {++spectrum_state;}
|
||||||
if(++blue_state>LIGHT_MAX) {spectrum_state = 0;}
|
break;
|
||||||
|
case pb:
|
||||||
|
if(++blue_state>LIGHT_MAX) {++spectrum_state;}
|
||||||
|
break;
|
||||||
|
case mg:
|
||||||
|
if(--green_state>LIGHT_MIN) {spectrum_state = 0;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user