CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

const structs

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 23, 2007 12:03 am     Reply with quote

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);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group