Jump to content

MIOS_LCD_PrintCString problems


Crypto71
 Share

Recommended Posts

Hi,

I guess this must have been asked numerous times, so sorry for me asking this again...

What I would like to do is this:

When I move or turn a fader or pot, I want to display a short message on the LED that says which pot was turned. So I have created a table that contains 64 message texts to displaying a short info on LED about which AIN pot was moved.

For doing that I started adjusting the ain64_din128_dout128_v2_0 main.c file.

The messages are stored in a variable like this:

code char * pot_text[]={    
    "U. Draw. 16\0"   , // 1 - Drawbar 1
    "U. Draw. 5 1/3\0", // 2 - Drawbar 2
    "U. Draw. 8\0"    , // 3 - Drawbar 3
    "U. Draw. 4\0"    , // 4 - Drawbar 4
    "U. Draw. 2 2/3\0", // 5 - Drawbar 5
    };
Call to display text:
MIOS_LCD_CursorSet(0x00);
MIOS_LCD_PrintCString(pot_text[last_ain_pin]);

When I try to implement the variable pot_text as a global variable inside main.c, it does not work. The displayed text is garbled and consists of garbage. But when I declare the pot_text variable as a local variable in DISPLAY_tick it works if I have a rather short pot_text table (not 64 entries but maybe about entries).

Is there a limit in size for variables for MIOS_LCD_PrintCString?

What is the recommended way for creating a message text table and displaying one of these messages on the LCD?

Thx for any help,

Crypto.

Link to comment
Share on other sites

Here's what works for me:

// the "\0" character gets added automatically, so defining
// a length of 8 gives you 7 characters to work with             
const char strings[3][8] = {"SomeStr", "MoreStf", "1234567"};

// ...

void DISPLAY_Init(void) __wparam
{
  MIOS_LCD_Clear();
  MIOS_LCD_CursorSet(0x00);
  MIOS_LCD_PrintCString(strings[0]);
  MIOS_LCD_CursorSet(0x28);
  MIOS_LCD_PrintCString(strings[2]);
}[/code]

I fixed the length of the two dimensions of the array for two reasons:

1) it doesn't work like that if you don't

2) the compiler generates warnings if you mess up the indexes/indices

Link to comment
Share on other sites

Hi again,

thanks a lot for Your help. It is working now  :D

I added the "constant" type and also increased the size of the array by one to implement the /0 null termination of the chars.

In the call to MIOS_LCD_PrintCString I added a (code const char*) type conversion to avoid any compiler warnings concerning wrong types.

Regards,

Crypto.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...