14 #ifdef EV3_SENSOR_IMPLEMENT 15 #define EV3_SENSOR_VAR( decl ) \ 17 #define EV3_SENSOR_VAR_INIT( decl, ... ) \ 20 #define EV3_SENSOR_INL 23 #define EV3_SENSOR_VAR( decl ) \ 25 #define EV3_SENSOR_VAR_INIT( decl, ... ) \ 28 #if __GNUC__ && !__GNUC_STDC_INLINE__ 29 #define EV3_SENSOR_INL \ 32 #define EV3_SENSOR_INL \ 54 #define SENSOR_DIR "/sys/class/lego-sensor" 67 #define SENSOR_DESC__LIMIT_ DESC_LIMIT 69 #define SENSOR__NONE_ SENSOR_DESC__LIMIT_ 74 EV3_SENSOR_VAR( EV3_SENSOR ev3_sensor[ SENSOR_DESC__LIMIT_ ] ); 80 SENSOR_TYPE__NONE_ = 0,
145 SENSOR_MODE__NONE_ = 0,
147 EV3_ANALOG_XX_ANALOG,
165 FCL_ALTITUDE_PRESSURE,
166 FCL_ALTITUDE_ALTITUDE,
168 FCL_GESTURE_PROXIMITY,
171 FCL_HUMIDITY_CENTIGRADE,
172 FCL_HUMIDITY_FAHRENHEIT,
173 FCL_HUMIDITY_HUMIDITY,
175 FCL_LIGHT_ILLUMINANCE,
184 HT_NXT_ANGLE_ANGLE_ACC,
188 HT_NXT_BAROMETRIC_PRESS,
189 HT_NXT_BAROMETRIC_TEMP,
190 HT_NXT_COLOR_V2_COLOR,
192 HT_NXT_COLOR_V2_GREEN,
193 HT_NXT_COLOR_V2_BLUE,
194 HT_NXT_COLOR_V2_WHITE,
195 HT_NXT_COLOR_V2_NORM,
197 HT_NXT_COLOR_V2_PASSIVE,
203 HT_NXT_IR_LINK_IRLINK,
204 HT_NXT_IR_RECEIVER_1_MOTOR,
205 HT_NXT_IR_RECEIVER_8_MOTOR,
207 HT_NXT_COMPASS_COMPASS,
209 HT_NXT_IR_SEEK_V2_DC,
210 HT_NXT_IR_SEEK_V2_AC,
211 HT_NXT_IR_SEEK_V2_DC_ALL,
212 HT_NXT_IR_SEEK_V2_AC_ALL,
222 LEGO_EV3_US_US_DIST_CM, US_US_DIST_CM = LEGO_EV3_US_US_DIST_CM,
223 LEGO_EV3_US_US_DIST_IN, US_US_DIST_IN = LEGO_EV3_US_US_DIST_IN,
224 LEGO_EV3_US_US_LISTEN, US_US_LISTEN = LEGO_EV3_US_US_LISTEN,
225 LEGO_EV3_US_US_SI_CM, US_US_SI_CM = LEGO_EV3_US_US_SI_CM,
226 LEGO_EV3_US_US_SI_IN, US_US_SI_IN = LEGO_EV3_US_US_SI_IN,
227 LEGO_EV3_US_US_DC_CM, US_US_DC_CM = LEGO_EV3_US_US_DC_CM,
228 LEGO_EV3_US_US_DC_IN, US_US_DC_IN = LEGO_EV3_US_US_DC_IN,
229 LEGO_EV3_GYRO_GYRO_ANG, GYRO_GYRO_ANG = LEGO_EV3_GYRO_GYRO_ANG,
230 LEGO_EV3_GYRO_GYRO_RATE, GYRO_GYRO_RATE = LEGO_EV3_GYRO_GYRO_RATE,
231 LEGO_EV3_GYRO_GYRO_FAS, GYRO_GYRO_FAS = LEGO_EV3_GYRO_GYRO_FAS,
232 LEGO_EV3_GYRO_GYRO_G_AND_A, GYRO_GYRO_G_AND_A = LEGO_EV3_GYRO_GYRO_G_AND_A,
233 LEGO_EV3_GYRO_GYRO_CAL, GYRO_GYRO_CAL = LEGO_EV3_GYRO_GYRO_CAL,
234 LEGO_EV3_COLOR_COL_REFLECT, COLOR_COL_REFLECT = LEGO_EV3_COLOR_COL_REFLECT,
235 LEGO_EV3_COLOR_COL_AMBIENT, COLOR_COL_AMBIENT = LEGO_EV3_COLOR_COL_AMBIENT,
236 LEGO_EV3_COLOR_COL_COLOR, COLOR_COL_COLOR = LEGO_EV3_COLOR_COL_COLOR,
237 LEGO_EV3_COLOR_REF_RAW, COLOR_REF_RAW = LEGO_EV3_COLOR_REF_RAW,
238 LEGO_EV3_COLOR_RGB_RAW, COLOR_RGB_RAW = LEGO_EV3_COLOR_RGB_RAW,
239 LEGO_EV3_COLOR_COL_CAL, COLOR_COL_CAL = LEGO_EV3_COLOR_COL_CAL,
240 LEGO_EV3_TOUCH_TOUCH, TOUCH_TOUCH = LEGO_EV3_TOUCH_TOUCH,
241 LEGO_EV3_IR_IR_PROX, IR_IR_PROX = LEGO_EV3_IR_IR_PROX,
242 LEGO_EV3_IR_IR_SEEK, IR_IR_SEEK = LEGO_EV3_IR_IR_SEEK,
243 LEGO_EV3_IR_IR_REMOTE, IR_IR_REMOTE = LEGO_EV3_IR_IR_REMOTE,
244 LEGO_EV3_IR_IR_REM_A, IR_IR_REM_A = LEGO_EV3_IR_IR_REM_A,
245 LEGO_EV3_IR_IR_S_ALT, IR_IR_S_ALT = LEGO_EV3_IR_IR_S_ALT,
246 LEGO_EV3_IR_IR_CAL, IR_IR_CAL = LEGO_EV3_IR_IR_CAL,
253 LEGO_POWER_STORAGE_IN_VOLT,
254 LEGO_POWER_STORAGE_IN_AMP,
255 LEGO_POWER_STORAGE_OUT_VOLT,
256 LEGO_POWER_STORAGE_OUT_AMP,
257 LEGO_POWER_STORAGE_JOULE,
258 LEGO_POWER_STORAGE_IN_WATT,
259 LEGO_POWER_STORAGE_OUT_WATT,
260 LEGO_POWER_STORAGE_ALL,
261 LEGO_NXT_TEMP_NXT_TEMP_C,
262 LEGO_NXT_TEMP_NXT_TEMP_F,
263 LEGO_NXT_TOUCH_TOUCH,
264 LEGO_NXT_LIGHT_REFLECT,
265 LEGO_NXT_LIGHT_AMBIENT,
268 LEGO_NXT_US_US_DIST_CM,
269 LEGO_NXT_US_US_DIST_IN,
270 LEGO_NXT_US_US_SI_CM,
271 LEGO_NXT_US_US_SI_IN,
272 LEGO_NXT_US_US_LISTEN,
277 MS_ABSOLUTE_IMU_TILT,
278 MS_ABSOLUTE_IMU_ACCEL,
279 MS_ABSOLUTE_IMU_COMPASS,
281 MS_ABSOLUTE_IMU_GYRO,
291 MS_LINE_LEADER_PID_ALL,
297 MS_NXTMMX_STATUS_OLD,
302 MS_PPS58_NX_ABS_MBAR,
305 MS_PPS58_NX_REL_MBAR,
307 MS_PIXY_ADAPTER_TRACK,
308 MS_NXT_TOUCH_MUX_TOUCH_MUX,
317 SENSOR_COMMAND__NONE_ = 0,
331 MS_ABSOLUTE_IMU_BEGIN_COMP_CAL,
332 MS_ABSOLUTE_IMU_END_COMP_CAL,
333 MS_ABSOLUTE_IMU_ACCEL_2G,
334 MS_ABSOLUTE_IMU_ACCEL_4G,
335 MS_ABSOLUTE_IMU_ACCEL_8G,
336 MS_ABSOLUTE_IMU_ACCEL_16G,
338 MS_LIGHT_ARRAY_CAL_WHITE,
339 MS_LIGHT_ARRAY_CAL_BLACK,
340 MS_LIGHT_ARRAY_SLEEP,
344 MS_LIGHT_ARRAY_UNIVERSAL,
345 MS_LINE_LEADER_CAL_WHITE,
346 MS_LINE_LEADER_CAL_BLACK,
347 MS_LINE_LEADER_SLEEP,
349 MS_LINE_LEADER_INV_COL,
350 MS_LINE_LEADER_RST_COL,
354 MS_LINE_LEADER_UNIVERSAL,
358 MS_NXTCAM_TRACK_LINE,
361 MS_NXTCAM5_TRACK_OBJ,
362 MS_NXTCAM5_TRACK_FACE,
363 MS_NXTCAM5_MULTI_MOVIE,
366 MS_NXTCAM5_TRACK_EYE,
368 MS_NXTCAM5_TRACK_LINE,
370 MS_PIXY_ADAPTER_SORT_SIZE,
371 MS_PIXY_ADAPTER_SORT_COL,
831 IR_REMOTE__NONE_ = 0,
838 RED_UP_BLUE_DOWN = 6,
839 RED_DOWN_BLUE_UP = 7,
840 RED_DOWN_BLUE_DOWN = 8,
842 RED_UP_RED_DOWN = 10,
843 BLUE_UP_BLUE_DOWN = 11,
852 #undef EV3_SENSOR_VAR 853 #undef EV3_SENSOR_VAR_INIT 854 #undef EV3_SENSOR_INL size_t multi_set_sensor_command_inx(uint8_t *sn, INX_T command_inx)
Write "command" attribute of several sensors by the index.
Definition: ev3_sensor.c:1556
Definition: ev3_sensor.h:309
size_t get_sensor_value0(uint8_t sn, float *buf)
Read "value0" attribute of the sensor.
Definition: ev3_sensor.c:230
const char * ev3_sensor_type(INX_T type_inx)
Get name of the specified sensor type.
Definition: ev3_sensor.c:314
Definition: ev3_sensor.h:137
uint8_t ev3_sensor_desc_addr(uint8_t sn)
Get I2C address from the sensor descriptor.
Definition: ev3_sensor.c:588
size_t get_sensor_value3(uint8_t sn, float *buf)
Read "value3" attribute of the sensor.
Definition: ev3_sensor.c:254
size_t get_sensor_value4(uint8_t sn, float *buf)
Read "value4" attribute of the sensor.
Definition: ev3_sensor.c:262
size_t multi_set_sensor_poll_ms(uint8_t *sn, dword value)
Write "poll_ms" attribute of several sensors.
Definition: ev3_sensor.c:215
size_t get_sensor_mode(uint8_t sn, char *buf, size_t sz)
Read "mode" attribute of the sensor.
Definition: ev3_sensor.c:160
size_t get_sensor_value1(uint8_t sn, float *buf)
Read "value1" attribute of the sensor.
Definition: ev3_sensor.c:238
size_t set_sensor_mode(uint8_t sn, char *value)
Write "mode" attribute of the sensor.
Definition: ev3_sensor.c:168
size_t get_sensor_driver_name(uint8_t sn, char *buf, size_t sz)
Read "driver_name" attribute of the sensor.
Definition: ev3_sensor.c:144
uint8_t addr
Definition: ev3_sensor.h:63
size_t get_sensor_decimals(uint8_t sn, dword *buf)
Read "decimals" attribute of the sensor.
Definition: ev3_sensor.c:136
size_t get_sensor_value7(uint8_t sn, float *buf)
Read "value7" attribute of the sensor.
Definition: ev3_sensor.c:286
size_t get_sensor_units(uint8_t sn, char *buf, size_t sz)
Read "units" attribute of the sensor.
Definition: ev3_sensor.c:222
size_t set_sensor_bin_data(uint8_t sn, byte *value, size_t sz)
Write "bin_data" attribute of the sensor.
Definition: ev3_sensor.c:67
const char * ev3_sensor_command(INX_T command_inx)
Get name of the specified sensor command.
Definition: ev3_sensor.c:1425
size_t get_sensor_bin_data(uint8_t sn, byte *buf, size_t sz)
Read "bin_data" attribute of the sensor.
Definition: ev3_sensor.c:59
uint8_t ev3_sensor_desc_port(uint8_t sn)
Get EV3 port from the sensor descriptor.
Definition: ev3_sensor.c:578
INX_T get_sensor_mode_inx(uint8_t sn)
Read "mode" attribute of the sensor and get the index.
Definition: ev3_sensor.c:1410
size_t get_sensor_direct(uint8_t sn, char *buf, size_t sz)
Read "direct" attribute of the sensor.
Definition: ev3_sensor.c:113
size_t get_sensor_num_values(uint8_t sn, dword *buf)
Read "num_values" attribute of the sensor.
Definition: ev3_sensor.c:191
uint8_t extport
Definition: ev3_sensor.h:62
size_t multi_set_sensor_bin_data(uint8_t *sn, byte *value, size_t sz)
Write "bin_data" attribute of several sensors.
Definition: ev3_sensor.c:75
INX_T type_inx
Definition: ev3_sensor.h:60
size_t get_sensor_value5(uint8_t sn, float *buf)
Read "value5" attribute of the sensor.
Definition: ev3_sensor.c:270
size_t set_sensor_mode_inx(uint8_t sn, INX_T mode_inx)
Write "mode" attribute of the sensor by the index.
Definition: ev3_sensor.c:1415
Structure of a sensor descriptor.
Definition: ev3_sensor.h:59
size_t get_sensor_desc(uint8_t sn, EV3_SENSOR *desc)
Read sensor attributes that are required for filling the descriptor.
Definition: ev3_sensor.c:551
EV3_SENSOR * ev3_sensor_desc(uint8_t sn)
Get descriptor of the sensor.
Definition: ev3_sensor.c:567
size_t set_sensor_command(uint8_t sn, char *value)
Write "command" attribute of the sensor.
Definition: ev3_sensor.c:90
Definition: ev3_sensor.h:372
size_t multi_set_sensor_direct(uint8_t *sn, char *value)
Write "direct" attribute of several sensors.
Definition: ev3_sensor.c:129
size_t multi_set_sensor_mode(uint8_t *sn, char *value)
Write "mode" attribute of several sensors.
Definition: ev3_sensor.c:176
size_t get_sensor_text_value(uint8_t sn, char *buf, size_t sz)
Read "text_value" attribute of the sensor.
Definition: ev3_sensor.c:294
size_t get_sensor_value(uint8_t inx, uint8_t sn, int *buf)
Read "value" attribute of the sensor.
Definition: ev3_sensor.c:302
uint8_t port
Definition: ev3_sensor.h:61
size_t set_sensor_command_inx(uint8_t sn, INX_T command_inx)
Write "command" attribute of the sensor by the index.
Definition: ev3_sensor.c:1551
size_t multi_set_sensor_mode_inx(uint8_t *sn, INX_T mode_inx)
Write "mode" attribute of several sensors by the index.
Definition: ev3_sensor.c:1420
int ev3_sensor_init(void)
Detect connected sensors.
Definition: ev3_sensor.c:1561
size_t get_sensor_commands(uint8_t sn, char *buf, size_t sz)
Read "commands" attribute of the sensor.
Definition: ev3_sensor.c:105
size_t set_sensor_poll_ms(uint8_t sn, dword value)
Write "poll_ms" attribute of the sensor.
Definition: ev3_sensor.c:207
char * ev3_sensor_port_name(uint8_t sn, char *buf)
Assemble EV3 port name from the sensor descriptor.
Definition: ev3_sensor.c:593
size_t get_sensor_modes(uint8_t sn, char *buf, size_t sz)
Read "modes" attribute of the sensor.
Definition: ev3_sensor.c:183
INX_T get_sensor_type_inx(uint8_t sn)
Read "driver_name" attribute and get index of the sensor type.
Definition: ev3_sensor.c:430
INX_T ev3_sensor_desc_type_inx(uint8_t sn)
Get type from the sensor descriptor.
Definition: ev3_sensor.c:573
size_t get_sensor_fw_version(uint8_t sn, char *buf, size_t sz)
Read "fw_version" attribute of the sensor.
Definition: ev3_sensor.c:152
size_t get_sensor_value6(uint8_t sn, float *buf)
Read "value6" attribute of the sensor.
Definition: ev3_sensor.c:278
uint8_t ev3_sensor_desc_extport(uint8_t sn)
Get extended port from the sensor descriptor.
Definition: ev3_sensor.c:583
bool ev3_search_sensor(INX_T type_inx, uint8_t *sn, uint8_t from)
Search of a sequence number of the specified sensor type.
Definition: ev3_sensor.c:598
size_t multi_set_sensor_command(uint8_t *sn, char *value)
Write "command" attribute of several sensors.
Definition: ev3_sensor.c:98
bool ev3_search_sensor_plugged_in(uint8_t port, uint8_t extport, uint8_t *sn, uint8_t from)
Search of a sequence number the sensor by plug-in attributes.
Definition: ev3_sensor.c:613
size_t get_sensor_value2(uint8_t sn, float *buf)
Read "value2" attribute of the sensor.
Definition: ev3_sensor.c:246
const char * ev3_sensor_mode(INX_T mode_inx)
Get name of the specified sensor mode.
Definition: ev3_sensor.c:635
size_t set_sensor_direct(uint8_t sn, char *value)
Write "direct" attribute of the sensor.
Definition: ev3_sensor.c:121
INX_T get_sensor_mode_inx_of_type(uint8_t sn, INX_T type_inx)
Read "mode" attribute of the specified sensor type and get the index.
Definition: ev3_sensor.c:1020
size_t get_sensor_address(uint8_t sn, char *buf, size_t sz)
Read "address" attribute of the sensor.
Definition: ev3_sensor.c:51
size_t get_sensor_bin_data_format(uint8_t sn, char *buf, size_t sz)
Read "bin_data_format" attribute of the sensor.
Definition: ev3_sensor.c:82
size_t get_sensor_poll_ms(uint8_t sn, dword *buf)
Read "poll_ms" attribute of the sensor.
Definition: ev3_sensor.c:199