EV3RT C API Reference [English]
An RTOS-based development platform for LEGO Mindstorms EV3.
 All Data Structures Functions Variables Enumerations Enumerator Groups
ev3api_motor.h
1 
19 #pragma once
20 
28 typedef enum {
29  EV3_PORT_A = 0,
30  EV3_PORT_B = 1,
31  EV3_PORT_C = 2,
32  EV3_PORT_D = 3,
34 } motor_port_t;
35 
43 typedef enum {
44  NONE_MOTOR = 0,
49 } motor_type_t;
50 
71 
85 ER_UINT ev3_motor_get_type(motor_port_t port);
86 
101 int32_t ev3_motor_get_counts(motor_port_t port);
102 
121 
139 ER ev3_motor_set_power(motor_port_t port, int power);
140 
155 
173 ER ev3_motor_stop(motor_port_t port, bool_t brake);
174 
196 ER ev3_motor_rotate(motor_port_t port, int degrees, uint32_t speed_abs, bool_t blocking);
197 
224 ER ev3_motor_steer(motor_port_t left_motor, motor_port_t right_motor, int power, int turn_ratio);
225 
230 #if 0 // Legacy code or unfinished work
231 
244 ER ev3_motor_reset(ID port);
245 
258 ER ev3_motor_set_speed(ID port, int speed);
259 
271 ER ev3_motor_set_power(ID port, int power);
272 
289 ER ev3_motors_init(motor_type_t typeA, motor_type_t typeB, motor_type_t typeC, motor_type_t typeD);
290 
291 /*
292  * TODO: documented this
293  * -100 <= speed <= 100, -100(left) <= turn_ration <= 100(right)
294  * Motor with smaller port number will be treated as left motor.
295  */
296 //extern void ev3_motor_sync(MotorPort portA, MotorPort portB, int speed, int turn_ratio);
297 
298 //extern ER ev3_motor_steer_for_degrees(ID left_motor, ID right_motor, int power, int turn_ratio, int degrees);
299 
315 ER ev3_motor_set_counts(motor_port_t port, int32_t counts);
316 
317 #endif
int32_t ev3_motor_get_counts(motor_port_t port)
Get the angular position of a motor port.
Definition: ev3api_motor.c:203
Port C.
Definition: ev3api_motor.h:31
Large servo motor.
Definition: ev3api_motor.h:46
motor_port_t
ID for supported motor ports.
Definition: ev3api_motor.h:28
Not connected.
Definition: ev3api_motor.h:44
ER ev3_motor_set_power(motor_port_t port, int power)
Set the unregulated power for a motor port.
Definition: ev3api_motor.c:264
Medium servo motor.
Definition: ev3api_motor.h:45
Number of motor types.
Definition: ev3api_motor.h:48
Port D.
Definition: ev3api_motor.h:32
motor_type_t
Enumeration type for supported motor types.
Definition: ev3api_motor.h:43
ER ev3_motor_stop(motor_port_t port, bool_t brake)
Stop a motor port.
Definition: ev3api_motor.c:310
ER ev3_motor_config(motor_port_t port, motor_type_t type)
Configure a motor port.
Definition: ev3api_motor.c:157
ER ev3_motor_reset_counts(motor_port_t port)
Reset the angular position of the motor to zero.
Definition: ev3api_motor.c:238
Unregulated motor.
Definition: ev3api_motor.h:47
Number of motor ports.
Definition: ev3api_motor.h:33
ER ev3_motor_rotate(motor_port_t port, int degrees, uint32_t speed_abs, bool_t blocking)
Rotate a motor port for specified degrees.
Definition: ev3api_motor.c:330
Port B.
Definition: ev3api_motor.h:30
Port A.
Definition: ev3api_motor.h:29
ER ev3_motor_steer(motor_port_t left_motor, motor_port_t right_motor, int power, int turn_ratio)
Move the robot along a curved path using two motors.
Definition: ev3api_motor.c:356
int ev3_motor_get_power(motor_port_t port)
Get the actual power of a motor port.
Definition: ev3api_motor.c:221
ER_UINT ev3_motor_get_type(motor_port_t port)
Get the type of a motor port.
Definition: ev3api_motor.c:190