1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

PIC with 5110 48x84 LCD screen

Discussion in 'Oshonsoft' started by camerart, Mar 12, 2017.

  1. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,294
    Likes:
    647
    Location:
    Derbyshire, UK
    ONLINE
    Hi Eric,

    It's not a matter of speed, it's a matter of been able to draw graphics - as you can't read from the screen you can't draw a line (or any other shape) on the screen without it wiping out an 8 bit high area across the display. By using aRAM buffer, you can write the line to the buffer, which as you can read it you can avoid over writing existing data, and then refresh the entire screen from the buffer.

    I've been playing with the 16F1827 version more today, and I've got the hardware working again (at LAST!!) - I knew it'd be something stupid, and I had CKE set the wrong way :oops:

    Here's a routine for drawing a horizontal line on the 5110, using a screen buffer, and the routine which copies it to the screen. You draw whatever you want to the buffer, then call Nokia_Update() to display it. If you're just displaying text, and you're not concerned with upsetting what's already on the screen, then there's no need to buffer.

    Code (text):

    void Nokia_ClrHLine(int x, int y, int l)
    {
       int by, bi, cx;

       if ((x>=0) & (x<84) & (y>=0) & (y<48))
       {
           for (cx=0; cx<l; cx++)
           {
               by=((y/8)*84)+x;
               bi=y % 8;

               scrbuf[by+cx] &= ~(1<<bi);
           }
       }
    }

    void Nokia_Update()
    {
       unsigned int b;
        if (_sleep==FALSE)
       {
           Nokia_WriteCmd(PCD8544_SETYADDR);
           Nokia_WriteCmd(PCD8544_SETXADDR);
           for (b=0; b<504; b++)
               Nokia_WriteData(scrbuf[b]);
       }
    }
     
     
  2. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,294
    Likes:
    647
    Location:
    Derbyshire, UK
    ONLINE
    Yes it is :D

    Such LCD's don't update very fast, they are really only suitable for static images - so there's no need to write the data with any great speed, particularly as the maximum data is only 504 bytes. If you're using colour LCD's it's a different matter, they respond much faster, and the amount of data is MUCH greater (pixel based, rather than byte based + colour data).

    I've just used 1MHz SPI (maximum for the hardware with a 4MHz clock) and software SPI (at about 15KHz - due to the free version of XC8), it makes no real difference.
     
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Nigel,
    When I get my colour LCD's I will start graphics, I have done it in the past with a monochrome LCD.
    Camerart, I understand is only interested in alpha numeric data at this time, thats why I focussed on text.

    E
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,368
    Likes:
    11
    Location:
    Dorset UK.

    Hi N,
    I'm afraid I can't read the above, because it's not BASIC. I've been going through Eric's BASIC program, and even though it's written exactly as I like it, it still takes me a long time to get it. Sorry for my limitations :(
    C.
     
  6. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,368
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    Previously I showed a program for Graphics: http://www.ablab.in/image2glcd-software/
    Members said it wasn't for this purpose! I was just checking it before deleting it, and it looked somehow interesting?
    Here is a Square drawn in PAINT, which has been converted to HEX using this program, is it definitely not useful for graphics and these screens?
    C.
     

    Attached Files:

  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,294
    Likes:
    647
    Location:
    Derbyshire, UK
    ONLINE
    It's perfectly fine, you can just copy it to the 5110 display just as you would in the line drawing example above. Basically all you're doing is drawing the graphics on your computer and then loading them to the display, rather than drawing them in your PIC, and then loading them to the display. As long as you're very careful, you can load such a graphic to the 5110, and then write text over it - you just have to be sure to miss the graphics :D

    If you look at this project:

    https://electrosome.com/digital-thermometer-arduino-ds18b20/

    It uses a similar technique, the thermometer symbol is a preloaded graphic, and the temperature value is written to avoid it, in a large font. I've got that exact project running in front of me, on an Arduino 3.3V Pro Mini, although it's only showing 18.3 degrees! :D
     
  8. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,368
    Likes:
    11
    Location:
    Dorset UK.
    Hi N,
    Ok, regarding graphics.

    I can't read your attached program, but thanks. This is why I'm on the Oshonsoft forum.
    C.
     
  9. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,294
    Likes:
    647
    Location:
    Derbyshire, UK
    ONLINE
    You don't need to read the program on the link, just look at the screen shots there (and the video if you want), which demonstrate the mix of downloaded graphics (the thermometer symbol) and internal text. The thermometer graphic was probably generated using the same program as you've already downloaded.
     
  10. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,368
    Likes:
    11
    Location:
    Dorset UK.
    Hi N,
    Ok, I see, thanks.
    Actually, as Eric mentions, I am quite happy at the moment to be able to use the 5110 as a text readout as an alternative to the 4X20 type, it's much neater.
    C.
     
  11. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,368
    Likes:
    11
    Location:
    Dorset UK.
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    You may find this program of interest, give it a run.
    E
     

    Attached Files:

  13. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,368
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    Bad news! 'Not enough ram' Don't panic, if you recall I had to change from 18LF2520 to 18F2420, because of the dodgy PCB I made. I am in progress of making a new 18LF2520 PCB, I'll be able to try it then.

    Looks like you've got scrolling etc.

    I've got to finish designing the SCH, then position the components on the PCB, then transfer it to the board, with an untried process, then etch it, then stick the bits on. It may be a while!
    C
     
  14. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    Flash and RAM memory is limited in some of the smaller PIC's, Fonts and Strings are greedy little beggars.
    That's why I test with the PIC 18F4520 and PICF4620.

    That V5 program scrolls Left for normal and big fonts.

    E
     
  15. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,368
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    The 18LF2520 has the same RAM as the 4520 (I think).
    I'll have a go at cleaning the 'dirty' PCB, to see if it works.
    C.
     
  16. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,294
    Likes:
    647
    Location:
    Derbyshire, UK
    ONLINE
    If anyone is interested, here's a video of my 5110 running a C demo (converted from Arduino C++) on a PIC 24F - it's actually two demos, the end clock display is a different demo.

    It's about 30meg, so here's a link:

    http://www.lpilsley.co.uk/temp/NOKIA5110.MP4

    Incidentally, I've been really struggling to take close-up images or videos, I used a Nikon compact camera for this, with macro-mode selected.
     
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    Looks OK.:)
    The clock needs a little work, looking forward to seeing some of your colour LCD work.
    My modules are due early Nov.
    E
     
  18. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,294
    Likes:
    647
    Location:
    Derbyshire, UK
    ONLINE
    The clock is how the downloaded demo works, and the display isn't symmetrical, hence the elliptical circle :D
     
  19. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,368
    Likes:
    11
    Location:
    Dorset UK.
    Hi N,
    Are the examples actual readouts i,e, the sign wave or simply a loaded program?
    C.
     
  20. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,294
    Likes:
    647
    Location:
    Derbyshire, UK
    ONLINE
    It's just a loaded program as a graphic demonstration of the 5110 library, the clock at the end is driven by a simple routine I wrote for the demo - it generates a random hour, minute, and second, then it's driven by timer interrupts at one second intervals. I have also had it running using the same hardware from a DS3231 I2C clock module - a similar one second interrupt, but generated by the DS3231, was used to update the clock display.

    This is the sine wave part:

    Code (text):

        Nokia_ClrScr();
        Nokia_DrawRect(0, 0, 83, 47);
        Nokia_DrawLine(0, 23, 84, 23);
        Nokia_DrawLine(41, 0, 41, 47);
        for (c = 0; c < 4; c++) {
            for (i = 0; i < 84; i++) {
                y = i * 0.017453292519943295769236907684886;
                Nokia_InvPixel(i, (sin(y * 6)*20) + 23);
                Nokia_Update();
                Delay_ms(20);
            }
        }
     
    I know it's in C, but it's simple to understand - the first four lines clear the screen, and draw the background.

    'for (c=' runs the routine four times, and 'for (i+' draws the 84 dots across the screen.

    InvPixel inverts a pixel in the buffer (you can't do it on the screen, as it's read only), Update transfers the buffer to the screen.

    I've no idea what the scaling value 0.017453292519943295769236907684886 is all about?, it was in the routine when I downloaded the Arduino version.
     
  21. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    266
    Likes:
    15
    Location:
    Helsinki, Finland
    Do you mean are the displayed graphics in the demo calculated online or loaded from a precalculated data?
    The pixels in lines, circles, rectangles are calculated in real time in a screen buffer in ram and then the lcd is updated from the buffer after one line, circle or rectangle is ready.
    The same with the sine wave, but there is a 20ms delay between screen updates.
     

Share This Page