Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Hexi_Buttons_Example Hexi_Click_Relay-v2_Example Hexi_Click_Relay-v3_Example Hexi_Catch-the-dot_Game ... more
Revision 7:f363aea73f45, committed 2016-09-25
- Comitter:
- khuang
- Date:
- Sun Sep 25 05:24:24 2016 +0000
- Parent:
- 4:8586f50385d2
- Commit message:
- Changed SendAccel, SendGyro,SendMag functions to accept int16_t for x,y,z instead of uint8_t. Payload length for these should be 6 bytes not 3.
Changed in this revision
| Hexi_KW40Z.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Hexi_KW40Z.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Hexi_KW40Z.cpp Tue Sep 20 22:52:28 2016 +0000
+++ b/Hexi_KW40Z.cpp Sun Sep 25 05:24:24 2016 +0000
@@ -33,6 +33,7 @@
* Project HEXIWEAR, 2015
*/
+
#include "Hexi_KW40Z.h"
#if defined (LIB_DEBUG)
@@ -150,6 +151,7 @@
}
#if defined (LIB_DEBUG)
+
void KW40Z::DebugPrintTxPacket(hostInterface_packet_t * txPacket)
{
char * txBuff = (char *)txPacket;
@@ -414,50 +416,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);
}
--- a/Hexi_KW40Z.h Tue Sep 20 22:52:28 2016 +0000
+++ b/Hexi_KW40Z.h Sun Sep 25 05:24:24 2016 +0000
@@ -194,9 +194,9 @@
void attach_notifications(notifications_t notFct);
void SendBatteryLevel(uint8_t percentage);
- void SendAccel(uint8_t x, uint8_t y, uint8_t z);
- void SendGyro(uint8_t x, uint8_t y, uint8_t z);
- void SendMag(uint8_t x, uint8_t y, uint8_t z);
+ void SendAccel(int16_t x, int16_t y, int16_t z);
+ void SendGyro(int16_t x, int16_t y, int16_t z);
+ void SendMag(int16_t x, int16_t y, int16_t z);
void SendAmbientLight(uint8_t percentage);
void SendTemperature(uint16_t celsius);
void SendHumidity(uint16_t percentage);