Crypto71 Posted February 25, 2008 Report Share Posted February 25, 2008 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. Quote Link to comment Share on other sites More sharing options...
Durisian Posted February 26, 2008 Report Share Posted February 26, 2008 looks like the old max 256 bytes to an array in sram issue.Try using the 'const' keyword to store the array into flash memory rather than sram. Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 26, 2008 Report Share Posted February 26, 2008 looks like the old max 256 bytes to an array in sram issue.You'll know if you hit that, cause the linker generates an errorTry using the 'const' keyword to store the array into flash memory rather than sram.Definitely. If the values don't need to change..... Quote Link to comment Share on other sites More sharing options...
nILS Posted February 26, 2008 Report Share Posted February 26, 2008 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't2) the compiler generates warnings if you mess up the indexes/indices Quote Link to comment Share on other sites More sharing options...
Crypto71 Posted February 26, 2008 Author Report Share Posted February 26, 2008 Hi again,thanks a lot for Your help. It is working now :DI 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.