News:

Let's find out together what makes a PIC Tick!

Main Menu

0.96" OLED displays with SSD1315 chip

Started by david, Apr 09, 2021, 09:22 PM

Previous topic - Next topic

david

Hi All,
A friend who is a contract pcb designer has given me about 6pcs of a small OLED display - 0.96" screen, 128x64 and using a SSD1315 chip.  He sent also a data sheet which appears to cover mainly the display more than the finished module but it does include an outline drawing of the board.  It mentions nothing about the various jumper options on the rear of the module - 2 are for I2C address options but the other 4 appear to have just + and - symbols next to them.    The data sheet indicates Typ supply 2.8V and Max 3.3V - not ideal for what I want.

I've never used OLED displays before and I'm curious as to the resources required.  2 pin displays sound great but not if they need heaps of code space and 1k RAM.
I know quite a few of you have used OLED displays - can you point me towards the beginners classes.  I don't need graphics and just little numbers would be fine.

Cheers,
David

xldaedalus

First, you need an I2C transmit code.  This will require you to get the I2C address of the display. See datasheet.

Yes, to print to the screen fast, you will need to have the entire display in RAM.  You can get by without it, but its a bit more complicated.

There are COMMAND strings and DATA strings. COMMANDs do things like turn the display ON and OFF, position the "cursor",   DATA strings are the bytes that contain the bits that turn the display pixels ON and OFF.  Unlike Alpha Numeric display, you will need to generate your own fonts.

Most graphic displays like your OLED have the byte data in vertical lines.  For example if you wanted to draw line across the screen (64 bytes wide) you'd send something like %00001000, %00001000, %00001000, ... etc 64 times. 1 = pixel ON. 0 = pixel OFF.

Yes, its a lot of work creating a library to do this.  It took me a couple of months to get something going that was fast and reliable.  I couldn't find any easy way to do it.  The fastest, best way to do write the display is create the display image in RAM, then send it using and interrupt.  Sending 1024 bytes takes a while if you stuck with I2C, which may be limited to 800khz - @ 1 byte per 10uS which is about 10mS to update the screen. It can take up to 60mS to do all the math required to build the image. If you have an EEPROM memory, you can pre-construction 1kbyte strings in memory that up can just upload - splash screens, data output with blanks, and have your code fill in the blanks before sending.  Obviously, if you are only changing a small portion of the screen, you just changes the bytes in your display string associated with the what you want to change.

There are lots of code examples of how all this is done using Google search.  Les has may nice libraries.  I've seen libraries on the previous site.  Maybe if you buy an upgrade to his latest compiler (the Procedures functions are absolutely awesome!!) or donate to the cause, he may throw in a library to help you on your way.  He may have posted them some where here, I don't know.  In any case, there is no easy way. But, in tackling a program like this, your skills as a good programmer while increase dramatically!  In the end, it will be will worth your effort.
Never, never, never give up

david

Many thanks for your detailed reply.
I did download the SSD1315 data sheet from Solomon last night and have been studying that.  It's certainly a much bigger task than I had expected but I have time on my side.
I guess I was hoping that I could use little jelly-bean PICs to talk to an I2C display but as feared the code resource is considerable and these are really little displays for biggish chips.
I have waded through some of the code examples on line but most are for the SSD1306 (not a big issue) but I get really frustrated when the example is full of "includes" and when you go off to look those up they also have includes and so on. Perhaps I'm old fashioned but I like all the code readable in one place.
I shall carry on even if it's just to light up a single pixel on the screen but longer term I may be better off with a 8x1 character LCD which requires a lot less code but more pins.  I guess what I'd really like is a miniature I2C OLED character display.
Thanks again for taking the time to reply - it has helped me understand these little devices better.

Best regards,
David

david

#3
Hi All,
I've been trying to come to grips with the OLED displays and now have something to show for the many confused hours spent.  It's just a crude demonstrator and does nothing useful but it perhaps indicates that for some simple applications these cheap displays (about 1.30 Pounds) may be usable even with little micros.  While they are low on pin count they are fairly demanding on code space and (ideally) RAM.  For larger chips they are very versatile displays.   My original application (RC plane max speed reading) only requires a 3 digit readout and I can use an 8 pin micro to do both the GPS parsing and the final readout.
There are plenty of resources on the internet but I wish you luck tracking down all the "include" files to make sense of what is going on. 

