part 3... (there's got to be a better way to do this...)
//fx3, default play internal driver script
//testing...
void ledfunction3(){
//default internal script (stop, play script 0, see example)
Serial.println("fx3 ");
lcdfx = 3;
// lcd.print("fx3 ");
unsigned long currentMillis = millis();
fx3currentMillis = millis();
//USDS mode
if(USDS_State > 0){
//turnoff set C if we have just changed
if ( USDS_Last == 0 ){
BlinkM_stopScript( setC );
BlinkM_fadeToRGB( setC, 0,0,0 );
Serial.println("off set C ");
} //c-check fx3 special case
//does this work? volitle variables?
//start default script for script a, b every x000ms (fx3send duration)
if(fx3currentMillis - fx3previousMillis > fx3send){
fx3previousMillis = fx3currentMillis;
startscript(setA);
startscript(setB);
Serial.println("send AB");
} //if fx3send
//keeping track of the last USDS mode
USDS_Last = 1;
} //if USDS
//USDS mode
else{
//start default script for script a, b ,c
if(fx3currentMillis - fx3previousMillis > fx3send){
fx3previousMillis = fx3currentMillis;
startscript(setA);
startscript(setB);
startscript(setC);
Serial.println("send ABC");
} //else fx3send
//keeping track of the last USDS mode
USDS_Last = 0;
}//else USDS
//last funcation sent to the drivers, so that we are cleaning up what is being sent to them.
lastfx = 3;
}//fx3
//------------------------------------------------------------------
//fx 4, pulsing red at half
//good, test this
void ledfunction4(){
//pulsing red, half intensity
Serial.println("fx4 red h ");
lcdfx = 4;
/*
//raw colors sent from the loop, for fx4, Red valve
byte color[48] = {
0x0A, 0x0a,
0x0A, 0x0a,
0x0A, 0x0a,
0x14, 0x14,
0x14, 0x14,
0x14, 0x14,
0x1e, 0x1e,
0x1e, 0x1e,
0x1e, 0x1e,
0x32, 0x32,
0x32, 0x32,
0x32, 0x32,
0x3c, 0x3c,
0x3c, 0x3c,
0x3c, 0x3c,
0x46, 0x46,
0x46, 0x46,
0x46, 0x46,
0x50, 0x50,
0x50, 0x50,
0x50, 0x50,
0x5a, 0x5a,
0x5a, 0x5a,
0x5a, 0x5a
}; //array
*/
//decimals by 10's
/* decimal to hex, by 10's
10 - 0a
20 - 14
30 - 1e
50 - 32
60 - 3c
70 - 46
80 - 50
90 - 5a
100 - 64
110 - 6e
120 - 78
130 - 82
140 - 8c
150 - 96
160 - a0
170 - aa
180 - b4
190 - be
200 - c8
210 - d2
220 - dc
230 - e6
240 - f0
250 - fa
*/
//if last fx was 3, stop default script, fade to black, continue
if (lastfx ==3 ){
//stop all
BlinkM_stopScript(setA);
BlinkM_stopScript(setB);
BlinkM_stopScript(setC);
delay(100);
//fade to black on all
BlinkM_fadeToRGB( setA, 0,0,0);
BlinkM_fadeToRGB( setB, 0,0,0);
BlinkM_fadeToRGB( setC, 0,0,0);
delay(100);
} //3-check
//USDS mode
if( USDS_State > 0 ){
//turnoff set C if we have just changed
if ( USDS_Last == 0 ){
BlinkM_fadeToRGB( setC, 0,0,0 );
} //c-check
//fade up, reading array values 1-20, pausing for a bit after each send
for(int i = 0; i < 47; i++){
//setA, setB
BlinkM_setRGB( setA, fx4color[i], fx4G, fx4B );
BlinkM_setRGB( setB, fx4color[i], fx4G, fx4B );
delay(15);
} // f_up
//fade down, reading array values 1-20, pausing for a bit after each send
for(int i = 47; i >0 ; i--){
//setA, setB
BlinkM_setRGB( setA, fx4color[i], fx4G, fx4B );
BlinkM_setRGB( setB, fx4color[i], fx4G, fx4B );
delay(15);
} //f_down
//keeping track of the last USDS mode
USDS_Last = 1;
}//if
//USDS mode
else{
//fade up, reading array values 1-20, pausing for a bit after each send
for(int i = 0; i < 47; i++){
//setA, setB
BlinkM_setRGB( setA, fx4color[i], fx4G, fx4B );
BlinkM_setRGB( setB, fx4color[i], fx4G, fx4B );
BlinkM_setRGB( setC, fx4color[i], fx4G, fx4B );
delay(15);
} // f_up
//fade down, reading array values 1-20, pausing for a bit after each send
for(int i = 47; i > 0 ; i--){
//setA, setB
BlinkM_setRGB( setA, fx4color[i], fx4G, fx4B );
BlinkM_setRGB( setB, fx4color[i], fx4G, fx4B );
BlinkM_setRGB( setC, fx4color[i], fx4G, fx4B );
delay(15);
}//f_down
//keeping track of the last USDS mode
USDS_Last = 0;
} //else
//last funcation sent to the drivers, so that we are cleaning up what is being sent to them.
lastfx = 4;
}//fx4
//------------------------------------------------------------------
//fx 5, show mode (currently 1% blue )
//good, test this
void ledfunction5(){
//solid green at half
Serial.println("fx5 grn ");
lcdfx = 5;
//if last fx was 3, stop default script, fade to black, continue
if (lastfx == 3 ){
//stop all
BlinkM_stopScript( setA );
BlinkM_stopScript( setB );
BlinkM_stopScript( setC );
delay(100);
//fade to black on all
BlinkM_fadeToRGB( setA, 0,0,0);
BlinkM_fadeToRGB( setB, 0,0,0);
BlinkM_fadeToRGB( setC, 0,0,0);
delay(100);
} //3-check
//solid blue 1% intensity
// byte R = 0x00;
// byte G = 0x00;
// byte B = 0x01;
//which drivers are we sending to. USDS mode
if( USDS_State > 0 ){
//turnoff set C if we have just changed
if ( USDS_Last == 0 ){
BlinkM_fadeToRGB( setC, 0,0,0 );
}
//send LED drivers here USDS set 1
BlinkM_setRGB( setA, fx5R, fx5G, fx5B );
BlinkM_setRGB( setB, fx5R, fx5G, fx5B );
//keeping track of the last USDS mode
USDS_Last = 1;
}//if
//which drivers are we sending to. USDS mode
else{
//send LED drivers here USDS set 2
BlinkM_setRGB( setA, fx5R, fx5G, fx5B );
BlinkM_setRGB( setB, fx5R, fx5G, fx5B );
BlinkM_setRGB( setC, fx5R, fx5G, fx5B );
//keeping track of the last USDS mode
USDS_Last = 0;
}//else
//last funcation sent to the drivers, so that we are cleaning up what is being sent to them.
lastfx = 5;
}//fx5
//fx to handle sycning the internal scripts
void startscript(byte blinkm_addr){
//stop script
BlinkM_stopScript( blinkm_addr );
delay(10);
//start script
BlinkM_playScript( blinkm_addr, 0,0,0 );
}//start script fx
//------------------------------------------------------------------
//intterupt function to handle the limit switch
void USDS_Funct(){
//switch debouce variables, 200ms is the current timing
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
if (interrupt_time - last_interrupt_time > 200)
{
USDS_State = !USDS_State; //elegant way to flip the state (multiply by -1)
}
last_interrupt_time = interrupt_time;
}//USDS_Funct
//------------------------------------------------------------------
void lcdStartup(){}