|
|
|
|
|
|
|
|
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 |