printCString from variable[13]?

Is this a limitation of mios/sdcc?

MIOS_LCD_PrintCString(event_map[found_event.entry].name);

doesn’t work, I think it was an incompatable type error when compiling I use this as a work around… which i believe the mios wrapper does this anyway.

for (t=0; t<12; t++) MIOS_LCD_PrintChar(event_map[found_evernt.entry].name[t]);

Just curious… might be one for the wiki

I got stuck at the typo:

event or evernt?

If you copy/pasted those then that might be your answer :slight_smile:

hehe, event…

nice catch, wrote it from memory… no typo’s this time… i swear :slight_smile:

So… to keep it simpler

if variable[5] = “abcd”

MIOS_PrintCString(variable) should print abcd on the screen

To be honest, I have no clue what you are asking exactly, but I guess you want to print a predefined char-array to the LCD. As you are giving not much information, I just can say, that it works pretty well for me, so the problem is possibly in your datastructure.

[tt]

const unsigned char scaleNames[3][4] = {

  { “—” }, { “min” }, { “MAJ” }

};

MIOS_LCD_PrintCString(scaleNames[1]);  // prints “min”

[/tt]


also:

[tt]if (variable[5] == “abcd”[/tt]) {

    [tt]MIOS_PrintCString(variable) [/tt] //doesn’t print anything, because you are trying to print the whole array.

}

Regards,

Michael

Yeh, you should just give a pointer to a memory location for it to work.

MIOS_PrintCString(variable[0]);

Might work… the function should continue until it hits the ‘0’ (the end of the quotes)

hmm.. cool will play with it some more

Cheers

MIOS_LCD_PrintCString works only for const char arrays

Of course thanks Rio! Those table reads in there are program memory only so it has to be a ‘const’

Ahhhhh… I don’t feel so much like a ‘complete’ idiot anymore  ;D

Thanks

Is it just me, or would it be handy to have such a function that worked in RAM?

I want to have it too :slight_smile:

Best regards, ilmenator

Hey dudes if someone would like to test this out come and meet me in the chatroom… my lcd cable is shorting somewhere ::slight_smile:

cmios.h (or header file of your choice):

extern void MIOS_LCD_PrintRAMString(unsigned char *str); // not supported by MIOS itself, but by the wrapper

mios_wrapper.asm (Right down the bottom, but ABOVE where it says “END”!)

;; --------------------------------------------------------------------------
.MIOS_LCD_PrintRAMString code
_MIOS_LCD_PrintRAMString
	global	_MIOS_LCD_PrintRAMString
	movff	PREINC0, FSR2L
	movff	PREINC0, FSR2H
_MIOS_LCD_PrintRAMStringLoop
	movf	POSTINC2, W
	bz	_MIOS_LCD_PrintRAMString_End
	call	MIOS_LCD_PrintChar
	bra	_MIOS_LCD_PrintRAMStringLoop
_MIOS_LCD_PrintRAMString_End
	return

Make yourself a string somehow (note **)

unsigned char foo[6];
....

    foo[0] = 'T';

    foo[1] = 'e';

    foo[2] = 's';

    foo[3] = 't';

    foo[4] = '.';

Call it

  MIOS_LCD_PrintRAMString(foo);

** Note: Actually filling the array with a string is not so straightforward. You cannot just do

foo = "New 1";

Because “New 1” is a string in code space and ‘foo’ is in RAM. That is probably bad pracice anyway. As has been suggested prieviously you could use a pointer to the string in code (like PrintCString) or you could use something like strcpy(). If you are printing a number you can use the BCD functions provided by TK. However - and this is untested - If you were filling the array from another variable then it could be useful. Maybe you’d like to try:

unsigned char foo[64];

MIOS_BANKSTICK_ReadPage(0x07ff, foo);

MIOS_LCD_PrintRAMString(foo);

I think that should work.

Have fun and post any requests and stuff :slight_smile:

The MIOS_LCD_PrintCString function of the updated MIOS wrapper is now able to handle strings located in code and RAM

So, a special function is not required anymore. :slight_smile:

Best Regards, Thorsten.

Nice one TK :slight_smile: