Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Function added to OLED library 'glcdSSD1306-I2C.lib'

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
O-Family

Bascom Member



Joined: 23 May 2010
Posts: 141
Location: Japan

japan.gif
PostPosted: Thu Dec 06, 2018 8:24 am    Post subject: Function added to OLED library 'glcdSSD1306-I2C.lib' Reply with quote

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
 
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4774
Location: Holland

blank.gif
PostPosted: Sun Dec 09, 2018 1:38 pm    Post subject: Reply with quote

Thanks for adding these useful options and sharing them Very Happy
_________________
Mark
Back to top
View user's profile Visit poster's website
BoA

Bascom Member



Joined: 13 Jan 2019
Posts: 1

blank.gif
PostPosted: Tue Jan 15, 2019 5:11 pm    Post subject: Reply with quote

Thanks a lot... it work .. Wink)
Back to top
View user's profile
mrak

Bascom Member



Joined: 14 Dec 2005
Posts: 24

poland.gif
PostPosted: Mon Sep 09, 2019 11:03 pm    Post subject: Library support for two SSD1306 displays on I2C bus Reply with quote

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
View user's profile
O-Family

Bascom Member



Joined: 23 May 2010
Posts: 141
Location: Japan

japan.gif
PostPosted: Tue Sep 10, 2019 9:22 am    Post subject: Reply with quote

I think that is possible by adding and modifying the library.
I will consider a fix when I have time.
Back to top
View user's profile Visit poster's website
mrak

Bascom Member



Joined: 14 Dec 2005
Posts: 24

poland.gif
PostPosted: Tue Sep 10, 2019 4:23 pm    Post subject: Library support for two SSD1306 displays on I2C bus Reply with quote

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
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1112
Location: SYDNEY

australia.gif
PostPosted: Tue Sep 10, 2019 11:39 pm    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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