1. Got a question or need help troubleshooting? Post to the troubleshooting forum or Search the forums!

Marlin Temperature Status Leds Bug

Discussion in 'Software' started by Ziggy, Oct 21, 2014.

  1. Ziggy

    Ziggy Moderator
    Staff Member

    Joined:
    Feb 20, 2013
    Messages:
    707
    Likes Received:
    530
    There is an optional function in Marlin which control two status leds to give an indication of the temperature of the bed and extruder.

    In configuration.h the description is:

    // Temperature status LEDs that display the hotend and bed temperature.
    // If all hotends and bed temperature and temperature setpoint are < 54C then the BLUE led is on.
    // Otherwise the RED led is on. There is 1C hysteresis.
    #define TEMP_STAT_LEDS

    I tried to use this function and the RED led output to control the fans on the Ramps and extruder so the fans would only be on when the bed and/or extruder was heating or the temperature was above a particular value I set. As you can see from the code it is very easy to define the temperatures for the status leds. The digital pins for the leds are defined in pins.h

    However I found the outputs did not work. It turns out the red/blue led digital pins are never defined as outputs in Marlin. As the default digital pin mode is "input" Marlin is trying to output to pins which are set as inputs and , of course, it does not work. (As it happens the input pins actually look like they change state but they can't source much current)

    The marlin_main.cpp file mod to fix this is as follows


    #ifdef TEMP_STAT_LEDS
    static bool blue_led = false;
    static bool red_led = false;
    static uint32_t stat_update = 0;
    static bool temp_stat_leds_output = false;



    void handle_status_leds(void) {
    float max_temp = 0.0;
    if(millis() > stat_update) {
    stat_update += 500; // Update every 0.5s
    for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
    max_temp = max(max_temp, degHotend(cur_extruder));
    max_temp = max(max_temp, degTargetHotend(cur_extruder));
    }
    #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
    max_temp = max(max_temp, degTargetBed());
    max_temp = max(max_temp, degBed());
    #endif

    // Ziggy 10 October 2014

    if (temp_stat_leds_output == false) {
    pinMode(STAT_LED_BLUE, OUTPUT);
    pinMode(STAT_LED_RED, OUTPUT);
    temp_stat_leds_output = true;
    }


    if((max_temp > 55.0) && (red_led == false)) {
    digitalWrite(STAT_LED_RED, 1);
    digitalWrite(STAT_LED_BLUE, 0);
    red_led = true;
    blue_led = false;
    }
    if((max_temp < 54.0) && (blue_led == false)) {
    digitalWrite(STAT_LED_RED, 0);
    digitalWrite(STAT_LED_BLUE, 1);
    red_led = false;
    blue_led = true;
    }
    }
    }
    #endif
     
    #1 Ziggy, Oct 21, 2014
    Last edited by a moderator: Oct 21, 2014
    4 people like this.
  2. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    You never cease to amaze.

    @donhuevo is this what you used to write your color change code?
     
  3. donhuevo

    donhuevo Active Member

    Joined:
    Mar 29, 2014
    Messages:
    138
    Likes Received:
    100
    no. I added neopixels to the bed and carriage. I had to include the neopixel files in my arduino project then added code here and there to make them go.
     

Share This Page