Menu

user defined chars

2021-04-06
2021-04-14
1 2 > >> (Page 1 of 2)
  • stan cartwright

    stan cartwright - 2021-04-06

    Using ili9341 328 glcd solutions/simple demo it uses "#define GLCD_EXTENDEDFONTSET1"
    Is it easy to redefine certain chars.
    I guess the char set is put in program mem when compiled but then can not be changed.
    If I knew were the data for the fontset was I could calculate where the char I wanted was and change it.
    Or is it easier to copy the font set and change the chars needed and use the renamed font set?
    Can not see where font files are or even if they could be edited.

     
  • Anobium

    Anobium - 2021-04-07

    Some background.

    The GLCD fonts are 5 x 8 (let us focus on 5 x8 fonts to start with) defined in 5 tables. Each table has a COLUMN of data. So, the 5 tables represent the complete character.

    The tables are in GLCD.H The tables are shared across all the GLCD drivers. There are many table for all the different font types.

    The table(s) data are part of the program and are therefore in PROGMEM in the hex..

    The GLCD print commands read these tables and then update the display.


    There would be two methods to change a GLCD character.

    1. Change the table data. - There is a demo that does this. See the GLCD demo folder. This essential redefines the table data but the could be made simple - just redefine the tables is all that is needed.

    2. Create a new method that takes the 5 byte values and write to PROGMEM (at the table definition location) to change the character.


    So, before you start the development. Have I answered the questions? I will add information, in my next post) on where each font set is located and how each font set is defined.

     
  • stan cartwright

    stan cartwright - 2021-04-07

    Thanks for replying sir.
    I thought the ascii char set was 255 bytes. What does extendedcharset mean?
    I checked glcd.h but can't see tables for chars.
    I agree swapping a table for another with modified chars would be simplest.

     
  • Chris Roper

    Chris Roper - 2021-04-07

    ASCII is 127 Bytes - 0x00 to 0x7F where 0x00 is the NUL Character.
    0x80 to 0xFF are undefined by the ASCII standard so over the years they have been used to represent graphics characters, game sprites or foreign characters.
    Hence being given the name "Extended Characters" as they were an undefined extension to the ASCII Standard.

     
  • Anobium

    Anobium - 2021-04-07

    Chris is spot on re the scope.

    CharSet File Found in Table
    Original GCB GLCD.h Table GLCDCharCol3,Table GLCDCharCol4,Table GLCDCharCol5,Table GLCDCharCol6 & Table GLCDCharCol7
    Extended Chars 128-255 GLCD.h GLCDCharCol3Extended1, GLCDCharCol4Extended1, GLCDCharCol5Extended1, GLCDCharCol6Extended1 & GLCDCharCol7Extended1,
    OLED Size 1 GLCD.h OLEDFont1Index and OLEDFont1Data
    OLED Size 2 GLCD.h OLEDFont2

    OLED Size 1 is the ONLY charset that is a proportional font. The Index has the look-up into the character data table (so, there are some chars with two columns .. up to 5 columns). To replace the OLED Size 1 charset is complex as you need to create the index and the dataset tables.

    So, all the other charsets are fix-width (non-proportional). These are the easy charsets to replace via a new set of tables.


    The demo C:\GCB@Syn\GreatCowBasic\Demos\glcd_solutions\glcd_demonstration_of_mapping_oled_character\glcd_simple_demonstation_16f887a_for_ks0108_remap_oled_character.gcb shows how to change a single char from the 'hash char' to the 'degree char' - as the original char was 5 chars wide and the the 'degree char' is also 5 chars wide then you can simply replace the data values. The replacement show is shown below.

    5, 0x06, 0x09, 0x06, 0x00, 0x00   ' degree                 'Change the # to a degree sign! here!!
    
    1       x x
    2     x     x
    4     x     x
    8       x x
    16     
    32  
    64          
    128  
    =     6 9 9 6 0 0        
    

    The proportional fonts have a similar mapping but each COLumn tables contain the data per column. So, to obtain the data for a single char extract the data from the five tables and assemble as shown above.

    :-)

     

    Last edit: Anobium 2021-04-07
  • stan cartwright

    stan cartwright - 2021-04-07

    Thanks again for detailed reply.
    When I searched in help oled chars get mentioned.
    The ili9341 dimple demo uses "#define GLCD_EXTENDEDFONTSET1" but the touch demo mentions no fonts so what does that code default to?
    I guess I'm used to 8x8 graphics.
    8x5...what happens to the other pixels if a char is a byte? Just 0bits?

     
  • Anobium

    Anobium - 2021-04-08

    The Help mentions OLED fonts and therefore the original GCB fonts.

    I added the OLED fonts to improve use of the smaller displays.

    Re 'GLCD_EXTENDEDFONTSET1' this supports CharCode>=178 and CharCode<=202. I am not sure why this is in the demos.

    8x5 - the characters are defined in columns, and these columns can be fixed or variable (fixed-width or proportional) and the supporting sub routines put the data ( the pixel map) on the display. If the column data is 0 then that column is empty, and, at the end of every character there is an empty column to provide inter character spacing.

    So, every character is made up of column data. The data table will contain values or zero for an empty column. If you consider the character '!' when this is fixed-with the data must be 0,0,0x5e,0,0 (across the five tables) but for proportional this 0x5e.

    0,0,0x5e,0,0 'DATA ACROSS THE FIVE TABLES
    
    1       
    2          X 
    4          X
    8          X
    16         X
    32         
    64         X 
    128  
    =    0  0  0x5e  0  0        
    
    0x5e 'DATA IN ONE TABLE - FOR oled FONT
    
    1       
    2    X 
    4    X
    8    X
    16   X
    32         
    64   X 
    128  
    =    0x5e
    

    This description provides insights into why OLED fonts are faster. There is simply less data to send to the GLCD.


    I think the best way to change the font is have a new command (a method) that changes the table that is defined in PROGMEM. This is the neatest.

    The alternative of redefining the tables is very easy. Simple extract the tables from the source library, add to your program, rename this tables and use #define to tell the compiler to use your character tables as follows (where the modified fixed-width tables have the prefix of my

    #define GLCDCharCol3 myGLCDCharCol3
    #define GLCDCharCol4 myGLCDCharCol4
    #define GLCDCharCol5 myGLCDCharCol5
    #define GLCDCharCol6 myGLCDCharCol6
    #define GLCDCharCol7 myGLCDCharCol7
    

    Easy....

     

    Last edit: Anobium 2021-04-08
  • David Stephenson

    On GLCDs you have in effect a blank canvas. You can make up your own fonts (and store them in lookup tables). If you want a change from the GCB fonts. I use the program
    http://www.eran.io/the-dot-factory-an-lcd-font-and-image-generator/
    It can take any TTF font resize and convert it to binary information (the largest I have made is 24x48, but with large fonts you've got to be careful of going over a page of memory).

    On character LCDs you are stuck with ASCII, but most will allow you to redefine a few characters (8 maybe).
    Yes ASCII was only 0-127 as the final bit was for parity as it was not agreed at the time whether 1 was low or high on some systems (there was also EBDIC around at the time as well).

     
  • Anobium

    Anobium - 2021-04-08

    My 'go to' font generator is http://oleddisplay.squix.ch/#/home

    This is usable across all platforms as it is web based. I also have the source to the web site from the author.

    Using http://oleddisplay.squix.ch/#/home you can see the two tables that make up the Great Cow BASIC OLED fonts. The Jump table (adapted) is the OLEDFont1Index table and Font Table is the OLEDFont1Data. The porting from http://oleddisplay.squix.ch/#/home data to Great Cow BASIC is relatively simple.

    Using the http://oleddisplay.squix.ch/#/home date to redefine the tables using the methods discussed previously means you can use all the GLCD commands rather than having to write/develop your own methods.

     
  • David Stephenson

    Yes that looks nice I will try it. My normal method is a bit fiddly to get into a form that I can use in a GCB table.

     
  • stan cartwright

    stan cartwright - 2021-04-08

    Thanks for the explanation Even.
    Should I need to change certain chars with ili then I'd use a bit of code to do the job if those chars were repeated ,,like bricks in a maze.

    a few things you could explain. oled fonts, can iliglcd use them?
    tff was introduce with no explanation.

    For ili I could use the sprite write code with 8x8 from a table for nostalgia..

    I can't really follow fonts maybe different displays.

    what has been understood is there's 127 chars and the rest are whatever you define?

     
    • Anobium

      Anobium - 2021-04-09

      Should I need to change certain chars with ili then I'd use a bit of code to do the job if those chars were repeated ,,like bricks in a maze.

      Not sure what you mean. Let us use some terms ( I may get these terms wrong but accept them for this debate).

      1. Certain chars would mean (to me) replacing an existing character with a new character and that this character is then put on the GLCD via the GLCDPrint commands.
      2. Bricks in a maze would mean (to me) a 'group of pixels'.

      GLCDPrint commands is very different from putting a group of pixels on the GLCD. GLCDPtint manages the end to end process from handling the string, the fonts, the screen position etc.

      Putting a group of pixels on the screen does not need the GLCDPrint commands. (As you know) you can use PSET directly. Using PSET directly will be a lot faster but you need to control every aspect of the GLCD operations.

      So, if you were going to put bricks in a maze... then, a specific method leverage PSET would be optimised. You could actually use the methods that PSET uses but then the program will be specific to a specific GLCD. I have ensured that PSET is public method that is common across all GLCDs. Any methods called by PSET is not public or consistently defined within the suite of the GLCD libraries.

      a few things you could explain. oled fonts, can iliglcd use them?

      OLED fonts are available across the suite of the GLCD libraries. Support for OLED fonts is consistently implemented in the 'GLCDDrawChar(I CharLocX , CharLocY, CharCode [, LineColour] )' method.

      tff was introduce with no explanation.

      I assume this is meant to be TFT. And, I assume this related to the color definitions.

      This is easy. When I started to write the library. I have no idea that color definitions could be shared. So, I initially used device specific color definitions. As I developed more libraries then I learnt that the color codes could be shared - so, started to use TFT_COLORs. So, use TFT colors.

      For ili I could use the sprite write code with 8x8 from a table for nostalgia..

      Agree. You did this in your earlier sprite programs.

      I can't really follow fonts maybe different displays.

      As discussed in this thread - the fonts are shared across all libraries. Remember, what you see is same.... but a character on a 128x64 with a 3 inch display will look a lot bigger (and chunker) than the same character on a 480x320 with a 5 inch display - where the same character will look tiny.

      what has been understood is there's 127 chars and the rest are whatever you define?>

      No. See https://en.wikipedia.org/wiki/Extended_ASCII
      It was incorrect to say the ASCII is chars 32-127. ASCII is well defined between 0-127 and with Extended ASCII (and codepages) the range of 129 to 255 is also defined.

      The Great Cow BASIC Extended ASCII Extended Chars 128-255 (see table above) supports the Greek codepage.

      But, yes... you can ignore the defined extended ASCII convention and define what ever you want.

       
  • stan cartwright

    stan cartwright - 2021-04-08

    2nd thought was check char number then read height,width then draw char from a table.

    when the needs comes I'll sort it.

     
    • Anobium

      Anobium - 2021-04-09

      2nd thought was check char number then read height,width then draw char from a table.

      when the needs comes I'll sort it.

      It depends what you are trying to do.

       
  • stan cartwright

    stan cartwright - 2021-04-08

    The graphics are all 8x5..why not 8x8? Is it for displays? and they still take a byte?

     
    • Anobium

      Anobium - 2021-04-09

      The graphics are all 8x5..why not 8x8? Is it for displays? and they still take a byte?

      Blimey Stan.... read the thread.

      The graphics are you talking about the an ASCII character to be display on a GLCD ?

      If yes.. then you have missed the point of the post where I discussed the definition of a fixed-width or proportional character.

      • fixed-with are always 8x5 therefore 5 bytes. Where each byte has the column pixel values defined as the bits. 8x5 is also the size of the LCD fonts.
      • proportional characters are any thing from 8x1 to 8x5. Where each byte has the column pixel values defined as the bits but the width is defined in the look up table.

      There was no point in using 8x8 (eight bytes) as the character can be defined in 8x5.

      Load up a 8x8 TrueType font into your computer. Then, in WORD select the 8x8 font it will look like a BBC Micro font set. Then, select Courier New font - Courier New font is a fixed-width font - notice the characters are fixed-width but tighter that the 8x8 font. Then, select ARIAL... a proportional font. This test shows the differences.

      Summary, if the font set is an 8x[whatever width] each column needs a byte. And, it correct to say the following:

      int( [character pixel height] / 8 )+1 = number of bytes to describe a single column of a single character.

       
  • stan cartwright

    stan cartwright - 2021-04-10

    I'm sorry if I seem moronic at times but fonts were just something you changed in a text editor.
    I have looked through the glcd.h and can't figure out where char tables are.
    Glcd.h is fine code. I love using and trying to understand it.

    I do try but when ttf chars are used in updated demos I get confused like ili demos.
    is ttf true type font? see, not a clue.

    Now your talking oled fonts. Way too fast for me to take in.
    Easy for everyone else :(

     
  • David Stephenson

    True type fonts (TTF) use Bézier curves to render the shape of letters they are readily resized and take up less space than bitmap fonts. Problem is they take some computer power and memory to render which microprocessors are short on so we use bitmap fonts. Bitmap fonts are essentially direct from (flash) memory onto the screen with no computation necessary.

     
  • stan cartwright

    stan cartwright - 2021-04-10

    just looking at extended char set 128-255.
    where is it? can it be edited? loads of changeable chars.

    alternative, if ascii code over 127 then use another char table.
    where's the char tables for ili?
    no mention off ttf or nextion and now oled. confused.

     
  • Anobium

    Anobium - 2021-04-10

    Step back a moment. Tell us what you are trying to achieve?

     
  • stan cartwright

    stan cartwright - 2021-04-10

    I want to change a space to a smiley...how?
    Have patience for those who don't get all aspects of gcb .
    Dunno how many people use glcd graphics ,especially larger displays.

     
  • Anobium

    Anobium - 2021-04-10

    what size?

     
  • stan cartwright

    stan cartwright - 2021-04-10

    320x240 but not the point. ili never mentioned tft or what was used with nextion but then uses it and now it's oled chars. bit hard to keep up.
    on a 328p then extendedfont works but can't find an example of modifying the chars past 127 .
    Are the char tables created at compile time so part of progmem?
    I think others may be interested and will come across this sometime or other.
    I don't want to make chr32 a smiley but how could I if I wanted?
    say with ili9341....or ssd1306 which uses a different font set...or so it appears.

     
    • Anobium

      Anobium - 2021-04-11

      I meant, what is the the thing you are putting on the GLCD? An 8x5, an 8x8, an 8x16 block of pixels ?

      Can I clarify ? what do you mean by ili? what do you mean by tft?

      Nextion is a special case. It can use the traditional Great Cow BASIC fixed-width fonts, or, the newer Great Cow BASIC OLED fonts but the Nextion also has it own fontsets which can be assessed via the Great Cow BASIC libraries. Great Cow BASIC can send Great Cow BASIC fonts can draw them slowly on the Nextion screen, or, you can select the Nextion fontset and send just the ASCII character values.

      on a 328p then extendedfont works but can't find an example of modifying the chars past 127 .

      For a really good example of the extended fontset do a search for 'greek' in your Demo folder. A code example (it is not all Greek to me :-) )

      CLS
      GLCDCLS
      GLCDPrint 0,10,"ÃåéÜ óïõ êüóìå"
      'Evan you are very cool guy
      GLCDPrint 10,20,"Evan åßóáé ðïëý cool ôýðïò"
      Wait 4 s
      

      Are the char tables created at compile time so part of progmem?

      Yes. As previously discussed. See https://sourceforge.net/p/gcbasic/discussion/579125/thread/2f3412d2c0/#ad45

      I don't want to make chr32 a smiley but how could I if I wanted?

      As previously discussed. See https://sourceforge.net/p/gcbasic/discussion/579125/thread/2f3412d2c0/#0b19 above - specifically *The demo C:\GCB@Syn\GreatCowBasic\Demos\glcdsolutions\glcddemonstrationofmappingoledcharacter\glcdsimpledemonstation16f887aforks0108remapoledcharacter.gcb shows how to change a single char from the 'hash char' to the 'degree char' - as the original char was 5 chars wide and the the 'degree char' is also 5 chars wide then you can simply replace the data values. The replacement show is shown below.

      5, 0x06, 0x09, 0x06, 0x00, 0x00 ' degree 'Change the # to a degree sign! here!!

      *

      say with ili9341....or ssd1306 which uses a different font set...or so it appears.

      There are demos that use the older Great Cow BASIC fixed-width fontset and there are demos that use the newer Great Cow BASIC OLED fontset. It would depend each demo.

       
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.