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
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.
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.
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.
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!
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.
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.
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?