'OLED drive with I2C  Needs 4.7k pull-up resistors on clk, data lines
'128x64 display (dual colour) using SSD1315 chip. 
'
'                  Vdd <1 U 8> Gnd   
'    Spare I/O     RA5 <2   7> RA0  Spare I/O
'    Spare I/O     RA4 <3   6> RA1  SCL
'   Spare input    RA3 <4   5> RA2  SDA           


Device = 12F1840
Config1 FCMEN_OFF, IESO_OFF, CLKOUTEN_OFF, BOREN_OFF, CPD_OFF, CP_OFF, MCLRE_OFF, PWRTE_ON, WDTE_OFF, FOSC_INTOSC
Config2 LVP_OFF, BORV_19, STVREN_OFF, PLLEN_OFF, WRT_OFF

Declare Xtal = 16 'Internal OSC
OSCCON = %01111010    '16MHz=01111010, 4MHz=01101010, 8MHz =01110010
TRISA = %00000110     '
Declare Hbus_Bitrate 400    '100kHz or 400kHz
SSPCON1=%00111000       'enable port, 7 bit address, master mode
Symbol OLED_W= %1111000  'OLED address and write
Symbol OLED_R= %1111001  'OLED address and read 

'**********    variables   ******************
Dim Col As Byte
Dim Pge As Byte

'initialize display
        HBusOut OLED_W,[$80,$AE,_      'display OFF
                        $00,$20,$00,_  'Mem mode  Horiz
                        $00,$81,$7F,_  'contrast control reg/value
                        $80,$A1,_      'set segment remap
                        $80,$A4,_      'graphic RAM displayed
                        $80,$A6,_      'display norm/reverse
                        $00,$A8,$3F,_  'multiplex ratio/value
                        $80,$C8,_      'com scan direction
                        $00,$D5,$90,_  'set osc division/value
                        $00,$D9,$22,_  'set precharge period/value
                        $00,$DA,$12,_  'set Com pins/value
                        $00,$DB,$30,_  'set vcomh/value
                        $00,$8D,$14,_  'set charge pump enable/value
                        $80,$AF]       'display ON
   
       DelayMS 1000
Wipe:      'clearing random display in RAM
       For Pge=$B0 To $B7
        HBusOut OLED_W,[$00,$22,Pge,$07]   'Set page start/end
         For Col=0 To 127
           HBusOut OLED_W,[$40,$00,$00,$00,$00,$00,$00,$00,$00]   
         Next Col       'wipe vertical columns
      Next Pge
      DelayMS 1000
     
'Writing to row 0 (yellow)
      HBusOut OLED_W,[$00,$21,$00,$7F]   'Reset column range and pointer
      HBusOut OLED_W,[$00,$22,$00,$07]   'Reset page range and pointer
      GoSub Numbers
     
'Writing to row 2  (blue)     
      HBusOut OLED_W,[$00,$21,$00,$7F]  'Reset column range And pointer
      HBusOut OLED_W,[$00,$22,$02,$07]   'Reset Page range And pointer
      GoSub Numbers
      DelayMS 5000
      GoTo Wipe
     
Numbers:
      HBusOut OLED_W,[$40,$7C, $A2, $92, $8A, $7C, $00]     '0
      HBusOut OLED_W,[$40,$00, $84, $FE, $80, $00, $00]     '1
      HBusOut OLED_W,[$40,$C4, $A2, $92, $92, $8C, $00]     '2
      HBusOut OLED_W,[$40,$44, $82, $92, $92, $6C, $00]     '3
      HBusOut OLED_W,[$40,$18, $14, $12, $FE, $10, $00]     '4
      HBusOut OLED_W,[$40,$9E, $92, $92, $92, $62, $00]     '5
      HBusOut OLED_W,[$40,$7C, $92, $92, $92, $64, $00]     '6
      HBusOut OLED_W,[$40,$06, $02, $E2, $12, $0E, $00]     '7
      HBusOut OLED_W,[$40,$6C, $92, $92, $92, $6C, $00]     '8
      HBusOut OLED_W,[$40,$4C, $92, $92, $92, $7C, $00]     '9
      Return     
       
