Beispiel #1
0
// *************************************************************************************************
// @fn          reset_altitude_measurement
// @brief       Reset altitude measurement.
// @param       none
// @return      none
// *************************************************************************************************
void reset_altitude_measurement(void)
{
   // Set default values
   sAlt.on = 0;
   sAlt.altitude = 0;
   sAlt.temperature_C = 0;
   sAlt.temperature_C_offset = 0;

   // Pressure sensor ok?
   if (ps_ok)
   {
      // Initialise pressure table
      init_pressure_table();

      // Do single conversion
      start_altitude_measurement();
      stop_altitude_measurement();

      // Apply calibration offset and recalculate pressure table
      if (sAlt.altitude_offset != 0)
      {
         sAlt.altitude += sAlt.altitude_offset;
         update_pressure_table(sAlt.altitude, sAlt.pressure, sAlt.temperature_K);
      }
   }
}
Beispiel #2
0
// *************************************************************************************************
// @fn          reset_altitude_measurement
// @brief       Reset altitude measurement.
// @param       none
// @return      none
// *************************************************************************************************
void reset_altitude_measurement(void)
{
    // Menu item is not visible
    sAlt.state 		= MENU_ITEM_NOT_VISIBLE;

    // Clear timeout counter
    sAlt.timeout	= 0;

    // Set default altitude value
    sAlt.altitude		= 0;

    // Pressure sensor ok?
    if (ps_ok)
    {
        // Initialise pressure table
        init_pressure_table();

        // Do single conversion
        start_altitude_measurement();
        stop_altitude_measurement();

        // Apply calibration offset and recalculate pressure table
        if (sAlt.altitude_offset != 0)
        {
            sAlt.altitude += sAlt.altitude_offset;
            update_pressure_table(sAlt.altitude, sAlt.pressure, sAlt.temperature);
        }
    }
}
// *************************************************************************************************
// @fn          reset_altitude_measurement
// @brief       Reset altitude measurement.
// @param       none
// @return      none
// *************************************************************************************************
void reset_altitude_measurement(void)
{
    // Show altitude
    PressDisplay = DISPLAY_DEFAULT_VIEW;
    // Offset for Ambient pressure
    AmbientPressureOffset = AMBIENT_PRESSURE_OFFSET_DEFAULT;
    
    // Menu item is not visible
    sAlt.state      = MENU_ITEM_NOT_VISIBLE;

    // Clear timeout counter
    sAlt.timeout    = 0;
    
    // Set default altitude value
    sAlt.altitude       = 0;
        
    // Pressure sensor ok?
    if (ps_ok)
    {
        // Initialise pressure table
        init_pressure_table();
        
        // Do single conversion
        start_altitude_measurement();
        stop_altitude_measurement();    

        // Apply calibration offset and recalculate pressure table
        if (sAlt.altitude_offset != 0)
        {
            sAlt.altitude += sAlt.altitude_offset;
            update_pressure_table(sAlt.altitude, sAlt.pressure, sAlt.temperature);
        }
    }
}
Beispiel #4
0
// *************************************************************************************************
// @fn          mx_altitude
// @brief       Mx button handler to set the altitude offset.
// @param       u8 line		LINE1
// @return      none
// *************************************************************************************************
void mx_altitude(u8 line)
{
	s32 altitude = sAlt.altitude;
	s32 limit_high = 9000, limit_low = -500;
	u8 units_symbol;

	if (sAlt.mode == ALTITUDE_SKYDIVING) {
		sAlt.altitude = 0;
		update_pressure_table(0, sAlt.pressure);
		display.flag.line1_full_update = 1;
	} else {
		// Clear display
		clear_display_all();

#ifdef CONFIG_ALTITUDE_UNIT_SETTABLE
		display_symbol(sys.flag.use_metric_units ? LCD_UNIT_L1_M : LCD_UNIT_L1_FT, SEG_ON);
#elif defined(CONFIG_ALTITUDE_UNIT_METERS)
		display_symbol(LCD_UNIT_L1_M, SEG_ON);
#elif defined(CONFIG_ALTITUDE_UNIT_FEET)
		display_symbol(LCD_UNIT_L1_FT, SEG_ON);
#endif

		// Loop values until all are set or user breaks	set
		while(1)
		{
			// Idle timeout: exit without saving
			if (sys.flag.idle_timeout) break;

			// Button STAR (short): save, then exit
			if (button.flag.star)
			{
				update_pressure_table(altitude, sAlt.pressure);
				display.flag.line1_full_update = 1;
				break;
			}

			// Set current altitude - offset is set when leaving function
			set_value(&altitude, 4, 3, limit_low, limit_high,
				  SETVALUE_DISPLAY_VALUE + SETVALUE_FAST_MODE + SETVALUE_DISPLAY_ARROWS, LCD_SEG_L1_3_0, display_value1);
		}

		display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF);
	}

	// Clear button flags
	button.all_flags = 0;
}
// *************************************************************************************************
// @fn          SetMyDefaults
// @brief       Set my default preferences
// @param       none
// @return      none
// *************************************************************************************************
void SetMyDefaults(void)
{
    DailyCorr               = MY_DAILY_CORRECTION_SEC;
    WeeklyCorr              = MY_WEEKLY_CORRECTION_SEC;
    DST_AutoFlag            = 1;    // DST_AUTO

    AmbientPressureOffset   = MY_AMBIENT_PRESSURE_OFFSET;
    sAlt.altitude           = MY_ALTITUDE;
    // Update pressure table
    update_pressure_table(sAlt.altitude, sAlt.pressure, sAlt.temperature);
    
    //Set cdtimer to a 6:30 minute default
    memcpy(scdtimer.defaultTime, "000630", sizeof(scdtimer.time));
    reset_cdtimer();
    
    // Set temperature offset
    sTemp.offset += MY_TEMPERATURE_OFFSET;
    
    // Automatic reset after Unified Clock System failed
    sUcsResetHandling.status = UCSRESET_AUTO;
}
Beispiel #6
0
// *************************************************************************************************
// @fn          simpliciti_sync_decode_ap_cmd_callback
// @brief       For SYNC mode only: Decode command from access point and trigger actions. 
// @param       none
// @return      none
// *************************************************************************************************
void simpliciti_sync_decode_ap_cmd_callback(void)
{
	u8 i;
	s16 t1, offset;
	
	// Default behaviour is to send no reply packets
	simpliciti_reply_count = 0;
	
	switch (simpliciti_data[0])
	{
		case SYNC_AP_CMD_NOP:			break;

		case SYNC_AP_CMD_GET_STATUS:	// Send watch parameters
										simpliciti_data[0]  = SYNC_ED_TYPE_STATUS;
										// Send single reply packet
										simpliciti_reply_count = 1;
										break;

		case SYNC_AP_CMD_SET_WATCH:		// Set watch parameters
										sys.flag.use_metric_units = (simpliciti_data[1] >> 7) & 0x01;
										sTime.hour 			= simpliciti_data[1] & 0x7F;
										sTime.minute 		= simpliciti_data[2];
										sTime.second 		= simpliciti_data[3];
										sDate.year 			= (simpliciti_data[4]<<8) + simpliciti_data[5];
										sDate.month 		= simpliciti_data[6];
										sDate.day 			= simpliciti_data[7];
										// Set temperature and temperature offset
										t1 = (s16)((simpliciti_data[10]<<8) + simpliciti_data[11]);
										offset = t1 - (sAlt.temperature_C - sAlt.temperature_C_offset);
										sAlt.temperature_C_offset = offset;	
										sAlt.temperature_C = t1;									
										// Set altitude
										sAlt.altitude = (s16)((simpliciti_data[12]<<8) + simpliciti_data[13]);
										update_pressure_table(sAlt.altitude, sAlt.pressure, sAlt.temperature_K);
										// Data logging mode
										sDatalog.mode = simpliciti_data[14];
										// Data logging interval
										sDatalog.interval = simpliciti_data[15];
										break;
												
		case SYNC_AP_CMD_GET_MEMORY_BLOCKS_MODE_1:	
										// Send sequential packets out in a burst 
										simpliciti_data[0]  = SYNC_ED_TYPE_MEMORY;
										// Get burst start and end packet
										burst_start = (simpliciti_data[1]<<8)+simpliciti_data[2];
										burst_end   = (simpliciti_data[3]<<8)+simpliciti_data[4];
										// Set burst mode
										burst_mode = 1;
										// Number of packets to send
										simpliciti_reply_count = burst_end - burst_start + 1;
										break;

		case SYNC_AP_CMD_GET_MEMORY_BLOCKS_MODE_2:	
										// Send specified packets out in a burst 
										simpliciti_data[0]  = SYNC_ED_TYPE_MEMORY;
										// Store the requested packets
										for (i=0; i<BM_SYNC_BURST_PACKETS_IN_DATA; i++)
										{
											burst_packet[i] = (simpliciti_data[i*2+1]<<8)+simpliciti_data[i*2+2];
										}
										// Set burst mode
										burst_mode = 2;
										// Number of packets to send
										simpliciti_reply_count = BM_SYNC_BURST_PACKETS_IN_DATA;
										break;
		
		case SYNC_AP_CMD_ERASE_MEMORY:	// Erase data logger memory
										for (i=DATALOG_PAGE_START; i<=DATALOG_PAGE_END; i++)
										{
											flash_erase_page(i);
										}	
										sDatalog.wptr = (u16*)DATALOG_MEMORY_START;
										sDatalog.flags.flag.memory_full = 0;
										break;
										
		case SYNC_AP_CMD_EXIT:			// Exit sync mode
										simpliciti_flag |= SIMPLICITI_TRIGGER_STOP;
										break;										
	}
	
}
Beispiel #7
0
// *************************************************************************************************
// @fn          mx_altitude
// @brief       Mx button handler to set the altitude offset.
// @param       u8 line		LINE1
// @return      none
// *************************************************************************************************
void mx_altitude(u8 line)
{
    s32 altitude;
    s32	limit_high, limit_low;

    // Clear display
    clear_display_all();
#ifdef CONFIG_ALTI_ACCUMULATOR
    // Display "ALt" on top line
    display_chars(LCD_SEG_L1_3_0, (u8*)"ALT ", SEG_ON);
    clear_line(LINE2);
#endif

    // Set lower and upper limits for offset correction
#ifdef CONFIG_METRIC_ONLY
    display_symbol(LCD_UNIT_L1_M, SEG_ON);

    // Convert global variable to local variable
    altitude  = sAlt.altitude;

    // Limits for set_value function
    limit_low = -100;
    limit_high = 9000;
#else
    if (sys.flag.use_metric_units)
    {
        // Display "m" symbol
        display_symbol(LCD_UNIT_L1_M, SEG_ON);

        // Convert global variable to local variable
        altitude  = sAlt.altitude;

        // Limits for set_value function
        limit_low = -100;
        limit_high = 9000;
    }
    else // English units
    {
        // Display "ft" symbol
        display_symbol(LCD_UNIT_L1_FT, SEG_ON);

        // Convert altitude in meters to feet
        altitude = sAlt.altitude;

        // Convert from meters to feet
        altitude = convert_m_to_ft(altitude);

        // Limits for set_value function
        limit_low = -500;
#ifdef CONFIG_ALTI_ACCUMULATOR
        limit_high = 33000;
#else
        limit_high = 9999;
#endif
    }
#endif
    // Loop values until all are set or user breaks	set
    while(1)
    {
        // Idle timeout: exit without saving
        if (sys.flag.idle_timeout) break;

        // Button STAR (short): save, then exit
        if (button.flag.star)
        {
            // When using English units, convert ft back to m before updating pressure table
#ifndef CONFIG_METRIC_ONLY
            if (!sys.flag.use_metric_units) altitude = convert_ft_to_m((s16)altitude);
#endif

            // Update pressure table
            update_pressure_table((s16)altitude, sAlt.pressure, sAlt.temperature);

            // Set display update flag
            display.flag.line1_full_update = 1;

            break;
        }

        // Set current altitude - offset is set when leaving function
#ifdef CONFIG_ALTI_ACCUMULATOR
        // use 2nd line as it displays larger numbers
        set_value(&altitude, 5, 4, limit_low, limit_high, SETVALUE_DISPLAY_VALUE + SETVALUE_FAST_MODE + SETVALUE_DISPLAY_ARROWS, LCD_SEG_L2_4_0, display_value1);
#else
        set_value(&altitude, 4, 3, limit_low, limit_high, SETVALUE_DISPLAY_VALUE + SETVALUE_FAST_MODE + SETVALUE_DISPLAY_ARROWS, LCD_SEG_L1_3_0, display_value1);
#endif
    }

    // Clear button flags
    button.all_flags = 0;
}
// *************************************************************************************************
// @fn          simpliciti_sync_decode_ap_cmd_callback
// @brief       For SYNC mode only: Decode command from access point and trigger actions.
// @param       none
// @return      none
// *************************************************************************************************
void simpliciti_sync_decode_ap_cmd_callback(void)
{
    u8 i;
    s16 t1, offset;

    // Default behaviour is to send no reply packets
    simpliciti_reply_count = 0;

    switch (simpliciti_data[0])
    {
        case SYNC_AP_CMD_NOP:
            break;

        case SYNC_AP_CMD_GET_STATUS: // Send watch parameters
            simpliciti_data[0] = SYNC_ED_TYPE_STATUS;
            // Send single reply packet
            simpliciti_reply_count = 1;
            break;

        case SYNC_AP_CMD_SET_WATCH:  // Set watch parameters
            sys.flag.use_metric_units = (simpliciti_data[1] >> 7) & 0x01;
            sTime.hour = simpliciti_data[1] & 0x7F;
            sTime.minute = simpliciti_data[2];
            sTime.second = simpliciti_data[3];
            sDate.year = (simpliciti_data[4] << 8) + simpliciti_data[5];
            sDate.month = simpliciti_data[6];
            sDate.day = simpliciti_data[7];
            sAlarm.hour = simpliciti_data[8];
            sAlarm.minute = simpliciti_data[9];
            // Set temperature and temperature offset
            t1 = (s16) ((simpliciti_data[10] << 8) + simpliciti_data[11]);
            offset = t1 - (sTemp.degrees - sTemp.offset);
            sTemp.offset = offset;
            sTemp.degrees = t1;
            // Set altitude
            sAlt.altitude = (s16) ((simpliciti_data[12] << 8) + simpliciti_data[13]);
            update_pressure_table(sAlt.altitude, sAlt.pressure, sAlt.temperature);

            display_chars(LCD_SEG_L2_5_0, (u8 *) "  DONE", SEG_ON);
            sRFsmpl.display_sync_done = 1;
            break;

        case SYNC_AP_CMD_GET_MEMORY_BLOCKS_MODE_1:
            // Send sequential packets out in a burst
            simpliciti_data[0] = SYNC_ED_TYPE_MEMORY;
            // Get burst start and end packet
            burst_start = (simpliciti_data[1] << 8) + simpliciti_data[2];
            burst_end = (simpliciti_data[3] << 8) + simpliciti_data[4];
            // Set burst mode
            burst_mode = 1;
            // Number of packets to send
            simpliciti_reply_count = burst_end - burst_start;
            break;

        case SYNC_AP_CMD_GET_MEMORY_BLOCKS_MODE_2:
            // Send specified packets out in a burst
            simpliciti_data[0] = SYNC_ED_TYPE_MEMORY;
            // Store the requested packets
            for (i = 0; i < BM_SYNC_BURST_PACKETS_IN_DATA; i++)
            {
                burst_packet[i] = (simpliciti_data[i * 2 + 1] << 8) + simpliciti_data[i * 2 + 2];
            }
            // Set burst mode
            burst_mode = 2;
            // Number of packets to send
            simpliciti_reply_count = BM_SYNC_BURST_PACKETS_IN_DATA;
            break;

        case SYNC_AP_CMD_ERASE_MEMORY: // Erase data logger memory
            break;

        case SYNC_AP_CMD_EXIT:         // Exit sync mode
            simpliciti_flag |= SIMPLICITI_TRIGGER_STOP;
            break;
    }
}
// *************************************************************************************************
// @fn          mx_altitude
// @brief       Mx button handler to set the altitude offset.
// @param       u8 line         LINE1
// @return      none
// *************************************************************************************************
void mx_altitude(u8 line)
{
    u8 select;
    s32 altitude;
    s32 limit_high, limit_low;
    s32 offset;
    
    select = 0;  
    
    // Clear display
    clear_display_all();

    offset = sAlt.pressure_offset;
    // Set lower and upper limits for offset correction
    if (sys.flag.use_metric_units)
    {
        // Display "m" symbol
        display_symbol(LCD_UNIT_L1_M, SEG_ON);

        // Convert global variable to local variable
        altitude = sAlt.altitude;        
        // Limits for set_value function
        limit_low = -100;
        limit_high = 4000;
    }
    else                        // English units
    {
        // Display "ft" symbol
        display_symbol(LCD_UNIT_L1_FT, SEG_ON);

        // Convert altitude in meters to feet
        altitude = sAlt.altitude;

        // Convert from meters to feet
        altitude = convert_m_to_ft(altitude);

        // Limits for set_value function
        limit_low = -500;
        limit_high = 9999;
    }

    // Loop values until all are set or user breaks set
    while (1)
    {
        // Idle timeout: exit without saving
        if (sys.flag.idle_timeout)
            break;

        // Button STAR (short): save, then exit
        if (button.flag.star)
        {
            // When using English units, convert ft back to m before updating pressure table
            if (!sys.flag.use_metric_units)
                altitude = convert_ft_to_m((s16) altitude);

            // Update pressure table
            update_pressure_table((s16) altitude, sAlt.pressure, sAlt.temperature);
            sAlt.pressure_offset = offset;
            
            // Set display update flag
            display.flag.line1_full_update = 1;

            break;
        }
        switch (select)
         {
         case 0:
           // Set current altitude - offset is set when leaving function
           if (sys.flag.use_metric_units)
            {
              // Display "m" symbol
              display_symbol(LCD_UNIT_L1_M, SEG_ON);
            }
           else
           {
             //        // Display "ft" symbol
              display_symbol(LCD_UNIT_L1_FT, SEG_ON);
           }
           display_symbol(LCD_UNIT_L1_PER_H, SEG_OFF);  
           display_chars(LCD_SEG_L2_5_0, (u8 *) "   ALT", SEG_ON);
           set_value(&altitude, 4, 3, limit_low, limit_high, SETVALUE_DISPLAY_VALUE +
                    SETVALUE_FAST_MODE + SETVALUE_DISPLAY_ARROWS + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_0,
                    display_value);           
           select = 1;
           break;
         case 1:
           // Set pressure offset
           display_symbol(LCD_UNIT_L1_PER_H, SEG_ON);                      
           display_symbol(LCD_UNIT_L1_M, SEG_OFF);
           display_symbol(LCD_UNIT_L1_FT, SEG_OFF);               
           display_chars(LCD_SEG_L2_5_0, (u8 *) " OFFS", SEG_ON);           
          set_value(&offset, 4, 3, -100, 100, SETVALUE_DISPLAY_VALUE +
                  SETVALUE_FAST_MODE + SETVALUE_DISPLAY_ARROWS + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_0,
                  display_value);           
           select = 0;
           break;           
         }        
    }

    // Clear button flags
    button.all_flags = 0;
}