EV3RT CXX API Reference [English]
An RTOS-based development platform for LEGO Mindstorms EV3.
Sensor Class Reference

Class Sensor. API for working with sensor. More...

#include <ev3cxx_sensor.h>

Inheritance diagram for Sensor:
ColorSensor GyroSensor TouchSensor UltrasonicSensor

Protected Member Functions

 Sensor (SensorPort port, sensor_type_t type)
 Constructor of class Sensor. More...
 
virtual ~Sensor ()
 Destructor of class Sensor.
 
sensor_port_t getPort ()
 Get sensor port set in constructor. More...
 
sensor_type_t getType ()
 Get actual sensor type. More...
 

Protected Attributes

sensor_port_t m_port
 
sensor_type_t m_type
 

Detailed Description

Class Sensor. API for working with sensor.

Definition at line 30 of file ev3cxx_sensor.h.

Constructor & Destructor Documentation

◆ Sensor()

Sensor ( SensorPort  port,
sensor_type_t  type 
)
inlineprotected

Constructor of class Sensor.

Parameters
portPort index (1-4).

Definition at line 38 of file ev3cxx_sensor.h.

39  : m_port(static_cast<sensor_port_t>(port)), m_type(type)
40  {
41  ev3_sensor_config(m_port, m_type);
42  }

Member Function Documentation

◆ getPort()

sensor_port_t getPort ( )
inlineprotected

Get sensor port set in constructor.

Returns
Index of set port: 1 - 4

Definition at line 55 of file ev3cxx_sensor.h.

55  {
56  return m_port;
57  }

◆ getType()

sensor_type_t getType ( )
inlineprotected

Get actual sensor type.

Returns
Index of set type (sensor_type_t)

Definition at line 64 of file ev3cxx_sensor.h.

64  {
65  return static_cast<sensor_type_t>(ev3_sensor_get_type(m_port));
66  }