WatchUSeek Watch Forums banner

1 - 7 of 7 Posts

·
Registered
Joined
·
672 Posts
Discussion Starter · #1 ·
I'm getting an error when I add a duration of 720 secs to the code below. Any suggestions on how to achieve this? Currently the app beeps constantly if HR is above 127 and below 121. I'd like an alarm at 12 minutes too. Any suggestions welcome.

/* While in sport mode do this once per second */
RESULT = (SUUNTO_MAX_HR);

if(SUUNTO_HR>=128){
Suunto.alarmBeep();
}

if(SUUNTO_HR<=121){
Suunto.alarmBeep();
}

if(SUUNTO_LAP_DISTANCE*1000<1300){
RESULT=1;
}
if((SUUNTO_LAP_DISTANCE*1000>=1300)&&(SUUNTO_LAP_DISTANCE*100<1600)){
RESULT=2;
}
if((SUUNTO_LAP_DISTANCE*1000>=1600)&&(SUUNTO_LAP_DISTANCE*1000<2000)){
RESULT=3;
}
if((SUUNTO_LAP_DISTANCE*1000>=2000)&&(SUUNTO_LAP_DISTANCE*1000<2400)){
RESULT=4;
}
if(SUUNTO_LAP_DISTANCE*1000>=2400){
RESULT=5;
}
 

·
Registered
Joined
·
379 Posts
I'm getting an error when I add a duration of 720 secs to the code below.
What error are you getting and what do you mean by 'add a duration of 720...', what does that code do?

Any suggestions on how to achieve this? Currently the app beeps constantly if HR is above 127 and below 121. I'd like an alarm at 12 minutes too. Any suggestions welcome.
Your code is saying beep every second if the HR is outside the range 121-127. It then will display 1-5 depending on how far you've travelled. What are you trying to achieve. As far as having an alarm at 720 seconds, you just need

Code:
if (SUUNTO_DURATION > 720) {
         Suunto.alarmBeep();
}
somewhere. It will be impossible to tell if beep is for the HR or the 720 seconds though as there's only a single beep sound.

Also, your existing code has a small bug

