News:

;) This forum is the property of Proton software developers

Main Menu

OLED libraries for SSD1306 and SH1106

Started by Dompie, Feb 05, 2021, 11:30 AM

Previous topic - Next topic

Dompie

I have put the latest versions of the SSD1306 and the SH1106 libraries in the Downloads.
SSD1306 library here
SH1106 library here

Johan

Bob (G8GFA)

Thanks a lot for sharing these Dompie. I've used your drivers in a number of projects and they've never let me down. Class programming!

OG

I've looked at the codes and videos now.
Nice job Johan.

RayEllam

Hi All,
Im looking at modifying the PIC18 code posted by Johan for SSD1306 so I can use it on a PIC24FJ. Obviously there are register differences between the PIC18 + PIC24 as well as compile errors relating to FSR registers for indirect addressing. Im wondering does anyone have working code for a PIC24 they would be willing to share? If not then ill have a stab at getting the code to work on PIC24.

Best regards
Ray

RayEllam

#4
Hi All,
I had a problem with the latest library, my setup is as follows

Display: SSD1306 I2C
PIC: 18F24J50
compiler: 3.7.5.5
Communications: I2C

The issue became apparent when putting the PIC in deep sleep mode, the PIC would go into deep sleep and draw around 5uA of current (expected) but when I tried to awake it via INT0 the PIC would wake up with normal current consumption but disappear into "never never land" (it did not run the POR code). I traced the issue to the SSD1306_Sub_v1.11.inc file. The problem was the HBUS commands that were presumably taking the PIC into unknown tertiary. I modified this file and named it SSD1306_BB_Sub_v1.11 (attached). I replaced all the HBUS commands with BUS commands so now it works as a bit banger rather than using the I2C PIC hardware.

Maybe this helps a few people who need ultra low power?

Regards
Ray

John Drew

Thanks Johan, I often use your library. A top programming job.
Ray, when you get it going on the 16 bit device please put it in downloads too.
John

RayEllam

I will John. Due to Microchips parametric search it told me that most devices containing an RTCC were 24 parts. I did NOT believe this and I manually  searched for parts with an RTCC on google and found that most of the PIC18FxxJxx parts have an RTCC.................the upshot being i have no need at the mo to modify the library :-)

LOTS of time saved, and do not TRUST the Microchip parametric search when selecting parts ;-)

Regards
Ray

Dompie

Thank you Ray, this may also the solution to the SSD1306 display getting upset sometimes (on some 1.3 "displays with SSD1306).

Johan

RayEllam

#8
Thank you Johan for the many hours of work you have put into this great library. Those little displays are super cheap and super bright, gone are the days of using LCD's (as far as I'm concerned)

John Drew

Ray, the 18f4685 has an internal clock if you add a watch crystal.
John

RayEllam

Thanks John, I'll check that out. I still have not ordered the pic I will use For this project. I have been developing the bulk of the code on a pic18f without an rtcc. I need to order by Monday, I'll add that one to my short list.

Cheers matey 😎

John Drew

#11
Ray, I think I mislead you. It was an old project and I wrote a routine for a clock, not a hardware RTC after all. Sorry about that. The 18f4685 does not have a RTC.
Cheers
John

RayEllam

No probs. I took a quick scan of the data sheet but it lacks deep sleep as well as some other stuff. The best candidate I have found so far is a pic18f25j11, it has a very low power deep sleep function and two 8 bit persistent registers I can write to before deep sleep 🥳 I think this is the one I'll order from mouser.

Yves

Hello Picsters,

I have a breakout for the SSD1306 and I can't find anymore the spec, there are many pins configuration and the internet is a bit confusing about the operating voltages some pretend they are 3.3 and other 5V compliant, Hope my particular unit being 5V. I have attached my unit and even though I think it is an I2C type I'm still confused about the pins name.  Please see attached.

Regards

Yves
Yves

top204

#14
It has a CS line, so it is probably SPI, because I2C does not use a Chip Select line. Take a look on the back of the PCB and if it has a regulator chip, it will operate from 5 volts, but if using a 5 volt microcontroller, place 2.2K Ohm series resistors on the lines leading to the LCD. It is a write only LCD board, so it does not matter that the LCD device will only give a 3.3 volt signal back, because nothing will be listening. :-)


trastikata

Thank you for the code and effort, Dompie. Some time ago I used your code as starting point and it was very helpful to understanding the SSD1306.

I looked through your functions and maybe it is worth adding the scrolling effect? Here is some code I used in one of my programs for horizontal left scroll of the first line using my font:

    GoSub PRINT_MY_LINE

    HBStart
        HBusOut SSD1306         ;Slave address
       
        HBusOut ControlByteCMD  ;
        HBusOut $2E             'Stop Scroll
       
        HBusOut ControlByteCMD  ;
        HBusOut $27             'Set horizontal left Scroll
       
        HBusOut ControlByteCMD  ;
        HBusOut $00             'A dummy
       
        HBusOut ControlByteCMD  ;
        HBusOut %00000000       'B Start page = 0
       
        HBusOut ControlByteCMD  ;
        HBusOut %00000111       'C time interval = 2 frames
       
        HBusOut ControlByteCMD  ;
        HBusOut %00000000       'D End page = 0
       
        HBusOut ControlByteCMD  ;
        HBusOut $00             'E dummy = 0
       
        HBusOut ControlByteCMD  ;
        HBusOut $FF             'F dummy = 255
       
        HBusOut ControlByteCMD  ;
        HBusOut $2F             'Start scrolling
    HBStop
   
    DelayMS 8000
   
    HBStart
        HBusOut SSD1306         ;Slave address
        HBusOut ControlByteCMD  ;
        HBusOut $2E             'Stop Scroll
    HBStop

 

Yves

Hello Johan,
I'm sorry to bother you but because you have a great knowledge of the SSD1306 I would like some advice on the connection of the SSD1306 I bought. As you know they come out with many brands. I have tried to connect it with your publish code in the forum "Graphic&SSD1306_20201101" I believe the code as is default is by default I2C. I'm also using the 18F26k22 chip too. My display can be connected to 5 V which is connected to Vin and ground to GND as Adafruit specification. Where I'm having problems is the rest of the connections as it is not working at the moment. I have attached pictures of the front and back of my display. Please let me know at what corresponding pins I should connect it. My display has the following pin connections:
GND, Vin, 3Vo, CS, RST, A0-DC, CLK and Data. The address is 0x3D
Yves

John Drew

While waiting for Johan. I have similar boards and mine default to SPI, but they can be changed to I2C by moving some of the SM resistors. My boards have the needed changes printed on the board.
John

Yves

Hi John,
It is getting confusing pulling my hairs. I thought the default mode was I2C but looking at the oscilloscope on  it resembles SPI protocol.

Regards,

Yves
Yves

John Drew

Hi Yves,
It is also possible to buy I2C boards only. I have 3 of those working. I2C is plenty fast enough for these little displays. They are surprisingly useful. I won't be using 2×16 LCDs any more.
I have another 3 of the dual mode devices but I've sent them to a friend to move the resistors. SM is beyond me - shaky hands. I've also had success with the larger graphic displays thanks to people on the forum.
Cheers
John