La Bougie (blinkm via rotary encoder)

code PART 2:

intro_start:

if (my_information == true) {   // if true, blink lights to inform you what menu you are in
  BlinkM_setFadeSpeed(blinkm_addr, 20);   // Fadespeed to visible
  Serial.print("Now informing the user about menu nr: ");
  Serial.print(my_menu);
 Serial.print("\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);
  if (i == my_menu) { my_information = false; } // resetting the information field when done
}
}
// When done informing, run the intro (if true) or selected menu with the next lines of code

else if (intro == true) {
my_power = true;                           // parameter to check later in code
my_power_history = true;                   // parameter needed to fade out in the end
digitalWrite(relais_pin, HIGH);            // power up the led driver
Serial.print("2 second delay to warm up the led drivers\n");
delay (2000);                              // Give the power led driver 2 sec. before firering the amps
BlinkM_setFadeSpeed(blinkm_addr, 1);
Serial.print("..intro start..\n");
bri_val = my_brightness;       // read the brightness variable
hue_val = my_hue;              // read the hue variable
BlinkM_fadeToHSB( blinkm_addr, hue_val, 255, bri_val );
delay(8000);  // This intro can last as long for this delay
Serial.print("..intro  done..\n\n");
intro = false;
goto increase_menu_number;
//my_menu++;
}


else {
if (my_menu == 1 ) { 
if (my_power_history == false) { BlinkM_setFadeSpeed(blinkm_addr, 5); }
else {  BlinkM_setFadeSpeed(blinkm_addr, 150);      }  // fading speed between colours
   my_brightness = rotary.position();               // This gives the brightness the new value
bri_val = my_brightness;       // read the brightness variable
hue_val = my_hue;              // read the hue variable
BlinkM_fadeToHSB( blinkm_addr, hue_val, 255, bri_val );
}

if (my_menu == 2) { 
   BlinkM_setFadeSpeed(blinkm_addr, 150);      // fading speed between colours
   my_hue = rotary.position();                  // This gives the hue the new value 
bri_val = my_brightness;       // read the brightness variable
hue_val = my_hue;              // read the hue variable
BlinkM_fadeToHSB( blinkm_addr, hue_val, 255, bri_val );
}

if (my_menu == 3 ) { 
  BlinkM_setFadeSpeed(blinkm_addr, 1);         // Fadespeed to slowest setting possible
  my_brightness = rotary.position();                         // This gives the brightness the new value    
  when_to_randomize_counter++;
  if (when_to_randomize_counter == when_to_randomize) {
  my_hue_random = random(255);
  Serial.print("\nChanging to a random colour   Hue : ");
  Serial.print(my_hue_random);
  Serial.print("   Brightness : ");
  Serial.print(my_brightness);
  Serial.print("\n");
  when_to_randomize_counter = 0;
bri_val = my_brightness;       // read the brightness variable
hue_val = my_hue;              // read the hue variable
BlinkM_fadeToHSB( blinkm_addr, my_hue_random, 255, bri_val );
// BlinkM_fadeToRandomRGB(blinkm_addr, my_hue_random,my_hue_random, my_hue_random); // Only for testing purposes, because MaxM's don't show the correct HUE colour
}
}   




delay(100);  // wait a bit because we don't need to change the light that fast

}
 

}