Local library
Dependencies: WakeUp PinDetect
Dependents: Inductive_Sensor Inductive_Sensor_Jasper Inductive_Sensor_3
Diff: Bob.cpp
- Revision:
- 7:0b23995256e7
- Parent:
- 6:0e7c0ad0508b
- Child:
- 9:3fe744aca1c0
diff -r 0e7c0ad0508b -r 0b23995256e7 Bob.cpp --- a/Bob.cpp Wed Aug 24 10:30:41 2016 +0000 +++ b/Bob.cpp Wed Sep 07 09:58:19 2016 +0000 @@ -22,7 +22,7 @@ -Bob::Bob(PinName process_led, PinName error_led, PinName button, PinName sd_present, PinName battery) : _led_process(process_led), _led_error(error_led), _button(button)// , _sd_enable(sd_enable) +Bob::Bob(PinName process_led, PinName error_led, PinName button, PinName enable, PinName sd_present, PinName battery) : _led_process(process_led), _led_error(error_led), _button(button), _enable(enable) { // setup leds _led_process = 0; // green @@ -35,14 +35,12 @@ _button.setSampleFrequency(); // setup SD card system - // _sd_enable = 1; _sd_card_detect = new DigitalIn( sd_present ); _sd_card_detect->mode( PullUp ); // setup battery _batt = new AnalogIn( battery ); - // WakeUp::calibrate(); } Bob::~Bob() {} @@ -51,24 +49,27 @@ bool Bob::checkSD(void) { - // _sd_enable.write(1); + // TODO: this should first check if _enable is on. if not, return false either way! + + _enable.write(1); + wait_ms(3); return !_sd_card_detect->read(); } -void Bob::wakeup(void) +void Bob::wakeup_periphery(void) { - // _sd_enable.write(1); // power SD-card + _enable.write(1); // power SD-card + wait_ms(3); // wait(0.3); // this shouldn't be necessary because loading the LDC library already takes 0.81 s } -void Bob::beforesleep(void) +void Bob::shutdown_periphery(void) { - // _sd_enable.write(0); + _enable.write(0); } void Bob::sleep(uint32_t ms) { - // _sd_enable.write(0); // unpower SD-card WakeUp::calibrate(); // calibration takes 100 ms WakeUp::set_ms( ms - 100 ); // substract this from the total sleep time deepsleep(); @@ -89,5 +90,8 @@ } } -void Bob::ledon(void) { _led_process = 1; } -void Bob::ledoff(void) { _led_process = 0; } +void Bob::processing(void) { _led_process = 1; } +void Bob::no_processing(void) { _led_process = 0; } + +void Bob::error(void) { _led_error = 1; } +void Bob::no_error(void) { _led_error = 0; }