ilmenator Posted November 5, 2006 Report Share Posted November 5, 2006 Hi all,I need to print 15 bytes stored in the Bankstick memory (starting at 0x0006) on the LCD. Unfortunately I do not fully understand which MIOS_LCD_Print... command to use. My idea was to store the bytes read from the Bankstick in an array [tt]unsigned char card_name[15][/tt], but then how can I display the content of that array on screen? The C functions description does not really get me there, because I get all kinds of "...from type...to type..." errors from the compiler. Can somebody help? Thanks, ilmenator Quote Link to comment Share on other sites More sharing options...
mess Posted November 6, 2006 Report Share Posted November 6, 2006 Hi,maybe you could use this for displaying the contents: unsigned int index; unsigned char value; //print first 8 numbers MIOS_LCD_CursorSet(0x00); for (index = 0x06; index < 0x06 + 8; index++) { value = MIOS_BANKSTICK_Read(index); MIOS_LCD_PrintHex2(value); } //print the other values on the second line MIOS_LCD_CursorSet(0x40); for (index = 0x06 + 8; index < 0x06 + 15; index++) { value = MIOS_BANKSTICK_Read(index); MIOS_LCD_PrintHex2(value); } it uses no array, but it seems to work all values are printed in hex without any spaces, otherwise it wouldn't fit on the lcd... About those errors, maybe you tried something like this? MIOS_LCD_PrintHex2(card_name); since the functions only accept a single byte, you have to right a little loop to print your array: unsigned char cnt; for(cnt = 0; cnt < 15; cnt++) { MIOS_LCD_PrintHex2(card_name[cnt]); } hope it helpsMichaël Quote Link to comment Share on other sites More sharing options...
ilmenator Posted November 6, 2006 Author Report Share Posted November 6, 2006 Thanks mess,this should work for numbers, but unfortunately those characters to be displayed are stored in ASCII format. From what I understand from the MIOS Functions Reference your suggestion will give me the hex representation of the characters, right?So I guess it comes down to using [tt]MIOS_LCD_PrintPreconfString[/tt], but how do I preconfigure that string by reading the bytes from the Bankstick's memory?Thanks for your input, ilmenator Quote Link to comment Share on other sites More sharing options...
audiocommander Posted November 6, 2006 Report Share Posted November 6, 2006 There's a function implemented in the ACSim Debugger code that prints bankstick contents as Hex and ASCII to the console. Maybe this is adaptable to MIOS-apps.http://www.midibox.org/dokuwiki/doku.php?id=acsim_toolbox_c(link to sourcecode) **MIOS_BANKSTICK_WritePage at 0x0 0: 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 16: 00 00 00 00 00 00 00 00 80 80 80 80 40 08 00 00 ............@... 32: 00 00 00 00 04 04 04 04 14 15 16 17 00 00 00 00 ................ 48: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ **MIOS_BANKSTICK_WritePage at 0x40 0: 08 08 08 08 00 00 00 00 04 04 04 04 00 00 00 00 ................ 16: 00 00 00 00 7f 00 00 00 40 40 40 40 7f 00 00 00 ........@@@@.... 32: 03 03 03 03 00 00 00 00 70 70 70 70 40 40 40 40 ........pppp@@@@ 48: 00 00 00 00 00 00 00 00 7f 7f 7f 7f 00 00 00 00 ................ Regards,Michael Quote Link to comment Share on other sites More sharing options...
mess Posted November 6, 2006 Report Share Posted November 6, 2006 Hi Ilmenator,I didn't know what kind of output you needed so I guessed hex :)for display ascii replace the print hex with this function: void MIOS_LCD_PrintChar(unsigned char c) byeMichaël Quote Link to comment Share on other sites More sharing options...
ilmenator Posted November 6, 2006 Author Report Share Posted November 6, 2006 Thank you both,I will try out your suggestions tonight and keep you informed :).Best regards, ilmenator Quote Link to comment Share on other sites More sharing options...
ilmenator Posted November 6, 2006 Author Report Share Posted November 6, 2006 Hi mess,your solution works okay, as long as I only want to display the memory content on the LCD at this very moment. void Print_CardName(unsigned char cursor) __wparam { unsigned char j; // counter variable unsigned char card_name_length = 15; card_l_addr = 0x06; MIOS_LCD_CursorSet(cursor); for(j=0; j<card_name_length; j++){ ram_byte = MIOS_BANKSTICK_Read(card_l_addr); card_name[j] = ram_byte; card_l_addr++; MIOS_LCD_PrintChar(ram_byte); } return; }What would I need to do to save it as a string for future use? I seem to be having difficulties with the const declaration required for the PreconfString. As the string will change rather often I am looking for something like the classic string type of C variable... how could I return this from my function?You notice that I have not been programming a lot...Best regards, ilmenator Quote Link to comment Share on other sites More sharing options...
mess Posted November 6, 2006 Report Share Posted November 6, 2006 If I remember correctly there is no real string variable in Csince a string is nothing more then a (null terminated) array of charsSo if you want to store the string you can just save the array,and to print them afterwards you iterate through the array with PrintCharmaybe there's a better solution, but that's how I would do itMichaël 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.