End

As mentioned the code shown doesn't do anything but it may encourage some to buy a display and have a play.
My ideal display would perhaps be an I2C controlled OLED character display - i.e low pin count, high contrast, wide viewing angle, low code overhead and small.
The attached photo shows one of the displays that has a dual colour layout - the top 16 rows are yellow LEDs while the remaining 48 rows are blue.
Next stage is to optimize the code a bit more and to make the font table addressable so that if my speed=125 I can then print "125" on the screen.  Still a long way to go but I hope it will all fit in to 1k which would make the displays usable for jelly-bean applications.

Cheers,
David
   

david

Hi All,
Slow progress but I now have a fairly full font table (ascii 46 to 122) stored in code and the basics of calling individual characters.  It's only small print in order to keep the code space down and even the font table has been pruned since all the characters had a column of $00 on the right side (character spacer) so this was removed and instead a blank column is printed after each character, saving about 70 bytes of code.
The picture shows a white display of continuous characters, some being split at the end of a row because the characters themselves are 7x5 but printed on an 8x6 grid and with the screen width at 128 pixels wide the 22nd character is split in to the next row.  I will eventually arrange to make the display a 21x8 character display.
Still to do is the conversion from a print string or variable to screen output but this should not be too hard.
The picture also shows a reverse side of the board.  The 3 pin device (looks like a SC-70 transistor) is I think a 5V-3.3V regulator.  I've not checked the voltages but I know one pin is connected to Vcc in and one to ground so I'm confident it's a regulator.  What I'm not sure about is if the SSD1315 likes the 5V I2C lines because of the external pull-ups.   No issues so far and it's clocking nicely at 1MHz.
The displays are very sharp and probably look even better with the protective film removed. Code space is 812 bytes with everything in one place - no endless "include" trails.
This is not going to compete with the much bigger OLED libraries running on much bigger chips but it may allow hobby applications on very modest hardware.
Latest code effort attached and I will add any further enhancements when available.  I would welcome other input for improvements and corrections.

Best regards,
David

'OLED drive with hardware I2C  Needs 4.7k pull-up resistors on clk, data lines
'128x64 display using SSD1315 chip.   818 bytes with fonts ascii 46 to 122
'
'                  Vdd <1 U 8> Gnd   
'    Spare I/O     RA5 <2   7> RA0  Spare I/O
'    Spare I/O     RA4 <3   6> RA1  SCL
'   Spare input    RA3 <4   5> RA2  SDA           


Device = 12F1840
Config1 FCMEN_OFF, IESO_OFF, CLKOUTEN_OFF, BOREN_OFF, CPD_OFF, CP_OFF, MCLRE_OFF, PWRTE_ON, WDTE_OFF, FOSC_INTOSC
Config2 LVP_OFF, BORV_19, STVREN_OFF, PLLEN_OFF, WRT_OFF

Declare Xtal = 16 'Internal OSC
OSCCON = %01111010    '16MHz=01111010, 4MHz=01101010, 8MHz =01110010
TRISA = %00000110     '
Declare Hbus_Bitrate 1000    '100kHz, 400kHz, 1000kHz
SSPCON1=%00111000       'enable port, 7 bit address, master mode
Symbol OLED_W= %1111000  'OLED address and write
Symbol OLED_R= %1111001  'OLED address and read 

'**********    variables   ******************
Dim Col As Byte  'columns - applies to Cdata, characters or absolute no.
Dim Pge As Byte  'effectively lines 0 to 7 down display
Dim num As Byte  'absolute index number in Cdata array
Dim Chr As Byte 'Character in Cdata array

