standalone sx1276 demo program

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Revision:
31:2c813f321db7
Parent:
29:0ea07cc7124b
Child:
32:a2472bbe7c92
diff -r 6b0785d23528 -r 2c813f321db7 hello.cpp
--- a/hello.cpp	Tue Jun 16 11:56:16 2015 +0000
+++ b/hello.cpp	Tue Jul 14 14:58:23 2015 +0000
@@ -2,7 +2,7 @@
 #include "sx1276-hal.h"
 #include "main.h"
 #include "debug.h"
-#include "vt100.h"
+// radfta #include "vt100.h"
 #include "serial_api.h"
 #include "GPS.h"
 #include <math.h>
@@ -46,6 +46,7 @@
     float a = 0;
     float d = 0;
     
+#ifdef radfta    
     gpsd.distance = 0;
     if (gpsd.l_latitude == 0.0)
     {
@@ -80,13 +81,13 @@
     }
     gpsd.distance = gpsd.distance + d;
    // printf("distance: %f\r\n", gpsd.distance);
-  
+#endif  
 }
  
 void check_gps(void)
 {
     static int gps_count=0;
-    
+#ifdef radfta    
     if (gps_count >= 0)
     {
         //printf("checking gps\r\n");
@@ -157,7 +158,7 @@
         //printf("not checking gps\r\n");
         gps_count++;
     }
-       
+#endif       
 }
 
 void hello(void)
@@ -200,8 +201,8 @@
 
             printf("rx timeout in gps/hello loop. ");
             printf("per=%d\r\n", per);
-            gpsd.r_latitude = 0;
-            gpsd.r_longitude = 0;
+            // radfta gpsd.r_latitude = 0;
+            // radfta gpsd.r_longitude = 0;
             // printf("rcv - rssi = %d snr = %d msg=%s\r\n", RssiValue, SnrValue, BufferRx);
             cLCD.setCursor(0,0);
             cLCD.printf("RI:NA SR:NA      ");
@@ -220,30 +221,37 @@
                 else
                 {
                   // float latitude, longitude;
+#ifdef radfta                  
                   if(sscanf((char *)BufferRx, "GP,%f,%f", &gpsd.r_latitude, &gpsd.r_longitude ) >= 1) 
                   {                    
                     led = !led;     
                     printf("rssi=%d snr=%d rlat=%0.5f rlon=%0.5f llat=%0.5f llon=%0.5f dst=%0.0fm ", RssiValue, SnrValue, gpsd.r_latitude, gpsd.r_longitude, gpsd.l_latitude, gpsd.l_longitude, gpsd.distance);
                     printf("per=%d\r\n", per);
-
                     cLCD.setCursor(0,0);
                     cLCD.printf("RI:%d SR:%d    ", RssiValue,SnrValue);
                     //printf("Msg received - Lat: %0.4f Lon: %0.4f\r\n", latitude, longitude);
                   }
                   else
                     printf("strange received message: %s\r\n", BufferRx);
-                 } 
+#else
+                  cLCD.setCursor(0,0);
+                  cLCD.printf("RI:%d SR:%d    ", RssiValue,SnrValue);
+                  printf("received message: %s\r\n", BufferRx);               
+#endif                    
+              }                  
             }
        case RX_ERROR:
             if (gpsEnabled)
             {
                 check_gps();
             }   
+#ifdef radfta            
             if (gpsEnabled)
                 sprintf((char *)BufferTx, "GP,%4.5f,%4.5f", gpsd.l_latitude, gpsd.l_longitude);
             else
+#else            
                 strcpy( ( char* )BufferTx, ( char* )HelloMsg );
-               
+#endif               
             BufferSize=strlen((char *)BufferTx);
             //printf("Sending new buffer\r\n");
             Radio.Send( BufferTx, BufferSize );