View previous topic :: View next topic |
Author |
Message |
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Thu Dec 06, 2018 8:24 am Post subject: Function added to OLED library 'glcdSSD1306-I2C.lib' |
|
|
The following functions have been added to the I2C OLED display library "glcdSSD1306-I2C.lib".
1. Added option to rotate display 180 degrees.
Const Ssd1306_rotate = 1 'Display rotation. [connection cable is lower side = 0, upper side = 1]
2. Control byte added to the "GLCDCMD" instruction.
Normal/Inverse Display [A6:Normal , A7:Inverse]
Display ON/OFF [AE:OFF(sleep mode) , AF:ON(normal mode)]
3. Contrast can be changed.
_contrast = 0 : Glcdcmd &H81 'Change contrast of the OLED [0:dark - 255:bright]
4. Underline option added to the "LCDAT" instruction. [2:Solid , 3:dotted]
Code: |
'-------------------------------------------------------------------------------
' SSD1306-I2C_V2.BAS
' (c) MCS Electronics 1995-2015
' Sample to demo the 128x64 I2C OLED display [V2]
'
'-------------------------------------------------------------------------------
$regfile = "m88pdef.dat"
$hwstack = 32
$swstack = 32
$framesize = 32
$crystal = 8000000
Config Clockdiv = 1 ' make sure the chip runs at 8 MHz
Config Scl = Portc.5 ' used i2c pins
Config Sda = Portc.4
Config Twi = 400000 ' i2c speed
I2cinit
$lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI
$lib "glcdSSD1306-I2C_V2.lib" ' override the default lib with this special one
#if _build < 20784
Dim ___lcdrow As Byte , ___lcdcol As Byte ' dim these for older compiler versions
#endif
Dim _contrast As Byte ' Contrast value of OLED. [0-255]
'Const Ssd1306_rotate = 1 ' Display rotation. [connection cable is lower side = 0, upper side = 1]
Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
Cls
Setfont Font8x8tt ' select font
Do
Lcdat 1 , 1 , "BASCOM-AVR"
Lcdat 2 , 10 , "1995-2015"
Lcdat 3 , 5 , "MCS Electronics" , 1 ' Optional invert
Lcdat 5 , 1 , " ABCDefg012345678 " , 2 ' Optional solid underline
Lcdat 7 , 1 , " ABCDefg012345678 " , 3 ' Optional dotted underline
Wait 3
Glcdcmd &HA7 ' Normal/Inverse Display [A7:Inverse]
Wait 3
Glcdcmd &HA6 ' Normal/Inverse Display [A6:Normal]
Wait 3
_contrast = 0 : Glcdcmd &H81 ' Change contrast of the OLED [0:dark - 255:bright]
Wait 3
_contrast = 255 : Glcdcmd &H81 ' Change contrast of the OLED [0:dark - 255:bright]
Wait 3
Glcdcmd &HAE ' Display ON/OFF [AE:OFF(sleep mode) , AF:ON(normal mode)]
Wait 3
Glcdcmd &HAF ' Display ON/OFF [AE:OFF(sleep mode) , AF:ON(normal mode)]
Wait 3
Showpic 0 , 0 , Plaatje
Wait 3
Cls
Loop
End
$include "font8x8TT.font" ' this is a true type font with variable spacing
Plaatje:
$bgf "ks108.bgf" ' include the picture data
|
-------------------------------------------------
Postscript
Modified the library for XMEGA and XTINY.
glcdSSD1306-I2C_V2.lib (Revision 002)
Last edited by O-Family on Sat Jul 09, 2022 11:06 am; edited 2 times in total |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5922 Location: Holland
|
Posted: Sun Dec 09, 2018 1:38 pm Post subject: |
|
|
Thanks for adding these useful options and sharing them _________________ Mark |
|
Back to top |
|
|
BoA
Joined: 13 Jan 2019 Posts: 1
|
Posted: Tue Jan 15, 2019 5:11 pm Post subject: |
|
|
Thanks a lot... it work .. ) |
|
Back to top |
|
|
mrak
Joined: 14 Dec 2005 Posts: 24
|
Posted: Mon Sep 09, 2019 11:03 pm Post subject: Library support for two SSD1306 displays on I2C bus |
|
|
The SSD1306-I2C displays enable configuration to have two devices on the same I2C bus under different addresses. Does the current "glcdSSD1306-I2C.lib" can be configured for such a setup? If no, do you plan to include such functionality? |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Tue Sep 10, 2019 9:22 am Post subject: |
|
|
I think that is possible by adding and modifying the library.
I will consider a fix when I have time. |
|
Back to top |
|
|
mrak
Joined: 14 Dec 2005 Posts: 24
|
Posted: Tue Sep 10, 2019 4:23 pm Post subject: Library support for two SSD1306 displays on I2C bus |
|
|
That would be excellent!
Users could get the most out of the "glcdSSD1306-I2C.lib" library and enjoy the experience of having full capability provided by two SSD1306 displays working in pair when one display is insufficient, like in my project. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Tue Sep 10, 2019 11:39 pm Post subject: |
|
|
There are also I2C switces that enable multiple devices with the same address on a buss
I am using one with two ADCs that only have one address.
Regards paul |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Fri Sep 20, 2019 3:40 am Post subject: 2-Displays version |
|
|
A version that controls two displays was created at the request of the user.
Enter the I2C slave address in the variable [I2c_addr] and specify the device. [&H78 or &H7A]
The OLED on the left side of the image is not a color, it is two fixed color types.
Code: |
'-------------------------------------------------------------------------------
' SSD1306-I2C_V2x2.BAS
' (c) MCS Electronics 1995-2015
' Sample to demo the 128x64 I2C OLED display [V2]
' (2-Displays version)
'-------------------------------------------------------------------------------
$regfile = "m88pdef.dat"
$hwstack = 32
$swstack = 32
$framesize = 32
$crystal = 8000000
Config Clockdiv = 1 ' make sure the chip runs at 8 MHz
Config Scl = Portd.2 ' When using software I2C.
Config Sda = Portd.3
Config I2cdelay = 1
I2cinit
'$lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI
'Config Scl = Portc.5 ' used i2c pins
'Config Sda = Portc.4
'Config Twi = 400000 ' i2c speed
'I2cinit
Dim _contrast As Byte ' Contrast value of OLED. [0-255]
Dim I2c_addr As Byte ' I2C slave address selection. [&H78 or &H7A]
'Const Ssd1306_rotate = 1 ' Display rotation. [connection cable is lower side = 0, upper side = 1]
$lib "glcdSSD1306-I2C_V2x2.lib" ' override the default lib with this special one
Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
I2c_addr = &H78 ' Select device [1]
Cls
I2c_addr = &H7A ' Select device [2]
Cls
Setfont Font8x8tt ' select font
I2c_addr = &H78 ' Select device [1]
Lcdat 1 , 1 , "BASCOM-AVR"
Lcdat 2 , 10 , "1995-2015"
Lcdat 3 , 5 , "MCS Electronics" , 1 ' Optional invert
Lcdat 5 , 1 , " Device [1] " , 2 ' Optional solid underline
Lcdat 7 , 1 , " Device [1] " , 3 ' Optional dotted underline
I2c_addr = &H7A ' Select device [2]
Lcdat 1 , 1 , "BASCOM-AVR"
Lcdat 2 , 10 , "1995-2015"
Lcdat 3 , 5 , "MCS Electronics" , 1 ' Optional invert
Lcdat 5 , 1 , " Device [2] " , 2 ' Optional solid underline
Lcdat 7 , 1 , " Device [2] " , 3 ' Optional dotted underline
End
$include "font8x8TT.font" ' this is a true type font with variable spacing
|
-----------------------------------------
Postscript
Modified the library for XMEGA and XTINY.
glcdSSD1306-I2C_V2x2.lib (Revision 002)
Last edited by O-Family on Sat Jul 09, 2022 11:07 am; edited 2 times in total |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5922 Location: Holland
|
Posted: Fri Sep 20, 2019 9:40 am Post subject: |
|
|
excellent work. thanks ! _________________ Mark |
|
Back to top |
|
|
Memen
Joined: 06 May 2016 Posts: 13
|
Posted: Fri Sep 20, 2019 8:19 pm Post subject: |
|
|
Fine! 1995 - 2019 amendment))) |
|
Back to top |
|
|
timbak
Joined: 18 Oct 2018 Posts: 8
|
Posted: Mon Jan 18, 2021 3:33 am Post subject: |
|
|
O-Family can you pls help with run this lib on Xmega?
Trying to run this on atxmega32a4u and getting errors:
Code: | Dim Twi_start As Byte
Open "twic" For Binary As #2
Config Twic = 400000
I2cinit #2
$lib "glcdSSD1306-I2C_V2.lib"
Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1306"
Cls
Setfont Font8x8tt
Lcdat 1 , 1 , "BASCOM-AVR" |
Quote: | Error : 5 Line : -625 No more space for BIT [_CONTRAST] , in File : C:\MCS\BASCAVR2083\LIB\GLCDSSD1306-I2C_V2.LIB
Error : 320 Line : 104 [syntax error, token = '{'] , in File : C:\MCS\BASCAVR2083\LIB\GLCDSSD1306-I2C_V2.LIB |
|
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Mon Jan 18, 2021 9:53 am Post subject: |
|
|
Declare _contrast as described in the test program I posted.
Code: | Dim _contrast As Byte ' Contrast value of OLED. [0-255] |
|
|
Back to top |
|
|
timbak
Joined: 18 Oct 2018 Posts: 8
|
Posted: Mon Jan 18, 2021 12:39 pm Post subject: |
|
|
O-Family thank You for quick response. Now it works!
I use 0.66" 64x48 display, and have some offset in coordinates, and this is different in rotation modes
my code:
Code: | Config Graphlcd = Custom , Cols = 64 , Rows = 48 , Lcdname = "SSD1306"
Cls
Const Ssd1306_rotate = 1
Setfont Font8x8tt
Glcdcmd &HA7
Lcdat 1 , 33 , "1234567#1"
Lcdat 2 , 33 , "1234567#2"
Lcdat 3 , 33 , "1234567#3"
Lcdat 4 , 33 , "1234567#4"
Lcdat 5 , 33 , "1234567#5"
Lcdat 6 , 33 , "1234567#6" |
it need set second coordinate to 33 for correct string drawing
this is what i get when Ssd1306_rotate is changed:
|
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Tue Jan 19, 2021 3:02 am Post subject: |
|
|
SSD1306 is a 128x64 Dot controller and I think your OLED has different address pin connections.
I don't have this OLED so I'm not sure if it works, but try this library. |
|
Back to top |
|
|
timbak
Joined: 18 Oct 2018 Posts: 8
|
Posted: Tue Jan 19, 2021 10:06 am Post subject: |
|
|
O-Family wrote: | SSD1306 is a 128x64 Dot controller and I think your OLED has different address pin connections.
I don't have this OLED so I'm not sure if it works, but try this library. |
O-Family, it works perfect! Thank You so much for the fiix |
|
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
|
|