|
RSeries astromech firmware
|
|
Go to the documentation of this file. 1 #ifndef ProgrammableController_h
2 #define ProgrammableController_h
51 fSpeed = max(min(speed, 1.0), 0.0);
104 #define CHECK_BUTTON_DOWN(b) evt.button_down.b = (!prev.button.b && state.button.b)
110 #define CHECK_BUTTON_UP(b) evt.button_up.b = (prev.button.b && !state.button.b)
116 #define CHECK_BUTTON_LONGPRESS(b) \
118 evt.long_button_up.b = false; \
119 if (evt.button_down.b) \
121 longpress.b.pressTime = millis(); \
122 longpress.b.longPress = false; \
124 else if (evt.button_up.b) \
126 longpress.b.pressTime = 0; \
127 if (longpress.b.longPress) \
128 evt.button_up.b = false; \
129 longpress.b.longPress = false; \
131 else if (longpress.b.pressTime != 0 && state.button.b) \
133 if (longpress.b.pressTime + SERIAL_CONSOLE_LONG_PRESS_TIME < millis()) \
135 longpress.b.pressTime = 0; \
136 longpress.b.longPress = true; \
137 evt.long_button_up.b = true; \
176 return 512 + 512 * speed;
182 if (fSerial->available())
184 int ch = fSerial->read();
188 switch (readCharBlocking())
191 switch (readCharBlocking())
208 switch (readCharBlocking())
235 switch (Serial.read())
244 switch (readCharBlocking())
253 switch (readCharBlocking())
277 if (
x != 512 ||
y != 512)
Definition: JoystickController.h:120
bool disconnect()
Definition: ProgrammableController.h:72
#define CHECK_BUTTON_DOWN(b)
State state
Definition: JoystickController.h:136
void update()
Definition: ProgrammableController.h:78
int8_t lx
Definition: JoystickController.h:9
bool longPress
Definition: ProgrammableController.h:33
Definition: ProgrammableController.h:7
void setSpeed(float speed)
Definition: ProgrammableController.h:49
struct ProgrammableController::@38 longpress
uint16_t w2
Definition: ProgrammableController.h:29
virtual void notify()
Definition: JoystickController.h:152
Definition: JoystickController.h:128
Analog analog
Definition: JoystickController.h:130
@ kPageDown
Definition: ProgrammableController.h:13
@ kEnd
Definition: ProgrammableController.h:14
int read()
Definition: ProgrammableController.h:179
LongPress square
Definition: ProgrammableController.h:40
LongPress l3
Definition: ProgrammableController.h:36
Button button
Definition: JoystickController.h:131
int8_t rx
Definition: JoystickController.h:11
@ kHome
Definition: ProgrammableController.h:11
static uint16_t updateDirection(float speed)
Definition: ProgrammableController.h:174
uint16_t x
Definition: ProgrammableController.h:27
AnalogStick stick
Definition: JoystickController.h:35
uint32_t fLastTime
Definition: ProgrammableController.h:171
#define CHECK_BUTTON_LONGPRESS(b)
int8_t ly
Definition: JoystickController.h:10
void updateState(float upDown, float leftRight)
Definition: ProgrammableController.h:165
bool button[5]
Definition: ProgrammableController.h:30
void decreaseSpeed()
Definition: ProgrammableController.h:59
void increaseSpeed()
Definition: ProgrammableController.h:54
ProgrammableController()
Definition: ProgrammableController.h:17
#define CHECK_BUTTON_UP(b)
AnalogButton button
Definition: JoystickController.h:36
@ kPageUp
Definition: ProgrammableController.h:12
Event event
Definition: JoystickController.h:137
float getSpeed()
Definition: ProgrammableController.h:44
virtual void onConnect()
Definition: JoystickController.h:153
int8_t ry
Definition: JoystickController.h:12
bool connect()
Definition: ProgrammableController.h:64
uint16_t y
Definition: ProgrammableController.h:26
bool fConnected
Definition: JoystickController.h:161
uint32_t lastPacket
Definition: ProgrammableController.h:42
Definition: JoystickController.h:4
LongPress cross
Definition: ProgrammableController.h:39
uint32_t pressTime
Definition: ProgrammableController.h:32
LongPress circle
Definition: ProgrammableController.h:38
Analog analog_changed
Definition: JoystickController.h:125
bool fConnecting
Definition: JoystickController.h:162
Definition: ProgrammableController.h:31
float fSpeed
Definition: ProgrammableController.h:172
LongPress triangle
Definition: ProgrammableController.h:37
uint16_t w1
Definition: ProgrammableController.h:28