LP Long Distance IR Vision Robot

Dependencies:   max77650_charger_sample BufferedSerial SX1276GenericLib Adafruit-MotorShield NEO-6m-GPS MAX17055_EZconfig Adafruit_GFX USBDeviceHT Adafruit-PWM-Servo-Driver

Revision:
25:1a031add188a
Parent:
24:e8d03912f303
Child:
26:69aba05f010f
--- a/main.cpp	Wed Jul 18 21:25:17 2018 +0000
+++ b/main.cpp	Thu Jul 19 21:13:19 2018 +0000
@@ -28,6 +28,8 @@
 
 DigitalOut myled(LED);
 
+Serial pc(USBTX, USBRX);
+
 
 #if   defined(TARGET_MAX32630FTHR) // Master Device: MAX32630FTHR BLE-to-LoRa Gateway
     /* No grid eye object needed. The function the master uses to convert the raw 
@@ -58,6 +60,11 @@
     dprintf("Starting a simple LoRa PingPong");
     
     /* Setup begins here: */
+    #if   defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway
+        dprintf("MAX32630FTHR: Master");
+    #elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot
+        dprintf("MAX32620FTHR: Slave");
+    #endif
     
     /***************************************************************************
      * Lora Communications
@@ -71,6 +78,7 @@
         int frame_idx = 0;
     #elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot
         // none yet
+        int frame_idx = 0;
     #endif
     
     
@@ -103,14 +111,49 @@
                 // Increment frame counter
                 frame_idx = frame_idx +1;
             }
+            
+            /* Next copy in data received from current data into buffer used for
+             * comparison next time the memcmp above is called. This prevents the 
+             * program from converting the same raw data aquired by the grid eye
+             * sensor on the slave device to the floating point array with the 
+             * 0.25 degrees celsius precision level when there is not new data. 
+             */
+            memcpy(prev_raw_frame_data_from_slave, curr_raw_frame_data_from_slave, sizeof(curr_raw_frame_data_from_slave));
+            
         #elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot
             // Aquire raw data about 8x8 frame from the grid eye sensor in this function call 
             gridEye.getRaw8x8FrameData(curr_raw_frame_data_to_master);
+            wait_ms( 1000 );  
+            
+            //if ( memcmp(prev_raw_frame_data_to_master, curr_raw_frame_data_to_master, sizeof(curr_raw_frame_data_to_master)) != 0 )
+            //{
+                // Convert raw data sent from slave to a 16 bit integer array by calling this
+                convRaw8x8Data2Point25degC(curr_raw_frame_data_to_master, conv_frame_data_to_master);
+                
+                // Next Print off the Converted data
+                pc.printf("\r\nFrame %d data: \r\n", frame_idx);
+                uint8_t idx;
+                float pixel_data;
+                for (int y = 0; y < 8; y++) {
+                    for (int x = 0; x < 8; x++) {
+                        idx = y*8 + x;
+                        pixel_data = conv_frame_data_to_master[idx]/4.0;
+                        pc.printf("%.2f  \t", pixel_data);
+                    }
+                    pc.printf("\r\n\r\n");
+                }
+                pc.printf("\r\n");
+                
+                // Increment frame counter
+                frame_idx = frame_idx +1;
+            //}
+            memcpy(prev_raw_frame_data_to_master, curr_raw_frame_data_to_master, sizeof(curr_raw_frame_data_to_master));
         #endif
 
         /***************************************************************************
         * Lora Communications
         **************************************************************************/
+        wait_ms( 10 );  
         SX1276PingPong();