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

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


if (type == 1) { if (type == 1) {
FlightSimInteger *item = FlightSimInteger::find(id); FlightSimInteger *item = FlightSimInteger::find(id);
if (!item) break; 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) { } else if (type == 2) {
FlightSimFloat *item = FlightSimFloat::find(id); FlightSimFloat *item = FlightSimFloat::find(id);
if (!item) break; 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; break;
case 0x03: // enable/disable case 0x03: // enable/disable

Loading…
Cancel
Save