Adafruit SSD1306 Library [Ported]


#7

peekay123, it doesn’t make a difference to me.

It looks to me like digitalPinToPort eventually does some AVR assembler to read an address from PROGMEM. We don’t really have an interface to something like PROGMEM, afaik, so we would probably need to just abstract this away. The ultimate result of that macro is: http://garretlab.web.fc2.com/en/arduino/inside/avr/pgmspace.h/LPM_enhanced.html


#8

huslage, it’s easy to get lost in the technicalities of the code when porting. I’ve done a lot of these and they pretty much work the same way. All the PROGMEM stuff is no longer necessary since the Spark has a unified memory architecture. As for the pin manipulation, it can all be replaced with digitalWrite() commands since they are faster on the Spark than on an arduino. I can try and have a port for you later today. :smile:


#9

Ah great. Thanks so much.


#10

Could you guys post a link to the GFX files please. I also look forward to @peekay123 's effort, I have been wanting to get my Adafruit OLED 128x64 working with the Sparkcore.


#11

My GFX files are in the github link above. We will certainly share the love :smile:


#12

huslage, everything is compiling using web IDE. I modified your surfsoon-oled.ino file to include the correct code for the Adafruit libary. Note that I configured your code to use I2C and the display RST line is on D4, both of which can be changed.

I posted the code and two Adafruit examples for the 128x64 display on my github. I don’t have one of those displays so you have to be the guinea pig! Let me know how it goes. :smile:


#13

Awesome. Thanks peekay! I’ll let you know.


#14

It’s working great. No problems so far.


#15

I Just took a look at Github files and i’m a little confused.

My thinking is that i should be looking for one file that includes the required library .cpp and .h code.

would you just run through what files go where in a bit more detail please.

thanks


Adafruit SSD1306 [SOLVED]
#16

BusterSpark, the web IDE can take more than one file using tabs. A tab is created when you create a new app. In that tab, you paste one of the demo .ino programs. Then, create two more tabs by clicking the small circular icon next to the first tab and name the first of the new tabs Adafruit_SSD1306.h and the second will automatically be name to .cpp. Cut an paste the github code for those fine in there. When you create those new tabs, the IDE will add a #include line at the top of the demo code in the first tab. You must remove that because the includes are already in the file. After that, do a verify and off you go! :smile:


#17

Trying to test this example but get the below error.
What do I miss?
Tested both the ssd1306 and surfsoon example without any luck.

In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:31,
from Adafruit_GFX.h:4,
from Adafruit_GFX.cpp:34:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:31,
from Adafruit_GFX.h:4,
from Adafruit_SSD1306.cpp:19:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:31,
from ssd1306_128x64_spi.cpp:4:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
ssd1306_128x64_spi.cpp:21:26: fatal error: Adafruit_GFX.h: No such file or directory
compilation terminated.
make: *** [ssd1306_128x64_spi.o] Error 1

Error: Could not compile. Please review your code.


#18

mippen, if you are using the web IDE and you have multiple files, you should have a tab called “Adafruit_GFX.h”. The IDE is not finding this tab.


#19

Is it my spelling thats wrong?
Tried a couple of times with copy/paste on the tab names.


#20

mippen, replace the “<” and “>” in the includes with double quotes like this:

#include "application.h"
#include "Adafruit_GFX.h"

I missed those in the demo file you picked! :open_mouth:


#21

See the same problem with “” include…


#22

mippen, I must have been asleep when I ported that demo code! Grab that file again from my github and it will work now. Geesh! :open_mouth:


#23

Yay… Works great with the spi example now… Thanks!


#24

Thanks for all the legwork that has been done.

So, i figured out tabs within projects, cool…thanks (I assume their compiled and downloaded within main .ino file) ?

@peekay123 I have compiled and downloaded your work, seems to verify and download to core, however, i’m getting nothing on oled display.

First thing, when i have been downloading to core, it then shuts me out and i cant communicate to it, i can reset and re-communicate, but again, i download the code and it locks up with comms from that point.

anyhow, do i have the correct connections on Spark for I2C ?

Pin 0 & 1, D0 & D1. or RX/TX on shield shield ? This would be Data & Clock, right ?

I know oled address is correct, verified from working arduino on I2C program on different setup.

thanks for help.


#25

BusterSpark, when I see RX/TX and I2C I get worried! The I2C standard uses SDA/SCL for data and clock and Serial communciations uses RX/TX for send and receive! So, in your case, the Spark pins don’t map directly to the shield shield pins. If you look at the documentation, pin 3 on the shield shield is Spark pin D0 and pin 5 is Spark pin D1.

BTW, I assume you have a 5V SSD1306 module and that is why you are using the shield shield to translate the voltage levels, correct?


#26

peekay123,

lol, got worried myself when i chose I2C.

Per my last comment, looks like Spark were doing a lot of upgrade stuff today, which could explain IDE taking approx 45 seconds to download to core.

Back to SSD1306, (I have a Adafruit 3.3v/5v Device)

My core is mounted in shield, so i have 3.3v or 5v available for display.
As soon as i read your comment, i was checking into pin assignment.

Yes, i was using RX/TX, but have now switched to D0 and D1 (so 3 & 5 on shield shield)

either way i get nothing, trying to use I2C.

cant get adafruit splash screen, have tried rx/tx pins before switching to shield shield 3 & 5, but no result.

no errors reported anywhere in IDE .

oh the fun getting something working, lol

ps, did find one thing. your Github file for Adafruit_SSD1306.h has a default display address which is not consistent.