|
RSeries astromech firmware
|
|
Go to the documentation of this file. 1 #ifndef SerialConsoleController_h
2 #define SerialConsoleController_h
7 #ifndef SERIAL_CONSOLE_LONG_PRESS_TIME
8 #define SERIAL_CONSOLE_LONG_PRESS_TIME 3000
56 fSpeed = max(min(speed, 1.0f), 0.0f);
95 #define CHECK_BUTTON_DOWN(b) evt.button_down.b = (!prev.button.b && state.button.b)
101 #define CHECK_BUTTON_UP(b) evt.button_up.b = (prev.button.b && !state.button.b)
107 #define CHECK_BUTTON_LONGPRESS(b) \
109 evt.long_button_up.b = false; \
110 if (evt.button_down.b) \
112 longpress.b.pressTime = millis(); \
113 longpress.b.longPress = false; \
115 else if (evt.button_up.b) \
117 longpress.b.pressTime = 0; \
118 if (longpress.b.longPress) \
119 evt.button_up.b = false; \
120 longpress.b.longPress = false; \
122 else if (longpress.b.pressTime != 0 && state.button.b) \
124 if (longpress.b.pressTime + SERIAL_CONSOLE_LONG_PRESS_TIME < millis()) \
126 longpress.b.pressTime = 0; \
127 longpress.b.longPress = true; \
128 evt.long_button_up.b = true; \
179 return 512 + 512 * speed;
287 if (
x != 512 ||
y != 512)
void connect()
Definition: SerialConsoleController.h:156
Definition: JoystickController.h:120
State state
Definition: JoystickController.h:136
LongPress cross
Definition: SerialConsoleController.h:44
void increaseSpeed()
Definition: SerialConsoleController.h:59
struct SerialConsoleController::@40 longpress
uint16_t w1
Definition: SerialConsoleController.h:33
int8_t lx
Definition: JoystickController.h:9
uint32_t lastPacket
Definition: SerialConsoleController.h:47
Stream * fSerial
Definition: SerialConsoleController.h:172
float fSpeed
Definition: SerialConsoleController.h:174
#define CHECK_BUTTON_UP(b)
virtual void notify()
Definition: JoystickController.h:152
Definition: JoystickController.h:128
uint32_t fLastTime
Definition: SerialConsoleController.h:173
char readCharBlocking()
Definition: SerialConsoleController.h:182
Analog analog
Definition: JoystickController.h:130
void setSpeed(float speed)
Definition: SerialConsoleController.h:54
LongPress circle
Definition: SerialConsoleController.h:43
SerialConsoleController(Stream &serial)
Definition: SerialConsoleController.h:21
LongPress square
Definition: SerialConsoleController.h:45
Button button
Definition: JoystickController.h:131
int8_t rx
Definition: JoystickController.h:11
Definition: SerialConsoleController.h:11
uint16_t x
Definition: SerialConsoleController.h:32
@ kPageDown
Definition: SerialConsoleController.h:17
bool longPress
Definition: SerialConsoleController.h:38
AnalogStick stick
Definition: JoystickController.h:35
int8_t ly
Definition: JoystickController.h:10
int read()
Definition: SerialConsoleController.h:189
#define CHECK_BUTTON_DOWN(b)
bool fEmulationActive
Definition: SerialConsoleController.h:175
bool button[5]
Definition: SerialConsoleController.h:35
void decreaseSpeed()
Definition: SerialConsoleController.h:64
AnalogButton button
Definition: JoystickController.h:36
@ kHome
Definition: SerialConsoleController.h:15
Event event
Definition: JoystickController.h:137
virtual void onConnect()
Definition: JoystickController.h:153
virtual void disconnect() override
Definition: SerialConsoleController.h:161
int8_t ry
Definition: JoystickController.h:12
bool isEmulationActive() const
Definition: SerialConsoleController.h:166
uint16_t y
Definition: SerialConsoleController.h:31
@ kPageUp
Definition: SerialConsoleController.h:16
LongPress l3
Definition: SerialConsoleController.h:41
Definition: SerialConsoleController.h:36
LongPress triangle
Definition: SerialConsoleController.h:42
bool fConnected
Definition: JoystickController.h:161
Definition: JoystickController.h:4
static uint16_t updateDirection(float speed)
Definition: SerialConsoleController.h:177
#define CHECK_BUTTON_LONGPRESS(b)
float getSpeed()
Definition: SerialConsoleController.h:49
Analog analog_changed
Definition: JoystickController.h:125
void update()
Definition: SerialConsoleController.h:69
uint16_t w2
Definition: SerialConsoleController.h:34
bool fConnecting
Definition: JoystickController.h:162
uint32_t pressTime
Definition: SerialConsoleController.h:37
@ kEnd
Definition: SerialConsoleController.h:18