PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 23, 2007 12:03 am |
|
|
I'm not sure exactly what you're asking for. Maybe this will help.
Here is demo program which displays some LCD menu strings
that are stored in structures, in a 'const' array.
The program was run in the MPLAB simulator. The output was sent
to 'UART1' and displayed in the Output Window as shown below:
Code: |
Menu 1
Menu 1, Line 2
sub-Menu 1A
1A Line 2
sub-Menu 1B
1B Line 2
Menu 2
Menu 2, Line 2
sub-Menu 2A
2A Line 2
sub-Menu 2B
2B Line 2
sub-Menu 2C
2C Line 2
Menu 3
Menu 3, Line 2
sub-Menu 3A
3A Line 2
sub-Menu 3B
3B Line 2
sub-Menu 3C
3C Line 2
sub-Menu 3D
3D Line 2
Menu 4
Menu 4, Line 2
sub-Menu 4A
4A Line 2
sub-Menu 4B
4B Line 2
|
Code: |
#include <18F452.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
typedef struct
{
char menu_type;
char menu_function_index;
char line1[17]; // For a 16x2 LCD
char line2[17];
}menu_t;
#define MAX_INDEX 15
// The PCH compiler allows const arrays larger than 256
// ROM words, so it's much better than PCM for this purpose.
const menu_t menu_screens[MAX_INDEX] =
{
{0, 1, "Menu 1", "Menu 1, Line 2"},
{1, 2, " sub-Menu 1A", " 1A Line 2"},
{2, 3, " sub-Menu 1B", " 1B Line 2"},
{0, 1, "Menu 2", "Menu 2, Line 2"},
{1, 2, " sub-Menu 2A", " 2A Line 2"},
{2, 3, " sub-Menu 2B", " 2B Line 2"},
{3, 4, " sub-Menu 2C", " 2C Line 2"},
{0, 1, "Menu 3", "Menu 3, Line 2"},
{1, 2, " sub-Menu 3A", " 3A Line 2"},
{2, 3, " sub-Menu 3B", " 3B Line 2"},
{3, 4, " sub-Menu 3C", " 3C Line 2"},
{4, 5, " sub-Menu 3D", " 3D Line 2"},
{0, 1, "Menu 4", "Menu 4, Line 2"},
{1, 2, " sub-Menu 4A", " 4A Line 2"},
{2, 3, " sub-Menu 4B", " 4B Line 2"}
};
void display_menu(int8 index);
//====================================
void main()
{
int8 i;
for(i = 0; i < MAX_INDEX; i++)
{
display_menu(i);
printf("\r");
}
while(1);
}
//===============================
// FUNCTIONS
//-----------------------------------------------
void display_menu(int8 index)
{
printf("%s\r", menu_screens[index].line1);
printf("%s", menu_screens[index].line2);
} |
|
|