'initialize display
        HBusOut OLED_W,[$80,$AE,_      'display OFF
                        $00,$20,$00,_  'Mem mode  Horiz
                        $00,$81,$7F,_  'contrast control reg/value
                        $80,$A1,_      'set segment remap
                        $80,$A4,_      'graphic RAM displayed
                        $80,$A6,_      'display norm/reverse
                        $00,$A8,$3F,_  'multiplex ratio/value
                        $80,$C8,_      'com scan direction
                        $00,$D5,$90,_  'set osc division/value
                        $00,$D9,$22,_  'set precharge period/value
                        $00,$DA,$12,_  'set Com pins/value
                        $00,$DB,$30,_  'set vcomh/value
                        $00,$8D,$14,_  'set charge pump enable/value
                        $80,$AF]       'display ON
   
       DelayMS 1000
Wipe:      'clearing random display in RAM
       For Pge=$B0 To $B7
        HBusOut OLED_W,[$00,$22,Pge,$B7]   'Set page start/end
         For Col=0 To 127
           HBusOut OLED_W,[$40,$00,$00,$00,$00,$00,$00,$00,$00]   
         Next Col       'wipe vertical columns
      Next Pge
      DelayMS 1000
     

'Printing the full character set ascii 46 - 122       
      HBusOut OLED_W,[$00,$21,$00,$7F]  'Reset column range And pointer
      HBusOut OLED_W,[$00,$22,$00,$07]   'Reset Page range And pointer
           
      For Chr=0 To 76      '(or ascii 46 to ascii 122)  print all the characters
       For Col=0 To 4
       num= CRead8 Fonts [Chr*5+Col]
        HBusOut OLED_W,[$40,num]
       Next Col                    'print 5 values into columns 0 to 4 for each character
       HBusOut OLED_W,[$40,$00]    'print blank spacer column in to 6th column
      Next Chr
       
      DelayMS 5000
      GoTo Wipe
     
                         
