void menu_main(void) { static uint8_t main_cursor = LINE0; // These are now static so as to remember the main menu position static uint8_t main_temp = 0; static uint8_t old_menu = 0; button = NONE; // Wait until user's finger is off button 1 Wait_BUTTON1(); while(button != BACK) { // Clear buffer before each update clear_buffer(buffer); // Print menu print_menu_frame(0); // Frame for (uint8_t i = 0; i < 4; i++) { LCD_Display_Text(main_top+i,(const unsigned char*)Verdana8,ITEMOFFSET,(uint8_t)pgm_read_byte(&lines[i])); // Lines } print_cursor(main_cursor); // Cursor write_buffer(buffer,1); // Poll buttons when idle poll_buttons(true); // Handle menu changes update_menu(MAINITEMS, MAINSTART, 0, button, &main_cursor, &main_top, &main_temp); // If main menu item has changed, reset sub-menu positions // and flag to sub-menus that positions need to be reset if (main_temp != old_menu) { cursor = LINE0; menu_temp = 0; old_menu = main_temp; menu_flag = 1; } // If ENTER pressed, jump to menu if (button == ENTER) { do_main_menu_item(main_temp); button = NONE; // Wait until user's finger is off button 1 Wait_BUTTON1(); } } }
void menu_main(void) { static uint8_t cursor = LINE0; // These are now static so as to remember the menu position static uint8_t top = MAINSTART; static uint8_t temp = 0; button = NONE; // Wait until user's finger is off button 1 while(BUTTON1 == 0) { _delay_ms(50); } while(button != BACK) { // Clear buffer before each update clear_buffer(buffer); // Print menu print_menu_frame(0); // Frame LCD_Display_Text(top,(prog_uchar*)Verdana8,ITEMOFFSET,LINE0); // First line LCD_Display_Text(top+1,(prog_uchar*)Verdana8,ITEMOFFSET,LINE1); // Second line LCD_Display_Text(top+2,(prog_uchar*)Verdana8,ITEMOFFSET,LINE2); // Third line LCD_Display_Text(top+3,(prog_uchar*)Verdana8,ITEMOFFSET,LINE3); // Fourth line print_cursor(cursor); // Cursor write_buffer(buffer,1); // Poll buttons when idle poll_buttons(); // Handle menu changes update_menu(MAINITEMS, MAINSTART, button, &cursor, &top, &temp); if (button == ENTER) { do_main_menu_item(temp); button = NONE; } } menu_beep(1); _delay_ms(200); }