Menu

Update to SDD1306 and SH1106 GLCD Driver

Anobium
2017-08-20
2023-04-15
<< < 1 2 (Page 2 of 2)
  • Bonkers

    Bonkers - 2023-04-12

    sorry - I didn't hit re-post, computer did.
    The ASM is now clean:
    ;I2C pins need to be input for SSP module when used on Microchip PIC device
    ;Dir HI2C_DATA in
    banksel TRISA
    bsf TRISA,2
    ;Dir HI2C_CLOCK in
    bsf TRISA,1

    but the APFCON register (11D, 285 decimal) doesn't seem to get defined - none of those 3 search terms find anything. It only needs to be cleared, so maybe that happens within a loop, clearing all the peripheral control registers, dunno.

     
  • Bonkers

    Bonkers - 2023-04-12

    Yes - still got the programmer attached - I'll try it with just 3V3 PSU.
    both SCL and SDA are pulled-up with 4k7.

     
  • Bonkers

    Bonkers - 2023-04-12

    Genius you - it's now chucking out lots of data - will connect to OLEDs shortly///

     
  • Anobium

    Anobium - 2023-04-12

    Add the following to ensure I2C Is setup ok

    #startup init, 75
    
    sub init
        afpcon = 0x00
    end sub
    

    This will ensure the afpcon register is set befire the init of the I2C.

     
  • Bonkers

    Bonkers - 2023-04-12
    IT WORKS !!

    Brilliant work, well done - 2 out of 3 displays working, the dead one probably has a different I2C address, will investigate. The font is really tiny, but again, now it works I can mess with that possibly... - does character mode support different font sizes?

    I'll add the code you mention - maybe it just works without this because UUUU is normally 0000 on a cold power-up.
    Would you like me to post a photo, or is that too much?

     
    • Anobium

      Anobium - 2023-04-12

      pictures are always good!

       
  • Bonkers

    Bonkers - 2023-04-12

    Here's a not very good picture of SSD1306 driver working on a 256-byte RAM part PIC12LF1552, with 2kW ROM, in character mode.
    - the top OLED is 96 x 16, CPC part SC15656
    - the middle one is 128 x 32, alibaba £1 part.
    - the lower OLED doesn't work, possibly an I2C address jumper is wrong.
    - Praise be to Anobium.

     
  • Bonkers

    Bonkers - 2023-04-13

    Progress report:
    I commented out the FONT2 disable, and set font 2 as the default:

    '#DEFINE GLCD_DISABLE_OLED_FONT2
    GLCDfntDefaultsize= 2 'A larger 10 width * 16 height pixel font.

    and here is a very pleasing result on the 128 x 32 tiny OLED:
    (picture)

     
  • Bonkers

    Bonkers - 2023-04-13

    Further reports...
    I'm trying to understand the driver directives, there are 8 possibilities - two drivers and 2 flags each - (low-mem and character-only) - and of course there are 2 fonts.
    - the two drivers are...
    - GLCD_TYPE GLCD_TYPE_SSD1306
    - GLCD_TYPE GLCD_TYPE_SSD1306_32
    not sure what is different about the _32 driver, versus the original with GLCD_HEIGHT set to 32 rather than 64.
    the _32 driver increases the apparent font size.
    however, both consume the same resources, at least in the case where GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY is defined.
    similarly, disabling font2, which is an option, has no effect on resource either.

    If CHARACTER_MODE_ONLY is defined (my only test case so far) then both drivers draw the same resource, and again the same whether GLCD_TYPE_SSD1306_LOWMEMORY_GLCD_MODE is true or false.

    It appears that GLCD_TYPE_SSD1306_LOWMEMORY_GLCD_MODE gets set whenever GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY is defined. - it does make a difference to the errors, I'm pretty sure I only get the warning:
    Warning: Selected MCU requires use of GLCD Open&Close Page Transaction.
    if LOWMEMORY is not declared - but operation and resource are the same.

    I can definitely state that the ifDEV directives that test for LOWMEMORY in the program, always finds it true.

        #ifdef GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY
          #ifdef GLCD_TYPE_SSD1306_LOWMEMORY_GLCD_MODE
            GLCDPrint 0,42, "LM GLCDMode SSD1306"
          #endif
        #endif
    
        #ifdef GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY
          #ifndef GLCD_TYPE_SSD1306_LOWMEMORY_GLCD_MODE
            GLCDPrint 0,32, "TX GLCDMode SSD1306"
          #endif
        #endif
    
        it always gives the first answer, regardless (or so it seems). 
        anyway - enough on that, it works and makes some very nice screenshots.
    
     
    • Anobium

      Anobium - 2023-04-13

      This would be true. See this segment of code from C:\GCstudio\GreatCowBasic\include\glcd_ssd1306.h

      Essentially, this will ensure low RAM chip use only LM mode.

      'Setup code for SSD1306 controllers
        #script     ' This script set the capabilities based upon the amount of RAM
      
           IGNORE_SPECIFIED_GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY = 0
           if IGNORE_GLCD_TYPE_SSD1306_LOW_MEMORY_WARNINGS then
              IGNORE_SPECIFIED_GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY = 1
           end if
      
           if GLCD_TYPE = GLCD_TYPE_SSD1306 then
             If ChipRAM < 1024  Then
                 GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY = TRUE
                 GLCD_TYPE_SSD1306_LOWMEMORY_GLCD_MODE = TRUE
      
                If ChipRAM < 225  Then
                  If ChipFamily = 14 Then
                    Error "Selected MCU has insufficient contiguous RAM to support GLCD operations"
                  End if
                End if
                If ChipRAM > 225  Then
                  if NODEF(IGNORE_SPECIFIED_GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY) then
                    Warning "Memory < 1024 bytes."
                    Warning "Selected MCU requires use of GLCD Open&Close Page Transaction."
                    Warning "See Help for usage."
                    Warning "Define a constant IGNORE_GLCD_TYPE_SSD1306_LOW_MEMORY_WARNINGS to remove this message."
                  end if
                End if
             End If
           end if
      
           if GLCD_TYPE = GLCD_TYPE_SSD1306_32 then
             If ChipRAM < 512  Then
                 GLCD_TYPE_SSD1306_CHARACTER_MODE_ONLY = TRUE
                 GLCD_TYPE_SSD1306_LOWMEMORY_GLCD_MODE = TRUE
                 If ChipRAM < 256  Then
                    Error "Chip has insufficient RAM to support this specific GLCD"
                 End if
             End If
           end if
         #endscript
      
       
  • Bonkers

    Bonkers - 2023-04-13

    Here's the base driver (not the 32-row version) and the bigger Font2

     
  • Bonkers

    Bonkers - 2023-04-13

    And here's the _32 version with the smaller Font1, looks very nice and fits a lot on the screen.
    It's John Cooper Clarke's first Haiku:

     
  • Bonkers

    Bonkers - 2023-04-13

    Thanks Anobium - I will look into the Font control.
    Just to round-off the discussion, I understand from your post above that the compiler forces the flags "LOWMEMORY" and "CHARACTER_MODE" - and that character mode is a subset of low memory operation. It all makes sense.

    I find that Font1 renders ever so much faster that Font2 - but needs to be used with the _32 driver or else the font is really tiny .

    For general info, here is the resource usage :
    Chip resource usage:
    Chip Model: 12LF1552
    Program Memory: 1743/2048 words (85.11%)
    RAM: 202/256 bytes (78.91%)
    OSC: INTOSC, 16Mhz (Internal oscillator)

    Not much room for user program on top of this, enough for a nifty little voltmeter certainly (watch this space) - which will fit well into this 8 pin device. There are bigger parts - I'd recommend 4kW minimum program memory.

    However, the intention here was just to see what overhead is needed to drive an OLED, and what font options you get - ultimately to see if we can get to a low-resource "improved character-only display" sort of thing. The answer is a definite yes, and I'm only starting to tinker with the font options, there are many more to try.

    I can't believe the level of support I've had, and the speed of it - many thanks to the GCB Gods!

    Oh, and the part I used is this https://www.aliexpress.com/item/32777216785.html
    They're about £1.50 all told if you get 5.

     
  • Anobium

    Anobium - 2023-04-13

    Really great to here the progress.

    Send me one of the SSD's. I need a spare.

    Evan

     
  • Bonkers

    Bonkers - 2023-04-15

    Spare SSD1306 128x32 is in the post, with a board to go with it like in the photo below.

    The PIC12LF1552 ROM (2kw) was filled by the time I added print statements for 3 screens, all with different fonts. - but hey, makes for a really neat greeting card message thingy running off a CR2032 battery...

    I was using both fonts 1 and 2 - maybe could get more screens by dropping Font2,
    But that's not the point anyway...
    The 3-screen greeting card is a stake in the ground, a calibration point, using standard GCBASIC - it's 2kw ROM and 202B RAM - without any attempt at further optimisation.
    I'd be interested to know what resources Arduino needs, to do the same thing.

    I'll post more screens later. The one below is GLCDFontWidth= 5, font1 - and is the best density. The default is GLCDFontWidth= 6, and just adds another column of kerning (2 pixels between characters not 1 pixel) - and reads better.

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.