Dim Fonts As Code=As Byte  $C0, $C0, $00, $00, $00,_     ' char .   0 Start +4   ascii 46
                           $80, $40, $20, $10, $08,_     ' char /   1  x5   +4
                           $7C, $A2, $92, $8A, $7C,_      ' char 0  2  x5   +4
                           $00, $84, $FE, $80, $00,_      ' char 1  3
                           $C4, $A2, $92, $92, $8C,_      ' char 2  4
                           $44, $82, $92, $92, $6C,_      ' char 3  5
                           $18, $14, $12, $FE, $10,_      ' char 4  6
                           $9E, $92, $92, $92, $62,_      ' char 5  7
                           $7C, $92, $92, $92, $64,_      ' char 6  8
                           $06, $02, $E2, $12, $0E,_      ' char 7  9
                           $6C, $92, $92, $92, $6C,_      ' char 8  10
                           $4C, $92, $92, $92, $7C,_      ' char 9  11
                           $CC, $CC, $00, $00, $00,_      ' char :  12
                           $AC, $6C, $00, $00, $00,_      ' char ;  13
                           $00, $10, $28, $44, $82,_      ' char <  14
                           $48, $48, $48, $48, $48,_      ' char =  15
                           $00, $82, $44, $28, $10,_      ' char >  16
                           $04, $02, $B2, $12, $0C,_      ' char ?  17
                           $7C, $82, $BA, $AA, $BC,_      ' char @  18
                           $F8, $14, $12, $14, $F8,_      ' char A  19
                           $FE, $92, $92, $92, $6C,_      ' char B  20
                           $7C, $82, $82, $82, $44,_      ' char C  21
                           $FE, $82, $82, $44, $38,_      ' char D  22
                           $FE, $92, $92, $82, $82,_      ' char E  23
                           $FE, $12, $12, $02, $02,_      ' char F  24
                           $7C, $82, $92, $92, $F4,_      ' char G  25
                           $FE, $10, $10, $10, $FE,_      ' char H  26
                           $00, $82, $FE, $82, $00,_      ' char I  27
                           $60, $80, $80, $80, $7E,_      ' char J  28
                           $FE, $10, $18, $24, $C2,_      ' char K  29
                           $FE, $80, $80, $80, $80,_      ' char L  30
                           $FE, $04, $38, $04, $FE,_      ' char M  31
                           $FE, $04, $08, $10, $FE,_      ' char N  32
                           $7C, $82, $82, $82, $7C,_      ' char O  33
                           $FE, $12, $12, $12, $0C,_      ' char P  34
                           $7C, $82, $A2, $C2, $FC,_      ' char Q  35
                           $FE, $12, $12, $12, $EC,_      ' char R  36
                           $4C, $92, $92, $92, $64,_      ' char S  37
                           $02, $02, $FE, $02, $02,_      ' char T  38
                           $7E, $80, $80, $80, $7E,_      ' char U  39
                           $3E, $40, $80, $40, $3E,_      ' char V  40
                           $FE, $80, $70, $80, $FE,_      ' char W  41
                           $C6, $28, $10, $28, $C6,_      ' char X  42    255
                           $06, $08, $F0, $08, $06,_      ' char Y  43
                           $C2, $A2, $92, $8A, $86,_      ' char Z  44
                           $00, $FE, $82, $82, $00,_      ' char [  45
                           $08, $10, $20, $40, $80,_      ' char BackSlash
                           $00, $82, $82, $FE, $00,_      ' char ]  47
                           $00, $08, $04, $02, $04,_      ' char ^  48
                           $80, $80, $80, $80, $80,_      ' char _  49
                           $00, $00, $02, $04, $00,_      ' char `  50
                           $40, $A8, $A8, $A8, $F0,_      ' char a  51
                           $FE, $88, $88, $88, $70,_      ' char b  52
                           $70, $88, $88, $88, $10,_      ' char c  53
                           $70, $88, $88, $88, $FE,_      ' char d  54
                           $70, $A8, $A8, $A8, $30,_      ' char e  55
                           $10, $FC, $12, $12, $04,_      ' char f  56
                           $90, $A8, $A8, $A8, $70,_      ' char g  57
                           $FE, $10, $10, $10, $E0,_      ' char h  58
                           $00, $90, $F4, $80, $00,_      ' char i  59
                           $40, $80, $80, $90, $74,_      ' char j  60
                           $FE, $20, $50, $88, $00,_      ' char k  61
                           $7E, $80, $80, $00, $00,_      ' char l  62
                           $F8, $08, $70, $08, $F0,_      ' char m  63
                           $F8, $08, $08, $08, $F0,_      ' char n  64
                           $70, $88, $88, $88, $70,_      ' char o  65
                           $F8, $28, $28, $28, $10,_      ' char p  66
                           $10, $28, $28, $F8, $80,_      ' char q  67
                           $F8, $08, $08, $08, $10,_      ' char r  68
                           $90, $A8, $A8, $A8, $48,_      ' char s  69
                           $08, $08, $FE, $88, $88,_      ' char t  70
                           $78, $80, $80, $80, $F8,_      ' char u  71
                           $38, $40, $80, $40, $38,_      ' char v  72
                           $F8, $80, $70, $80, $F8,_      ' char w  73
                           $88, $50, $20, $50, $88,_      ' char x  74
                           $18, $A0, $A0, $A0, $78,_      ' char y  75
                           $88, $C8, $A8, $98, $88        ' char z  76  x5 +4    ascii 122
 End               


david

#5
Hi All,
Attached is the third and probably final version of this demonstration code. The font table now covers ascii 32 (Space) to ascii 122 (lower case z) and the code includes a simple string print on screen.  Total code space is 950 bytes and with only 2 I/O pins required it should be possible to use something like this for modest hobby projects.
It is reasonably well commented so should be possible to follow the processes involved.  The SSD1315 appears to be a later version of the widely used SSD1306 chip. 
Never again will I take for granted the simple command Print at x,y, "Hello World".

Cheers,
David

'OLED drive with hardware I2C  Needs 4.7k pull-up resistors on clk, data lines
'128x64 display using SSD1315 chip.   949 bytes with fonts ascii 32 to 122 
'
'                  Vdd <1 U 8> Gnd   
'    Spare I/O     RA5 <2   7> RA0  Spare I/O
'    Spare I/O     RA4 <3   6> RA1  SCL
'   Spare input    RA3 <4   5> RA2  SDA           


Device = 12F1840
Config1 FCMEN_OFF, IESO_OFF, CLKOUTEN_OFF, BOREN_OFF, CPD_OFF, CP_OFF, MCLRE_OFF, PWRTE_ON, WDTE_OFF, FOSC_INTOSC
Config2 LVP_OFF, BORV_19, STVREN_OFF, PLLEN_OFF, WRT_OFF

