Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Function added to OLED library 'glcdSSD1306-I2C.lib'
Goto page Previous  1, 2, 3  Next
 
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
timbak

Bascom Member



Joined: 18 Oct 2018
Posts: 8

blank.gif
PostPosted: Wed May 26, 2021 7:15 pm    Post subject: Reply with quote

O-Family hello again!

Still try to work with OLED 0.66" 64x48 and Atxmega32A4. Some strange behavior with display increment values.

This code works perfect:
Code:
Do
...  
   Setfont Font6x8
   Lcdat 1 , 1 , "1234567890"
...
Loop


i can see the whole string on display 1234567890

But these examples don't work as expected:
Code:
Do
...
   Setfont Font6x8
   Lcdat 1 , 1 , Increment

   Incr Increment
   Waitms 500
...
Loop
or
Code:
Do
...  
   Tempstr = Str(increment)
   Setfont Font6x8
   Lcdat 1 , 1 , Tempstr

   Incr Increment
   Waitms 500
...
Loop
I see only one last digit.

Actually if value is SINGLE, i can see incrementation on screen - after 9.0 i got 10.0.. 11.0.. 12.00 and ect.
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Sat May 29, 2021 1:48 am    Post subject: Reply with quote

I tried to test with ATXmega128A1, but the display itself does not work properly.
There may be a problem with the original "SSD1306-I2C" library.

Please show your source code.
Back to top
View user's profile Visit poster's website
timbak

Bascom Member



Joined: 18 Oct 2018
Posts: 8

blank.gif
PostPosted: Sat May 29, 2021 11:14 am    Post subject: Reply with quote

Code:
$regfile = "xm32a4udef.dat"
$crystal = 32000000
$hwstack = 180
$swstack = 180
$framesize = 180

'$noramclear
Config Submode = New

