spectrum
This commit is contained in:
parent
f34c6acec4
commit
941fcb8205
@ -1,6 +1,7 @@
|
|||||||
// #include <stddef.h>
|
// #include <stddef.h>
|
||||||
#include "ROBO_TX_PRG.h"
|
#include "ROBO_TX_PRG.h"
|
||||||
#include "ROBO_TX_FW.h"
|
#include "ROBO_TX_FW.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#define LIGHT_MAX DUTY_MAX
|
#define LIGHT_MAX DUTY_MAX
|
||||||
#define LIGHT_MIN DUTY_MIN
|
#define LIGHT_MIN DUTY_MIN
|
||||||
@ -12,8 +13,7 @@
|
|||||||
#define BEG_LAMP_IDX 0
|
#define BEG_LAMP_IDX 0
|
||||||
#define END_LAMP_IDX 2
|
#define END_LAMP_IDX 2
|
||||||
#define COLOR_AMOUNT 3
|
#define COLOR_AMOUNT 3
|
||||||
enum color_pin {GREEN, RED, BLUE};
|
enum color_pin {RED, GREEN, BLUE};
|
||||||
enum spectrum_transisition {r, br, g, rg, b, gb};
|
|
||||||
|
|
||||||
static unsigned long cur_time;
|
static unsigned long cur_time;
|
||||||
static unsigned long prev_time;
|
static unsigned long prev_time;
|
||||||
@ -22,7 +22,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 spectrum_transisition spectrum_state;
|
enum color_pin spectrum_state;
|
||||||
static int lamp_idx;
|
static int lamp_idx;
|
||||||
static int n_loops;
|
static int n_loops;
|
||||||
static int wait;
|
static int wait;
|
||||||
@ -41,11 +41,11 @@ void PrgInit
|
|||||||
green_state = LIGHT_MIN;
|
green_state = LIGHT_MIN;
|
||||||
red_state = LIGHT_MIN;
|
red_state = LIGHT_MIN;
|
||||||
blue_state = LIGHT_MIN;
|
blue_state = LIGHT_MIN;
|
||||||
states[0] = &green_state;
|
states[0] = &red_state;
|
||||||
states[1] = &red_state;
|
states[1] = &green_state;
|
||||||
states[2] = &blue_state;
|
states[2] = &blue_state;
|
||||||
spectrum_state = 0;
|
spectrum_state = 0;
|
||||||
pin = GREEN;
|
pin = RED;
|
||||||
lamp_idx = BEG_LAMP_IDX;
|
lamp_idx = BEG_LAMP_IDX;
|
||||||
n_loops = 10;
|
n_loops = 10;
|
||||||
wait = 1000;
|
wait = 1000;
|
||||||
@ -76,23 +76,17 @@ void spectrum()
|
|||||||
{
|
{
|
||||||
switch(spectrum_state)
|
switch(spectrum_state)
|
||||||
{
|
{
|
||||||
case g:
|
case RED:
|
||||||
if(++green_state>=LIGHT_MAX) { ++spectrum_state; }
|
--blue_state;
|
||||||
|
if(++red_state>LIGHT_MAX) {++spectrum_state;}
|
||||||
break;
|
break;
|
||||||
case br:
|
case GREEN:
|
||||||
if(--blue_state<=LIGHT_MIN) { ++spectrum_state; }
|
--red_state;
|
||||||
|
if(++green_state>LIGHT_MAX) {++spectrum_state;}
|
||||||
break;
|
break;
|
||||||
case r:
|
case BLUE:
|
||||||
if(++red_state>=LIGHT_MAX) { ++spectrum_state; }
|
--green_state;
|
||||||
break;
|
if(++blue_state>LIGHT_MAX) {spectrum_state = 0;}
|
||||||
case gb:
|
|
||||||
if(--green_state<=LIGHT_MIN) { ++spectrum_state; }
|
|
||||||
break;
|
|
||||||
case b:
|
|
||||||
if(++blue_state>=LIGHT_MAX) { ++spectrum_state; }
|
|
||||||
break;
|
|
||||||
case rg:
|
|
||||||
if(--red_state<=LIGHT_MIN) { spectrum_state = 0; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user