Declare Xtal = 16 'Internal OSC
OSCCON = %01111010    '16MHz=01111010, 4MHz=01101010, 8MHz =01110010
TRISA = %00000110     '
Declare Hbus_Bitrate 1000    '100kHz, 400kHz, 1000kHz
SSPCON1=%00111000       'enable port, 7 bit address, master mode
Symbol OLED_W= %1111000  'OLED address and write
Symbol OLED_R= %1111001  'OLED address and read 

'**********    variables   ******************
Dim Col As Byte  'columns - applies to Cdata, characters or absolute no.
Dim Pge As Byte  'effectively lines 0 to 7 down display
Dim num As Byte  'absolute index number in Cdata array
Dim Chr As Byte 'Character in Cdata array
Dim length As Byte
Dim mystring As String *20
Dim ascii As Byte

'initialize display
        HBusOut OLED_W,[$80,$AE,_      'display OFF
                        $00,$20,$00,_  'Mem mode  Horiz
                        $00,$81,$7F,_  'contrast control reg/value
                        $80,$A1,_      'set segment remap
                        $80,$A4,_      'graphic RAM displayed
                        $80,$A6,_      'display norm/reverse
                        $00,$A8,$3F,_  'multiplex ratio/value
                        $80,$C8,_      'com scan direction
                        $00,$D5,$90,_  'set osc division/value
                        $00,$D9,$22,_  'set precharge period/value
                        $00,$DA,$12,_  'set Com pins/value
                        $00,$DB,$30,_  'set vcomh/value
                        $00,$8D,$14,_  'set charge pump enable/value
                        $80,$AF]       'display ON
       DelayMS 1000
       
'clearing random display in RAM       
Wipe:     
       For Pge=$B0 To $B7
        HBusOut OLED_W,[$00,$22,Pge,$B7]   'Set page start/end
         For Col=0 To 127
           HBusOut OLED_W,[$40,$00,$00,$00,$00,$00,$00,$00,$00]   
         Next Col       'wipe vertical columns
      Next Pge
      DelayMS 1000

'printing a sample string on the screen 
     mystring="Hello World 12345"      'print input
     HBusOut OLED_W,[$00,$21,$00,$7F]  'Reset column range, pointer to zero
     HBusOut OLED_W,[$00,$22,$00,$07]  'Reset Page range, pointer to zero

'indexing the look up table     
     For Chr=0 To Len (mystring)-1     
     ascii=mystring[Chr]-32
       For Col=0 To 4                  '5 bytes per character
       num= CRead8 Fonts [ascii*5+Col]
        HBusOut OLED_W,[$40,num]       'print 5 values into columns 0 to 4 for each character
       Next Col                   
       HBusOut OLED_W,[$40,$00]        'print blank spacer column in to 6th column
      Next Chr
       
      DelayMS 5000                   'delay
      GoTo Wipe                      'do it again
     
