// ************************************************************************************************* // @fn display_update // @brief Process display flags and call LCD update routines. // @param none // @return none // ************************************************************************************************* void display_update(void) { unsigned char line; unsigned char string[8]; // --------------------------------------------------------------------- // Call Line1 display function if (display.flag.full_update || display.flag.line1_full_update) { clear_line(LINE1); fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_FULL); } else if (ptrMenu_L1->display_update()) { // Update line1 only when new data is available fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_PARTIAL); } // --------------------------------------------------------------------- // If message text should be displayed on Line2, skip normal update if (message.flag.show) { line = LINE2; // Select message to display if (message.flag.type_locked) memcpy(string, " LO?T", 6); else if (message.flag.type_unlocked) memcpy(string, " OPEN", 6); // Clear previous content clear_line(line); fptr_lcd_function_line2(line, DISPLAY_LINE_CLEAR); // Next second tick erases message and repaints original screen content message.all_flags = 0; message.flag.erase = 1; } // --------------------------------------------------------------------- // Call Line2 display function else if (display.flag.full_update || display.flag.line2_full_update) { clear_line(LINE2); fptr_lcd_function_line2(LINE2, DISPLAY_LINE_UPDATE_FULL); } else if (ptrMenu_L2->display_update() && !message.all_flags) { // Update line2 only when new data is available fptr_lcd_function_line2(LINE2, DISPLAY_LINE_UPDATE_PARTIAL); } // Clear display flag display.all_flags = 0; }
// ************************************************************************************************* // @fn menu_skip_next // @brief skip to next menu item // @param line line to skip in // @return none // ************************************************************************************************* void menu_skip_next(line_t line) { if(line==LINE1) { // Clean up display before activating next menu item fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR); if(++menu_L1_position>=menu_L1_size) { menu_L1_position=0; } // Go to next menu entry ptrMenu_L1 = menu_L1[menu_L1_position]; // Assign new display function fptr_lcd_function_line1 = ptrMenu_L1->display_function; } else if(line==LINE2) { // Clean up display before activating next menu item fptr_lcd_function_line2(LINE2, DISPLAY_LINE_CLEAR); if(++menu_L2_position>=menu_L2_size) menu_L2_position=0; // Go to next menu entry ptrMenu_L2 = menu_L2[menu_L2_position]; // Assign new display function fptr_lcd_function_line2 = ptrMenu_L2->display_function; } }
// ************************************************************************************************* // @fn sx_altitude // @brief Altitude direct function. Sx restarts altitude measurement. // @param u8 line LINE1, LINE2 // @return none // ************************************************************************************************* void sx_altitude(u8 line) { sAlt.mode++; if (sAlt.mode >= ALTITUDE_LAST_MODE) { sAlt.mode = ALTITUDE_REGULAR; } display.flag.line1_full_update = 1; if (sAlt.mode == ALTITUDE_SKYDIVING) { fptr_lcd_function_line2(LINE2, DISPLAY_LINE_CLEAR); ptrMenu_L2 = &menu_L2_Altitude; display.flag.line2_full_update = 1; fptr_lcd_function_line2 = ptrMenu_L2->display_function; } else if (ptrMenu_L2 != menu_L2[menu_L2_position]) { fptr_lcd_function_line2(LINE2, DISPLAY_LINE_CLEAR); ptrMenu_L2 = menu_L2[menu_L2_position]; display.flag.line2_full_update = 1; fptr_lcd_function_line2 = ptrMenu_L2->display_function; } }
// ************************************************************************************************* // @fn display_update // @brief Process display flags and call LCD update routines. // @param none // @return none // ************************************************************************************************* void display_update(void) { u8 line; u8 string[8]; // --------------------------------------------------------------------- // Call Line1 display function if (display.flag.full_update || display.flag.line1_full_update) { clear_line(LINE1); fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_FULL); } else if (ptrMenu_L1->display_update()) { // Update line1 only when new data is available fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_PARTIAL); } // --------------------------------------------------------------------- // If message text should be displayed on Line2, skip normal update if (message.flag.show) { line = LINE2; // Select message to display if (message.flag.type_locked) memcpy(string, " LO?T", 6); else if (message.flag.type_unlocked) memcpy(string, " OPEN", 6); else if (message.flag.type_lobatt) memcpy(string, "LOBATT", 6); else if (message.flag.type_alarm_on) { memcpy(string, " ON", 4); line = LINE1; } else if (message.flag.type_alarm_off) { memcpy(string, " OFF", 4); line = LINE1; } // Clear previous content clear_line(line); fptr_lcd_function_line2(line, DISPLAY_LINE_CLEAR); if (line == LINE2) display_chars(LCD_SEG_L2_5_0, string, SEG_ON); else display_chars(LCD_SEG_L1_3_0, string, SEG_ON); // Next second tick erases message and repaints original screen content message.all_flags = 0; message.flag.erase = 1; } // --------------------------------------------------------------------- // Call Line2 display function else if (display.flag.full_update || display.flag.line2_full_update) { clear_line(LINE2); fptr_lcd_function_line2(LINE2, DISPLAY_LINE_UPDATE_FULL); } else if (ptrMenu_L2->display_update() && !message.all_flags) { // Update line2 only when new data is available fptr_lcd_function_line2(LINE2, DISPLAY_LINE_UPDATE_PARTIAL); } // --------------------------------------------------------------------- // Restore blinking icons (blinking memory is cleared when calling set_value) if (display.flag.full_update) { /* if (is_bluerobin() == BLUEROBIN_CONNECTED) { // Turn on beeper icon to show activity display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_OFF); display_symbol(LCD_ICON_BEEPER2, SEG_ON_BLINK_OFF); display_symbol(LCD_ICON_BEEPER3, SEG_ON_BLINK_OFF); } */ } // Clear display flag display.all_flags = 0; }
// ************************************************************************************************* // @fn wakeup_event // @brief Process external / internal wakeup events. // @param none // @return none // ************************************************************************************************* void wakeup_event(void) { // Enable idle timeout sys.flag.idle_timeout_enabled = 1; // If buttons are locked, only display "buttons are locked" message if (button.all_flags && sys.flag.lock_buttons) { // Show "buttons are locked" message synchronously with next second tick if (!(BUTTON_NUM_IS_PRESSED && BUTTON_DOWN_IS_PRESSED)) { message.flag.prepare = 1; message.flag.type_locked = 1; } // Clear buttons button.all_flags = 0; } // Process long button press event (while button is held) else if (button.flag.star_long) { // Clear button event button.flag.star_long = 0; // Call sub menu function ptrMenu_L1->mx_function(LINE1); // Set display update flag display.flag.full_update = 1; } else if (button.flag.num_long) { // Clear button event button.flag.num_long = 0; // Call sub menu function ptrMenu_L2->mx_function(LINE2); // Set display update flag display.flag.full_update = 1; } // Process single button press event (after button was released) else if (button.all_flags) { // M1 button event --------------------------------------------------------------------- // (Short) Advance to next menu item if (button.flag.star) { // Clean up display before activating next menu item fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR); // Go to next menu entry ptrMenu_L1 = ptrMenu_L1->next; // Assign new display function fptr_lcd_function_line1 = ptrMenu_L1->display_function; // Set Line1 display update flag display.flag.line1_full_update = 1; // Clear button flag button.flag.star = 0; } // NUM button event --------------------------------------------------------------------- // (Short) Advance to next menu item else if (button.flag.num) { // Clear rfBSL confirmation flag rfBSL_button_confirmation = 0; // Clean up display before activating next menu item fptr_lcd_function_line2(LINE2, DISPLAY_LINE_CLEAR); // Go to next menu entry ptrMenu_L2 = ptrMenu_L2->next; // Assign new display function fptr_lcd_function_line2 = ptrMenu_L2->display_function; // Set Line2 display update flag display.flag.line2_full_update = 1; // Clear button flag button.flag.num = 0; } // UP button event --------------------------------------------------------------------- // Activate user function for Line1 menu item else if (button.flag.up) { // Call direct function ptrMenu_L1->sx_function(LINE1); // Set Line1 display update flag display.flag.line1_full_update = 1; // Clear button flag button.flag.up = 0; } // DOWN button event --------------------------------------------------------------------- // Activate user function for Line2 menu item else if (button.flag.down) { if (ptrMenu_L2 == &menu_L2_RFBSL) { } // Call direct function ptrMenu_L2->sx_function(LINE2); // Set Line1 display update flag display.flag.line2_full_update = 1; // Clear button flag button.flag.down = 0; } } // Process internal events if (sys.all_flags) { // Idle timeout --------------------------------------------------------------------- if (sys.flag.idle_timeout) { // Clear timeout flag sys.flag.idle_timeout = 0; // Clear display clear_display(); // Set display update flags display.flag.full_update = 1; } } // Disable idle timeout sys.flag.idle_timeout_enabled = 0; }