mirror of
https://github.com/okalachev/flix.git
synced 2025-07-29 04:19:00 +00:00
Improve logic of passing channels data in simulated SBUS
Return the data the same way as on the real drone without touching channels global vairable
This commit is contained in:
parent
b6286a50b2
commit
3cc3014ca0
@ -14,12 +14,10 @@ public:
|
|||||||
SBUS(HardwareSerial& bus, const bool inv = true) {};
|
SBUS(HardwareSerial& bus, const bool inv = true) {};
|
||||||
SBUS(HardwareSerial& bus, const int8_t rxpin, const int8_t txpin, const bool inv = true) {};
|
SBUS(HardwareSerial& bus, const int8_t rxpin, const int8_t txpin, const bool inv = true) {};
|
||||||
void begin() {};
|
void begin() {};
|
||||||
bool read() { return joystickGet(); };
|
bool read() { return true; };
|
||||||
SBUSData data() {
|
SBUSData data() {
|
||||||
SBUSData data;
|
SBUSData data;
|
||||||
for (uint8_t i = 0; i < 16; i++) {
|
joystickGet(data.ch);
|
||||||
data.ch[i] = channels[i];
|
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@ void joystickInit() {
|
|||||||
memcpy(channelMax, channelMaxOverride, sizeof(channelMaxOverride));
|
memcpy(channelMax, channelMaxOverride, sizeof(channelMaxOverride));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool joystickGet() {
|
bool joystickGet(int16_t ch[16]) {
|
||||||
if (!joystickInitialized) {
|
if (!joystickInitialized) {
|
||||||
joystickInit();
|
joystickInit();
|
||||||
return false;
|
return false;
|
||||||
@ -49,8 +49,8 @@ bool joystickGet() {
|
|||||||
|
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
for (uint8_t i = 0; i < sizeof(channels) / sizeof(channels[0]); i++) {
|
||||||
channels[i] = SDL_JoystickGetAxis(joystick, i);
|
ch[i] = SDL_JoystickGetAxis(joystick, i);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user