Replacing array member on the fly (big LCD characters idea)


Closed Thread
Results 1 to 38 of 38
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default Replacing array member on the fly (big LCD characters idea)

    Hello.
    I've created a large "font" from custom definable LCD characters, which look quite good. But to use with them with real software, I need a code which will translate some variable into these digit display. So to accomplish this, I've created two arrays, one for top row and one for bottom, which hold appropriate number of corresponding custom chars for the digit display. So to display the required char, I simply read values from arrays from index at that position and pass it to display. The code is as follows:

    Code:
    DTOP VAR BYTE[10] 'array for top line
    DBOT VAR BYTE[10] 'array for bottom line
    DTOP[0]=21 '0
    DBOT[0]=37
    DTOP[1]=96 '1 9 REPLACES 16
    DBOT[1]=96
    DTOP[2]=05 '2
    DBOT[2]=24
    DTOP[3]=05 '3
    DBOT[3]=47
    DTOP[4]=37 '4
    DBOT[4]=96
    DTOP[5]=20 '5
    DBOT[5]=45
    DTOP[6]=20 '6
    DBOT[6]=35
    DTOP[7]=81 '7
    DBOT[7]=96
    DTOP[8]=25 '8
    DBOT[8]=25
    DTOP[9]=25 '9
    DBOT[9]=96
    
    
    QROMA:
    FOR CNT=0 TO 9
    LCDOUT $FE,$01,DTOP[CNT] DIG 1, DTOP[CNT] DIG 0
    LCDOUT $FE,$C0,DBOT[CNT] DIG 1, DBOT[CNT] DIG 0
    PAUSE 1000
    NEXT
    GOTO QROMA
    But I run into problem, since I'm using "space" for some characters shape, namely 4, 7 and 9 and DEC code for space is 16, I can't put it into that arrays. In fact I can put it, but when I read array like I do in example code, with DIG statement, it will get ,messed, because say I need to display space at left and 6th custom char at right. If I put 166 into array (16 for space and 6 for that custom char), when I read it, the DIG 1 will return 6, not 16.

    So what can I do? One way I see is to use individual array elements, and omit usage of DIG, but this doubles array size.

    Any other ideas?
    Name:  CHARGEN.jpg
Views: 1787
Size:  185.7 KB

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)


  3. #3
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Yes and I have done way better font for 2004 LCD, but here we're talking about 1602 parallel LCD, not serial, as in 1st link.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Here is my font for 20x4 LCD displays. Far better than posted in the link above.
    Name:  charset.png
Views: 1763
Size:  56.0 KB

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Really nice job on the big numbers.

    What is the difference between parallel - serial LCD? Other than electrical connections and some specific commands? Have not used serial so far but I guess behind the serial driver everything else is the same.

    Ioannis

  6. #6
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Thanks. I have experience of making pseudographics (so called ASCII art) since early 80s. That set of characters also can be used to display most latin alphabet letters, except some. Regarding the LCD, I have no idea, but above example uses serial LCD and I don't see any PBP manual entries for serial LCD.

  7. #7
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    I counted 8 custom characters and a full block(possibly from the existing character set). Is that correct?

    Enumerating,

    Full rounded top left corner,
    Full rounded top right corner
    Full rounded bot left corner
    Full rounded bot right corner
    bottom line
    top line
    half rounded top left corner
    half rounded top right corner
    and
    the full block

  8. #8
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Yes, there are 8 custom characters and char #255 - Full block is used.

  9. #9
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Here's 2x2 font for 1602 OLED (Here you can write bytes directly, not limited by 8 custom chars).

    Name:  picbasical.jpg
