Hexiwear library for communicating with the on-board KW40Z BLE device. KW40Z handles also the touch buttons.
Dependents: Hexi_BLE_Example_Modified Hexi_BLE_Example_ModifiedPOTATO
Fork of Hexi_KW40Z by
Diff: Hexi_KW40Z.cpp
- Revision:
- 8:2b9b24f3154d
- Parent:
- 6:23323e8aeda4
- Child:
- 9:8058541a8e2d
--- a/Hexi_KW40Z.cpp Sun Sep 25 04:28:52 2016 +0000 +++ b/Hexi_KW40Z.cpp Sun Sep 25 05:50:22 2016 +0000 @@ -398,50 +398,60 @@ SendPacket(&txPacket, true); } -void KW40Z::SendAccel(uint8_t x, uint8_t y, uint8_t z) +void KW40Z::SendAccel(int16_t x, int16_t y, int16_t z) { hostInterface_packet_t txPacket = {0}; txPacket.start1 = gHostInterface_startByte1; txPacket.start2 = gHostInterface_startByte2; txPacket.type = packetType_accel; - txPacket.length = 3; - txPacket.data[0] = x; - txPacket.data[1] = y; - txPacket.data[2] = z; - txPacket.data[3] = gHostInterface_trailerByte; + txPacket.length = 6; + + txPacket.data[0] = (uint8_t) ((x >> 8)&0xFF); + txPacket.data[1] = (uint8_t) x; + txPacket.data[2] = (uint8_t) ((y >> 8)&0xFF); + txPacket.data[3] = (uint8_t) y; + txPacket.data[4] = (uint8_t) ((z >> 8)&0xFF); + txPacket.data[5] = (uint8_t) z; + txPacket.data[6] = gHostInterface_trailerByte; SendPacket(&txPacket, true); } -void KW40Z::SendGyro(uint8_t x, uint8_t y, uint8_t z) +void KW40Z::SendGyro(int16_t x, int16_t y, int16_t z) { hostInterface_packet_t txPacket = {0}; txPacket.start1 = gHostInterface_startByte1; txPacket.start2 = gHostInterface_startByte2; txPacket.type = packetType_gyro; - txPacket.length = 3; - txPacket.data[0] = x; - txPacket.data[1] = y; - txPacket.data[2] = z; - txPacket.data[3] = gHostInterface_trailerByte; + txPacket.length = 6; + txPacket.data[0] = (uint8_t) ((x >> 8)&0xFF); + txPacket.data[1] = (uint8_t) x; + txPacket.data[2] = (uint8_t) ((y >> 8)&0xFF); + txPacket.data[3] = (uint8_t) y; + txPacket.data[4] = (uint8_t) ((z >> 8)&0xFF); + txPacket.data[5] = (uint8_t) z; + txPacket.data[6] = gHostInterface_trailerByte; SendPacket(&txPacket, true); } -void KW40Z::SendMag(uint8_t x, uint8_t y, uint8_t z) +void KW40Z::SendMag(int16_t x, int16_t y, int16_t z) { hostInterface_packet_t txPacket = {0}; txPacket.start1 = gHostInterface_startByte1; txPacket.start2 = gHostInterface_startByte2; txPacket.type = packetType_magnet; - txPacket.length = 3; - txPacket.data[0] = x; - txPacket.data[1] = y; - txPacket.data[2] = z; - txPacket.data[3] = gHostInterface_trailerByte; + txPacket.length = 6; + txPacket.data[0] = (uint8_t) ((x >> 8)&0xFF); + txPacket.data[1] = (uint8_t) x; + txPacket.data[2] = (uint8_t) ((y >> 8)&0xFF); + txPacket.data[3] = (uint8_t) y; + txPacket.data[4] = (uint8_t) ((z >> 8)&0xFF); + txPacket.data[5] = (uint8_t) z; + txPacket.data[6] = gHostInterface_trailerByte; SendPacket(&txPacket, true); }