simulate satellite program structure

Dependencies:   mbed HeptaBattery SDFileSystem HeptaCamera_GPS Hepta9axis HeptaTemp HeptaXbee

Fork of Lab7-01_template by HEPTA-Sat Training 2017~2018

Files at this revision

API Documentation at this revision

Comitter:
HEPTA
Date:
Wed Aug 08 11:02:16 2018 +0000
Parent:
16:f11a9421a3c7
Child:
18:af8431b9a4ea
Commit message:
simulate satellite program structure

Changed in this revision

HeptaCamera_GPS.lib Show annotated file Show diff for this revision Revisions of this file
HeptaXbee.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/HeptaCamera_GPS.lib	Fri Nov 17 02:10:06 2017 +0000
+++ b/HeptaCamera_GPS.lib	Wed Aug 08 11:02:16 2018 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/HEPTA/code/HeptaCamera_GPS/#2a3668c3918d
+https://developer.mbed.org/users/HEPTA/code/HeptaCamera_GPS/#0726a3aa3320
--- a/HeptaXbee.lib	Fri Nov 17 02:10:06 2017 +0000
+++ b/HeptaXbee.lib	Wed Aug 08 11:02:16 2018 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/HEPTA/code/HeptaXbee/#8e925f198e21
+https://developer.mbed.org/users/HEPTA/code/HeptaXbee/#96ed36bbc9dd
--- a/main.cpp	Fri Nov 17 02:10:06 2017 +0000
+++ b/main.cpp	Wed Aug 08 11:02:16 2018 +0000
@@ -14,12 +14,74 @@
 HeptaTemp temp(p17);
 HeptaBattery battery(p16,p26);
 
-DigitalOut myled(LED1);
+DigitalOut myleds[] = {LED1,LED2,LED3,LED4};;
 
 int main()
 {
-    myled = 1;
-    wait(0.5);
-    myled = 0;
-    wait(0.5);
-}
\ No newline at end of file
+    pc.baud(9600);
+    float bt;
+    float temper;
+    char str[100];
+    char gx[4],gy[4],gz[4],ax[4],ay[4],az[4],mx[4],my[4],mz[4],lad[8],log[8],height[4],bat[4],temperature[4];
+    int flag = 0;
+    int rcmd=0,cmdflag=0;
+    while(1) {
+        battery.power_saving_mode(&flag,&bt);
+        temp.temp_sense(&temper);
+        wait(0.5);
+        xbee.printf("flag = %d, bt = %.2f [V], temp = %.1f [C]\r\n",flag,bt,temper);
+        if(flag == 1) {
+            xbee.printf("Low Battery\r\n");
+        } else if(temper > 35.0) {
+            xbee.printf("High Temperaturer\n");
+        } else if((flag == 1) & (temper > 35.0)) {
+            xbee.printf("Low Battery and High Temperaturer\n");
+        }
+        xbee.xbee_receive(&rcmd,&cmdflag);
+        if (cmdflag == 1) {
+            xbee.printf("Command Get = %d\r\n",rcmd);
+            if (rcmd == 'a') {
+                for(int i = 0; i < 10; i++) {
+                    xbee.printf("Count = %d\r\n",i);
+                    wait(1.0);
+                }
+            }
+            if (rcmd == 'b') {
+                mkdir("/sd/mydir", 0777);
+                FILE *fp = fopen("/sd/mydir/battery.txt","w");
+                if(fp == NULL) {
+                    error("Could not open file for write\r\n");
+                } else {
+                    for(int i = 0; i < 10; i++) {
+                        battery.vol(&bt);
+                        fprintf(fp,"%f\r\n",bt);
+                        wait(1.0);
+                    }
+                    fclose(fp);
+                }
+                FILE *fp1 = fopen("/sd/mydir/battery.txt","r");
+                if(fp1 == NULL) {
+                    error("Could not open file for read\r\n");
+                } else {
+                    for(int i = 0; i < 10; i++) {
+                        fgets(str,100,fp1);
+                        xbee.printf("%s",str);
+                        wait(1.0);
+                    }
+                    fclose(fp1);
+                }
+            }//
+            if (rcmd == 'c') {
+                
+                
+                
+            }
+            if (rcmd == 'd') {
+                cam_gps.Sync();
+                cam_gps.initialize(HeptaCamera_GPS::Baud115200, HeptaCamera_GPS::JpegResolution320x240);
+                cam_gps.test_jpeg_snapshot_data("/sd/test.jpg");
+            }
+            xbee.initialize();
+        }
+    }
+}