View previous topic :: View next topic |
Author |
Message |
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Fri Aug 17, 2018 11:30 am Post subject: Can Bascom BASIC use an Arduino library ? |
|
|
Hi,
As per previous posts I'm pretty much a noobie and I'm still trying to use an SSD1306 (or similar) under I2C to display lines, circles and boxes etc. So far witgout a great deal of success ! Text and pictures (BGF) are possible but pixel-level stuff... nothing / nada !!
Appologies in advance if I seem to be a little 'retentive' here, I simply cant find a straight-up answer - anywhere !
I do understand that I may well be able to set up a RAM page in basic (thanks to aphawk) , draw my page offscreen (in RAM) and then upload it to the SSD but this seems a little overly complicated (maybe it's just my ignorance) for what I'm trying to achieve.
A SSD1306 under SPI seems to have no problems.
Adafruit supply a graphics library for the SSD1306 over I2C (ssd1306.h / ssd1306.c). It supports pixel level (lines, boxes, circles etc) gfx. I don't use Arduino though ! (and nor, particularly, do I want to - I'm happy here with Bascom for my AVR work).
Question 1 :
Can one use an Adafruit / Arduino library from within Bascom without any additional (uner-the-hood) modification ?
If the answer is still 'Dunno' or simply 'No, you cannot manipulate pixels directly (lines, circles etc) with a SSD1306 under I2C', then is there a similar display (using I2C) where I can ? What display type DOES have this functionality in Bascom ?
Quite frankly, whilst I have a quite a few SSD1306-type OLEDs, I'm not married to them ! I can and am more than willing to switch to some other, similar-type, display. Ideas ?
Thanks in advance and, again, sorry to bang on about SSD1306's under I2C and lines, circles, boxes etc... Surely, I cannot be the only one confused with this... or maybe I am... in which case even more 'sorries' !!!
(BASCOM-AVR version : 2.0.8.1 ) _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Fri Aug 17, 2018 11:49 am Post subject: |
|
|
no you can not use an arduino lib but you can convert it to bascom.
in order to understand why you can not draw pixels you need to read the datasheet. And then understand about bits and bytes.
In order to save space, the manufacture of the display combines bits into bytes. That means that 8 pixels beside each other need to be written as a byte.
Now when you want to change one of those bits/pixels you need to :
- read the byte
- change the byte
- write back the byte
this is how it is done for all displays. but the lcd with I2C are only capable of WRITING. So you can not read back the data.
There is a simple trick : use a screen buffer
- write to buffer AND the lcd
- when time to read, read from the buffer
- write back to buffer and lcd
i made such a driver long time ago (dont recall for which lcd)
The downside is that you need a lot of RAM to store the screen !
And when you see apps or libs, they always use a bigger micro with more RAM. So even if you could read the arduino lib i am sure it will not work with the M8.
Another method is to write the complete buffer after each change with seems a waste of time to me. but on the bright side, it is very simple to do so.
it does use the same amount of screen buffer space : hor pixels time vert. pixels divided by 8 _________________ Mark |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Fri Aug 17, 2018 12:02 pm Post subject: |
|
|
Hi Mark,
THANK YOU.
I did kind-of understand the 8 bit/byte requirement just not the read part of the process !
Again, thanks - I'll stop wasting my time trying to write pixel-level gfx using I2C to the SSD1306.
Deffinitely moving forward.
I do have two questions though :
[1] How do I select a display (so that I may go purchase / design projects around) where this IS possible / is there a list of supported displays I could select from ?
[2] If I switched to SPI on this display, then is this directly supported via an existing lib ?
Thanks in advance. _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Fri Aug 17, 2018 12:25 pm Post subject: |
|
|
2 : no
1 : have a look at the 'share your code' section and on the WIKI page for LCD. There are a lot of LCD drivers available from various authors. _________________ Mark |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Fri Aug 17, 2018 12:55 pm Post subject: |
|
|
Thanks Mark.
My pain is ended !!
I'm off to look at other displays.
Again, thanks. Really appreciated. _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
|