![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Swim-It, is a waterproof counter for arm movement
Dependencies: Hexi_KW40Z Hexi_OLED_SSD1351
Fork of Hexi_BLE_Example by
Revision 4:c2ab3a0de448, committed 2016-09-26
- Comitter:
- cotigac
- Date:
- Mon Sep 26 05:29:51 2016 +0000
- Parent:
- 2:b8ec0a54094e
- Commit message:
- Added dummy data generation
Changed in this revision
diff -r b8ec0a54094e -r c2ab3a0de448 Hexi_KW40Z.lib --- a/Hexi_KW40Z.lib Tue Sep 20 22:56:09 2016 +0000 +++ b/Hexi_KW40Z.lib Mon Sep 26 05:29:51 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/Hexiwear/code/Hexi_KW40Z/#8586f50385d2 +https://developer.mbed.org/teams/Hexiwear/code/Hexi_KW40Z/#3f5ed7abc5c7
diff -r b8ec0a54094e -r c2ab3a0de448 Hexi_OLED_SSD1351.lib --- a/Hexi_OLED_SSD1351.lib Tue Sep 20 22:56:09 2016 +0000 +++ b/Hexi_OLED_SSD1351.lib Mon Sep 26 05:29:51 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/Hexiwear/code/Hexi_OLED_SSD1351/#9961c525e249 +https://developer.mbed.org/teams/Hexiwear/code/Hexi_OLED_SSD1351/#ae5fad429790
diff -r b8ec0a54094e -r c2ab3a0de448 main.cpp --- a/main.cpp Tue Sep 20 22:56:09 2016 +0000 +++ b/main.cpp Mon Sep 26 05:29:51 2016 +0000 @@ -7,7 +7,8 @@ #define LED_ON 0 #define LED_OFF 1 - + +void UpdateSensorData(void); void StartHaptic(void); void StopHaptic(void const *n); void txTask(void); @@ -32,6 +33,15 @@ /* Text Buffer */ char text[20]; +uint8_t battery = 100; +uint8_t light = 0; +uint16_t humidity = 4500; +uint16_t temperature = 2000; +uint16_t pressure = 9000; +uint16_t x = 0; +uint16_t y = 5000; +uint16_t z = 10000; + /****************************Call Back Functions*******************************/ void ButtonRight(void) { @@ -62,21 +72,21 @@ int main() { - /* Get OLED Class Default Text Properties */ - oled_text_properties_t textProperties = {0}; - oled.GetTextProperties(&textProperties); + /* Register callbacks to application functions */ + kw40z_device.attach_buttonLeft(&ButtonLeft); + kw40z_device.attach_buttonRight(&ButtonRight); + kw40z_device.attach_passkey(&PassKey); /* Turn on the backlight of the OLED Display */ oled.DimScreenON(); /* Fills the screen with solid black */ oled.FillScreen(COLOR_BLACK); + + /* Get OLED Class Default Text Properties */ + oled_text_properties_t textProperties = {0}; + oled.GetTextProperties(&textProperties); - /* Register callbacks to application functions */ - kw40z_device.attach_buttonLeft(&ButtonLeft); - kw40z_device.attach_buttonRight(&ButtonRight); - kw40z_device.attach_passkey(&PassKey); - /* Change font color to Blue */ textProperties.fontColor = COLOR_BLUE; oled.SetTextProperties(&textProperties); @@ -95,7 +105,8 @@ oled.Label((uint8_t *)text,22,80); uint8_t prevLinkState = 0; - uint8_t currLinkState = 0; + uint8_t currLinkState = 0; + txThread.start(txTask); /*Start transmitting Sensor Tag Data */ while (true) @@ -113,6 +124,7 @@ while (true) { + UpdateSensorData(); /*Notify Hexiwear App that it is running Sensor Tag mode*/ kw40z_device.SendSetApplicationMode(GUI_CURRENT_APP_SENSOR_TAG); @@ -120,28 +132,51 @@ /*The following is sending dummy data over BLE. Replace with real data*/ /*Send Battery Level for 20% */ - kw40z_device.SendBatteryLevel(20); + kw40z_device.SendBatteryLevel(battery); /*Send Ambient Light Level at 50% */ - kw40z_device.SendAmbientLight(50); + kw40z_device.SendAmbientLight(light); /*Send Humidity at 90% */ - kw40z_device.SendHumidity(9000); + kw40z_device.SendHumidity(humidity); /*Send Temperature at 25 degrees Celsius */ - kw40z_device.SendTemperature(2500); + kw40z_device.SendTemperature(temperature); /*Send Pressure at 100kPA */ - kw40z_device.SendPressure(10000); + kw40z_device.SendPressure(pressure); /*Send Mag,Accel,Gyro Data. */ - kw40z_device.SendGyro(0,0,0); - kw40z_device.SendAccel(0,0,0); - kw40z_device.SendMag(0,0,0); + kw40z_device.SendGyro(x,y,z); + kw40z_device.SendAccel(z,x,y); + kw40z_device.SendMag(y,z,x); + Thread::wait(1000); } } +void UpdateSensorData(void) +{ + battery -= 5; + if(battery < 5) battery = 100; + + light += 20; + if(light > 100) light = 0; + + humidity += 500; + if(humidity > 8000) humidity = 2000; + + temperature -= 200; + if(temperature < 200) temperature = 4200; + + pressure += 300; + if(pressure > 10300) pressure = 7500; + + x += 1400; + y -= 2300; + z += 1700; +} + void StartHaptic(void) { hapticTimer.start(50); haptic = 1;