cancel
Showing results for 
Search instead for 
Did you mean: 

Basic question: String/ Char. output to LCD/ UART

L C
Associate II
Posted on May 29, 2017 at 03:04

Hello!

I have success to access LCD(ili9341).

And let it display characters. Note the code for string/char to LCD display still under develop.

In general of C, many case use 'printf' for output.

Q1) How can I to use 'printf'? e.g. include stdio.h and then ....?

Sorry I am beginner of C, please give me some information/guild to lean,.

In AVR, they have something to transfer printf string stream to specific LCD driver.

static FILE mydata = FDEV_SETUP_STREAM(ili9341_putchar_printf, NULL, _FDEV_SETUP_WRITE);//mydata declaration and converting it into stream

Q2) How to manage printf for different kind of output such LCD & UART?

In some system, they have LCD for display(in operation) AND using UART communicate with PC for remote/ data logging or trace logging.

If only one 'printf', how to operate between different output device.

Please share your comment/ experience to me.

BR

LC

11 REPLIES 11
Posted on May 29, 2017 at 04:51

Depends on the tool chain, with Keil I can implement a routine to send a character to multiple output devices. I could use fprintf() and a handle to output to specific devices.

Consider using sprintf(), and then push the string buffer to the devices you want to use.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 29, 2017 at 06:20

Clive One

Thanks for your comment.

I am using IAR for software development.

Do you have implementation information with IAR for me?

As you said that '

I could use fprintf() and a handle to output to specific devices.'.

Is it necessary specifier devices before use

 fprintf()?

BR

LC

Posted on May 29, 2017 at 16:30

I don't actively use IAR tools, you'll need to review the documentation/examples related to the tools you have chosen.

GNU/GCC and Keil provide means to provide board specific character IO functions.

fprintf() provides for a FILE handle to be passed, and that could be managed in the fputc() retargeting code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 29, 2017 at 16:49

As far as I remember, the IAR WB has a detailed tutorial for redirecting console output.

But IMHO

fprintf()

is not the best way.

Files are an OS metaphor, and the OS is missing here.

I would use

sprintf()

and work on strings, as suggested earlier.
Posted on May 29, 2017 at 19:07

fprintf() provides a standard method to get output to different devices/streams, whether you use the handle as a 32-bit constant, or a pointer to a user defined structure. Generally avoids having to reinvent the wheel or create non-portable code. People should pick what's appropriate for them.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
L C
Associate II
Posted on June 01, 2017 at 08:44

Hi ALL

I still cannot output string to LCD module.

Please share a code for my reference.

BR

LC

LMI2
Lead
Posted on June 01, 2017 at 16:36

There are much more working libraries for Arduino boards. For your display also I think. Here you are supposed to make your own, or if you are lucky a library can be found (with Google). There are some working examples or APIs for displays which are meant for STM32 devices.

https://github.com/MaJerle/stm32fxxx_hal_libraries

  or

http://majerle.eu/

  has interesting libraries too.

BSP_LCD_DisplayStringAt(oma, BSP_LCD_GetYSize() / 2 + 45,(uint8_t *) buffer, CENTER_MODE); works for STM32F746 Discovery board. It has a LCD display.

L C
Associate II
Posted on June 03, 2017 at 09:01

Hi mich.lei

In before, I am testing all(every related LCD) code in ''main.c'' and it work fine in compile.

I move all code and relative reference(include & define) to separated file(ili9341.c & ili9341.h).

Of cause, the preprocessor has updated with location for them.

Unfortunately, there have error in linking and show below.

 0690X00000607DkQAI.png

0690X00000607E9QAI.png

Please help me and give me your comment.

BR

Lewis

LMI2
Lead
Posted on June 03, 2017 at 16:52

I am afraid I can't help you much with linking. I just fight back when my IDE does something odd. Besides, you seem to use different IDE  than I.

If you have a IDE/linking problem, why don't you start a new discussion about that?