Browse Source

Fix USB flightsim on Teensy-LC

main
PaulStoffregen 9 years ago
parent
commit
8545ba7ffb
1 changed files with 23 additions and 2 deletions
  1. +23
    -2
      teensy3/usb_flightsim.cpp

+ 23
- 2
teensy3/usb_flightsim.cpp View File

@@ -228,6 +228,11 @@ FlightSimClass::FlightSimClass()
void FlightSimClass::update(void)
{
uint8_t len, maxlen, type, *p, *end;
union {
uint8_t b[4];
long l;
float f;
} data;
usb_packet_t *rx_packet;
uint16_t id;

@@ -249,11 +254,27 @@ void FlightSimClass::update(void)
if (type == 1) {
FlightSimInteger *item = FlightSimInteger::find(id);
if (!item) break;
item->update(*(long *)(p + 6));
#ifdef KINETISK
data.l = *(long *)(p + 6);
#else
data.b[0] = p[6];
data.b[1] = p[7];
data.b[2] = p[8];
data.b[3] = p[9];
#endif
item->update(data.l);
} else if (type == 2) {
FlightSimFloat *item = FlightSimFloat::find(id);
if (!item) break;
item->update(*(float *)(p + 6));
#ifdef KINETISK
data.f = *(float *)(p + 6);
#else
data.b[0] = p[6];
data.b[1] = p[7];
data.b[2] = p[8];
data.b[3] = p[9];
#endif
item->update(data.f);
}
break;
case 0x03: // enable/disable

Loading…
Cancel
Save