Views: 1630
Size:  63.5 KB

  10. #10
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Wanted to store above font in EEPROM. each character takes 2x13 bytes. so 260 byte of memory are needed, but most chips have only 256 bytes of eeprom available.
    I come up with run length encoding compression idea. Since there are only 5 bits used, can use remaining 3 as a counter, showing how many times current pattern should be repeated. This gives ability to repeat up to 8 positions

    Say for character 4 (top left part), in "normal" mode, bit pattern looks like this: %11000. But if we add %110 to end of it, so it now looks like %11000110, decoder software will know that it have to repeat that pattern 6 times.

    So code for reading and decoding char to appropriate DDRAM or whatever it is called, should work like this:

    1. Set pointer address from which the bitmap should be read.
    2. Read it, if 3 last bits<>0 then separate it, and do the loop, writing the code of first 5 bits, repeating them times specified in these 3 bits.
    3. Continue reading of bitmap as needed.

    But I have issue with statement for dividing bit variable into two. Say I have %10101010. How should I divide it into two variables, one which has 5 bits from left, and another having 3 bits from right?

  11. #11
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Just did a rough estimation - the above idea should save 30-40% of EEPROM space. Not bad.

  12. #12
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Also it is possible to separate and replace some similar blocks with additional indexes - this should save additional 10-20%...

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Quote Originally Posted by CuriousOne View Post
    But I have issue with statement for dividing bit variable into two. Say I have %10101010. How should I divide it into two variables, one which has 5 bits from left, and another having 3 bits from right?
    Something like this?

    Code:
    byte_var    var byte
    a_left         var byte
    b_left         var byte
    
    byte_var=%10101010
    a_left=byte_var & %11111000
    b_left=byte_var & %00000111
    Ioannis

  14. #14
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Yes, but I was thinking about either <<, >> or DIG() operators...

  15. #15
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    then combine accordingly like that:

    Code:
    a_left=(byte_var & %11111000)>>3
    to make it right justified if needed.

    Ioannis

  16. #16
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Found interesting thing. On power up, custom character area in normal LCD are empty, but on WS0010 OLED displays, they are filled with random numbers on power up.

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    On the custom character, unless explicitly stated, you should consider it full of rubbish.

    Ioannis

  18. #18
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Yes, but on LCD it is usually empty. On OLED - it is filled with different garbage on each power up.
    Anyways, problem solved, also did some nice animation, will post code and video later.

  19. #19
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)


  20. #20
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Nice and clear fonts. Good work!

    Ioannis

  21. #21
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Actually, it works on any 1602 LCD too, just animation is not so smooth. Will post code a bit later.

  22. #22
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Code:
    'font data, left side start, going down, then right side going down
    data %00000,%00000,%00000,%00000,%00000,%00000,%00000,%00000,%00000 '0 1
    data %00110,%01110,%11110,%11110,%00110,%00110,%00110,%00110 '1 9
    data %00110,%00110,%00110,%11111,%11111,%00000,%00000,%00000 '2 17
    data %01111,%11111,%11000,%00000,%00000,%00000,%01111,%11111 '3 25
    data %11000,%11000,%11000,%11111,%11111,%00000,%00000,%00000 '4 33
    data %11110,%11111,%00011,%00011,%00011,%00011,%11111,%11110 '5 41
    data %00000,%00000,%00000,%11111,%11111,%00000,%00000,%00000 '6 49
    data %01111,%11111,%11000,%00000,%00000,%00000,%00000,%00000 '7 58
    data %00000,%00000,%11000,%11111,%01111,%00000,%00000,%00000 '8 66
    data %00011,%00011,%00011,%11111,%11110,%00000,%00000,%00000 '9 74
    data %11000,%11000,%11000,%11000,%11000,%11000,%11111,%01111 '10 82
    data %00011,%00011,%00011,%00011,%00011,%00011,%11111,%11111 '11 90
    data %00011,%00011,%00011,%00011,%00011,%00000,%00000,%00000 '12 98
    data %11111,%11111,%11000,%11000,%11000,%11000,%11111,%11111 '13 106
    data %11111,%11111,%00000,%00000,%00000,%00000,%11110,%11111 '14 114
    data %01111,%11111,%11000,%11000,%11000,%11000,%11111,%11111 '15 122
    data %11000,%11000,%11000,%11111,%01111,%00000,%00000,%00000 '16 130
    data %11110,%11111,%00011,%00000,%00000,%00000,%11110,%11111 '17 138
    data %11111,%11111,%11000,%00000,%00000,%00000,%00000,%00000 '18 146
    data %11111,%11111,%00011,%00011,%00111,%01110,%11100,%11000 '19 154
    data %11000,%11000,%11000,%11000,%11000,%00000,%00000,%00000 '20 162
    data %01111,%11111,%11000,%11000,%11000,%11000,%11111,%01111 '21 170
    data %11110,%11111,%00011,%00011,%00011,%00011,%11111,%11111 '22 178
    data %01111,%11111,%11000,%11000,%11000,%11000,%11000,%11000 '23 186
    data %11110,%11111,%00011,%00011,%00011,%00011,%00011,%00011 '24 194
    
    x var word ' counter variable
    D VAR WORD 'VARIABLE TO BE DECODED
    y var byte 'eeprom reader var
    LFT VAR BYTE 
    LB VAR BYTE
    RT VAR BYTE 
    RB VAR BYTE 'LEFT TOP, LEFT BOTTOM, RIGHT TOP, RIGHT BOTTOM  variables
    T1 VAR BYTE 
    T2 VAR BYTE
    T3 VAR BYTE
    T4 VAR BYTE 'TEMP VARIABLES FOR DATA READ
    
    
    CLEANER: 'CLEAR ALL CHARS
    FOR X=0 TO 7
    LCDOUT $FE,64+X,0
    LCDOUT $FE,72+X,0
    LCDOUT $FE,80+X,0
    LCDOUT $FE,88+X,0
    NEXT
    
    
    
    
    MAINER:
    lcdout $fe,$80,0,2,0,2,".",0,2,0,2,".",0,2,0,2
    lcdout $fe,$c0,1,3,1,3," ",1,3,1,3," ",1,3,1,3
    'd=0
    for d=0 to 9
    GOSUB DECODER
    GOSUB EREADER
    
    
    PAUSE 1000
    
    
    FOR X=0 TO 7 'Clean screen between chars
    LCDOUT $FE,64+X,0
    LCDOUT $FE,72+X,0
    LCDOUT $FE,80+X,0
    LCDOUT $FE,88+X,0
    NEXT
    next
    GOTO MAINER
    
    
    
    
    DECODER 'DECODE THE VARIABLE
    IF D=0 THEN LFT=185:LB=129:RT=193:RB=73 '0
    IF D=1 THEN LFT=1:LB=1:RT=9:RB=17 '1
    IF D=2 THEN LFT=25:LB=33:RT=41:RB=49 '2
    IF D=3 THEN LFT=57:LB=65:RT=41:RB=73 '3
    IF D=4 THEN LFT=81:LB=1:RT=89:RB=97 '4
    IF D=5 THEN LFT=105:LB=65:RT=113:RB=73 '5
    IF D=6 THEN LFT=121:LB=129:RT=137:RB=73 '6
    IF D=7 THEN LFT=145:LB=1:RT=153:RB=161 '7
    IF D=8 THEN LFT=169:LB=129:RT=41:RB=73 '8
    IF D=9 THEN LFT=169:LB=65:RT=177:RB=73 '9
    RETURN
    
    
    
    
    
    
    EREADER: 'read eeprom data into screen user area with reversal of direction for lower line, for cooler look
    for x=0 to 7
    READ LFT+7-X,T1
    READ LB+X,T2
    READ RT+X,T3
    READ RB+7-X,T4
    LCDOUT $FE,64+7-X,T1
    LCDOUT $FE,72+X,T2
    LCDOUT $FE,80+X,T3
    LCDOUT $FE,88+7-X,T4
    pause 25
    NEXT 
    RETURN
    Pin configs, defines and other, personalized settings not included in the above code.

  23. #23
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    But can it show the time or date or anything else but the one digit ?

    if you really want big chr's on that size display get a 122x32 graphical job
    Warning I'm not a teacher

  24. #24
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Yes, why not?
    Here I was having fun with animation process - direct reading from EEPROM is a new thing for me. I already have clock code written to use these 2x2 chars, will post it after I'll tidy it up.

    Graphical screens might be good but 1602 OLED have 2 advantages:

    1. We know the interface.
    2. They're cheap for their size (comparable physical size Graphical OLED is more expensive)

  25. #25
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    And almost forgot - 1602 OLEDs also support mixed mode - having both character and graphic mode together. So you can save on memory when displaying the text and digits, and use graphics only where needed - and you're not limited by 8 custom characters in that case.

  26. #26
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Quote Originally Posted by CuriousOne View Post
    Yes, why not?
    the font you depict has 22 "shapes" that i can see, the display can hold only eight user defined [cga ram] shapes at any one time

    try to show this

    Name:  Untitled.jpg