'''******************************** SYS CLOCK CONFIG *****************************

Config Osc = Enabled , 32mhzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1

Config Single = Scientific , Digits = 1
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled

'********************************* CONFIG TWI ************************************

Dim Twi_start As Byte
Open "twic" For Binary As #2
Config Twic = 100000
I2cinit #2

'************************* CONFIG OLED 0.66 SSD1306 64x48  ***********************

Config Portd.0 = Output : Oled_rst Alias Portd.0 : Oled_rst = 1       'OLED RESET

'$lib "glcdSSD1306-I2C_V2.lib"
$lib "glcdSSD1306-I2C_V2_0R66_64x48.lib"

Dim _contrast As Byte                                       ' Contrast value of OLED. [0-255]
Const Ssd1306_rotate = 1
Config Graphlcd = Custom , Cols = 64 , Rows = 48 , Lcdname = "SSD1306"
Cls

'Glcdcmd &HA7                                                'Inversion
Glcdcmd &HAF                                                'Display ON

'*********************************************************************************

Dim Increment As Byte , Tempval As Single , Tempstr As String * 8 , Strlen As Byte

Setfont Font6x8

Enable Interrupts

Do

   Waitms 500
   Incr Increment
'__________________________________________________________________________________

   'This is what i want to do: increment the value "Increment" and show it on display.
   'It doen't works - i see only last digit. I.e if Increment = 123 on display i see only "3"
   'It works if Increment value dimensioned as a single: "Dim Increment As Single"
   'But in this case i see on display 123.0

   Lcdat 1 , 1 , Increment ; "  "

'________________________________________________________________________________

   'This is my workaround: Tempval(single) get value of Increment(byte)
   'Represent Tempval as a string
   'and then i delete from the string fractional part with point and send it to the screen

   Tempval = Increment
   Tempstr = Str(tempval)
   Strlen = Len(tempstr) - 2
   Tempstr = Left(tempstr , Strlen )

   Lcdat 1 , 1 , Tempstr ; "  "

Loop
End


$include "Font6x8.font"
$include "font12x16.font"
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Sat May 29, 2021 3:14 pm    Post subject: Reply with quote

Certainly my ATXmega128A1 had the same symptoms.

It is only the last digit when displaying a variable with the LCDAT instruction using Xmega.
It works fine with normal AVR.

I tried to save all the registers in the [_gwrite_lcdchar] routine of the library, but the symptom does not change.
This may be a problem with BASCOM's internal processing, so please check with Mark.
Back to top
View user's profile Visit poster's website
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Sun May 30, 2021 1:18 am    Post subject: Reply with quote

A remedy was found.
Code:
'The following behaves abnormally.
$hwstack = 180
$swstack = 180
$framesize = 180

'Of the three stack settings, setting one or more to something other than 180 will be normal.
$hwstack = 181
$swstack = 180
$framesize = 180

This is a very strange behaviour, and it seems that setting the stack to 180 for all three will corrupt the contents of the registers or the data passed by the stack.

There seems to be a strange and fatal bug in the operation of the stack.
Nothing more can be solved by me.

It can be verified with the following simple program.
(You can also check it in the simulator)
Code:
$regfile = "xm128A1def.dat"
$crystal = 32000000

$hwstack = 180                                              'An abnormality occurs.
'$hwstack = 181                                              'It works normally.
$swstack = 180
$framesize = 180

   Config Osc = Enabled , 32mhzosc = Enabled
   Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1

   Config Com1 = 9600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8

   Dim Temp1 As Byte

   Do
      Print Temp1
      Incr Temp1
      Waitms 300
   Loop

   End
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Tue Jun 01, 2021 9:47 am    Post subject: Reply with quote

and what happens ? it seems to run normal in the sim. I also see no problem with the stacks.
i do not know which version you use? or the TS ?

also, to use xmega with ssd1306 there is the lib for xmega named : glcdSSD1306-I2C-TWI.lib

_________________
Mark
Back to top
View user's profile Visit poster's website
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Tue Jun 01, 2021 1:35 pm    Post subject: Reply with quote

Check the difference in the simulator results.

Compiler version :2.0.8.3
Compiler build :2.0.8.3.005
IDE version :2.0.8.3.003

"glcdSSD1306-I2C-TWI.lib" is a version with added support for Xtiny, and I think "glcdSSD1306-I2C.lib" also supports Xmega's TWIC.
Back to top
View user's profile Visit poster's website
timbak

Bascom Member



Joined: 18 Oct 2018
Posts: 8

blank.gif
PostPosted: Sun Jun 06, 2021 7:41 pm    Post subject: Reply with quote

albertsm wrote:
and what happens ? it seems to run normal in the sim. I also see no problem with the stacks.
i do not know which version you use? or the TS ?

also, to use xmega with ssd1306 there is the lib for xmega named : glcdSSD1306-I2C-TWI.lib


Compiler version :2.0.8.3
Compiler build :2.0.8.3.005
IDE version :2.0.8.3.003
Back to top
View user's profile
bifi

Bascom Member



Joined: 28 Feb 2005
Posts: 25

germany.gif
PostPosted: Wed Sep 29, 2021 1:23 pm    Post subject: Reply with quote

Is it possible to make the lib "glcdSSD1306-I2C_V2.lib" working with "i2cv2.lib" ?

I get no output when using hardware I2C. The I2C bus hangs.

Michael
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Thu Sep 30, 2021 12:21 am    Post subject: Reply with quote

The "glcdSSD1306-I2C_V2.lib" is TWI (hardware I2C) compatible and has been tested.
For TWI, "i2cv2.lib" is not used.

Are there any problems with your hardware or connections?
What type of display unit are you using?
Back to top
View user's profile Visit poster's website
bifi

Bascom Member



Joined: 28 Feb 2005
Posts: 25

germany.gif
PostPosted: Thu Sep 30, 2021 8:29 am    Post subject: Reply with quote

I try to implement a display 128x32 pixels from alibaba in an existent hardware
based on an ATMega644 that uses the "i2cv2.lib".

I made a demoboard with an atmega88 and this works fine
with the TWI lib, but shows nothing with the i2cv2.

I don't know if the existent hardware will run wit the i2c_twi lib.
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Thu Sep 30, 2021 9:32 am    Post subject: Reply with quote

I am not sure what your problem is.
Please describe your symptoms in detail.
It is also important to attach the program.
Back to top
View user's profile Visit poster's website
bifi

Bascom Member



Joined: 28 Feb 2005
Posts: 25

germany.gif
PostPosted: Thu Sep 30, 2021 9:50 am    Post subject: Reply with quote

Sorry, i mixed hardware and software twi.
I thought that i2c_twi was the software interface, but reading the help
should be done first.
Back to top
View user's profile
georgestheking

Bascom Member



Joined: 06 May 2005
Posts: 134

PostPosted: Tue Feb 21, 2023 11:47 am    Post subject: SSD1306 128 X 32 Reply with quote

Hi,

I am using a new device on AlliExpress : a Arduino NANO + a display SSD1306 on the same board.
The resolution is 128 x 32.

using

Config Graphlcd = Custom , Cols = 128 , Rows = 32 , Lcdname = "SSD1306"

I get something on the display but completly crush.

Any idea ?

Best regards

Georges
Back to top
View user's profile
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 320
Location: Japan

japan.gif
PostPosted: Wed Feb 22, 2023 2:08 am    Post subject: Reply with quote

Please show me the program you used for the test and a picture of the display screen.
Back to top
View user's profile Visit poster's website
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
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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