this->register_for_event(ON_PAUSE);
this->enable = this->kernel->config->value( pause_button_enable_checksum )->by_default(false)->as_bool();
- this->button = this->kernel->config->value( pause_button_pin_checksum )->by_default("2.12")->as_pin()->as_input();
- this->led = this->kernel->config->value( pause_led_pin_checksum )->by_default("4.28")->as_pin()->as_output();
+ this->button.from_string( this->kernel->config->value( pause_button_pin_checksum )->by_default("2.12")->as_string())->as_input();
+ this->led.from_string( this->kernel->config->value( pause_led_pin_checksum )->by_default("4.28")->as_string())->as_output();
this->kernel->slow_ticker->attach( 100, this, &PauseButton::button_tick );
}
uint32_t PauseButton::button_tick(uint32_t dummy){
if(!this->enable) return 0;
// If button changed
- if(this->button_state != this->button->get()){
- this->button_state = this->button->get();
+ if(this->button_state != this->button.get()){
+ this->button_state = this->button.get();
// If button pressed
if( this->button_state ){
if( this->play_state ){
}
void PauseButton::on_play( void* argument ){
- this->led->set(0);
+ this->led.set(0);
}
void PauseButton::on_pause( void* argument ){
- this->led->set(1);
+ this->led.set(1);
}
class PauseButton : public Module {
public:
PauseButton();
-
+
void on_module_loaded();
uint32_t button_tick(uint32_t dummy);
void on_play( void* argument );
void on_pause( void* argument );
-
+
bool enable;
- Pin* button;
- Pin* led;
+ Pin button;
+ Pin led;
bool button_state;
bool play_state;
};