// *************************************************************************************************
// @fn          init_global_variables
// @brief       Initialize global variables.
// @param       none
// @return      none
// *************************************************************************************************
void init_global_variables(void)
{
    // set menu pointers to default menu items
            ptrMenu_L1 = &menu_L1_Acceleration;

            ptrMenu_L2 = &menu_L2_Stopwatch;

    // Assign LINE1 and LINE2 display functions
    fptr_lcd_function_line1 = ptrMenu_L1->display_function;
    fptr_lcd_function_line2 = ptrMenu_L2->display_function;

    // Init system flags
    button.all_flags = 0;
    sys.all_flags = 0;
    request.all_flags = 0;
    display.all_flags = 0;
    message.all_flags = 0;

    // Force full display update when starting up
    display.flag.full_update = 1;

#ifndef ISM_US
    // Use metric units when displaying values
    sys.flag.use_metric_units = 1;
#endif
    // Set buzzer to default value
    reset_buzzer();

    // Reset stopwatch
    reset_stopwatch();

    // Reset acceleration measurement
    reset_acceleration();
}
Esempio n. 2
0
// *************************************************************************************************
// @fn          mx_stopwatch
// @brief       Stopwatch set routine. Mx stops stopwatch and resets count.
// @param       u8 line LINE2
// @return      none
// *************************************************************************************************
void mx_stopwatch(u8 line)
{
    // Stop stopwatch
    stop_stopwatch();

    // Reset stopwatch count
    reset_stopwatch();

    // Display "00:00:00"
    display_stopwatch(line, DISPLAY_LINE_UPDATE_FULL);
}
int cardio_state(void){
	if(stopwatch_started_or_stopped()){
			switch(stopwatch_started()){
				case true:
					stop_stopwatch();
					break;
				case false:
					start_stopwatch();
					break;
				default:
					return -1;
			}
		}
		if(stopwatch_reset()){			
			reset_stopwatch(); 	   // Save observed values, set stopwatch to 00:00:00:00
			save_to_data();	   	   // Push observed values to datastate
			reset_observed_data(); // Reset the observed values
		}
			
	output_heartrate();
	output_stopwatch();
	
	return 0;
}
Esempio n. 4
0
// *************************************************************************************************
// @fn          init_global_variables
// @brief       Initialize global variables.
// @param       none
// @return      none
// *************************************************************************************************
void init_global_variables(void)
{
	// --------------------------------------------
	// Apply default settings

	// set menu pointers to default menu items
	ptrMenu_L1 = &menu_L1_Time;
//	ptrMenu_L1 = &menu_L1_Alarm;
//	ptrMenu_L1 = &menu_L1_Heartrate;
//	ptrMenu_L1 = &menu_L1_Speed;
//	ptrMenu_L1 = &menu_L1_Temperature;
//	ptrMenu_L1 = &menu_L1_Altitude;
//	ptrMenu_L1 = &menu_L1_Acceleration;
	ptrMenu_L2 = &menu_L2_Date;
//	ptrMenu_L2 = &menu_L2_Stopwatch;
//	ptrMenu_L2 = &menu_L2_Rf;
//	ptrMenu_L2 = &menu_L2_Ppt;
//	ptrMenu_L2 = &menu_L2_Sync;
//	ptrMenu_L2 = &menu_L2_Distance;
//	ptrMenu_L2 = &menu_L2_Calories;
//	ptrMenu_L2 = &menu_L2_Battery;
//	ptrMenu_L2 = &menu_L2_Phase;

	// Assign LINE1 and LINE2 display functions
	fptr_lcd_function_line1 = ptrMenu_L1->display_function;
	fptr_lcd_function_line2 = ptrMenu_L2->display_function;

	// Init system flags
	button.all_flags 	= 0;
	sys.all_flags 		= 0;
	request.all_flags 	= 0;
	display.all_flags 	= 0;
	message.all_flags	= 0;
	
	// Force full display update when starting up
	display.flag.full_update = 1;

#ifndef ISM_US
	// Use metric units when displaying values
    sys.flag.use_metric_units = 1;
#else 
#ifdef CONFIG_METRIC_ONLY
	sys.flag.use_metric_units = 1;
#endif
#endif
	
	// Read calibration values from info memory
	read_calibration_values();
	
	// Set system time to default value
	reset_clock();
	
	// Set date to default value
	reset_date();
	
	// Set alarm time to default value 
	reset_alarm();
	
	// Set buzzer to default value
	reset_buzzer();
	
	// Reset stopwatch
	reset_stopwatch();
	
	// Reset altitude measurement
#ifdef CONFIG_ALTITUDE
	reset_altitude_measurement();
#endif
	
	// Reset acceleration measurement
	reset_acceleration();
	
	// Reset BlueRobin stack
	//pfs
	#ifndef ELIMINATE_BLUEROBIN 
	reset_bluerobin();
	#endif

#ifdef CONFIG_EGGTIMER
	//Set Eggtimer to a 5 minute default
	memcpy(seggtimer.defaultTime, "00010000", sizeof(seggtimer.time));
	reset_eggtimer();
#endif

#ifdef CONFIG_PHASE_CLOCK
	// default program
	sPhase.program = 0;
#endif

	// Reset SimpliciTI stack
	reset_rf();
	
	// Reset temperature measurement 
	reset_temp_measurement();

	// Reset battery measurement
	reset_batt_measurement();
	battery_measurement();
}
Esempio n. 5
0
// *************************************************************************************************
// @fn          init_global_variables
// @brief       Initialize global variables.
// @param       none
// @return      none
// *************************************************************************************************
void init_global_variables(void)
{
	// --------------------------------------------
	// Apply default settings

	// set menu pointers to default menu items
	ptrMenu_L1 = &menu_L1_Time;
//	ptrMenu_L1 = &menu_L1_Alarm;
//	ptrMenu_L1 = &menu_L1_Heartrate;
//	ptrMenu_L1 = &menu_L1_Speed;
//	ptrMenu_L1 = &menu_L1_Temperature;
//	ptrMenu_L1 = &menu_L1_Altitude;
//	ptrMenu_L1 = &menu_L1_Acceleration;
	ptrMenu_L2 = &menu_L2_Date;
//	ptrMenu_L2 = &menu_L2_Stopwatch;
//	ptrMenu_L2 = &menu_L2_Rf;
//	ptrMenu_L2 = &menu_L2_Ppt;
//	ptrMenu_L2 = &menu_L2_Sync;
//	ptrMenu_L2 = &menu_L2_Distance;
//	ptrMenu_L2 = &menu_L2_Calories;
//	ptrMenu_L2 = &menu_L2_Battery;

	// Assign LINE1 and LINE2 display functions
	fptr_lcd_function_line1 = ptrMenu_L1->display_function;
	fptr_lcd_function_line2 = ptrMenu_L2->display_function;

	// Init system flags
	button.all_flags 	= 0;
	sys.all_flags 		= 0;
	request.all_flags 	= 0;
	display.all_flags 	= 0;
	message.all_flags	= 0;
	
	// Force full display update when starting up
	display.flag.full_update = 1;

#ifndef ISM_US
	// Use metric units when displaying values
	sys.flag.use_metric_units = 1;
#endif
	
	// Read calibration values from info memory
	read_calibration_values();
	
	// Set system time to default value
	reset_clock();
	
	// Set date to default value
	reset_date();
	
	// Set alarm time to default value 
	reset_alarm();
	
	// Set buzzer to default value
	reset_buzzer();
	
	// Reset stopwatch
	reset_stopwatch();
	
	// Reset altitude measurement
	reset_altitude_measurement();
	
	// Reset acceleration measurement
	reset_acceleration();
	
	// Reset BlueRobin stack
	reset_bluerobin();

	// Reset SimpliciTI stack
	reset_rf();
	
	// Reset temperature measurement 
	reset_temp_measurement();

	// Reset battery measurement
	reset_batt_measurement();
	battery_measurement();

    //Set cdtimer to a 5:00 minute default
    memcpy(scdtimer.defaultTime, "000500", sizeof(scdtimer.time));
    reset_cdtimer();
    
    // Reset random generator
    reset_random();
    
    // Reset agility measurement
    reset_agility();
    
    // Reset number storage
    reset_number_storage();
}
Esempio n. 6
0
// *************************************************************************************************
// @fn          stopwatch_tick
// @brief       Called by 1/100Hz interrupt handler.
//                              Increases stopwatch counter and triggers display update.
// @param       none
// @return      none
// *************************************************************************************************
void stopwatch_tick(void)
{
    static u8 delay = 0;

    // Default view (< 20 minutes): display and count MM:SS:hh
    if (sStopwatch.viewStyle == DISPLAY_DEFAULT_VIEW)
    {
        // Add 1/100 sec
        sStopwatch.time[7]++;

        // Draw flag minimizes display update activity
        //
        // swt.drawFlag = 1: second L
        // swt.drawFlag = 2: second H/L
        // swt.drawFlag = 3: minutes L, second H/L
        // swt.drawFlag = 4: minutes H/L, second H/L
        // swt.drawFlag = 5: hours L, minutes H/L, second H/L
        // swt.drawFlag = 6: hours H/L, minutes H/L, second H/L
        // swt.drawFlag = 7: 1/10 sec, 1/100 sec
        // swt.drawFlag = 8: 1/100 sec (every 17/100 sec to reduce display draw activity)
        if (delay++ > 17)
        {
            sStopwatch.drawFlag = 8;
            delay = 0;
        }

        // Add 1/10 sec
        if (sStopwatch.time[7] == 0x3A)
        {
            sStopwatch.time[7] = '0';
            sStopwatch.time[6]++;

            // 1/10Hz trigger
            sStopwatch.swtIs10Hz = 1;

            // Update draw flag
            sStopwatch.drawFlag = 7;
        }
    }
    else                        // Alternative view (20 minutes .. 20 hours): display and count
                                // HH:MM:SS
    {
        // Just add 1 second
        sStopwatch.time[6] = 0x3A;
    }

    // Second overflow?
    if (sStopwatch.time[6] == 0x3A)
    {
        // Reset draw flag
        sStopwatch.drawFlag = 1;

        // 1Hz trigger
        sStopwatch.swtIs1Hz = 1;

        // Add data
        sStopwatch.time[6] = '0';
        sStopwatch.time[5]++;                      // second  L (0 - 9)
        if (sStopwatch.time[5] == 0x3A)
        {
            sStopwatch.drawFlag++;                 // 2
            sStopwatch.time[5] = '0';
            sStopwatch.time[4]++;                  // second  H (0 - 5)
            if (sStopwatch.time[4] == '6')
            {
                sStopwatch.drawFlag++;             // 3
                sStopwatch.time[4] = '0';
                sStopwatch.time[3]++;              // minutes L (0 - 9)
                if (sStopwatch.time[3] == 0x3A)
                {
                    sStopwatch.drawFlag++;         // 4
                    sStopwatch.time[3] = '0';
                    sStopwatch.time[2]++;          // minutes H (0 - 5)
                    if (sStopwatch.time[2] == '2')
                    {
                        // SWT display changes from MM:SS:hh to HH:MM:SS when reaching 20 minutes
                        sStopwatch.viewStyle = DISPLAY_ALTERNATIVE_VIEW;
                        display_stopwatch(LINE2, DISPLAY_LINE_UPDATE_FULL);

                    }
                    else if (sStopwatch.time[2] == '6')
                    {
                        sStopwatch.drawFlag++;     // 5
                        sStopwatch.time[2] = '0';
                        sStopwatch.time[1]++;      // hours L (0-9)

                        if (sStopwatch.time[1] == 0x3A)
                        {
                            sStopwatch.drawFlag++; // 6
                            sStopwatch.time[1] = '0';
                            sStopwatch.time[0]++;  // hours H (0-1)

                            if (sStopwatch.time[0] == '2')
                            {
                                // When reaching 20 hours, start over
                                reset_stopwatch();
                                sStopwatch.state = STOPWATCH_RUN;
                                display_stopwatch(LINE2, DISPLAY_LINE_UPDATE_FULL);
                            }
                        }
                    }
                }
            }
        }
    }

    // Always set display update flag
    display.flag.update_stopwatch = 1;
}
Esempio n. 7
0
// *************************************************************************************************
// @fn          init_global_variables
// @brief       Initialize global variables.
// @param       none
// @return      none
// *************************************************************************************************
void init_global_variables(void)
{
	// --------------------------------------------
	// Apply default settings

	menu_L1_position=0;
	menu_L2_position=0;
	// set menu pointers to default menu items
	ptrMenu_L1 = menu_L1[menu_L1_position];
	ptrMenu_L2 = menu_L2[menu_L2_position];

	// Assign LINE1 and LINE2 display functions
	fptr_lcd_function_line1 = ptrMenu_L1->display_function;
	fptr_lcd_function_line2 = ptrMenu_L2->display_function;

	// Init system flags
	button.all_flags 	= 0;
	sys.all_flags 		= 0;
	request.all_flags 	= 0;
	display.all_flags 	= 0;
	message.all_flags	= 0;
	
	// Force full display update when starting up
	display.flag.full_update = 1;

#ifndef ISM_US
	// Use metric units when displaying values
    sys.flag.use_metric_units = 1;
#else 
#ifdef CONFIG_METRIC_ONLY
	sys.flag.use_metric_units = 1;
#endif
#endif
	
	// Read calibration values from info memory
	read_calibration_values();
#ifdef CONFIG_ALTI_ACCUMULATOR
	// By default, don't have the altitude accumulator running
	alt_accum_enable = 0;
#endif
	
	
	#ifdef CONFIG_INFOMEM
	if(infomem_ready()==-2)
	{
		infomem_init(INFOMEM_C, INFOMEM_C+2*INFOMEM_SEGMENT_SIZE);
	}
	#endif
	
	// Set system time to default value
	reset_clock();
	
	// Set date to default value
	reset_date();
	
	#ifdef CONFIG_SIDEREAL
	reset_sidereal_clock();
	#endif
	
	#ifdef CONFIG_ALARM
	// Set alarm time to default value 
	reset_alarm();
	#endif
	
	// Set buzzer to default value
	reset_buzzer();
	
#ifdef CONFIG_STOP_WATCH
	// Reset stopwatch
	reset_stopwatch();
#endif
	
	// Reset altitude measurement
#ifdef CONFIG_ALTITUDE
	reset_altitude_measurement();
#endif
	
	#ifdef FEATURE_PROVIDE_ACCEL
	// Reset acceleration measurement
	reset_acceleration();
	#endif
	
	// Reset BlueRobin stack
	//pfs
	#ifndef ELIMINATE_BLUEROBIN 
	reset_bluerobin();
	#endif

#ifdef CONFIG_EGGTIMER
	init_eggtimer(); // Initialize eggtimer
#endif

#ifdef CONFIG_PROUT
        reset_prout();
#endif

#ifdef CONFIG_PHASE_CLOCK
	// default program
	sPhase.program = 0;
#endif

	// Reset SimpliciTI stack
	reset_rf();
	
	// Reset temperature measurement 
	reset_temp_measurement();

	#ifdef CONFIG_BATTERY
	// Reset battery measurement
	reset_batt_measurement();
	battery_measurement();
	#endif
}
Esempio n. 8
0
void make_watch_go(ClickRecognizerRef recognizer, Window *window) {
    window_stack_push(&main_window, true);
    reset_stopwatch(false);
}
Esempio n. 9
0
void window_appear(Window *window) {
    reset_stopwatch(false);
}
Esempio n. 10
0
// *************************************************************************************************
// @fn          init_global_variables
// @brief       Initialize global variables.
// @param       none
// @return      none
// *************************************************************************************************
void init_global_variables(void)
{
    // --------------------------------------------
    // Apply default settings

    // set menu pointers to default menu items
    ptrMenu_L1 = &menu_L1_Time;
    //      ptrMenu_L1 = &menu_L1_Alarm;
    //      ptrMenu_L1 = &menu_L1_Temperature;
    //      ptrMenu_L1 = &menu_L1_Altitude;
    //      ptrMenu_L1 = &menu_L1_Acceleration;
    ptrMenu_L2 = &menu_L2_Date;
    //      ptrMenu_L2 = &menu_L2_Stopwatch;
    //      ptrMenu_L2 = &menu_L2_Battery;
    //      ptrMenu_L2 = &menu_L2_Acc;
    //      ptrMenu_L2 = &menu_L2_Ppt;
    //      ptrMenu_L2 = &menu_L2_Sync;
    //      ptrMenu_L2 = &menu_L2_RFBSL;

    // Assign LINE1 and LINE2 display functions
    fptr_lcd_function_line1 = ptrMenu_L1->display_function;
    fptr_lcd_function_line2 = ptrMenu_L2->display_function;

    // Init system flags
    button.all_flags = 0;
    sys.all_flags = 0;
    request.all_flags = 0;
    display.all_flags = 0;
    message.all_flags = 0;

    // Force full display update when starting up
    display.flag.full_update = 1;

#ifndef ISM_US
    // Use metric units when displaying values
    sys.flag.use_metric_units = 1;
#endif

    // Read calibration values from info memory
    read_calibration_values();

    // Set system time to default value
    reset_clock();

    // Set date to default value
    reset_date();

    // Set alarm time to default value
    reset_alarm();

    // Set buzzer to default value
    reset_buzzer();

    // Reset stopwatch
    reset_stopwatch();

    // Reset altitude measurement
    reset_altitude_measurement();

    // Reset acceleration measurement
    reset_acceleration();

#ifdef BLUEROBIN    
    // Reset BlueRobin stack
    reset_bluerobin();
#endif
    // Reset SimpliciTI stack
    reset_rf();

    // Reset temperature measurement
    reset_temp_measurement();

    // Reset battery measurement
    reset_batt_measurement();
    battery_measurement();
}