EV3RT CXX API Reference [English]
An RTOS-based development platform for LEGO Mindstorms EV3.
ev3cxx_gyro_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 GyroSensor : public Sensor
21 {
22 public:
28  GyroSensor(SensorPort port) : Sensor(port, GYRO_SENSOR) {
29  resetHard();
30  }
31 
39  int angle() {
40  return ev3_gyro_sensor_get_angle(m_port);
41  }
42 
49  int rate() {
50  return ev3_gyro_sensor_get_rate(m_port);
51  }
52 
60  void reset() {
61  ev3_gyro_sensor_reset(m_port);
62  }
63 
69  void resetHard() {
70  angle();
71  reset();
72  rate();
73  reset();
74  angle();
75  }
76 
77 }; // class GyroSensor
78 
79 } // namespace ev3cxx
Definition: ev3cxx.h:35
Class Sensor. API for working with sensor.
Definition: ev3cxx_sensor.h:30
void reset()
Reset gyro.
EV3RT CPP API for sensor.
void resetHard()
Hard reset gyro. Solve the problem with drifting value after standard reset().
SensorPort
Enum with index of sensor port.
Definition: ev3cxx_sensor.h:19
int angle()
Get angle in degrees from gyro.
GyroSensor(SensorPort port)
Constructor of class GyroSensor.
int rate()
Get angular speed from gyro. Speed = degrees per seconde.
Class GyroSensor. API for working with gyro sensor.