PauseButton: static Pins
authorMichael Moon <triffid.hunter@gmail.com>
Sat, 9 Feb 2013 13:46:03 +0000 (00:46 +1100)
committerMichael Moon <triffid.hunter@gmail.com>
Sat, 9 Feb 2013 13:46:03 +0000 (00:46 +1100)
src/modules/utils/pausebutton/PauseButton.cpp
src/modules/utils/pausebutton/PauseButton.h

index 5c62ff6..e3e2beb 100644 (file)
@@ -14,8 +14,8 @@ void PauseButton::on_module_loaded(){
     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 );
 }
@@ -25,8 +25,8 @@ void PauseButton::on_module_loaded(){
 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 ){
@@ -42,10 +42,10 @@ uint32_t PauseButton::button_tick(uint32_t dummy){
 }
 
 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);
 }
 
index 20203f3..1e23da6 100644 (file)
 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;
 };