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.
Dependencies: FXAS21002 FXOS8700 Hexi_KW40Z Hexi_OLED_SSD1351 MAXIM W25Q64FVSSIG HTU21D MPL3115A2 TSL2561
Fork of HexiHeart_Alex by
Revision 22:3de592f8e696, committed 2018-05-10
- Comitter:
- asong
- Date:
- Thu May 10 03:44:47 2018 +0000
- Parent:
- 21:76237b62466b
- Commit message:
- Added stages to the heart rate simulation
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 76237b62466b -r 3de592f8e696 main.cpp
--- a/main.cpp Tue May 08 03:05:45 2018 +0000
+++ b/main.cpp Thu May 10 03:44:47 2018 +0000
@@ -257,6 +257,7 @@
uint8_t Current_Zone = 1;
uint8_t Prev_Zone = 1;
uint8_t Heart_Rate = 0;
+uint8_t rand_stage;
uint8_t *HR_return;
uint8_t Age = 25; // Initialize age
uint8_t Max_Bpm = 220 - Age; // Initialize Max BPM
@@ -573,6 +574,7 @@
StartHaptic();
if(maxim == 0)
{
+ simulation_stage = 0;
Heart_Rate_Mode = 1;
hr_led.attach(&Led_Zone_Indicator, HR_LED_period);
hr_simulation.attach(&HR_Simulation, 5.0);
@@ -4700,9 +4702,33 @@
Heart_Rate = HR_Zone3[0] + rand() %( HR_Zone3[1] - HR_Zone3[0] + 1);
}
+ else if(simulation_stage == 5)
+ {
+ Heart_Rate = HR_Zone2[0] + rand() %( HR_Zone2[1] - HR_Zone2[0] + 1);
+ }
+ else if(simulation_stage == 6)
+ {
+ Heart_Rate = HR_Zone1[0] + rand() %( HR_Zone1[1] - HR_Zone1[0] + 1);
+ }
else
{
- simulation_stage = -1;
+ rand_stage = rand() % 4 + 1;
+ if(rand_stage == 1)
+ {
+ Heart_Rate = HR_Zone1[0] + rand() %( HR_Zone1[1] - HR_Zone1[0] + 1);
+ }
+ else if(rand_stage == 2)
+ {
+ Heart_Rate = HR_Zone2[0] + rand() %( HR_Zone2[1] - HR_Zone2[0] + 1);
+ }
+ else if(rand_stage == 3)
+ {
+ Heart_Rate = HR_Zone3[0] + rand() %( HR_Zone3[1] - HR_Zone3[0] + 1);
+ }
+ else if(rand_stage == 4)
+ {
+ Heart_Rate = HR_Zone4[0] + rand() %( HR_Zone4[1] - HR_Zone4[0] + 1);
+ }
}
simulation_stage++;
Determine_Current_Zone();
