La Bougie (blinkm via rotary encoder)

VERSION 2.5 PART 3 (LAST)

// INFORMATIONAL BLINK - START
int my_information(int InformationBlink) {
  BlinkM_setFadeSpeed(blinkm_addr, 20);   // Fadespeed to visible
  Serial.print("Now blinking ");
  Serial.print(my_menu);
 Serial.print(" time(s), to inform the user in which menu we are.\n");
  delay(250);
  for (int i=1; i <= my_menu; i++){
    BlinkM_fadeToHSB( blinkm_addr, hue_val, 255, 0 );            // Light go out
  delay(250);                                          // wait a bit
  BlinkM_fadeToHSB( blinkm_addr, hue_val, 255, bri_val );      // Back to the current value
  delay(250);
}
}
// INFORMATIONAL BLINK - STOP


// INTRO - START
int intro() {
my_power = true;                           // parameter to check later in code
digitalWrite(relais_pin, HIGH);            // power up the led driver
Serial.print("Power up with aelay to warm up the psu capacitors\n");
delay (my_driver_warmup);                              // Give the power led driver 2 sec. before firering the amps
Serial.print("..intro start..\n");
bri_val = my_brightness;                 // read the last brightness variable
hue_val = my_hue;                       // read the last hue variable
  BlinkM_begin();                          // Start the L2C bus protocol on arduino's analog pin 4 (data) and 5 (clock)
  BlinkM_stopScript(blinkm_addr);          // turn off BlinkM script
  BlinkM_setFadeSpeed(blinkm_addr, 1);                     // Fade nicely in at startup, 
  BlinkM_fadeToHSB( blinkm_addr, hue_val, 255, bri_val );  // or do some other fancy rgb test over here.
delay(5000);                               // Give the intro some time to fade in, before the menu starts.
Serial.print("..intro  done..\n\n");

}
// INTRO - STOP

// POWERDOWN - START
int powerdown() {
  Serial.print("Power down\n");
  my_power = false;                           // Have to say again that power is false, if it did not get here via a menu choice
  my_menu = 1 ;                                // Reset the menu to 1, so when pressing again, the menu is back at the beginning again.
  my_option = 1;
  BlinkM_setFadeSpeed(blinkm_addr, 5);        // Slow down fade speed, so the lights will dim before power is cut
  BlinkM_stopScript(blinkm_addr);             // turn off BlinkM script    
  BlinkM_fadeToHSB( blinkm_addr, hue_val, 255, 0);  // Start the fade out to black
  Wire.endTransmission();                    // stop the L2C bus on arduino, so we can kill the power to the LED's, otherwise arduino freezes.
  delay(my_driver_cooldown);                 //  give the psu some cool down time so the psu fan can cool the psu before we kill the power.
  digitalWrite(relais_pin, LOW);             // un-power a relais that triggers the power-led driver
  Serial.print("\nPower is off, relais for psu is not active\n");  
  Serial.print("press the button to power up\n\n");
  }
// POWERDOWN - STOP

// STATUS UPDATE - START
int status_update() {
  Serial.print("Status:");
  Serial.print("  brightness = ");
  Serial.print(bri_val, DEC);
  Serial.print("  Hue = ");  
  Serial.print(hue_val, DEC);
  Serial.print("  Saturation = ");  
  Serial.print(sat_val, DEC);
  Serial.print("\n");
}
// STATUS UPDATE - STOP

// PROGRAM RUNNING BLINK - START
int blinkyblink() {
  delay(100);  // wait a bit because we don't need to run the whole program so fast

   if (millis() - running_led_Millis > running_led_interval) {
    // save the last time you blinked the LED 
    running_led_Millis = millis();   

    // if the LED is off turn it on and vice-versa:
    if (running_led_state == LOW)
      running_led_state = HIGH;
    else
      running_led_state = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(running_led_port, running_led_state);
   }
} 
// PROGRAM RUNNING BLINK - STOP