Views: 2551
Size:  49.2 KB
    Last edited by richard; - 21st November 2020 at 23:39.
    Warning I'm not a teacher

  27. #27
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    This is 1602 OLED, using WS0010 controller, and besides the standard mode, it also has Graphical mode. So you can write whatever you want. Or you can use a trick - Draw something with these 8 custom chars. Switch display to graphic mode - all image on screen remains, but it is turned into graphics. Now turn back to standard mode, update custom charset and draw next symbol at next place (the symbol you've drawn previously is kept on display, because it turned into graphics) and so on.

  28. #28
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    And there is Nextion displays, in many sizes, low cost, with touch and colors to do anything like that with almost zero overhead in programming.

    But in either case, nice study case.

    Ioannis

  29. #29
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    I am using the Nextion displays more and more. Not only can they display anything you like, they're easy to program, use a simple UART communication protocol (with user defined Baud rate), and because they're touch screen, they eliminate the need for buttons, knobs, and switches. You can load practically any font you want into your project, along with graphics for fancy buttons etc.

    (Nuts & Volts Magazine currently has Part 4 of a 7 part article series on using the Nextion... and yes, I wrote it.)

  30. #30
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Unfortunately, nextion displays are junk in several aspects:

    1. Low display brightness, bad viewing angles, zero daylight visibility, bad contrast. Can't be compared to OLED in this field. And who needs "ease of programming" (which is very questionable), if you can't see the result?
    2. Their IDE is written with left rear feet and has appropriate usability.
    3. Price? Above mentioned 1602 OLED module costs $9. I'd love to have Nextion for that price.

    All above is based on personal experience with nextion displays, not other's ideas or impressions.

  31. #31
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    OK, depends on what you want to do. If you want to place the LCD opposite of the sun, yes, nextion will not fit in.

    In anyway, most of the user interface is well covered with these displays. As for the price, well, you can't have touch for free, right?

    And the IDE is not that bad. You need to take your time, see some tutorials (there are many on-line), ask Mike if needed, he is here and very helpful and off you go.

    At the end of the day, you will offer your client a more attractive device than the classic 2x16 display.

    Ioannis

  32. #32
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    It is 21st century, and Nextion using cheapest TN+Film panels, but asking premium prices is just a funny thing They can do at least IPS, for better angles and contrast. For the touch screen, a simple glass add-on touch screen (which is used in Nextion), sized for 1602 display, costs about 30 cents in china. So you can upgrade even 1602 LCD with touch screen (I don't see any practical purpose in that, but this is possible) And by the way, topic is not about Nextion

  33. #33
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Quote Originally Posted by CuriousOne View Post
    3. Price? Above mentioned 1602 OLED module costs $9
    might i ask where from , i cannot find anyone in Australia that stocks them , most tell me they are end of product life
    or only have units with different chipset
    ebay has no hits
    crystalfontz says end of life [extortionate shipping cost]
    google zip nil nothing other than the winstar site

    i would get one to play with but it looks to be not worthwhile
    Warning I'm not a teacher

  34. #34
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    https://item.taobao.com/item.htm?spm...u=p2otmf3i3dd2

    Yellow one from video above was bought exactly from that link.

  35. #35
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    thanks for the effort, but i cannot get that site to work ,seems you need to sign up and login to get the buttons to work
    its not for me.
    Warning I'm not a teacher

  36. #36
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)



    Will be doing mechanical counter animation next

  37. #37
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    With timings adjusted, it looks quite good even on normal 1602 LCD.


  38. #38
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,793


    Did you find this post helpful? Yes | No

    Default Re: Replacing array member on the fly (big LCD characters idea)

    Indeed, it looks very nice! Nice work.

    Ioannis

Similar Threads

  1. String of characters(array) to decimal value
    By tacbanon in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 20th June 2012, 15:30
  2. write big text to lcd
    By isaac in forum General
    Replies: 3
    Last Post: - 8th October 2008, 02:45
  3. Big big big memory or tiny SDs!
    By Ron Marcus in forum Off Topic
    Replies: 9
    Last Post: - 25th May 2007, 19:02
  4. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 03:21
  5. Replacing an ARRAY with EEPROM write to save space?
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th March 2005, 19:31

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts