Local library

Dependencies:   WakeUp PinDetect

Dependents:   Inductive_Sensor Inductive_Sensor_Jasper Inductive_Sensor_3

Committer:
bobgiesberts
Date:
Fri Dec 18 15:49:34 2015 +0000
Revision:
0:17943815800f
Child:
1:2234e0b31d94
Communication with Leds and SD-card

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bobgiesberts 0:17943815800f 1 /**
bobgiesberts 0:17943815800f 2 * @file Bob.cpp
bobgiesberts 0:17943815800f 3 * @brief just so functions to communicate with the
bobgiesberts 0:17943815800f 4 * processor board for the LDC1101
bobgiesberts 0:17943815800f 5 *
bobgiesberts 0:17943815800f 6 * @author Bob Giesberts
bobgiesberts 0:17943815800f 7 *
bobgiesberts 0:17943815800f 8 * @date 2015-12-18
bobgiesberts 0:17943815800f 9 */
bobgiesberts 0:17943815800f 10
bobgiesberts 0:17943815800f 11 #include "Bob.h"
bobgiesberts 0:17943815800f 12 #include "mbed.h"
bobgiesberts 0:17943815800f 13
bobgiesberts 0:17943815800f 14 Bob::Bob(PinName redled, PinName greenled, PinName sd_enable, PinName sd_present) : _red(redled), _green(greenled), _sdE(sd_enable)
bobgiesberts 0:17943815800f 15 {
bobgiesberts 0:17943815800f 16 _red = 0;
bobgiesberts 0:17943815800f 17 _green = 0;
bobgiesberts 0:17943815800f 18
bobgiesberts 0:17943815800f 19 _sdE = 1;
bobgiesberts 0:17943815800f 20 _sdP = new DigitalIn( sd_present );
bobgiesberts 0:17943815800f 21 _sdP->mode( PullUp );
bobgiesberts 0:17943815800f 22
bobgiesberts 0:17943815800f 23 }
bobgiesberts 0:17943815800f 24
bobgiesberts 0:17943815800f 25 bool Bob::checkSD(void)
bobgiesberts 0:17943815800f 26 {
bobgiesberts 0:17943815800f 27 // Check if any card is present
bobgiesberts 0:17943815800f 28 if(_sdP->read() != 1) {
bobgiesberts 0:17943815800f 29 flash_green(2);
bobgiesberts 0:17943815800f 30 return 1;
bobgiesberts 0:17943815800f 31 }else{
bobgiesberts 0:17943815800f 32 green();
bobgiesberts 0:17943815800f 33 return 0;
bobgiesberts 0:17943815800f 34 }
bobgiesberts 0:17943815800f 35 }
bobgiesberts 0:17943815800f 36
bobgiesberts 0:17943815800f 37 void Bob::flash( int n )
bobgiesberts 0:17943815800f 38 {
bobgiesberts 0:17943815800f 39 _red = 0;
bobgiesberts 0:17943815800f 40 _green = 0;
bobgiesberts 0:17943815800f 41 for(int i=0; i<n*2; i++){
bobgiesberts 0:17943815800f 42 _red = 1-_red; _green = 1-_green; wait(0.2);
bobgiesberts 0:17943815800f 43 }
bobgiesberts 0:17943815800f 44 }
bobgiesberts 0:17943815800f 45
bobgiesberts 0:17943815800f 46 void Bob::flash_red( int n )
bobgiesberts 0:17943815800f 47 {
bobgiesberts 0:17943815800f 48 _red = 0;
bobgiesberts 0:17943815800f 49 for(int i=0; i<n*2; i++){
bobgiesberts 0:17943815800f 50 _red = 1-_red; wait(0.2);
bobgiesberts 0:17943815800f 51 }
bobgiesberts 0:17943815800f 52 }
bobgiesberts 0:17943815800f 53
bobgiesberts 0:17943815800f 54 void Bob::flash_green( int n )
bobgiesberts 0:17943815800f 55 {
bobgiesberts 0:17943815800f 56 _green = 0;
bobgiesberts 0:17943815800f 57 for(int i=0; i<n*2; i++){
bobgiesberts 0:17943815800f 58 _green = 1-_green; wait(0.2);
bobgiesberts 0:17943815800f 59 }
bobgiesberts 0:17943815800f 60 }
bobgiesberts 0:17943815800f 61
bobgiesberts 0:17943815800f 62 void Bob::red(void) { _red = 1; wait(0.2); }
bobgiesberts 0:17943815800f 63 void Bob::green(void) { _green = 1; wait(0.2); }
bobgiesberts 0:17943815800f 64