// ************************************************************************************************* // @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 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; }