View previous topic :: View next topic |
Author |
Message |
Pzx
Joined: 05 May 2015 Posts: 39
|
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Sat Feb 25, 2017 2:00 pm Post subject: |
|
|
Hey. What about using forum searchengine with inquiry "SSD1306"
You will find already maked optimised asm library for this display maded by Mrshilov
This link take you there
About writing this in Basic you dont need to use AVR-DOS and BGF can be stored in uC flash memory with easy.
BGF is encoded RLE for less code binary file.
So all what is needed is to use Restore Some_example_label and then use Read sequentially bytes till picture end.
In two first bytes header in BGF picture height and width is stored. |
|
Back to top |
|
|
Pzx
Joined: 05 May 2015 Posts: 39
|
Posted: Sat Feb 25, 2017 2:35 pm Post subject: |
|
|
Thanks for your fast replay, as usuall EDC
You are right, that would be the best way, but unfortunately Mrshilov SSD1306 SPI-4 and SPI-3 library does not work with my display. The screen remains black. Maybe firstly I should deeper investigate that.
Link to the display:
http://www.waveshare.com/1.3inch-oled-b.htm
I tryied with Mrshilov bas and libs SPI-4 from the link:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=13550&highlight=ssd1306
and after changindg display config into SPI-3:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=13641&highlight=ssd1306
My Oled does not work with the above codes, but works well with hkipniks Oled SPI code (link in my first post)
Port config of my ATMEGA 2560 is as follow:
'Config for hkipniks code:
Config Portb.0 = Output 'DISPLAY_SS CS
Config Portk.5 = Output 'DISPLAY_RS D/C
Config Portb.2 = Output 'Spi_mosi D1
Config Portb.1 = Output 'SPI_SCK D0
Config Portk.6 = Output 'DISPLAY_Reset
'Config for Mrshilov SPI-4 code:
$lib "glcdSSD1306-SPI.lib"
Config Graphlcd = 128x64sed , A0 = Portk.5 , Si = Portb.2 , Sclk = Portb.1 , Cs1 = Portb.0 , Rst = Portk.6
'Config for Mrshilov SPI-3 code:
$lib "glcdSSD1306-SPI-3.lib"
Config Graphlcd = 128x64sed , Si = Portb.2 , Sclk = Portb.1
Reset = +5V
CS= Disconected
D/C = 0V
Can anyone help with finding why it does not work?
Last edited by Pzx on Sat Feb 25, 2017 8:53 pm; edited 2 times in total |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Sat Feb 25, 2017 4:19 pm Post subject: |
|
|
Unfortunately I dont have this display so this is my first dealing with this.
But after quick look at the code I`m thinking that it is some kind of software SPI and any uC pins can be used.
So not only hardware ISP and question is do you set those choosen control pins as outputs?
Please try it without initiate hardware SPI (if used) and set pins as outputs.
Also note this, that in two wire mode CS should be grounded not disconnected. |
|
Back to top |
|
|
Pzx
Joined: 05 May 2015 Posts: 39
|
Posted: Sat Feb 25, 2017 8:28 pm Post subject: |
|
|
I bought another Oled SPI-4 SSD1306 display (this model is without CS pin):
https://telmal.com/pl/p/Wyswietlacz-OLED-0%2C96-SPI-3-5V-SSD1306-niebieski-/408
The result is exactly the same - works well with hkipniks code (I tested with sw SPI and hw SPI) but still does not work with Mrshilov code.
I tried also to initialize hw SPI and to set ports as outputs in Mrshilov code - no result.
EDC, if you want to play a little with this display I can send you one |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Sun Feb 26, 2017 5:03 am Post subject: |
|
|
Pzx,
your lcd only have DI pin not DO (NC)
lib use this pin ,
my 1.3" sh1106 have the DO pin and works fine with
Mrshilov SSD1306 SPI-4 & hkipniks Oled SPI code
_________________ / Kim |
|
Back to top |
|
|
Pzx
Joined: 05 May 2015 Posts: 39
|
Posted: Sun Feb 26, 2017 9:18 am Post subject: |
|
|
Kimmi, thanks for your answer and a nice foto.
I think there are different names of the same pins of different Oleds producers.
One direction SPI-3 interface needs at list CLK (SCLK) and DATA that is sent from uP to Oled (MOSI). When we use SPI-4 the interface needs additionaly D/C signal (SS) for Command/Data identification.
In my oppinion in case of your display D0 and D1 are used as CLK and DATA signals (or the opposite).
The remaining pins are:
RST - Reset
DC - D/C (SS)
CS - Chip Select |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
|
Back to top |
|
|
Pzx
Joined: 05 May 2015 Posts: 39
|
Posted: Mon Feb 27, 2017 11:30 pm Post subject: |
|
|
After some tests I found out that port k of ATMEGA2560 can not be used as D/C pin in Mrshilov SPI code (can be used in hkipniks code).
With that assuption samaller (0,96') display that has SSD1306 controller started to work well.
Changing Reset time and Initialization sequence in the lib had no impact - still works well.
Example of good pin configuration:
$lib "glcdSSD1306-SPI.lib"
Config Graphlcd = 128x64sed , Si = Portb.2 , Sclk = Portb.1 , A0 = Portb.0 , Rst = Portb.3
Si->SDA
Sclk->SCL
A0->D/C
Rst->RST
Unfortunately bigger display (1,3') with SH1106 controller (very similar to SSD1306) still does not work with Mrshilov SPI code (works with hkipniks code)
Changing Reset time and Initialization sequence in the lib did not help.
My pin configuration:
$lib "glcdSSD1306-SPI.lib"
Config Graphlcd = 128x64sed , Cs1 = Portb.7 , Si = Portb.2 , Sclk = Portb.1 , A0 = Portb.0 , Rst = Portb.3
Cs1->CS
Si->DIN
Sclk->CLK
A0->D/C
Rst->RES |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Mon Feb 27, 2017 11:36 pm Post subject: |
|
|
Quote: | Unfortunately bigger display (1,3') with SH1106 controller (very similar to SSD1306) still does not work with Mrshilov SPI code (works with hkipniks code) |
i dont get it mine lcd is a Sh1106 controller 1.3" and dont have problems with Mrshilov code its muts faster than hkipniks code
here is my code and pin setup (M328P) and works fine
Quote: | Pin description
GND: power ground
VCC: 3.3V or 5V power supply
D0: CLK clock
D1: MOSI data
RST: reset
DC: data / command
CS: chip select signal |
Code: | '-------------------------------------------------------------------------------
' SSD1306
' BASCOM-AVR - Mrshilov 2016
'===============================================================================
$regfile = "m328Pdef.dat"
$crystal = 8000000
$hwstack = 64
$swstack = 64
$framesize = 64
Config Clockdiv = 1
Mcucr.7 = 1 'Turn OFF JTAG
Mcucr.7 = 1
'-------------------------------- Display --------------------------------------
$lib "glcdSSD1306-SPI.lib"
Config Graphlcd = 128x64sed , A0 = Portb.4 , Si = Portb.3 , Sclk = Portb.2 , Cs1 = Portb.5 , Rst = Portb.1
Const Lcd_remap = 1 ' Default remap = 1, for some models = 2
'DC PB.4
'DI PB.3
'DO PB.2 '
'CS PB.5
'RES PB.1
'gnd gnd '
'vcc +3.3v
Dim I As Byte , N As Byte
'-------------------------------- Program --------------------------------------
Cls
Setfont Font12x16
Do
Lcdat 0 , 30 , "SH1106"
Wait 1
Lcdat 2 , 30 , "4-WIRE" , 1 ' inverse text
Wait 1
Showpic 0 , 0 , Pic
Wait 1
Lcdat 4 , 20 , "CONTRAST" , 0 ' inverse text
For N = 255 To 0 Step - 1 'down contrast
Lcdcontrast N
Lcdat 6 , 52 , N ; " "
Waitms 2
Next N
Wait 1
For N = 1 To 255 'up contrast
Lcdcontrast N
Lcdat 6 , 52 , N ; " "
Waitms 2
Next N
Wait 1
Cls
Loop
End
'===============================================================================
$include "font12x16.font"
Pic:
$bgf "picture.bgf"
|
then code is almost same for SSD1306 & Sh1106
set charge pump enable & external VCC are diffrent you can try to set it in this 2 ways (both work for me)
for ssd1306 its AD 8B
for SH1116 its 8D 14
in glcdSSD1306-SPI.lib : (\MCS Electronics\BASCOM-AVR\LIB\)
Code: | If SH1106
_lcd_init_data:
.db $AE, $A1, $C8, $20, $00, $D5, $F0, $A8, $3F, $D3, $00
.db $40, $DA, $12, $81, $FF, $D9, $F1, $A4, $A6, $8D, $14, $AF
If SSD1306
_lcd_init_data:
.db $AE, $A1, $C8, $20, $00, $D5, $F0, $A8, $3F, $D3, $00
.db $40, $DA, $12, $81, $FF, $D9, $F1, $A4, $A6, $AD, $8B, $AF |
_________________ / Kim |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Tue Feb 28, 2017 12:16 am Post subject: |
|
|
I also take a look into basic code again and today I saw:
Code: | Const Driver_typ = 0 'SSD1306 =1 SH1106 =0 |
and below in code for example:
Code: | #if Driver_typ = 1
Call Lcd_comm_out(&H00) 'column address lower 4 bits + 0x00 H02 for SH1106
#else
Call Lcd_comm_out(&H02)
#endif |
So these differences should be taken into account.
About PORTK is a extended IO but one from PORTA to PORTG should work fine |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
|
Back to top |
|
|
Pzx
Joined: 05 May 2015 Posts: 39
|
|
Back to top |
|
|
Pzx
Joined: 05 May 2015 Posts: 39
|
Posted: Tue Mar 21, 2017 6:48 pm Post subject: |
|
|
After several days of tests I give up because I still can not effectively work with SH 1106 1,3' oled display using SPI interface. Hkipniks code works fine but offers limited functionality (no bgf and TT fonts) and its relatively slow. This display is very popular because its easy to buy, cheap (10$) and 30% bigger than SSD1306.
Maybe I could have a question or suggestion for Mark and/or Mrshilov to write a Bascom driver for SH 1106 using SPI interface (SW and HW options would be great). I would buy with pleasure a new version of Bascom with that feature included. For sure not only me. |
|
Back to top |
|
|
Hkipnik
Joined: 03 May 2010 Posts: 20
|
Posted: Fri Mar 24, 2017 11:05 am Post subject: |
|
|
Hello,
For the SH1106-SPI Display you can use this LIB |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|