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_snooze_button( Config &cfg )
{
    cfg.get_bool("SnoozeButton", "enabled", m_snooze_button_enabled);
    unsigned pin_num=18;
    cfg.get_unsigned("SnoozeButton","button_gpio",pin_num);
    if (m_test_mode) return;
    if (m_snooze_button_enabled) {
        if (not config_gpio_pin( m_pbutton_gpio, pin_num, Gpio::IN, GPIO_NC)) {
            m_fan_control_enabled = false;
            LOG_ERROR(Lgr) << "No GPIO snooze button available this session";
        } else {
            LOG_INFO(Lgr) << "Snooze button enabled on GPIO " << pin_num;
        }
        m_last_pbstate = m_pbutton_gpio.get_value();
        LOG_INFO(Lgr) << "Button is now "
                      << ((GPIO_OFF == m_last_pbstate) ? "down" : "up");
    } else if (m_pbutton_gpio) { 
         m_pbutton_gpio.release();
    }
}
void Cooling :: init_snooze_button ( Config & cfg ) { cfg . get_bool ( " " , " " , m_snooze_button_enabled ) ; unsigned pin_num = 18 ; cfg . get_unsigned ( " " , " " , pin_num ) ; if ( m_test_mode ) return ; if ( m_snooze_button_enabled ) { if ( not config_gpio_pin ( m_pbutton_gpio , pin_num , Gpio :: IN , GPIO_NC ) ) { m_fan_control_enabled = false ; LOG_ERROR ( Lgr ) << " " ; } else { LOG_INFO ( Lgr ) << " " << pin_num ; } m_last_pbstate = m_pbutton_gpio . get_value ( ) ; LOG_INFO ( Lgr ) << " " << ( ( GPIO_OFF == m_last_pbstate ) ? " " : " " ) ; } else if ( m_pbutton_gpio ) { m_pbutton_gpio . release ( ) ; } }
Initialize snooze button and GPIO, if enabled.
Initialize snooze button and GPIO if enabled .
// Claim the GPIO--but only if snooze button control is enabled // release the gpio if held