EV3RT CXX API Reference [English]
An RTOS-based development platform for LEGO Mindstorms EV3.
ev3cxx_color_sensor.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <stdio.h>
10 
11 #include "ev3api.h"
12 #include "ev3cxx_sensor.h"
13 
14 namespace ev3cxx {
15 
20 class ColorSensor : public Sensor
21 {
22 public:
23  struct ColorRaw_t { int r; int g; int b; };
24 
30  ColorSensor(SensorPort port) : Sensor(port, COLOR_SENSOR) {}
31 
37  int getReflected() {
38  return ev3_color_sensor_get_reflect(m_port);
39  }
40 
46  rgb_raw_t getReflectedRawRgb() {
47  rgb_raw_t color;
48  ev3_color_sensor_get_rgb_raw(m_port, &color);
49  return color;
50  }
51 
57  int getAmbient() {
58  return ev3_color_sensor_get_ambient(m_port);
59  }
60 
66  colorid_t getColor() {
67  return ev3_color_sensor_get_color(m_port);
68  }
69 }; // class ColorSensor
70 
71 } // namespace ev3cxx
Definition: ev3cxx.h:35
Class Sensor. API for working with sensor.
Definition: ev3cxx_sensor.h:30
colorid_t getColor()
Get color.
int getAmbient()
Get ambient light intensity. Red LEDs off.
rgb_raw_t getReflectedRawRgb()
Get raw reflected light intensity (red, green, blue). Red LED on.
EV3RT CPP API for sensor.
SensorPort
Enum with index of sensor port.
Definition: ev3cxx_sensor.h:19
ColorSensor(SensorPort port)
Constructor of class ColorSensor.
Class ColorSensor. API for working with color sensor.
int getReflected()
Get reflected light intensity. Red LED on.