![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
hexiwear code that transmits sensor data via bluetooth
Dependencies: FXAS21002 FXOS8700 Hexi_KW40Z Hexi_OLED_SSD1351
Fork of Hexi_BLE_Example_Modified by
Revision 6:8a9b0eb4835d, committed 2018-06-12
- Comitter:
- adrayv
- Date:
- Tue Jun 12 03:39:57 2018 +0000
- Parent:
- 5:b479668a7373
- Commit message:
- cleaned up code
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r b479668a7373 -r 8a9b0eb4835d main.cpp --- a/main.cpp Tue Jun 12 03:34:17 2018 +0000 +++ b/main.cpp Tue Jun 12 03:39:57 2018 +0000 @@ -54,15 +54,13 @@ void ButtonRight(void) { StartHaptic(); - kw40z_device.SendAccel(x,y,z); -// kw40z_device.ToggleAdvertisementMode(); + kw40z_device.ToggleAdvertisementMode(); } void ButtonLeft(void) { StartHaptic(); - kw40z_device.SendAccel(x,y,z); -// kw40z_device.ToggleAdvertisementMode(); + kw40z_device.ToggleAdvertisementMode(); } void PassKey(void) @@ -170,29 +168,16 @@ /*The following is sending dummy data over BLE. Replace with real data*/ /*Send Battery Level for 20% */ + // SendAccel does not work and is not stable over bluetooth + // So we will use SendBattery + // But since SendBattery cannot send multiple values at a time + // We will have to advertise to Pi what value it should expect next kw40z_device.SendBatteryLevel('x'); kw40z_device.SendBatteryLevel(abs_x); kw40z_device.SendBatteryLevel('y'); kw40z_device.SendBatteryLevel(abs_y); kw40z_device.SendBatteryLevel('z'); kw40z_device.SendBatteryLevel(abs_z); - - /*Send Ambient Light Level at 50% */ -// kw40z_device.SendAmbientLight(light); - - /*Send Humidity at 90% */ -// kw40z_device.SendHumidity(humidity); - - /*Send Temperature at 25 degrees Celsius */ -// kw40z_device.SendTemperature(temperature); - - /*Send Pressure at 100kPA */ -// kw40z_device.SendPressure(pressure); - - /*Send Mag,Accel,Gyro Data. */ -// kw40z_device.SendGyro(x,y,z); - kw40z_device.SendAccel(x,y,z); -// kw40z_device.SendMag(y,z,x); Thread::wait(1000); } @@ -200,14 +185,15 @@ void GetSensorData(void) { accel.acquire_accel_data_g(accel_data); + + // get x,y,z data and amplify them by 100 + // convert x,y,z data to positive numbers since SendBattery only supports unsigned ints x = (int16_t)(accel_data[0] * 100); y = (int16_t)(accel_data[1] * 100); z = (int16_t)(accel_data[2] * 100); abs_x = abs(x); abs_y = abs(y); abs_z = abs(z); -// printf("ACCEL: %d %4.2f %4.2f\n",x, accel_data[1], accel_data[2]); -// printf("ACCEL (x100): X:%d Y:%d Z:%d\n",x,y,z); printf("ACCEL (x100)(ABS): X:%d Y:%d Z:%d\n",abs_x,abs_y,abs_z); }