12 #define CAN_ID_REF_CAN0_IN 0x0160
13 #define CAN_ID_REF_CAN0_OUT 0x0161
14 #define CAN_ID_REF_CAN1_IN 0x0162
15 #define CAN_ID_REF_CAN1_OUT 0x0163
16 #define CAN_ID_REF_CAN2_IN 0x0164
17 #define CAN_ID_REF_CAN2_OUT 0x0165
18 #define CAN_ID_REF_CAN3_IN 0x0166
19 #define CAN_ID_REF_CAN3_OUT 0x0167
20 #define CAN_ID_REF_CAN4_IN 0x0168
21 #define CAN_ID_REF_CAN4_OUT 0x0169
22 #define CAN_ID_REF_CAN5_IN 0x016A
23 #define CAN_ID_REF_CAN5_OUT 0x016B
24 #define CAN_ID_REF_CAN6_IN 0x016C
25 #define CAN_ID_REF_CAN6_OUT 0x016D
26 #define CAN_ID_REF_CAN7_IN 0x016E
27 #define CAN_ID_REF_CAN7_OUT 0x016F
29 #define MRM_REF_CAN_SENSOR_COUNT 9
32 #define COMMAND_REF_CAN_MEASURE_ONCE_CENTER 0x04
33 #define COMMAND_REF_CAN_MEASURE_CONTINUOUS_CENTER 0x05
34 #define COMMAND_REF_CAN_SENDING_SENSORS_1_TO_3 0x06
35 #define COMMAND_REF_CAN_SENDING_SENSORS_4_TO_6 0x07
36 #define COMMAND_REF_CAN_SENDING_SENSORS_7_TO_9 0x08
37 #define COMMAND_REF_CAN_CALIBRATE 0x09
38 #define COMMAND_REF_CAN_CALIBRATION_DATA_DARK_1_TO_3 0x0A
39 #define COMMAND_REF_CAN_CALIBRATION_DATA_DARK_4_TO_6 0x0B
40 #define COMMAND_REF_CAN_CALIBRATION_DATA_DARK_7_TO_9 0x0C
41 #define COMMAND_REF_CAN_CALIBRATION_DATA_BRIGHT_1_TO_3 0x0F
42 #define COMMAND_REF_CAN_CALIBRATION_DATA_BRIGHT_4_TO_6 0x50
43 #define COMMAND_REF_CAN_CALIBRATION_DATA_BRIGHT_7_TO_9 0x51
44 #define COMMAND_REF_CAN_CALIBRATION_DATA_REQUEST 0x0D
45 #define COMMAND_REF_CAN_SENDING_SENSORS_CENTER 0x0E
46 #define COMMAND_REPORT_ALIVE_QUEUELESS 0x0F
48 #define MRM_REF_CAN_INACTIVITY_ALLOWED_MS 10000
52 enum mode { ANALOG_VALUES, DIGITAL_AND_BRIGHT_CENTER, DIGITAL_AND_DARK_CENTER };
54 std::vector<uint16_t[MRM_REF_CAN_SENSOR_COUNT]>* calibrationDataDark;
55 std::vector<uint16_t[MRM_REF_CAN_SENSOR_COUNT]>* calibrationDataBright;
56 std::vector<uint8_t>* dataFresh;
63 std::vector<uint8_t>* _mode;
64 bool readingDigitalAndCenter =
true;
65 std::vector<uint16_t[MRM_REF_CAN_SENSOR_COUNT]>* _reading;
66 std::vector<uint16_t>* centerOfMeasurements;
72 bool analogStarted(uint8_t deviceNumber);
78 bool dataCalibrationFreshAsk(uint8_t deviceNumber) {
return ((*dataFresh)[deviceNumber] & 0b00011100) == 0b00011100; }
84 bool dataFreshAsk(uint8_t deviceNumber) {
return (*dataFresh)[deviceNumber] == 0xFF; }
90 void dataFreshCalibrationSet(
bool setToFresh, uint8_t deviceNumber = 0);
96 void dataFreshReadingsSet(
bool setToFresh, uint8_t deviceNumber = 0);
104 bool digitalStarted(uint8_t deviceNumber,
bool darkCenter,
bool startIfNot =
true);
121 void add(
char * deviceName = (
char*)
"");
129 bool any(
bool dark =
true, uint8_t deviceNumber = 0, uint8_t fistTransistor = 0, uint8_t lastTransistor = 0xFF);
134 void calibrate(uint8_t deviceNumber = 0xFF);
142 uint16_t
calibrationDataGet(uint8_t receiverNumberInSensor,
bool isDark, uint8_t deviceNumber = 0);
159 uint16_t
center(uint8_t deviceNumber = 0,
bool ofDark =
true);
167 bool dark(uint8_t receiverNumberInSensor, uint8_t deviceNumber = 0,
bool fromAnalog =
false);
180 uint16_t
reading(uint8_t receiverNumberInSensor, uint8_t deviceNumber = 0);
189 void test(
bool analog);
Definition: mrm-ref-can.h:51
void calibrationPrint()
Definition: mrm-ref-can.cpp:197
bool dark(uint8_t receiverNumberInSensor, uint8_t deviceNumber=0, bool fromAnalog=false)
Definition: mrm-ref-can.cpp:229
Mrm_ref_can(Robot *robot=NULL, uint8_t maxNumberOfBoards=4)
Definition: mrm-ref-can.cpp:10
void readingsPrint()
Definition: mrm-ref-can.cpp:429
uint16_t center(uint8_t deviceNumber=0, bool ofDark=true)
Definition: mrm-ref-can.cpp:216
uint16_t reading(uint8_t receiverNumberInSensor, uint8_t deviceNumber=0)
Definition: mrm-ref-can.cpp:415
void test(bool analog)
Definition: mrm-ref-can.cpp:441
void calibrate(uint8_t deviceNumber=0xFF)
Definition: mrm-ref-can.cpp:125
bool messageDecode(uint32_t canId, uint8_t data[8])
Definition: mrm-ref-can.cpp:316
void calibrationDataRequest(uint8_t deviceNumber=0, bool waitForResult=false)
Definition: mrm-ref-can.cpp:173
void add(char *deviceName=(char *)"")
Definition: mrm-ref-can.cpp:27
uint16_t calibrationDataGet(uint8_t receiverNumberInSensor, bool isDark, uint8_t deviceNumber=0)
Definition: mrm-ref-can.cpp:160
bool any(bool dark=true, uint8_t deviceNumber=0, uint8_t fistTransistor=0, uint8_t lastTransistor=0xFF)
Definition: mrm-ref-can.cpp:105
Definition: mrm-robot.h:42
Definition: mrm-board.h:356