![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
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
GridEye/GridEye.h@40:6f8744c366c2, 2018-08-01 (annotated)
- Committer:
- dev_alexander
- Date:
- Wed Aug 01 03:52:55 2018 +0000
- Revision:
- 40:6f8744c366c2
- Parent:
- 28:0ed92c590607
Removed conflict that prevented ble.waitForEvent from being compiled due to a #define that was removed in cleaning up the main.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dev_alexander | 23:f74a50977593 | 1 | /********************************************************************** |
dev_alexander | 23:f74a50977593 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
dev_alexander | 23:f74a50977593 | 3 | * |
dev_alexander | 23:f74a50977593 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
dev_alexander | 23:f74a50977593 | 5 | * copy of this software and associated documentation files (the "Software"), |
dev_alexander | 23:f74a50977593 | 6 | * to deal in the Software without restriction, including without limitation |
dev_alexander | 23:f74a50977593 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
dev_alexander | 23:f74a50977593 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
dev_alexander | 23:f74a50977593 | 9 | * Software is furnished to do so, subject to the following conditions: |
dev_alexander | 23:f74a50977593 | 10 | * |
dev_alexander | 23:f74a50977593 | 11 | * The above copyright notice and this permission notice shall be included |
dev_alexander | 23:f74a50977593 | 12 | * in all copies or substantial portions of the Software. |
dev_alexander | 23:f74a50977593 | 13 | * |
dev_alexander | 23:f74a50977593 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
dev_alexander | 23:f74a50977593 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
dev_alexander | 23:f74a50977593 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
dev_alexander | 23:f74a50977593 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
dev_alexander | 23:f74a50977593 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
dev_alexander | 23:f74a50977593 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
dev_alexander | 23:f74a50977593 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
dev_alexander | 23:f74a50977593 | 21 | * |
dev_alexander | 23:f74a50977593 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
dev_alexander | 23:f74a50977593 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
dev_alexander | 23:f74a50977593 | 24 | * Products, Inc. Branding Policy. |
dev_alexander | 23:f74a50977593 | 25 | * |
dev_alexander | 23:f74a50977593 | 26 | * The mere transfer of this software does not imply any licenses |
dev_alexander | 23:f74a50977593 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
dev_alexander | 23:f74a50977593 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
dev_alexander | 23:f74a50977593 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
dev_alexander | 23:f74a50977593 | 30 | * ownership rights. |
dev_alexander | 23:f74a50977593 | 31 | **********************************************************************/ |
dev_alexander | 23:f74a50977593 | 32 | |
dev_alexander | 23:f74a50977593 | 33 | |
dev_alexander | 23:f74a50977593 | 34 | #ifndef GRIDEYE_H |
dev_alexander | 23:f74a50977593 | 35 | #define GRIDEYE_H |
dev_alexander | 23:f74a50977593 | 36 | |
dev_alexander | 23:f74a50977593 | 37 | |
dev_alexander | 23:f74a50977593 | 38 | #include "mbed.h" |
dev_alexander | 23:f74a50977593 | 39 | |
dev_alexander | 23:f74a50977593 | 40 | #define I2C_WR_SUCCESS 0 |
dev_alexander | 23:f74a50977593 | 41 | #define I2C_WR_ERROR -1 |
dev_alexander | 23:f74a50977593 | 42 | |
dev_alexander | 23:f74a50977593 | 43 | /** |
dev_alexander | 23:f74a50977593 | 44 | * @brief Object for interfacing to MAXREFDES131# |
dev_alexander | 23:f74a50977593 | 45 | * |
dev_alexander | 23:f74a50977593 | 46 | * @details MAXREFDES131# combines the DS28E17 1-wire to I2C bridge |
dev_alexander | 23:f74a50977593 | 47 | * with the Panasonic AMG8833 GridEye sensor. The reference design also |
dev_alexander | 23:f74a50977593 | 48 | * includes a DS2413 2ch open drain switch for controlling the MAX4717 |
dev_alexander | 23:f74a50977593 | 49 | * dual SPDT analog switch. The DS28E17 and AMG8833 are connected to |
dev_alexander | 23:f74a50977593 | 50 | * the 1-wire bus via COM2 of the MAX4717 and COM1 is used for |
dev_alexander | 23:f74a50977593 | 51 | * daisy-chaining additional modules. Disconnecting the DS28E17/AMG8833 |
dev_alexander | 23:f74a50977593 | 52 | * from the main 1-wire branch puts both devices to sleep and reduces current |
dev_alexander | 23:f74a50977593 | 53 | * consumption from 10mA to a couple hundred uA. |
dev_alexander | 23:f74a50977593 | 54 | */ |
dev_alexander | 23:f74a50977593 | 55 | class GridEye |
dev_alexander | 23:f74a50977593 | 56 | { |
dev_alexander | 23:f74a50977593 | 57 | private: |
dev_alexander | 23:f74a50977593 | 58 | I2C &m_i2cBus; |
dev_alexander | 23:f74a50977593 | 59 | static const uint8_t I2C_ADRS = 0x68; |
dev_alexander | 40:6f8744c366c2 | 60 | static const uint8_t I2C_W_ADRS_GRIDEYE = (uint8_t)((I2C_ADRS)<<1); |
dev_alexander | 40:6f8744c366c2 | 61 | static const uint8_t I2C_R_ADRS_GRIDEYE = (uint8_t)((I2C_ADRS)<<1)+1; |
dev_alexander | 23:f74a50977593 | 62 | |
dev_alexander | 23:f74a50977593 | 63 | public: |
dev_alexander | 23:f74a50977593 | 64 | |
dev_alexander | 23:f74a50977593 | 65 | /** |
dev_alexander | 23:f74a50977593 | 66 | * @brief GridEye operating modes |
dev_alexander | 23:f74a50977593 | 67 | */ |
dev_alexander | 23:f74a50977593 | 68 | enum OperatingMode |
dev_alexander | 23:f74a50977593 | 69 | { |
dev_alexander | 23:f74a50977593 | 70 | NormalMode = 0x00, |
dev_alexander | 23:f74a50977593 | 71 | SleepMode = 0x10, |
dev_alexander | 23:f74a50977593 | 72 | StandBy60sec = 0x20, |
dev_alexander | 23:f74a50977593 | 73 | StandBy10sec = 0x21 |
dev_alexander | 23:f74a50977593 | 74 | }; |
dev_alexander | 23:f74a50977593 | 75 | |
dev_alexander | 23:f74a50977593 | 76 | /** |
dev_alexander | 23:f74a50977593 | 77 | * @brief GridEye operating modes |
dev_alexander | 23:f74a50977593 | 78 | */ |
dev_alexander | 23:f74a50977593 | 79 | enum FrameRate |
dev_alexander | 23:f74a50977593 | 80 | { |
dev_alexander | 23:f74a50977593 | 81 | TenFPS = 0x00, |
dev_alexander | 23:f74a50977593 | 82 | OneFPS = 0x01 |
dev_alexander | 23:f74a50977593 | 83 | }; |
dev_alexander | 23:f74a50977593 | 84 | |
dev_alexander | 23:f74a50977593 | 85 | /** |
dev_alexander | 23:f74a50977593 | 86 | * @brief AMG8833 register map |
dev_alexander | 23:f74a50977593 | 87 | */ |
dev_alexander | 23:f74a50977593 | 88 | enum GridEyeRegister |
dev_alexander | 23:f74a50977593 | 89 | { |
dev_alexander | 23:f74a50977593 | 90 | OPERATING_MODE, |
dev_alexander | 23:f74a50977593 | 91 | RESET, |
dev_alexander | 23:f74a50977593 | 92 | FRAME_RATE, |
dev_alexander | 23:f74a50977593 | 93 | INT_CONTROL, |
dev_alexander | 23:f74a50977593 | 94 | STATUS, |
dev_alexander | 23:f74a50977593 | 95 | STATUS_CLEAR, |
dev_alexander | 23:f74a50977593 | 96 | AVERAGE = 7, |
dev_alexander | 23:f74a50977593 | 97 | INT_LEVEL_1, |
dev_alexander | 23:f74a50977593 | 98 | INT_LEVEL_2, |
dev_alexander | 23:f74a50977593 | 99 | INT_LEVEL_3, |
dev_alexander | 23:f74a50977593 | 100 | INT_LEVEL_4, |
dev_alexander | 23:f74a50977593 | 101 | INT_LEVEL_5, |
dev_alexander | 23:f74a50977593 | 102 | INT_LEVEL_6, |
dev_alexander | 23:f74a50977593 | 103 | THERMISTOR_LOW, |
dev_alexander | 23:f74a50977593 | 104 | THERMISTOR_HI, |
dev_alexander | 23:f74a50977593 | 105 | INT_1, |
dev_alexander | 23:f74a50977593 | 106 | INT_2, |
dev_alexander | 23:f74a50977593 | 107 | INT_3, |
dev_alexander | 23:f74a50977593 | 108 | INT_4, |
dev_alexander | 23:f74a50977593 | 109 | INT_5, |
dev_alexander | 23:f74a50977593 | 110 | INT_6, |
dev_alexander | 23:f74a50977593 | 111 | INT_7, |
dev_alexander | 23:f74a50977593 | 112 | INT_8, |
dev_alexander | 23:f74a50977593 | 113 | PIXEL_BASE_ADRS = 0x80 |
dev_alexander | 23:f74a50977593 | 114 | }; |
dev_alexander | 23:f74a50977593 | 115 | |
dev_alexander | 23:f74a50977593 | 116 | /* static const uint8_t DS2413_FAMILY_CODE = 0x3A; |
dev_alexander | 23:f74a50977593 | 117 | |
dev_alexander | 23:f74a50977593 | 118 | static const uint8_t DS28E17_FAMILY_CODE = 0x19; |
dev_alexander | 23:f74a50977593 | 119 | */ |
dev_alexander | 23:f74a50977593 | 120 | /** |
dev_alexander | 23:f74a50977593 | 121 | * @brief GridEye Constructor |
dev_alexander | 23:f74a50977593 | 122 | * |
dev_alexander | 23:f74a50977593 | 123 | * @details setI2CBridge() by passing in I2C parameter |
dev_alexander | 23:f74a50977593 | 124 | * |
dev_alexander | 23:f74a50977593 | 125 | * @param[in] selector - MultidropRomIterator object that |
dev_alexander | 23:f74a50977593 | 126 | * encapsulates ROM fxs of 1-wire protocol |
dev_alexander | 23:f74a50977593 | 127 | */ |
dev_alexander | 23:f74a50977593 | 128 | GridEye(I2C &i2c); |
dev_alexander | 23:f74a50977593 | 129 | |
dev_alexander | 23:f74a50977593 | 130 | |
dev_alexander | 23:f74a50977593 | 131 | |
dev_alexander | 23:f74a50977593 | 132 | |
dev_alexander | 23:f74a50977593 | 133 | /** |
dev_alexander | 23:f74a50977593 | 134 | * @brief gridEyeWriteReg |
dev_alexander | 23:f74a50977593 | 135 | * |
dev_alexander | 23:f74a50977593 | 136 | * @details Provides read/write access to the AMG8833 |
dev_alexander | 23:f74a50977593 | 137 | * |
dev_alexander | 23:f74a50977593 | 138 | * On Entry: |
dev_alexander | 23:f74a50977593 | 139 | * @param[in] regAdrs - AMG8833 register to start reading/writting |
dev_alexander | 23:f74a50977593 | 140 | * from/to |
dev_alexander | 23:f74a50977593 | 141 | * @param[in] numBytes - Number of bytes of data to write |
dev_alexander | 23:f74a50977593 | 142 | * @param[in] dataBuf - Pointer to data buffer for storing data in |
dev_alexander | 23:f74a50977593 | 143 | * on read, or data to be written on write |
dev_alexander | 23:f74a50977593 | 144 | * |
dev_alexander | 23:f74a50977593 | 145 | * On Exit: |
dev_alexander | 23:f74a50977593 | 146 | * |
dev_alexander | 23:f74a50977593 | 147 | * @return CmdResult - return 0 if the operation was sucessful, return -1 if unsucessful |
dev_alexander | 23:f74a50977593 | 148 | */ |
dev_alexander | 23:f74a50977593 | 149 | int8_t gridEyeWriteReg(GridEyeRegister reg_addr, int num_bytes, char * data_buf); |
dev_alexander | 23:f74a50977593 | 150 | |
dev_alexander | 23:f74a50977593 | 151 | /** |
dev_alexander | 23:f74a50977593 | 152 | * @brief gridEyeReadReg |
dev_alexander | 23:f74a50977593 | 153 | * |
dev_alexander | 23:f74a50977593 | 154 | * @details Provides read/write access to the AMG8833 |
dev_alexander | 23:f74a50977593 | 155 | * |
dev_alexander | 23:f74a50977593 | 156 | * On Entry: |
dev_alexander | 23:f74a50977593 | 157 | * @param[in] regAdrs - AMG8833 register to start reading/writting |
dev_alexander | 23:f74a50977593 | 158 | * from/to |
dev_alexander | 23:f74a50977593 | 159 | * @param[in] numBytes - Number of bytes to read |
dev_alexander | 23:f74a50977593 | 160 | * @param[in] dataBuf - Pointer to data buffer for storing data in |
dev_alexander | 23:f74a50977593 | 161 | * on read, or data to be written on write |
dev_alexander | 23:f74a50977593 | 162 | * |
dev_alexander | 23:f74a50977593 | 163 | * On Exit: |
dev_alexander | 23:f74a50977593 | 164 | * @param[out] dataBuf - Read data on read operation |
dev_alexander | 23:f74a50977593 | 165 | * |
dev_alexander | 23:f74a50977593 | 166 | * @return CmdResult - return 0 if the operation was sucessful, return -1 if unsucessful |
dev_alexander | 23:f74a50977593 | 167 | */ |
dev_alexander | 23:f74a50977593 | 168 | int8_t gridEyeReadReg(GridEyeRegister reg_addr, int num_bytes, char * data_buf); |
dev_alexander | 23:f74a50977593 | 169 | |
dev_alexander | 23:f74a50977593 | 170 | |
dev_alexander | 23:f74a50977593 | 171 | /** |
dev_alexander | 23:f74a50977593 | 172 | * @brief getThermistorTemperature |
dev_alexander | 23:f74a50977593 | 173 | * |
dev_alexander | 23:f74a50977593 | 174 | * @details Gets internal thermistor temperature |
dev_alexander | 23:f74a50977593 | 175 | * |
dev_alexander | 23:f74a50977593 | 176 | * On Entry: |
dev_alexander | 23:f74a50977593 | 177 | * @param[in] thermTemp - reference to int16_t var that will be overwritten |
dev_alexander | 23:f74a50977593 | 178 | * with thermistor data |
dev_alexander | 23:f74a50977593 | 179 | * |
dev_alexander | 23:f74a50977593 | 180 | * On Exit: |
dev_alexander | 23:f74a50977593 | 181 | * @param[out] thermTemp - thermistor data |
dev_alexander | 23:f74a50977593 | 182 | * |
dev_alexander | 23:f74a50977593 | 183 | * @return CmdResult - result of operation |
dev_alexander | 23:f74a50977593 | 184 | */ |
dev_alexander | 23:f74a50977593 | 185 | int8_t getThermistorTemperature(int16_t & therm_temp); |
dev_alexander | 23:f74a50977593 | 186 | |
dev_alexander | 23:f74a50977593 | 187 | |
dev_alexander | 23:f74a50977593 | 188 | /** |
dev_alexander | 23:f74a50977593 | 189 | * @brief getPixelTemperature |
dev_alexander | 23:f74a50977593 | 190 | * |
dev_alexander | 23:f74a50977593 | 191 | * @details Gets individual pixel temperature |
dev_alexander | 23:f74a50977593 | 192 | * |
dev_alexander | 23:f74a50977593 | 193 | * On Entry: |
dev_alexander | 23:f74a50977593 | 194 | * @param[in] pixelAdrs - address of pixel to read |
dev_alexander | 23:f74a50977593 | 195 | * @param[in] pixelTemp - reference to int16_t var that will be overwritten |
dev_alexander | 23:f74a50977593 | 196 | * with thermistor data |
dev_alexander | 23:f74a50977593 | 197 | * |
dev_alexander | 23:f74a50977593 | 198 | * On Exit: |
dev_alexander | 23:f74a50977593 | 199 | * @param[out] pixelTemp - pixel data |
dev_alexander | 23:f74a50977593 | 200 | * |
dev_alexander | 23:f74a50977593 | 201 | * @return CmdResult - result of operation |
dev_alexander | 23:f74a50977593 | 202 | */ |
dev_alexander | 23:f74a50977593 | 203 | int8_t getPixelTemperature(uint8_t pixel_addr, int16_t & pixel_temp); |
dev_alexander | 23:f74a50977593 | 204 | |
dev_alexander | 23:f74a50977593 | 205 | /** |
dev_alexander | 23:f74a50977593 | 206 | * @brief getRaw8x8FrameData |
dev_alexander | 23:f74a50977593 | 207 | * |
dev_alexander | 23:f74a50977593 | 208 | * @details Gets pixel frame(64 pixels in 128 bytes) temperature |
dev_alexander | 23:f74a50977593 | 209 | * |
dev_alexander | 23:f74a50977593 | 210 | * On Entry: |
dev_alexander | 23:f74a50977593 | 211 | * @param[in] raw_frame_data - buffer to hold 2 bytes data per pixel |
dev_alexander | 23:f74a50977593 | 212 | * |
dev_alexander | 23:f74a50977593 | 213 | * On Exit: |
dev_alexander | 23:f74a50977593 | 214 | * @param[out] raw_frame_data - pixel data not yet formatted |
dev_alexander | 23:f74a50977593 | 215 | * |
dev_alexander | 23:f74a50977593 | 216 | * @return int8_t - result of operation, 0 on success, -1 on failure |
dev_alexander | 23:f74a50977593 | 217 | */ |
dev_alexander | 23:f74a50977593 | 218 | int8_t getRaw8x8FrameData(char * raw_frame_data); |
dev_alexander | 23:f74a50977593 | 219 | |
dev_alexander | 23:f74a50977593 | 220 | |
dev_alexander | 28:0ed92c590607 | 221 | /** |
dev_alexander | 28:0ed92c590607 | 222 | * @brief softwareReset |
dev_alexander | 28:0ed92c590607 | 223 | * |
dev_alexander | 28:0ed92c590607 | 224 | * @details Makes the Grid Eye device perform a software restart with Initial conditions |
dev_alexander | 28:0ed92c590607 | 225 | * |
dev_alexander | 28:0ed92c590607 | 226 | * @return int8_t - result of operation, 0 on success, -1 on failure |
dev_alexander | 28:0ed92c590607 | 227 | */ |
dev_alexander | 28:0ed92c590607 | 228 | int8_t softwareReset(); |
dev_alexander | 28:0ed92c590607 | 229 | |
dev_alexander | 28:0ed92c590607 | 230 | |
dev_alexander | 28:0ed92c590607 | 231 | /** |
dev_alexander | 28:0ed92c590607 | 232 | * @brief setOperatingMode |
dev_alexander | 28:0ed92c590607 | 233 | * |
dev_alexander | 28:0ed92c590607 | 234 | * @details Sets the mode of operation for the Grid Eye device |
dev_alexander | 28:0ed92c590607 | 235 | * |
dev_alexander | 28:0ed92c590607 | 236 | * On Entry: |
dev_alexander | 28:0ed92c590607 | 237 | * @param[in] mode - Choose power operating mode from struct |
dev_alexander | 28:0ed92c590607 | 238 | * |
dev_alexander | 28:0ed92c590607 | 239 | * @return int8_t - result of operation, 0 on success, -1 on failure |
dev_alexander | 28:0ed92c590607 | 240 | */ |
dev_alexander | 23:f74a50977593 | 241 | int8_t setOperatingMode(GridEye::OperatingMode mode); |
dev_alexander | 23:f74a50977593 | 242 | |
dev_alexander | 28:0ed92c590607 | 243 | |
dev_alexander | 28:0ed92c590607 | 244 | /** |
dev_alexander | 28:0ed92c590607 | 245 | * @brief setFrameRate |
dev_alexander | 28:0ed92c590607 | 246 | * |
dev_alexander | 28:0ed92c590607 | 247 | * @details Sets the frames per second that the grid eye device resolves |
dev_alexander | 28:0ed92c590607 | 248 | * |
dev_alexander | 28:0ed92c590607 | 249 | * On Entry: |
dev_alexander | 28:0ed92c590607 | 250 | * @param[in] mode - Choose option from either 10 fps or 1 fps |
dev_alexander | 28:0ed92c590607 | 251 | * |
dev_alexander | 28:0ed92c590607 | 252 | * @return int8_t - result of operation, 0 on success, -1 on failure |
dev_alexander | 28:0ed92c590607 | 253 | */ |
dev_alexander | 23:f74a50977593 | 254 | int8_t setFrameRate(GridEye::FrameRate rate); |
dev_alexander | 23:f74a50977593 | 255 | |
dev_alexander | 23:f74a50977593 | 256 | }; |
dev_alexander | 23:f74a50977593 | 257 | |
dev_alexander | 23:f74a50977593 | 258 | |
dev_alexander | 23:f74a50977593 | 259 | void convRaw8x8Data2Int(char * data, int16_t * frame_temp); |
dev_alexander | 23:f74a50977593 | 260 | |
dev_alexander | 23:f74a50977593 | 261 | void convRaw8x8Data2Point25degC(char * data, int16_t * frame_temp); |
dev_alexander | 23:f74a50977593 | 262 | |
dev_alexander | 23:f74a50977593 | 263 | void convSingleRawTempData2Int(char * data, int16_t & pixel_temp); |
dev_alexander | 23:f74a50977593 | 264 | |
dev_alexander | 23:f74a50977593 | 265 | #endif /*GridEye_H*/ |