Hi all,
I'm building a project with tiny library C_4i_CF_SZ.a
I want to use printf to write on my LCD display.
My routines are ok and tested. What I want to do is to redirect the printf to my proprietary function that use my GUI.
As usual I tryed to redirect the stdout->write_proc to my function Write_Display.
I debugged my code and I'm sure that the correct address is filled in the right position of stdout structure, but when I use printf and fflush functions my proprietary function is not colled.
Where is my error??
Thanks for your support
You could also use sprintf to print to a string and then copy the data in the string to the LCD using some LCD driving routines.
That is how I do it anyway...
Yes, I undestand your solution, but it isn't so fast.
Otherwise It's a problem that I want to understand to know better the MSL library.
Hi,
If you want, you can just define your own printf() which overrides the default putchar routine, as described here:
Then you can change your putchar() routine to write to your LCD, and use printf() normally to access it.
There's also some background on how the whole printf path works in that thread.
-- Rich
Thanks Rich, buts I know the way you explained to me.
I made the same some time ago, using the entire printf_tiny_io.c in my progect linked before the MSL library with my modification.
What I want to understand is why, with tiny support, I cannot use the stdout with printf. Probably I have to configure something in the stdout structure to make it able to work....
Did you tested the low level by sending to the same custom file descriptor using fprintf() ?
Yes! I tested the fprintf function with stdout.
I checked also that the write_proc is the correct one when teh fprintf is executed and all is ok.
I'm desperate.
To better understand the issue, could you send using fprintf() to another (non-stdout and non-LCD) file descriptor? Say, to TCP socket?
Generally, if everything is seems correct, but isn't working, the direction of the search is wrong.
The only thing that I found is that always the printf calls WriteUARTN function. I think that is this the problem, that cause that my chars are not placed into the stdout structure.
Onother strange thing is that all stdout structure seems not initialize (eg. stdout->buffer_ptr = 0x0000)