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