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: GridEye/GridEye.cpp
- Revision:
- 28:0ed92c590607
- Parent:
- 23:f74a50977593
- Child:
- 38:c10d2a04a0c2
--- a/GridEye/GridEye.cpp Fri Jul 20 21:29:53 2018 +0000 +++ b/GridEye/GridEye.cpp Mon Jul 23 23:39:35 2018 +0000 @@ -38,6 +38,8 @@ GridEye::GridEye(I2C &i2c) : m_i2cBus(i2c) { + //Perform a software reset upon power on. + softwareReset(); } @@ -124,6 +126,18 @@ return result; } +//********************************************************************* +int8_t GridEye::softwareReset() +{ + int8_t result; + char initial_reset[1]; + //This value when programmed to the Grid Eye's RESET reg will perform initial reset on device + initial_reset[0] = 0x3F; + result = this->gridEyeWriteReg(GridEye::RESET, 1, initial_reset); + if (result == I2C_WR_SUCCESS) + return result; + return I2C_WR_ERROR; +} //********************************************************************* int8_t GridEye::setOperatingMode(GridEye::OperatingMode mode) @@ -155,6 +169,7 @@ int8_t upper_byte = data[1]; int8_t lower_byte = data[0]; int16_t upper_byte_mask = 0x0F00; + //int16_t sign_bit = 0x0400; int16_t sign_bit = 0x0200; int16_t finish_neg_val = 0xFC00; int16_t pixel; @@ -181,6 +196,7 @@ int8_t upper_byte; int8_t lower_byte; int16_t upper_byte_mask = 0x0F00; + //int16_t sign_bit = 0x0400; int16_t sign_bit = 0x0200; int16_t finish_neg_val = 0xFC00; int16_t pixel; @@ -213,6 +229,7 @@ int8_t upper_byte; int8_t lower_byte; int16_t upper_byte_mask = 0x0F00; + //int16_t sign_bit = 0x1000; int16_t sign_bit = 0x0800; int16_t finish_neg_val = 0xF000; int16_t pixel; @@ -223,14 +240,15 @@ upper_byte = data[idx*2+1]; lower_byte = data[idx*2+0]; pixel = (upper_byte << 8); - pixel &= upper_byte_mask; + //pixel &= upper_byte_mask; pixel |= lower_byte; - //no shift needed since we would lose the two lsb that give 0.25*C precision //if negative, properly convert to 16 bit int format to represent 2's compliment if (pixel & sign_bit) pixel |= finish_neg_val; + else + pixel &= 0x0FFF; //set the coresponding pixel to be in the passed in array frame_temp[idx] = pixel;