'character font table             
Dim Fonts As Code=As Byte  $00, $00, $00, $00, $00,_      ' char space  0 Start +4chr ascii 32
                           $00, $00, $BE, $00, $00,_      ' char !      1  *5   +4chr
                           $00, $00, $03, $00, $03,_      ' char "
                           $50, $F8, $50, $F8, $50,_      ' char #
                           $48, $54, $FE, $54, $24,_      ' char $
                           $98, $58, $20, $D0, $C8,_      ' char %
                           $60, $9C, $AA, $44, $80,_      ' char &
                           $00, $00, $00, $03, $00,_      ' char '
                           $00, $38, $44, $82, $00,_      ' char (
                           $00, $82, $44, $38, $00,_      ' char )
                           $02, $06, $03, $06, $02,_      ' char *
                           $10, $10, $7C, $10, $10,_      ' char +
                           $A0, $60, $00, $00, $00,_      ' char ,
                           $10, $10, $10, $10, $10,_      ' char -
                           $C0, $C0, $00, $00, $00,_      ' char . 
                           $80, $40, $20, $10, $08,_      ' char / 
                           $7C, $A2, $92, $8A, $7C,_      ' char 0 
                           $00, $84, $FE, $80, $00,_      ' char 1 
                           $C4, $A2, $92, $92, $8C,_      ' char 2 
                           $44, $82, $92, $92, $6C,_      ' char 3 
                           $18, $14, $12, $FE, $10,_      ' char 4 
                           $9E, $92, $92, $92, $62,_      ' char 5 
                           $7C, $92, $92, $92, $64,_      ' char 6 
                           $06, $02, $E2, $12, $0E,_      ' char 7 
                           $6C, $92, $92, $92, $6C,_      ' char 8 
                           $4C, $92, $92, $92, $7C,_      ' char 9 
                           $CC, $CC, $00, $00, $00,_      ' char : 
                           $AC, $6C, $00, $00, $00,_      ' char ; 
                           $00, $10, $28, $44, $82,_      ' char < 
                           $48, $48, $48, $48, $48,_      ' char = 
                           $00, $82, $44, $28, $10,_      ' char > 
                           $04, $02, $B2, $12, $0C,_      ' char ? 
                           $7C, $82, $BA, $AA, $BC,_      ' char @ 
                           $F8, $14, $12, $14, $F8,_      ' char A 
                           $FE, $92, $92, $92, $6C,_      ' char B 
                           $7C, $82, $82, $82, $44,_      ' char C 
                           $FE, $82, $82, $44, $38,_      ' char D 
                           $FE, $92, $92, $82, $82,_      ' char E 
                           $FE, $12, $12, $02, $02,_      ' char F 
                           $7C, $82, $92, $92, $F4,_      ' char G 
                           $FE, $10, $10, $10, $FE,_      ' char H 
                           $00, $82, $FE, $82, $00,_      ' char I 
                           $60, $80, $80, $80, $7E,_      ' char J 
                           $FE, $10, $18, $24, $C2,_      ' char K 
                           $FE, $80, $80, $80, $80,_      ' char L 
                           $FE, $04, $38, $04, $FE,_      ' char M 
                           $FE, $04, $08, $10, $FE,_      ' char N 
                           $7C, $82, $82, $82, $7C,_      ' char O 
                           $FE, $12, $12, $12, $0C,_      ' char P 
                           $7C, $82, $A2, $C2, $FC,_      ' char Q 
                           $FE, $12, $12, $12, $EC,_      ' char R 
                           $4C, $92, $92, $92, $64,_      ' char S 
                           $02, $02, $FE, $02, $02,_      ' char T 
                           $7E, $80, $80, $80, $7E,_      ' char U 
                           $3E, $40, $80, $40, $3E,_      ' char V 
                           $FE, $80, $70, $80, $FE,_      ' char W 
                           $C6, $28, $10, $28, $C6,_      ' char X     
                           $06, $08, $F0, $08, $06,_      ' char Y 
                           $C2, $A2, $92, $8A, $86,_      ' char Z 
                           $00, $FE, $82, $82, $00,_      ' char [ 
                           $08, $10, $20, $40, $80,_      ' char \
                           $00, $82, $82, $FE, $00,_      ' char ] 
                           $00, $08, $04, $02, $04,_      ' char ^ 
                           $80, $80, $80, $80, $80,_      ' char _ 
                           $00, $00, $02, $04, $00,_      ' char ` 
                           $40, $A8, $A8, $A8, $F0,_      ' char a 
                           $FE, $88, $88, $88, $70,_      ' char b 
                           $70, $88, $88, $88, $10,_      ' char c 
                           $70, $88, $88, $88, $FE,_      ' char d 
                           $70, $A8, $A8, $A8, $30,_      ' char e 
                           $10, $FC, $12, $12, $04,_      ' char f 
                           $90, $A8, $A8, $A8, $70,_      ' char g 
                           $FE, $10, $10, $10, $E0,_      ' char h 
                           $00, $90, $F4, $80, $00,_      ' char i 
                           $40, $80, $80, $90, $74,_      ' char j 
                           $FE, $20, $50, $88, $00,_      ' char k 
                           $7E, $80, $80, $00, $00,_      ' char l 
                           $F8, $08, $70, $08, $F0,_      ' char m 
                           $F8, $08, $08, $08, $F0,_      ' char n 
                           $70, $88, $88, $88, $70,_      ' char o 
                           $F8, $28, $28, $28, $10,_      ' char p 
                           $10, $28, $28, $F8, $80,_      ' char q 
                           $F8, $08, $08, $08, $10,_      ' char r 
                           $90, $A8, $A8, $A8, $48,_      ' char s 
                           $08, $08, $FE, $88, $88,_      ' char t 
                           $78, $80, $80, $80, $F8,_      ' char u 
                           $38, $40, $80, $40, $38,_      ' char v 
                           $F8, $80, $70, $80, $F8,_      ' char w 
                           $88, $50, $20, $50, $88,_      ' char x 
                           $18, $A0, $A0, $A0, $78,_      ' char y 
                           $88, $C8, $A8, $98, $88        ' char z     ascii 122

 End               



