• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD menu in C?

Status
Not open for further replies.

picstudent

New Member
Hello
Please help me to locate some examples or details for implementing a LCD based menu using C language and PIC 18 MCU.

Thanks
 

Noggin

Member
Code:
/* global variables */
Uint8 display_buffer[NBR_LINES][NBR_CHARS_PER_LINE];
Int8 selected_item;

void Init_Menu( void )
{
Uint8 line;

   // Init the display lines with whatever you want them to say
   for (line = 0; line < NBR_LINES; line++)
      sprintf(display_buffer[line], "  Menu Item %d", line);
}

void Service_Selected_Item( Uint8 cmd )
{
   // This function allows the user to change the selected menu item
   switch (cmd)
   {
      case INCREMENT_SELECTION:
         selected_item++;
         if (selected_item > NBR_LINES)
            selected_item = 0;
         break;
      
      case DECREMENT_SELECTION:
         selected_item--;
         if (selected_item < 0)
            selected_item = NBR_LINES - 1;
         break;
   }
}

void Service_Display( cmd )
{
   switch ( cmd )
   {
      case DRAW_MENU:
         Init_Menu();
         /* Each line now contains some text that the user can read to decide what he wants to select.  Insert a character into the appropriate line to allow the user to know which item is selected */
         display_buffer[selected_item][0] = '>';
         Update_Display();
         break;

      case SOME_OTHER_DISPLAY_STATE:
         break;
   }
}
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top