Local library

Dependencies:   WakeUp PinDetect

Dependents:   Inductive_Sensor Inductive_Sensor_Jasper Inductive_Sensor_3

Revision:
9:3fe744aca1c0
Parent:
7:0b23995256e7
--- a/Bob.cpp	Wed Sep 07 11:47:37 2016 +0000
+++ b/Bob.cpp	Wed Sep 21 14:23:19 2016 +0000
@@ -9,9 +9,7 @@
 */
 
 #include "Bob.h"
-#include "mbed.h"
-#include "mbed_debug.h"
-#include "WakeUp.h"
+
 
 
 void keyPressed( void )
@@ -68,6 +66,24 @@
     _enable.write(0);
 }
 
+void Bob::shutdown_pin(PinName pin, int value, PinMode pull )
+{
+    if( value == 1 )
+    {
+        DigitalInOut *_pin = new DigitalInOut( pin );
+        _pin->output();
+        _pin->mode( pull );
+        _pin->write( value );
+        delete _pin;
+        _pin = NULL;
+    }else{
+        DigitalOut *_pin = new DigitalOut( pin );
+        _pin->write( value );
+        delete _pin;
+        _pin = NULL;
+    }
+}
+
 void Bob::sleep(uint32_t ms)
 {
      WakeUp::calibrate();           // calibration takes 100 ms
@@ -81,17 +97,37 @@
     return (float)_batt->read() * 3.0 * 2.0;
 }
 
-void Bob::flash( int n )
+void Bob::flash( int n, int led )
 {
-    _led_process = 0;
+    if( led == 0 || led == 1 ) _led_process = 0;
+    if( led == 0 || led == 2 ) _led_error = 0;
     for(int i=0; i<n*2; i++){
-        _led_process = 1-_led_process; 
+        if( led == 0 || led == 1 ) _led_process = 1-_led_process; 
+        if( led == 0 || led == 2 ) _led_error = 1-_led_error; 
         wait(0.2);
     }
 }
 
-void Bob::processing(void)   { _led_process   = 1; }
+void Bob::processing( int n)
+{
+    if( n == 0 ) {
+        _led_process = 1; 
+    }else{
+        _led_process = 0;
+        flash( n, 1 );
+        wait(0.8);
+    }     
+}
 void Bob::no_processing(void)  { _led_process   = 0; }
 
-void Bob::error(void)   { _led_error   = 1; }
+void Bob::error( int n )
+{
+    if( n == 0 ) {
+        _led_error = 1; 
+    }else{
+        _led_error = 0;
+        flash( n, 2 );
+        wait(0.8);
+    }     
+}
 void Bob::no_error(void)  { _led_error   = 0; }