3/26/16 12:25 am JJ
ShortRangeSensor.h@0:08b7f391566c, 2016-03-26 (annotated)
- Committer:
- j_j205
- Date:
- Sat Mar 26 05:26:10 2016 +0000
- Revision:
- 0:08b7f391566c
3/26/16 12:25 am JJ
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j_j205 | 0:08b7f391566c | 1 | #ifndef SHORTRANGESENSOR_H |
j_j205 | 0:08b7f391566c | 2 | #define SHORTRANGESENSOR_H |
j_j205 | 0:08b7f391566c | 3 | |
j_j205 | 0:08b7f391566c | 4 | #include "mbed.h" |
j_j205 | 0:08b7f391566c | 5 | |
j_j205 | 0:08b7f391566c | 6 | //constants for i2c communication |
j_j205 | 0:08b7f391566c | 7 | const int ADDR = 0x52; |
j_j205 | 0:08b7f391566c | 8 | const char SYSRANGE__START_SAMPLE[] = {0x00,0x18,0x01}; |
j_j205 | 0:08b7f391566c | 9 | const char RESULT__RANGE_VAL[] = {0x00,0x62}; |
j_j205 | 0:08b7f391566c | 10 | const char RESULT__RANGE_STATUS[] = {0x00,0x4D}; |
j_j205 | 0:08b7f391566c | 11 | const char SYSRANGE__RANGE_CHECK_ENABLES[] = {0x00,0x2D,0x10}; |
j_j205 | 0:08b7f391566c | 12 | const char SYSRANGE__PART_TO_PART_RANGE_OFFSET_INIT[] = {0x00,0x24,0x00}; //once correct offset is found, chage 0x00 to correct offset |
j_j205 | 0:08b7f391566c | 13 | const char SYSRANGE__PART_TO_PART_RANGE_OFFSET[] = {0x00,0x24}; |
j_j205 | 0:08b7f391566c | 14 | |
j_j205 | 0:08b7f391566c | 15 | class ShortRangeSensor |
j_j205 | 0:08b7f391566c | 16 | { |
j_j205 | 0:08b7f391566c | 17 | public: |
j_j205 | 0:08b7f391566c | 18 | ShortRangeSensor(PinName sda, PinName scl); |
j_j205 | 0:08b7f391566c | 19 | //returns range in mm |
j_j205 | 0:08b7f391566c | 20 | int getRange(); |
j_j205 | 0:08b7f391566c | 21 | //returns value of status register |
j_j205 | 0:08b7f391566c | 22 | int getStatus(); |
j_j205 | 0:08b7f391566c | 23 | //returns value of part to part range offset register |
j_j205 | 0:08b7f391566c | 24 | int getPPOffset(); |
j_j205 | 0:08b7f391566c | 25 | //sets value of part to part range offset register, -128 to 128 |
j_j205 | 0:08b7f391566c | 26 | void setPPOffset(int offset); |
j_j205 | 0:08b7f391566c | 27 | |
j_j205 | 0:08b7f391566c | 28 | private: |
j_j205 | 0:08b7f391566c | 29 | I2C i2c; |
j_j205 | 0:08b7f391566c | 30 | }; |
j_j205 | 0:08b7f391566c | 31 | |
j_j205 | 0:08b7f391566c | 32 | #endif |