Ejemplo n.º 1
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();
}
// *************************************************************************************************
// @fn          mx_sync
// @brief       Mx button (STAR button) handler to do some stuff. Works only if SimpliciTI is off!
// @param       u8 line		LINE2
// @return      none
// *************************************************************************************************
void mx_sync(u8 line)
{
 u8 select;
 s32 Tmp;
         
 // Check for running SimpliciTI
 if(sRFsmpl.mode == SIMPLICITI_OFF)
 {   
    // Init value index
    select = 0; 
    
    clear_display_all();
    
    // Loop values until all are set or user breaks set
    while(1) 
    {
        // Idle timeout: exit without saving 
        if (sys.flag.idle_timeout) break;
        
        // NUM Button (short): save, then exit 
        if (button.flag.num) 
        {
            //Set display update flag
            display.flag.full_update = 1;
            break;
        }

        switch (select)
        {
            case 0: // Set "my defaults"
                    Tmp = 0;
                    display_symbol(LCD_SEG_L2_DP, SEG_OFF);
                    display_chars(LCD_SEG_L2_4_0, (u8 *)"MYDEF", SEG_ON);
                    set_value(&Tmp, 0, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_0, display_NO_YES);
                    if(Tmp == 1) { SetMyDefaults(); }
                    select = 1;
                    break;
            case 1: // Clear number storage and unlock storage 
                    Tmp = 0;
                    display_chars(LCD_SEG_L2_4_0, (u8 *)"CLEAR", SEG_ON);
                    set_value(&Tmp, 0, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_0, display_NO_YES);
                    if(Tmp == 1) { reset_number_storage(); }
                    select = 2;
                    break;
            case 2: // Reset watch 
                    Tmp = 0;
                    display_chars(LCD_SEG_L2_4_0, (u8 *)"RESET", SEG_ON);
                    set_value(&Tmp, 0, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_0, display_NO_YES);
                    if(Tmp == 1) { ResetWatch(); }
                    select = 3;
                    break;
            case 3: // Reset Unified Clock System 
                    Tmp = (s32)sUcsResetHandling.status;
                    display_chars(LCD_SEG_L2_4_0, (u8 *)"OSC-R", SEG_ON);
                    set_value(&Tmp, 0, 0, 0, 3, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_0, display_NO_YES_AUTO_MAN);
                    if(Tmp == 1) // YES
                    { 
                        __disable_interrupt();
                        init_ucs();
                        __enable_interrupt();
                        display_symbol(LCD_SYMB_MAX, SEG_OFF);
                    }
                    if(Tmp == 2) { sUcsResetHandling.status = UCSRESET_AUTO; }
                    if(Tmp == 3) { sUcsResetHandling.status = UCSRESET_MAN; }
                    select = 4;
                    break;
            case 4: // Display software version
                    Tmp = 0;
                    display_chars(LCD_SEG_L2_5_0, (u8 *)" S    ", SEG_ON);                   // "S"
                    display_charSegments(LCD_SEG_L2_3, SEG_C+SEG_D+SEG_E+SEG_F, SEG_ON);    // 1/2 "W"
                    display_charSegments(LCD_SEG_L2_2, SEG_B+SEG_C+SEG_D+SEG_E, SEG_ON);    // 1/2 "W"
                    set_value(&Tmp, 0, 0, 0, 3, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_0, display_SW_Version);
                    select = 0;
                    break;
        }
    }
 }
 // Clear button flag
 button.all_flags = 0;
}