6 comments on “PIC and 5110 Interface with SPI hardware – PR3

  1. Great site! I was wondering how I could modify the code to print variables that I have initialized ? Please let me know as soon as you can :) Thanks !

  2. Hi Sarah,
    did you try using the LCD5110_sendstring function? You can pass your string there and it will print it. Try it and let me know.

  3. So are you saying for …

    LCD5110_sendstring(“Hello World”);

    I would write:

    float P=5;
    LCD5110_sendstring(P);

    and then the LCD should show 5 ?

    I don’t have my LCD with me right now but I will in a bit. Let me know if this is the right approach.

    Seeing as how P is a float instead of an int, would I need to modify this part of your code:

    void LCD5110_sendchar(unsigned char character)
    {
    unsigned char column = 0;
    character = character – 0×20; // 0×20 is the first element of the array

    for (column = 0; column < 5; column++) // Pass through each column
    {
    LCD5110_send(font[(int) character * 5 + column], 1);
    }

    LCD5110_send(0×00, 1); // Send a small space
    }

    Thanks for your help!

  4. Hello Sarah,
    I see what you are saying. The function wont work like that because its meant to output strings not numbers. You will have to format your data as a string before using that function, something like printf.
    Hope that helps!

  5. So I wrote

    int P;
    P = 5;
    printf(“%d\n”,P);

    LCD5110_send(0×40 + 0, 0);
    LCD5110_send(0×80, 0);
    LCD5110_sendstring(P);

    The build succeeded but LCD outputs nothing. Any tips ? Thanks!

  6. Sarah

    printf sends its output to standard output — console etc in the unix world.

    You need a version of printf that does the same formatting but places the result into a string variable rather than sending the result to standard output.
    I believe the standard library function sprintf does what you need.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">