John Drew

G'day David, that's a really nifty solution and too good to be lost in the depths of the forum.
How about putting an article in the WIKI?
Cheers
John

david

#7
Hello John,
I'll think on that.  I would like to promote these little displays for hobby work but generally the libraries are quite big and hard to follow for plodders like me.  Can you outline what's involved in a WIKI contribution?

It's now pretty much where I want it and this morning I had a crash course in what was a numeric variable and what was a string and how to switch between them for doing maths one moment and printing the next.

This says it all-
mystring= "1st " +Str$(Dec speed1) + "  kph"      'print input
GoSub printing 

I think it's at a level where someone more competent could make it very useful but of course it is limited to a small font and no graphics to squeak in under the 1K code size.
The attached photo shows the OLED code blended with my earlier RC plane GPS speed project. I no longer log the data to EEPROM for later playback and instead keep a live track of the top 3 speeds detected during a flight.  That allows field changes (like props) and immediate retrials.  Only 3 micro pins required!   BTW - that's me running - not my plane flying.......

Cheers,
David

John Drew

Greetings David,
Re the Wiki, from the home page click on:
WIKI
Code Examples
LCD Graphic
New topic

and from there it's just like a normal post where you can add attachments if need be.

A couple of questions:
How fast does your program clear the screen?
I think I can see how you adjust the position on the screen. Any chance of a procedure like the AT_XY(x,y) to position the cursor? I can probably work it out myself using your column and row section but I reckon it would be a useful addition to the program - understanding you were limiting the size of the program intentionally. Your one size fonts is a good compromise. It amazes me how clear those little displays are.

All the best
John

david

Thanks for the info John - I'll see what I can do in the next few days.

I started running the I2C at 100kHz then went to 400kHz and lastly 1000kHz.  It's fast - you see a blink but it's not like a fast scan.  I was pleasantly surprised how quick it was but I may look at an alternative method just to compare.

I wondered about a Print at x,y but it's almost superfluous.  Take the present basic command-

     HBusOut OLED_W,[$00,$21,$00,$7F]  'Reset column range, pointer to zero
     HBusOut OLED_W,[$00,$22,$04,$07]  'Reset Page range, pointer to 4
     mystring= "2nd "+Str$ (Dec speed2) +"  kph"      'print input
     Gosub printing

In line one the 3rd and 4th data bit ($00, $7F or 0, 127) set the column start (from left side) and column end.  If you wanted to start printing half way across the page you would use ($40, $7F or 64, 127)
Similarly in line two the 3rd and 4th data bits ($04, $07 or 4, 7) set the print line start (from top line) and end.  So the first 3 lines are effectively -
Location x
Location Y
Print string information

I use a gosub for the actual print routine but I'm sure procedures could be used. 
The overhead compared to a Print at x,y "nnnnn" is really not too bad and quick to get familiar with.

They are very cheap and very sharp little displays but that print is quite small.  That said,  it does provide 21 characters x 8 lines.  I remember thinking 16x2 LCDs were too limiting.....    There are all sorts of effects you can use such as changing contrast on the fly, dimming to off, flashing, inverse etc but once the Gee Whiz factor is over how often do you use them?

Cheers,
David