Skip to content
This repository has been archived by the owner on Apr 27, 2020. It is now read-only.

Commit

Permalink
Animation changes
Browse files Browse the repository at this point in the history
The duration of animations should now add up exactly to one minute instead of doing the weird math before.

It should now also play the exact number of times per minute it was supposed to. Previously, it was over by one.
  • Loading branch information
aaronhktan committed Dec 8, 2016
1 parent 9a84b6d commit 7565a22
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 180 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
"watchface": false
}
},
"version": "1.2.0"
"version": "2.0.0"
}
309 changes: 160 additions & 149 deletions src/c/breathe_window.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "src/c/appglance.h"

static void init() {
APP_LOG(APP_LOG_LEVEL_INFO, "You are running version 1.1 of the Breathe app.");
APP_LOG(APP_LOG_LEVEL_INFO, "You are running version 2.0 of the Breathe app.");
#if PBL_HEALTH
health_init(); // Subscribe to health service if health API is available
#endif
Expand Down
26 changes: 5 additions & 21 deletions src/c/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,34 +224,18 @@ int settings_get_breathDuration() {
} else if (heart_rate > 65 && heart_rate <= 70) {
return (MILLISECONDS_PER_MINUTE - (2000 * 6)) / 6 / 2;
} else if (heart_rate > 70 && heart_rate <= 80) {
return (MILLISECONDS_PER_MINUTE - 4000 - (2000 * 7)) / 7 / 2;
return (MILLISECONDS_PER_MINUTE - (2000 * 7)) / 7 / 2;
} else if (heart_rate > 80 && heart_rate <= 90) {
return (MILLISECONDS_PER_MINUTE - 4000 - (2000 * 8)) / 8 / 2;
return (MILLISECONDS_PER_MINUTE - (2000 * 8)) / 8 / 2;
} else if (heart_rate > 90 && heart_rate <= 100) {
return (MILLISECONDS_PER_MINUTE + 3000 - (2000 * 9)) / 9 / 2;
return (MILLISECONDS_PER_MINUTE - (2000 * 9)) / 9 / 2;
} else { // The heart rate is more than 100
return (MILLISECONDS_PER_MINUTE - (2000 * 10)) / 10 / 2;
}
} else {
switch(settings.breathsPerMinute) {
case 4:
case 5:
case 6:
case 10:
/* Return one minute minus 2 second delay for each breath, divided by the number of breaths to take
/* Return one minute minus 2 second delay for each breath, divided by the number of breaths to take
That gives us how many seconds the entire breath should take, so divide by 2 to get inhale/exhale duration */
APP_LOG(APP_LOG_LEVEL_DEBUG, "The duration of breaths is %d.", (MILLISECONDS_PER_MINUTE - (2000 * settings.breathsPerMinute)) / settings.breathsPerMinute / 2);
return (MILLISECONDS_PER_MINUTE - (2000 * settings.breathsPerMinute)) / settings.breathsPerMinute / 2;
break;
case 7:
case 8:
// Like above, but taking removing 4 seconds because otherwise a decimal would happen. Don't want that happening!
return (MILLISECONDS_PER_MINUTE - 4000 - (2000 * settings.breathsPerMinute)) / settings.breathsPerMinute / 2;
break;
default: // 9 breaths per minute
return (MILLISECONDS_PER_MINUTE + 3000 - (2000 * settings.breathsPerMinute)) / settings.breathsPerMinute / 2;
break;
}
return (MILLISECONDS_PER_MINUTE - (2000 * settings.breathsPerMinute)) / settings.breathsPerMinute / 2;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/pkjs/config-de.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "Dies sind die Einstellungen für die Breathe-App. Sie benutzen Version 1.2 von Breathe.",
"defaultValue": "Dies sind die Einstellungen für die Breathe-App. Sie benutzen Version 2.0 von Breathe.",
},
{
"type": "section",
Expand Down Expand Up @@ -215,7 +215,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "<em><center>Vielen Dank an die Betatester: <br>Paula&nbsp;Bosca, Nikita&nbsp;Cheng, Ayush&nbsp;Gupta, Ellen&nbsp;Huang, Yvonne&nbsp;Tan, David&nbsp;Voicu, /u/dryingsocks, and /u/PiwwowPants.</center></em>",
"defaultValue": "<em><center>Vielen Dank an die Betatester: <br>Paula&nbsp;Bosca, Nikita&nbsp;Cheng, Ayush&nbsp;Gupta, Ellen&nbsp;Huang, Yvonne&nbsp;Tan, David&nbsp;Voicu, /u/dryingsocks, /u/JohnEdwa, and /u/PiwwowPants.</center></em>",
},
{
"type": "submit",
Expand Down
4 changes: 2 additions & 2 deletions src/pkjs/config-es.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "Esta es la página de ajustes para la app Breathe. Estás usando la versión 1.2 de la app.",
"defaultValue": "Esta es la página de ajustes para la app Breathe. Estás usando la versión 2.0 de la app.",
},
{
"type": "section",
Expand Down Expand Up @@ -215,7 +215,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "<em><center>Muchas gracias a los probadores beta: <br>Paula&nbsp;Bosca, Nikita&nbsp;Cheng, Ayush&nbsp;Gupta, Ellen&nbsp;Huang, Yvonne&nbsp;Tan, David&nbsp;Voicu, /u/dryingsocks, y /u/PiwwowPants</center></em>",
"defaultValue": "<em><center>Muchas gracias a los probadores beta: <br>Paula&nbsp;Bosca, Nikita&nbsp;Cheng, Ayush&nbsp;Gupta, Ellen&nbsp;Huang, Yvonne&nbsp;Tan, David&nbsp;Voicu, /u/dryingsocks, /u/JohnEdwa, y /u/PiwwowPants</center></em>",
},
{
"type": "submit",
Expand Down
4 changes: 2 additions & 2 deletions src/pkjs/config-fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "Ceci est la page de configuration pour l'app Breathe. Vous utilisez version 1.2 de l'app.",
"defaultValue": "Ceci est la page de configuration pour l'app Breathe. Vous utilisez version 2.0 de l'app.",
},
{
"type": "section",
Expand Down Expand Up @@ -215,7 +215,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "<em><center>Un grand merci aux bêta-testeurs: <br>Paula&nbsp;Bosca, Nikita&nbsp;Cheng, Ayush&nbsp;Gupta, Ellen&nbsp;Huang, Yvonne&nbsp;Tan, David&nbsp;Voicu, /u/dryingsocks, et /u/PiwwowPants</center></em>",
"defaultValue": "<em><center>Un grand merci aux bêta-testeurs: <br>Paula&nbsp;Bosca, Nikita&nbsp;Cheng, Ayush&nbsp;Gupta, Ellen&nbsp;Huang, Yvonne&nbsp;Tan, David&nbsp;Voicu, /u/dryingsocks, /u/JohnEdwa, et /u/PiwwowPants</center></em>",
},
{
"type": "submit",
Expand Down
4 changes: 2 additions & 2 deletions src/pkjs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "This is the settings page for the Breathe app. You are running version 1.2 of Breathe.",
"defaultValue": "This is the settings page for the Breathe app. You are running version 2.0 of Breathe.",
},
{
"type": "section",
Expand Down Expand Up @@ -215,7 +215,7 @@ module.exports = [
},
{
"type": "text",
"defaultValue": "<em><center>Many thanks to the beta testers: <br>Paula&nbsp;Bosca, Nikita&nbsp;Cheng, Ayush&nbsp;Gupta, Ellen&nbsp;Huang, Yvonne&nbsp;Tan, David&nbsp;Voicu, /u/dryingsocks, and /u/PiwwowPants.</center></em>",
"defaultValue": "<em><center>Many thanks to the beta testers: <br>Paula&nbsp;Bosca, Nikita&nbsp;Cheng, Ayush&nbsp;Gupta, Ellen&nbsp;Huang, Yvonne&nbsp;Tan, David&nbsp;Voicu, /u/dryingsocks, /u/JohnEdwa, and /u/PiwwowPants.</center></em>",
},
{
"type": "submit",
Expand Down

0 comments on commit 7565a22

Please sign in to comment.