if((SUUNTO_LAP_DISTANCE*1000>=1300)&&(SUUNTO_LAP_DISTANCE*100<1600)){
Second multiplier is 100, not 1000.

Couple of other points: From an efficiency point of view, it's better to use if...else if... when the 2 (or more) statements can never have more than one outcome, it avoids processing power. Also, the SUUNTO_LAP_DISTANCE * 1000 might be better done once as I don't expect it will be optimised by the compiler, so
Code:
if (SUUNTO_HR>=128){
    Suunto.alarmBeep();
}
else if (SUUNTO_HR<=121){
    Suunto.alarmBeep();
}

distance = SUUNTO_LAP_DISTANCE*1000;
if (distance < 1300){
    RESULT=1;
}
else if((distance >= 1300) && (distance < 1600)){
    RESULT=2;
}
else if ((distance >= 1600) && (distance < 2000)){
    RESULT=3;
}
else if ((distance >= 2000) && (distance < 2400)){
    RESULT=4;
}
else if(distance>=2400){
    RESULT=5;
}


and you'd need to set up your 'own variable' distance.

There is of course a more optimal way to do these tests, so only making a single test per if statement. Just test the range > high value first and then go down the ranges, i.e.

Code:
if (distance>=2400){
    RESULT=5;
}
else if (distance >= 2000){
    RESULT=4;
}
else if (distance >= 1600){
    RESULT=3;
}
else if ((distance >= 1300){
    RESULT=2;
}
else {
    RESULT=1;
}

 

·
Registered
Joined
·
672 Posts
Discussion Starter · #3 ·
What error are you getting and what do you mean by 'add a duration of 720...', what does that code do?



Your code is saying beep every second if the HR is outside the range 121-127. It then will display 1-5 depending on how far you've travelled. What are you trying to achieve. As far as having an alarm at 720 seconds, you just need

Code:
if (SUUNTO_DURATION > 720) {
         Suunto.alarmBeep();
}
somewhere. It will be impossible to tell if beep is for the HR or the 720 seconds though as there's only a single beep sound.

Also, your existing code has a small bug



Second multiplier is 100, not 1000.

Couple of other points: From an efficiency point of view, it's better to use if...else if... when the 2 (or more) statements can never have more than one outcome, it avoids processing power. Also, the SUUNTO_LAP_DISTANCE * 1000 might be better done once as I don't expect it will be optimised by the compiler, so
Code:
if (SUUNTO_HR>=128){
    Suunto.alarmBeep();
}
else if (SUUNTO_HR<=121){
    Suunto.alarmBeep();
}

distance = SUUNTO_LAP_DISTANCE*1000;
if (distance < 1300){
    RESULT=1;
}
else if((distance >= 1300) && (distance < 1600)){
    RESULT=2;
}
else if ((distance >= 1600) && (distance < 2000)){
    RESULT=3;
}
else if ((distance >= 2000) && (distance < 2400)){
    RESULT=4;
}
else if(distance>=2400){
    RESULT=5;
}


and you'd need to set up your 'own variable' distance.

There is of course a more optimal way to do these tests, so only making a single test per if statement. Just test the range > high value first and then go down the ranges, i.e.

Code:
if (distance>=2400){
    RESULT=5;
}
else if (distance >= 2000){
    RESULT=4;
}
else if (distance >= 1600){
    RESULT=3;
}
else if ((distance >= 1300){
    RESULT=2;
}
else {
    RESULT=1;
}

Thanks. On reflection, I think all I need in addition to the HR alarms is a timer that fires at 12 minutes. When I add the 'duration' code I get a whoops error.

I'll try your code. Is it possible to get 2 beeps or some other variation as a differentiator? Or could I extend the HR beeps to every 2 secs and have the 12 min alarm beep twice?
 

·
Registered
Joined
·
379 Posts
Thanks. On reflection, I think all I need in addition to the HR alarms is a timer that fires at 12 minutes. When I add the 'duration' code I get a whoops error.

I'll try your code. Is it possible to get 2 beeps or some other variation as a differentiator? Or could I extend the HR beeps to every 2 secs and have the 12 min alarm beep twice?
In that Nutrition reminder app I posted in your other thread, it shows two 'beep types', one of 2 beeps after 20 minutes and one of 4 beeps after 40. It then repeats. Those are enough of a differentiator for me when running to notice the different types.

I was planning to add another one at every 60 and a bit minutes, that rather than beep each second, would beep every 2 or three seconds and repeat 5 times, so I don't miss it. That would be my salt tablet reminder.

I don't know of a way to get a different sound - that would be a nice enhancement.

The logic to have those 2 or 3 second gaps is quite simple, e.g. one way might be something like

if (saltBeep > 0)
{
if (Suunto.mod(saltBeep, 3) == 0)
Suunto.alarmBeep();
saltBeep = saltBeep - 1;
}

so, setting saltBeep to 15 when the correct condition is met would cause 5 single beeps, one every 3 seconds.

You could for example, set your low HR beep to single beep, your high HR beep to double beep and at 12 minutes, beep every 2 seconds until you stop the exercise. You may miss the first beep or two of that 12 minute alarm until you recognise it's not a HR alarm, but you'll get to know when it's due to go off, so will be ready for it. If your code prevents repeat beeps for over/under HR for a period, e.g. 15 seconds, after the first notification, then you'll easily recognise the consistent beeping as "end of test".
 

·
Registered
Joined
·
672 Posts
Discussion Starter · #5 · (Edited)
In that Nutrition reminder app I posted in your other thread, it shows two 'beep types', one of 2 beeps after 20 minutes and one of 4 beeps after 40. It then repeats. Those are enough of a differentiator for me when running to notice the different types.

I was planning to add another one at every 60 and a bit minutes, that rather than beep each second, would beep every 2 or three seconds and repeat 5 times, so I don't miss it. That would be my salt tablet reminder.

I don't know of a way to get a different sound - that would be a nice enhancement.

The logic to have those 2 or 3 second gaps is quite simple, e.g. one way might be something like

if (saltBeep > 0)
{
if (Suunto.mod(saltBeep, 3) == 0)
Suunto.alarmBeep();
saltBeep = saltBeep - 1;
}

so, setting saltBeep to 15 when the correct condition is met would cause 5 single beeps, one every 3 seconds.

You could for example, set your low HR beep to single beep, your high HR beep to double beep and at 12 minutes, beep every 2 seconds until you stop the exercise. You may miss the first beep or two of that 12 minute alarm until you recognise it's not a HR alarm, but you'll get to know when it's due to go off, so will be ready for it. If your code prevents repeat beeps for over/under HR for a period, e.g. 15 seconds, after the first notification, then you'll easily recognise the consistent beeping as "end of test".
Thanks. I should probably explain what I am trying to achieve here. I'm working with a new trainer who tells me I have an aerobic/anaerobic imbalance which is hampering my race pace severely; in effect I mostly work anaerobically which pushes my HR too high and lowers my pace. I've a HR 'zone' to work to which is between 117 and 127 BPM which I now use for 80% of my training (and until further notice :roll: . I have an app that beeps at me when I fall outside these limits and also which shows my live MHR for the 'move'. What I'd like to do is to add a 'cooper' test alarm at 12 mins so that I can track my distance for that specific time and at the same time I'd like to still stay within my HR 'zone'.

Initially I had wanted to be able to display on scale of 1 to 5 where I am for the cooper test but that is less important than the two areas above and can wait until I have an Ambit2 and can run multiple apps.

So I need a beep when I'm above or below (it might be nice to differentiate the tones) and then a final alarm when I hit 12 mins whereby I need to take note of the distance via 'lap' or by ending the move. I'm not quite sure what you mean by 'saltBeep' or how to put this all together. Thanks so far and any further help is most welcome.
 

·
Registered
Joined
·
379 Posts
I've a HR 'zone' to work to which is between 117 and 127 BPM which I now use for 80% of my training (and until further notice :roll: . I have an app that beeps at me when I fall outside these limits and also which shows my live MHR for the 'move'. What I'd like to do is to add a 'cooper' test alarm at 12 mins so that I can track my distance for that specific time and at the same time I'd like to still stay within my HR 'zone'.

Initially I had wanted to be able to display on scale of 1 to 5 where I am for the cooper test but that is less important than the two areas above and can wait until I have an Ambit2 and can run multiple apps.

So I need a beep when I'm above or below (it might be nice to differentiate the tones) and then a final alarm when I hit 12 mins whereby I need to take note of the distance via 'lap' or by ending the move. I'm not quite sure what you mean by 'saltBeep' or how to put this all together. Thanks so far and any further help is most welcome.
Don't worry about saltBeep, it was just an example.

See this app

It's set to beep when the HR is below 117 or above 127 and also after 12 minutes. The beeping sounds are done like this

Below 117 - Beep every second for two seconds then silent for a second and repeat
Over 127 - Beep every second
After 12 minutes - Beeps every other second

There are a couple of comments in the code to show what's going on. I've not tested the 12 minute alarm, but it should work. The differentiator between low and high beeps is the 1 second gap after 2 low HR beeps. The slower alternate second beep at the end should tell you it's over. It doesn't handle pre-start or pause modes. It also will not allow you to do another lap within the same move, that would require additional logic.

Hope it's useful.
 

·
Registered
Joined
·
672 Posts
Discussion Starter · #7 ·
The code has an error.

I've created my own app that works fine in that it beeps constantly if HR is outside the specified range (which is what I want) and it shows the 'live' performance against the 'Cooper distance' which changes as the specified distance is reached. However, the 12 minutes alarm fails to sound though when tested in the designer it works perfectly. Here is the code but with the duration set to 90 secs.

Any help would be appreciated.

/* While in sport mode do this once per second */


if(SUUNTO_LAP_DURATION == 90){
Suunto.alarmBeep();
}


if(SUUNTO_DURATION>0 && SUUNTO_HR>127){
Suunto.alarmBeep();
}
else if(SUUNTO_DURATION>0 && SUUNTO_HR<117){
Suunto.alarmBeep();
}
if(SUUNTO_LAP_DISTANCE*1000<1300){
RESULT=1;
}
else if((SUUNTO_LAP_DISTANCE*1000<1600)){
RESULT=2;
}
else if((SUUNTO_LAP_DISTANCE*1000<2000)){
RESULT=3;
}
else if((SUUNTO_LAP_DISTANCE*1000<2400)){
RESULT=4;
}
else if(SUUNTO_LAP_DISTANCE*1000>=2400){
RESULT=5;
}
 
1 - 7 of 7 Posts
Top