Shop OBEX P1 Docs P2 Docs Learn Events
P1 SPIN code for SSD1306 OLED — Parallax Forums

P1 SPIN code for SSD1306 OLED

128x64 pixel display

Has anyone got a SPIN code demo running different size fonts ?

I found something in OBEX with a 5x7 font, but it's too tiny.
There's another with 16x32, but it's too large, taking 4 rows out of an available 8.

Looking for something in the middle, maybe taking 2 or 3 rows, perhaps 8x12 or 8x16 (or 12x...) size fonts?

Comments

  • JonnyMacJonnyMac Posts: 8,997

    I found this (really old) SD1306 driver for the P1 that embeds an 8x8 font and will also print it to the screen as 16x16. Its only Spin, so probably very slow (which is why there are a lot of comments about converting sections to PASM). Perhaps you can "kit bash" this code to do what you need.

  • Thank you @JonnyMac

    That worked very nicely as-is.
    I'm curious if you had ever implemented the FONT_PLX option ?

    The font included works just right; no need for anything else, unless perhaps even larger fonts are required by someone.

    Here's a demo wrapper for anyone wanting to run a quick test:

    {{
    
      Quick test of an 128x64 OLED display
      with JonnyMac's jm_ssd1306_128x64_ez.spin object
    
    }}
    
    
    ' ----------------------------------------------------------------------------------------------------------------
    CON { timing }
    
         _clkmode       = xtal1 + pll16x    'Standard clock mode * crystal frequency = 80 MHz
         _xinfreq       = 5_000_000
    
    
    ' ----------------------------------------------------------------------------------------------------------------
    CON { pins }
    
         OLED_CS        = 7
         OLED_RST       = 9
         OLED_DC        = 8
         OLED_CLK       = 6
         OLED_DATA      = 4
    
    
    ' ----------------------------------------------------------------------------------------------------------------
    OBJ { code objects / drivers }
    
        oled : "jm_ssd1306_128x64_ez.spin"
    
    
    ' ----------------------------------------------------------------------------------------------------------------
    PUB Main
    
       ' #1, FONT_NORM, FONT_WIDE, FONT_BIG                            ' font sizes
       ' #0, PIXEL_OFF, PIXEL_ON, PIXEL_XOR                            ' pixel styles
    
       ' oled.startx(rstpin, dcpin, cspin, dopin, clkpin)              ' start object
       ' oled.str(p_str, size, style)                                  ' write string to display
       ' oled.goto_xy(column, row)                                     ' move cursor to xy position
    
    
        ' Start the OLED driver
        oled.startx(OLED_RST, OLED_DC, OLED_CS, OLED_DATA, OLED_CLK)
        oled.enable(true)
        oled.clear
    
        ' Move to column, row.  Then write some text!
        oled.goto_xy(0, 0)
        oled.str(string(" Hello! "), oled#FONT_BIG, oled#PIXEL_ON )
    
        oled.goto_xy(0, 2)
        oled.str(string("12345678"), oled#FONT_BIG, oled#PIXEL_ON )
    
        oled.goto_xy(0, 4)
        oled.str(string("ABCDEFGH"), oled#FONT_BIG, oled#PIXEL_ON )
    
        oled.goto_xy(0, 6)
        oled.str(string("INVERTME"), oled#FONT_BIG, oled#PIXEL_ON )
    
        oled.goto_xy(0, 6)
        oled.str(string("INVERTME"), oled#FONT_BIG, oled#PIXEL_OFF )
    
    
        ' Repeat endlessly to prevent IO pins changing state
    
        repeat ' forever
          waitcnt(0)
    
    
    
    
  • @JonnyMac
    do you mind if I post that demo to OBEX, and include your object src ?

  • JonnyMacJonnyMac Posts: 8,997

    I'm curious if you had ever implemented the FONT_PLX option ?

    I did in a different OLED driver (for the P2). The storage of the Parallax font is interleaved so it has to be done as in a separate object.

    do you mind if I post that demo to OBEX, and include your object src ?

    Not at all.

Sign In or Register to comment.