C4EV3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
ev3_output.h
Go to the documentation of this file.
1 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #ifndef ev3_output_h
34 #define ev3_output_h
35 
36 #include <stdio.h>
37 #include <fcntl.h>
38 #include <stdlib.h>
39 #include <unistd.h>
40 #include <string.h>
41 #include <signal.h>
42 #include <sys/mman.h>
43 #include <stdbool.h>
44 #include <limits.h>
45 
46 #include "ev3_wait.h"
47 #include "ev3_constants.h"
48 
49 
50 // Gets the tacho count used in sensor mode
51 bool OutputGetCount(uint8_t Output, int * Tacho);
52 
53 // Read steps from last reset
54 bool OutputGetTachoCount(uint8_t Output, int * Tacho);
55 
56 // Read actual speed
57 bool OutputGetActualSpeed(uint8_t Output, int8_t * Speed);
58 
59 void OffEx(uint8_t Outputs, uint8_t reset);
60 
61 void FloatEx(uint8_t Outputs, uint8_t reset);
62 
63 static inline void Off(uint8_t _outputs) {
64  OffEx(_outputs, RESET_NONE);
65 }
66 
67 static inline void Float(uint8_t _outputs) {
68  FloatEx(_outputs, RESET_NONE);
69 }
70 
71 void OnFwdEx(uint8_t Outputs, int8_t Power, uint8_t reset);
72 
73 static inline void OnRevEx(uint8_t Outputs, int8_t Power, uint8_t reset) {
74  OnFwdEx(Outputs, -Power, reset);
75 }
76 
77 void OnFwdRegEx(uint8_t Outputs, int8_t Speed, uint8_t RegMode, uint8_t reset);
78 
79 static inline void OnRevRegEx(uint8_t Outputs, int8_t Speed, uint8_t RegMode, uint8_t reset) {
80  OnFwdRegEx(Outputs, -Speed, RegMode, reset);
81 }
82 
83 static inline void OnFwdReg(uint8_t _outputs, int8_t _speed) {
84  OnFwdRegEx(_outputs, _speed, OUT_REGMODE_SPEED, RESET_NONE);
85 }
86 
87 static inline void OnRevReg(uint8_t _outputs, int8_t _speed) {
88  OnRevRegEx(_outputs, _speed, OUT_REGMODE_SPEED, RESET_NONE);
89 }
90 
91 void OnFwdSyncEx(uint8_t Outputs, int8_t Speed, short Turn, uint8_t reset);
92 
93 static inline void OnRevSyncEx(uint8_t Outputs, int8_t Speed, short Turn, uint8_t reset) {
94  OnFwdSyncEx(Outputs, -Speed, Turn, reset);
95 }
96 
97 static inline void OnFwdSync(uint8_t _outputs, int8_t _speed) {
98  OnFwdSyncEx(_outputs, _speed, 0, RESET_NONE);
99 }
100 
101 static inline void OnRevSync(uint8_t _outputs, int8_t _speed) {
102  OnRevSyncEx(_outputs, _speed, 0, RESET_NONE);
103 }
104 
105 void RotateMotorNoWaitEx(uint8_t Outputs, int8_t Speed, int Angle, short Turn, bool Sync, bool Stop);
106 
107 static inline void RotateMotorNoWait(uint8_t _outputs, int8_t _speed, int _angle) {
108  RotateMotorNoWaitEx(_outputs, _speed, _angle, 0, true, true);
109 }
110 
111 void RotateMotorEx(uint8_t Outputs, int8_t Speed, int Angle, short Turn, bool Sync, bool Stop);
112 
113 static inline void RotateMotor(uint8_t _outputs, int8_t _speed, int _angle) {
114  RotateMotorEx(_outputs, _speed, _angle, 0, true, true);
115 }
116 
117 void OnForSyncEx(uint8_t Outputs, int Time, int8_t Speed, short Turn, bool Stop);
118 
119 static inline void OnForSync(uint8_t _outputs, int _time, int _speed) {
120  OnForSyncEx(_outputs, _time, _speed, 0, true);
121 }
122 
123 void OnForEx(uint8_t Outputs, int Time, int8_t Power, uint8_t reset);
124 
125 static inline void OnFor(uint8_t _outputs, int _time) {
126  OnForEx(_outputs, _time, OUT_POWER_DEFAULT, RESET_NONE);
127 }
128 
129 void ResetTachoCount(uint8_t Outputs);
130 
131 void ResetBlockTachoCount(uint8_t Outputs);
132 
133 void ResetRotationCount(uint8_t Outputs);
134 
135 void ResetAllTachoCounts(uint8_t Outputs);
136 
137 void ResetCount(uint8_t Outputs, uint8_t reset);
138 
139 int MotorTachoCount(uint8_t Output);
140 
141 int MotorBlockTachoCount(uint8_t Output);
142 
143 int8_t MotorPower(uint8_t Output);
144 
145 int8_t MotorActualSpeed(uint8_t Output);
146 
147 int MotorRotationCount(uint8_t Output);
148 
149 #endif
150 
151 #ifdef __cplusplus
152 }
153 #endif
void ResetTachoCount(uint8_t Outputs)
int8_t MotorActualSpeed(uint8_t Output)
void OnFwdEx(uint8_t Outputs, int8_t Power, uint8_t reset)
void ResetBlockTachoCount(uint8_t Outputs)
void OnForSyncEx(uint8_t Outputs, int Time, int8_t Speed, short Turn, bool Stop)
void OnFwdRegEx(uint8_t Outputs, int8_t Speed, uint8_t RegMode, uint8_t reset)
Constants for various EV3 modules.
void ResetAllTachoCounts(uint8_t Outputs)
int8_t MotorPower(uint8_t Output)
#define OUT_REGMODE_SPEED
Definition: ev3_constants.h:142
void FloatEx(uint8_t Outputs, uint8_t reset)
int MotorTachoCount(uint8_t Output)
void OnFwdSyncEx(uint8_t Outputs, int8_t Speed, short Turn, uint8_t reset)
bool OutputGetActualSpeed(uint8_t Output, int8_t *Speed)
bool OutputGetCount(uint8_t Output, int *Tacho)
#define RESET_NONE
Definition: ev3_constants.h:152
int MotorBlockTachoCount(uint8_t Output)
int MotorRotationCount(uint8_t Output)
bool OutputGetTachoCount(uint8_t Output, int *Tacho)
void OffEx(uint8_t Outputs, uint8_t reset)
void ResetRotationCount(uint8_t Outputs)
void OnForEx(uint8_t Outputs, int Time, int8_t Power, uint8_t reset)
#define OUT_POWER_DEFAULT
Definition: ev3_constants.h:131
void RotateMotorEx(uint8_t Outputs, int8_t Speed, int Angle, short Turn, bool Sync, bool Stop)
void RotateMotorNoWaitEx(uint8_t Outputs, int8_t Speed, int Angle, short Turn, bool Sync, bool Stop)
void ResetCount(uint8_t Outputs, uint8_t reset)