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

Class ColorSensor. API for working with color sensor. More...

#include <ev3cxx_color_sensor.h>

Inheritance diagram for ColorSensor:
Sensor

Data Structures

struct  ColorRaw_t
 

Public Member Functions

 ColorSensor (SensorPort port)
 Constructor of class ColorSensor. More...
 
int getReflected ()
 Get reflected light intensity. Red LED on. More...
 
rgb_raw_t getReflectedRawRgb ()
 Get raw reflected light intensity (red, green, blue). Red LED on. More...
 
int getAmbient ()
 Get ambient light intensity. Red LEDs off. More...
 
colorid_t getColor ()
 Get color. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Sensor
 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 inherited from Sensor
sensor_port_t m_port
 
sensor_type_t m_type
 

Detailed Description

Class ColorSensor. API for working with color sensor.

Definition at line 20 of file ev3cxx_color_sensor.h.

Constructor & Destructor Documentation

◆ ColorSensor()

ColorSensor ( SensorPort  port)
inline

Constructor of class ColorSensor.

Parameters
portPort index (1-4).

Definition at line 30 of file ev3cxx_color_sensor.h.

30 : Sensor(port, COLOR_SENSOR) {}
Sensor(SensorPort port, sensor_type_t type)
Constructor of class Sensor.
Definition: ev3cxx_sensor.h:38

Member Function Documentation

◆ getAmbient()

int getAmbient ( )
inline

Get ambient light intensity. Red LEDs off.

Returns
Range: 0 - 100

Definition at line 57 of file ev3cxx_color_sensor.h.

57  {
58  return ev3_color_sensor_get_ambient(m_port);
59  }

◆ getColor()

colorid_t getColor ( )
inline

Get color.

Returns
Return colorid_t (COLOR_NONE, COLOR_BLACK, COLOR_BLUE).

Definition at line 66 of file ev3cxx_color_sensor.h.

66  {
67  return ev3_color_sensor_get_color(m_port);
68  }

◆ getReflected()

int getReflected ( )
inline

Get reflected light intensity. Red LED on.

Returns
Range: 0 - 100

Definition at line 37 of file ev3cxx_color_sensor.h.

37  {
38  return ev3_color_sensor_get_reflect(m_port);
39  }

◆ getReflectedRawRgb()

rgb_raw_t getReflectedRawRgb ( )
inline

Get raw reflected light intensity (red, green, blue). Red LED on.

Returns
Return rgb_raw_t (r, g, b)

Definition at line 46 of file ev3cxx_color_sensor.h.

46  {
47  rgb_raw_t color;
48  ev3_color_sensor_get_rgb_raw(m_port, &color);
49  return color;
50  }