Menu

SSD1306 Controller and GLCD fonts.

Help
2017-12-23
2017-12-25
  • George Alvarez

    George Alvarez - 2017-12-23

    In my code, I choose one of two sizes for the font I use:

      #include <glcd.h>
    
    ; ----- Define GLCD Hardware settings
      ;#define GLCD_TYPE GLCD_TYPE_SSD1306
      #define GLCD_TYPE GLCD_TYPE_SSD1306_32
      #define GLCD_I2C_Address 0x78
     ' #define GLCD_OLED_FONT
      #define SSD1306_DISPLAYOFF 0xAE
      #define SSD1306_DISPLAYON 0xAF
    
    ...
    
      GLCDCLS
      GLCDfntDefaultSize = 1  'small
    
      GLCDPrint 0,0,"Hello"
      ' or
      GLCDfntDefaultSize = 2    'large
    
      GLCDPrint 20,0,"There"
    

    and that will give me two different fonts, one large and one small. Let's call those my RAW fonts.

    If I also include this:

    #define GLCD_OLED_FONT
    

    then I can still get two different sized fonts, but the OLED font is different than the RAW font. Once I use it I'm unable to use the other two RAW fonts. It seems like an either/or decision.

    What I'm wondering is if I can use both the RAW font and the OLED font, and switch back and forth between them somehow. Is that possible?

    Thanks

     

    Last edit: George Alvarez 2017-12-23
  • stan cartwright

    stan cartwright - 2017-12-23

    Totally irrellevent but you could draw the chars with lines and circles. It would look interesting at least...sorry, just a thought

     
  • George Alvarez

    George Alvarez - 2017-12-24

    Hi Stan, actually, that's what I did at the very beginning. It was my maiden effort for GCB... they look very 7 segment-ish, so now I'm shooting for a more polished look.

     
  • George Alvarez

    George Alvarez - 2017-12-24

    In case you're interested, this is a slightly modified version. I'm doing a music thing, so I got rid of the sharp and flat accents to the letters, haven't tried this version yet, but you should get the idea.

    I might add rounded corners next.

    ; ----- position variables for 7 segment font
      Dim ColPos1,ColPos2,ColPos3,ColPos4,MidPos1,WhichChar,TopLeft,CharWidth,Between,SharpWidth,SharpAdd,v_sharp,v_flat,n_char as Byte
      ColPos1 = 0
      ColPos2 = 0
      ColPos3 = 0
      ColPos4 = 4
      MidPos1 = 4
      WhichChar = 0
      TopLeft = 1
      CharWidth = 10
      Between = 5
    
    Sub Ltr(v_seg)
      ; Each line is a segment like 7 segment LCD
      ; in order:
      ;          A
      ;     F         B
      ;          G
      ;     E         C
      ;          D
      ; just include the segments you want to light up
      ; example: GoSub Ltr("AFED") will give you a C
      n_char = v_ctr - 1
      ColPos1 = TopLeft + n_char *(CharWidth + Between)
      MidPos1 = TopLeft + 6 + n_char *(CharWidth + Between)
      ColPos2 = ColPos1 + CharWidth
      'GLCDCLS
      'GLCDPRINT 0,0,n_char
      'GLCDPRINT 30,0,ColPos1
      'Wait 5 s
      'GLCDCLS
      For v_inot = 1 to 7
        If Instr(v_seg,"A") > 0 then Line (ColPos1,0,ColPos2,0)  'A
        If Instr(v_seg,"B") > 0 then Line (ColPos2,0,ColPos2,10) 'B
        If Instr(v_seg,"C") > 0 then Line (ColPos2,10,ColPos2,22)'C
        If Instr(v_seg,"D") > 0 then Line (ColPos1,22,ColPos2,22)'D
        If Instr(v_seg,"E") > 0 then Line (ColPos1,0,ColPos1,22) 'E
        If Instr(v_seg,"F") > 0 then Line (ColPos1,10,ColPos1,22)'F
        If Instr(v_seg,"G") > 0 then Line (ColPos1,10,ColPos2,10)'G
        If Instr(v_seg,"M") > 0 then Line (MidPos1,12,ColPos2,12)'HALF OF G SEGMENT G
      Next v_inot
    End Sub
    
     
  • stan cartwright

    stan cartwright - 2017-12-24

    That is brill. They are graphic displays and seems a waste just to use text.
    Drawing chars with line and moving the x,y start and redrawing a few times makes 3D looking chars.
    Get your moneys worth from the little displays or stick to 2 line x 16 char boring displays :)

     
  • George Alvarez

    George Alvarez - 2017-12-24

    I found this too, just wanted to keep it all in one place.

    SSD1306 fonts

    Google: ssd1306 font generator

     

    Last edit: George Alvarez 2017-12-24

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.