EV3RT CXX API Reference [English]
An RTOS-based development platform for LEGO Mindstorms EV3.
ev3cxx_sensor.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <stdio.h>
10 
11 #include "ev3api.h"
12 
13 namespace ev3cxx {
14 
19 enum class SensorPort {
20  S1 = 0,
21  S2,
22  S3,
23  S4
24 };
25 
30 class Sensor
31 {
32 protected:
38  Sensor(SensorPort port, sensor_type_t type)
39  : m_port(static_cast<sensor_port_t>(port)), m_type(type)
40  {
41  ev3_sensor_config(m_port, m_type);
42  }
43 
48  virtual ~Sensor() {}
49 
55  sensor_port_t getPort() {
56  return m_port;
57  }
58 
64  sensor_type_t getType() {
65  return static_cast<sensor_type_t>(ev3_sensor_get_type(m_port));
66  }
67 
68  sensor_port_t m_port;
69  sensor_type_t m_type;
70 }; // class Sensor
71 
72 
73 } // namespace ev3cxx
74 
Definition: ev3cxx.h:35
Sensor port 2.
virtual ~Sensor()
Destructor of class Sensor.
Definition: ev3cxx_sensor.h:48
Sensor(SensorPort port, sensor_type_t type)
Constructor of class Sensor.
Definition: ev3cxx_sensor.h:38
Sensor port 4.
Class Sensor. API for working with sensor.
Definition: ev3cxx_sensor.h:30
sensor_type_t getType()
Get actual sensor type.
Definition: ev3cxx_sensor.h:64
SensorPort
Enum with index of sensor port.
Definition: ev3cxx_sensor.h:19
Sensor port 1.
Sensor port 3.
sensor_port_t getPort()
Get sensor port set in constructor.
Definition: ev3cxx_sensor.h:55