Swimming data field, counting series

Former Member
Former Member

(if the text below is not clear enough please let me know.)

Hello All,

currently i am working on a data field that counts how many times i managed to swum a certain distance.

the counting ellement of the datafield isn't that hard. for now when the datafield starts up it will start counting.

the thing i can not figure out is how to use the pause function of the swimming app. because i whan't to let it count when you stop your timer.

hope someone here has experiance with that.

maybe usefull to mention. i have looked at the sample code "input" but could not figure out if i could use someting from that.

using Toybox.WatchUi;
using Toybox.System;
using Toybox.Time;

class SeriesCounterView extends WatchUi.SimpleDataField {


	

	var counter;
    var previousRound;
    var timeStrech;
	
	
    // Constructor
    function initialize() {
        SimpleDataField.initialize();
        label = "Series";
        counter = 0;
		previousRound = 0; 
		timeStrech = 0;       
        
        
    }
 
    // Handle the update event
   function compute(info) {
  
        
    var value_picked = "--";
    
    
    var thisRound = info.elapsedDistance;     
     
   
    if(counter == 0 && info.elapsedDistance != null){
    	previousRound = thisRound;
    	counter = 1;
    }
    
    if(counter != 0 && previousRound == thisRound && info.elapsedDistance != null ){ 
    	counter++;
    }   
    
    if(counter != 0 && info.elapsedDistance != null && previousRound != thisRound){
    	previousRound = thisRound;
    	counter = 1;
    
    }
    
    value_picked = counter;
    
    return value_picked;
    
    return previousRound;
    return thisRound;
   
	}
}

just a little recap for what i need.

if i swim 100m --> couter will set to 1

if i swim another 100m --> counter will set to 2

if i do that another 3x100m--> counter will set to 5

if i swim a different distance for example 200m --> counter will return to 1