Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

mendy32 Nov 29th, 2018 69 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #ifdef TEMP_STAT_LEDS
  2. //Edit 01/11/2016 Marquis Johnson
  3. static uint32_t stat_update = 0;
  4. //Virtual Variables
  5. int t = 2;
  6. int Rval = 1;
  7. int Gval = 1;
  8. int Bval = 1;
  9. int LEDmax = 160;
  10. int ExtTemp;
  11. int BedTemp;
  12. int ExtTarg;
  13. int BedTarg;
  14. //Static Colors
  15. void off(){Rval = 0;Gval = 0;Bval = 0;}
  16. void white(){Rval = LEDmax;Gval = LEDmax;Bval = LEDmax;}
  17. void red(){Rval = LEDmax;Gval = 0;Bval = 0;}
  18. void green(){Rval = 0;Gval = LEDmax;Bval = 0;}
  19. void blue(){Rval = 0;Gval = 0;Bval = LEDmax;}
  20. void yellow(){Rval = LEDmax;Gval = LEDmax;Bval = 0;}
  21. void cyan(){Rval = 0;Gval = LEDmax;Bval = LEDmax;}
  22. void magenta(){Rval = LEDmax;Gval = 0;Bval = LEDmax;}
  23. //Handle Led Stauts
  24. void handle_status_leds(){
  25.   if(millis() > stat_update) {
  26.     stat_update += 50; // Update every 0.05s
  27.     for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
  28.        ExtTemp = thermalManager.degHotend(cur_extruder);
  29.        ExtTarg = thermalManager.degTargetHotend(cur_extruder);
  30.        BedTemp = thermalManager.degTargetBed();
  31.        BedTarg = thermalManager.degBed();
  32.     }
  33. //Fade Leds On when starting up
  34.     if(Rval+Gval+Bval == 3){
  35. //length of delay
  36.       for(int r = 0; r<LEDmax; r++){Rval = r;analogWrite(STAT_LED_RED_PIN, Rval);delay(t);}
  37.       for(int r = LEDmax; r>0; r--){Rval = r;analogWrite(STAT_LED_RED_PIN, Rval);delay(t);}
  38.       for(int g = 0; g<LEDmax; g++){Gval = g;analogWrite(STAT_LED_GREEN_PIN, Gval);delay(t);}
  39.       for(int g = LEDmax; g>0; g--){Gval = g;analogWrite(STAT_LED_GREEN_PIN, Gval);delay(t);}
  40.       for(int b = 0; b<LEDmax; b++){Bval = b;analogWrite(STAT_LED_BLUE_PIN, Bval);delay(t);}
  41.       for(int b = LEDmax; b>0; b--){Bval = b;analogWrite(STAT_LED_BLUE_PIN, Bval);delay(t);}
  42.       for(int w = 0; w<LEDmax; w++){Rval = w; Gval = w; Bval = w;analogWrite(STAT_LED_RED_PIN, Rval);analogWrite(STAT_LED_GREEN_PIN, Gval);analogWrite(STAT_LED_BLUE_PIN, Bval);delay(t);}
  43.     }
  44.     if((BedTarg == 71)||(BedTarg == 1)){off();}
  45.     if(BedTarg == 100){yellow();}
  46.     if(ExtTarg == 0){off();}
  47.     if((ExtTarg != 0)
  48.      &&(BedTarg != 1)
  49.      &&(BedTarg != 69)
  50.      &&(BedTarg != 71)
  51.      &&(BedTarg != 100)){    
  52.         if((ExtTarg >= ExtTemp-TEMP_HYSTERESIS)
  53.          &&(ExtTarg <= ExtTemp+TEMP_HYSTERESIS)){white();}
  54.         else if((BedTarg == 5)&&(BedTemp <= 50)){green();}
  55.         else{
  56.           int MidTemp = (((EXTRUDE_MINTEMP)-40)/2);
  57.           if(ExtTemp < 40){blue();}
  58.           if(ExtTemp > EXTRUDE_MINTEMP){red();}
  59.           if((ExtTemp > 40)&&(ExtTemp < MidTemp)){
  60.             Rval = map(ExtTemp,40,MidTemp,0,LEDmax);
  61.             Gval = 0;  
  62.             Bval = LEDmax;
  63.           }
  64.           if((ExtTemp > MidTemp)&&(ExtTemp < EXTRUDE_MINTEMP)){
  65.             Rval = LEDmax;
  66.             Gval = 0;
  67.             Bval = map(ExtTemp,MidTemp,EXTRUDE_MINTEMP,LEDmax,0);
  68.           }
  69.         }
  70.       }
  71.   //Write to LEDs
  72.       analogWrite(STAT_LED_RED_PIN, Rval);
  73.       analogWrite(STAT_LED_GREEN_PIN, Gval);
  74.       analogWrite(STAT_LED_BLUE_PIN, Bval);
  75.     }
  76.   }
  77. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top