![](/media/cache/profiles/profile_pic_for_github_less_than_1MB.jpg.50x50_q85.jpg)
This is example code that can get you started with building your own IR vision robot that communicates over LoRa
Dependencies: Adafruit-MotorShield Adafruit-PWM-Servo-Driver Adafruit_GFX BufferedSerial MAX17055_EZconfig NEO-6m-GPS SX1276GenericLib USBDeviceHT max32630fthr max77650_charger_sample
Fork of MAX326xxFTHR_LoRa_Example_test by
Diff: main.cpp
- Revision:
- 35:bae9b236070b
- Parent:
- 33:52c898aca207
- Child:
- 36:09e8b51fc91d
--- a/main.cpp Tue Jul 31 02:00:57 2018 +0000 +++ b/main.cpp Tue Jul 31 21:16:10 2018 +0000 @@ -15,7 +15,7 @@ #include "mbed.h" #include <string> -//#define DEBUG_GRID_EYE_SLAVE +//#define DEBUG_GRID_EYE #define RASPBERRY_PI @@ -399,16 +399,6 @@ #if defined(RASPBERRY_PI) if( memcmp(prev_raw_frame_from_slave, curr_raw_frame_from_slave, sizeof(curr_raw_frame_from_slave)) != 0 ) { - /* - //for (int idx = 0; idx < 8; idx++) - // pc.printf("%c", ID_of_slave[idx]); - string grid_eye_msg; - grid_eye_msg[0]=0x55; - grid_eye_msg[1]=0xaa; - for (int idx = 0; idx < 128; idx++) - grid_eye_msg[idx+2] = (unsigned char)curr_raw_frame_from_slave[idx]; - pc.printf(grid_eye_msg); - */ char grid_eye_msg[130]; grid_eye_msg[0]=0x55; grid_eye_msg[1]=0xaa; @@ -417,8 +407,10 @@ //pc.printf(grid_eye_msg); for (int idx = 0; idx < 130; idx++) pc.putc(grid_eye_msg[idx]); + pc.printf("\r\n"); // seperate the lines } - #else + #endif + #if defined(DEBUG_GRID_EYE) if( memcmp(prev_raw_frame_from_slave, curr_raw_frame_from_slave, sizeof(curr_raw_frame_from_slave)) != 0 ) { // Convert raw data sent from slave to a 16 bit integer array by calling this @@ -454,8 +446,21 @@ // Aquire raw data about 8x8 frame from the grid eye sensor in this function call gridEye.getRaw8x8FrameData(curr_raw_frame_to_master); wait_ms( 20 ); - - #if defined(DEBUG_GRID_EYE_SLAVE) + #if defined(RASPBERRY_PI) + if( memcmp(prev_raw_frame_to_master, curr_raw_frame_to_master, sizeof(curr_raw_frame_to_master)) != 0 ) + { + char grid_eye_msg[130]; + grid_eye_msg[0]=0x55; + grid_eye_msg[1]=0xaa; + for (int idx = 0; idx < 128; idx++) + grid_eye_msg[idx+2] = curr_raw_frame_to_master[idx]; + //pc.printf(grid_eye_msg); + for (int idx = 0; idx < 130; idx++) + pc.putc(grid_eye_msg[idx]); + pc.printf("\r\n"); // seperate the lines + } + #endif + #if defined(DEBUG_GRID_EYE) if( memcmp(prev_raw_frame_to_master, curr_raw_frame_to_master, sizeof(curr_raw_frame_to_master)) != 0 ) { wait_ms( 5 ); @@ -482,19 +487,6 @@ frame_idx = frame_idx +1; } #endif - #if defined(RASPBERRY_PI) - if( memcmp(prev_raw_frame_to_master, curr_raw_frame_to_master, sizeof(curr_raw_frame_to_master)) != 0 ) - { - char grid_eye_msg[130]; - grid_eye_msg[0]=0x55; - grid_eye_msg[1]=0xaa; - for (int idx = 0; idx < 128; idx++) - grid_eye_msg[idx+2] = curr_raw_frame_to_master[idx]; - //pc.printf(grid_eye_msg); - for (int idx = 0; idx < 130; idx++) - pc.putc(grid_eye_msg[idx]); - } - #endif wait_ms( 20 ); memcpy(prev_raw_frame_to_master, curr_raw_frame_to_master, sizeof(curr_raw_frame_to_master)); #endif