For thermal pod
Dependencies: Hepta9axis HeptaBattery HeptaCamera_GPS HeptaTemp HeptaXbee SDFileSystem mbed
main.cpp@16:83536ace57fb, 2017-09-08 (annotated)
- Committer:
- HEPTA
- Date:
- Fri Sep 08 17:49:21 2017 +0000
- Revision:
- 16:83536ace57fb
- Parent:
- 13:a1fa75a002f6
- Child:
- 17:904bcb46a48d
Hepta Lab6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:bdbd3d6fc5d5 | 1 | #include "mbed.h" |
mbed_official | 0:bdbd3d6fc5d5 | 2 | #include "SDFileSystem.h" |
umeume | 2:1c5cdb2c3e0f | 3 | #include "HeptaXbee.h" |
umeume | 2:1c5cdb2c3e0f | 4 | #include "HeptaTemp.h" |
umeume | 2:1c5cdb2c3e0f | 5 | |
umeume | 2:1c5cdb2c3e0f | 6 | Serial pc(USBTX,USBRX); |
HEPTA | 9:942eb6e8c117 | 7 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
umeume | 2:1c5cdb2c3e0f | 8 | HeptaXbee xbee(p9,p10); |
HEPTA | 16:83536ace57fb | 9 | HeptaTemp temper(p17); |
umeume | 5:c5ccb1b07e8f | 10 | |
umeume | 2:1c5cdb2c3e0f | 11 | int main() |
umeume | 2:1c5cdb2c3e0f | 12 | { |
HEPTA | 16:83536ace57fb | 13 | int rcmd=0,cmdflag=0; |
HEPTA | 16:83536ace57fb | 14 | float voltage; |
HEPTA | 16:83536ace57fb | 15 | mkdir("/sd/mydir", 0777); |
HEPTA | 16:83536ace57fb | 16 | while(1) { |
HEPTA | 16:83536ace57fb | 17 | wait(1.0); |
HEPTA | 16:83536ace57fb | 18 | xbee.xbee_recieve(&rcmd,&cmdflag); |
HEPTA | 16:83536ace57fb | 19 | pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag); |
HEPTA | 16:83536ace57fb | 20 | if (cmdflag == 1) { |
HEPTA | 16:83536ace57fb | 21 | pc.printf("Command Get %d\r\n",rcmd); |
HEPTA | 16:83536ace57fb | 22 | if(rcmd == 'a') { |
HEPTA | 16:83536ace57fb | 23 | while(1) { |
HEPTA | 16:83536ace57fb | 24 | FILE *fp = fopen("/sd/mydir/test.txt", "a"); |
HEPTA | 16:83536ace57fb | 25 | temper.temp_sensing_vol(&voltage); |
HEPTA | 16:83536ace57fb | 26 | pc.printf("Volt = %f\r\n",voltage); |
HEPTA | 16:83536ace57fb | 27 | fprintf(fp,"%f\r\n",voltage); |
HEPTA | 16:83536ace57fb | 28 | fclose(fp); |
HEPTA | 16:83536ace57fb | 29 | wait(0.5); |
HEPTA | 16:83536ace57fb | 30 | } |
HEPTA | 16:83536ace57fb | 31 | xbee.initialize(); |
HEPTA | 16:83536ace57fb | 32 | } |
HEPTA | 16:83536ace57fb | 33 | if(rcmd == 'b') { |
HEPTA | 16:83536ace57fb | 34 | pc.printf("SD test Mode\r\n"); |
HEPTA | 16:83536ace57fb | 35 | FILE *fp = fopen("/sd/myfile.txt", "w"); |
HEPTA | 16:83536ace57fb | 36 | if(fp == NULL) { |
HEPTA | 16:83536ace57fb | 37 | pc.printf("Could not open file for write\r\n"); |
HEPTA | 16:83536ace57fb | 38 | } else { |
HEPTA | 16:83536ace57fb | 39 | fprintf(fp, "\n\rHello World!\n\r"); |
HEPTA | 16:83536ace57fb | 40 | pc.printf("SD Check Complete!!\r\n"); |
HEPTA | 16:83536ace57fb | 41 | fclose(fp); |
HEPTA | 16:83536ace57fb | 42 | } |
HEPTA | 16:83536ace57fb | 43 | xbee.initialize(); |
HEPTA | 16:83536ace57fb | 44 | } |
HEPTA | 16:83536ace57fb | 45 | } |
HEPTA | 16:83536ace57fb | 46 | } |
umeume | 2:1c5cdb2c3e0f | 47 | } |