cooling/cooling.cc
/// Initialize snooze button and GPIO, if enabled.
/// \arg \c cfg  Configuration object
///
Initialize snooze button and GPIO, if enabled.
\arg \c cfg  Configuration object
Initialize snooze button and GPIO if enabled . \ arg \ c cfg Configuration object
void Cooling::init_panel_leds( Config &cfg )
{
    cfg.get_bool("PanelLEDs", "enabled", m_panel_leds_enabled);
    if (m_panel_leds_enabled) {
        unsigned green_pin_num=17;
        unsigned red_pin_num=27;
        cfg.get_unsigned("PanelLEDs","red_gpio",red_pin_num);
        cfg.get_unsigned("PanelLEDs","green_gpio",green_pin_num);
        if (m_test_mode) return;
        if (not config_gpio_pin( m_grn_gpio, green_pin_num, Gpio::OUT, GPIO_OFF)) {
            LOG_ERROR(Lgr) << "No green GPIO panel LED available this session";
        } else {
            LOG_INFO(Lgr) << "Green panel LED enabled on GPIO " << green_pin_num;
        }
        if (not config_gpio_pin( m_red_gpio, red_pin_num, Gpio::OUT, GPIO_OFF)) {
            LOG_ERROR(Lgr) << "No red GPIO panel LED available this session";
        } else {
            LOG_INFO(Lgr) << "Red panel LED enabled on GPIO " << red_pin_num;
        }
    }  else {                     release the gpio if held
        if (m_grn_gpio) {
            m_grn_gpio.set_value(0);  turn it off
            m_grn_gpio.release();
        }
        if (m_red_gpio) {
            m_red_gpio.set_value(0);  turn it off
            m_red_gpio.release();
        }
    }
}
void Cooling :: init_panel_leds ( Config & cfg ) { cfg . get_bool ( " " , " " , m_panel_leds_enabled ) ; if ( m_panel_leds_enabled ) { unsigned green_pin_num = 17 ; unsigned red_pin_num = 27 ; cfg . get_unsigned ( " " , " " , red_pin_num ) ; cfg . get_unsigned ( " " , " " , green_pin_num ) ; if ( m_test_mode ) return ; if ( not config_gpio_pin ( m_grn_gpio , green_pin_num , Gpio :: OUT , GPIO_OFF ) ) { LOG_ERROR ( Lgr ) << " " ; } else { LOG_INFO ( Lgr ) << " " << green_pin_num ; } if ( not config_gpio_pin ( m_red_gpio , red_pin_num , Gpio :: OUT , GPIO_OFF ) ) { LOG_ERROR ( Lgr ) << " " ; } else { LOG_INFO ( Lgr ) << " " << red_pin_num ; } } else { if ( m_grn_gpio ) { m_grn_gpio . set_value ( 0 ) ; m_grn_gpio . release ( ) ; } if ( m_red_gpio ) { m_red_gpio . set_value ( 0 ) ; m_red_gpio . release ( ) ; } } }
Initialize snooze button and GPIO, if enabled.
Initialize snooze button and GPIO if enabled .
// Claim the GPIO--but only if panel LEDs are enabled // // release the gpio if held // turn it off // turn it off