Local library
Dependencies: WakeUp PinDetect
Dependents: Inductive_Sensor Inductive_Sensor_Jasper Inductive_Sensor_3
Revision 9:3fe744aca1c0, committed 2016-09-21
- Comitter:
- bobgiesberts
- Date:
- Wed Sep 21 14:23:19 2016 +0000
- Parent:
- 8:42b54bfe81db
- Commit message:
- Libraries loaded in .h (and not double in .cpp)
Changed in this revision
Bob.cpp | Show annotated file Show diff for this revision Revisions of this file |
Bob.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 42b54bfe81db -r 3fe744aca1c0 Bob.cpp --- 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; }
diff -r 42b54bfe81db -r 3fe744aca1c0 Bob.h --- a/Bob.h Wed Sep 07 11:47:37 2016 +0000 +++ b/Bob.h Wed Sep 21 14:23:19 2016 +0000 @@ -12,7 +12,9 @@ */ #include "mbed.h" +#include "mbed_debug.h" #include "PinDetect.h" +#include "WakeUp.h" class Bob { public: @@ -36,15 +38,16 @@ * Powers down the SD card system, the crystal and the LDC1614 */ void shutdown_periphery(void); + void shutdown_pin(PinName pin, int value = 0, PinMode pull = PullNone ); void sleep(uint32_t ms); float battery(void); - void flash(int n); - void processing(void); + void flash(int n, int led = 0 ); + void processing( int n = 0 ); void no_processing(void); - void error(void); + void error( int n = 0 ); void no_error(void); private: