Hi,
I’m trying to get this display (https://learn.adafruit.com/096-mini-color-oled/overview) to work on spark. Has somebody made this work so far and happens to have the library for me?
Thanks,
Hi,
I’m trying to get this display (https://learn.adafruit.com/096-mini-color-oled/overview) to work on spark. Has somebody made this work so far and happens to have the library for me?
Thanks,
@huxlot I may be able to port this library for later today.
@huxlot, I posted the updated library on my github here. The test program is set to use the hardware SPI configuration. Let me know how it goes!
@peekay123 You are the best! I’ll update as soon as the parts arrive and I’m able to try it!
Hi again,
I tried to compile the test.ino from your library, but I’m running into an error.
As you will see, I have no idea what I’m doing. Therefore I’m assuming that I’m doing some fundamental mistakes.
What I have done is:
and the error:
Adafruit_SSD1331.cpp:14:26: fatal error: Adafruit_GFX.h: No such file or directory
#include "Adafruit_GFX.h"
^
compilation terminated.
make: *** [Adafruit_SSD1331.o] Error 1
After the first error I tried adding the Adafruit_GFX library to the app, but received this (basically the same thing?):
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_GFX/Adafruit_GFX.h:4,
from Adafruit_GFX/Adafruit_GFX.cpp:34:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
Adafruit_SSD1331.cpp:14:26: fatal error: Adafruit_GFX.h: No such file or directory
#include "Adafruit_GFX.h"
^
compilation terminated.
make: *** [Adafruit_SSD1331.o] Error 1
Any help would be greatly appreciated.
@huxlot, try changing the #include line in Adafruit_SSD1331.cpp to:
#include Adafruit_GFX/Adafruit_GFX.h
The path “issues” when using IDE libraries is part of the reason I use Spark CLI and Spark DEV. Let me know how it goes.
I appreciate your help a lot!
Using the line you suggested worked for the path error, and there was another one for glcdfont.c. I included the glcdfont files from your github (https://github.com/pkourany/Adafruit_SharpMem) and the path “issues” seem to be fixed.
Another day, another error:
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_GFX/Adafruit_GFX.h:4,
from Adafruit_GFX/Adafruit_GFX.cpp:34:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_GFX/Adafruit_GFX.h:4,
from Adafruit_SSD1331.cpp:14:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
Adafruit_SSD1331.cpp: In member function 'void Adafruit_SSD1331::spiwrite(uint8_t)':
Adafruit_SSD1331.cpp:53:22: error: '_BV' was not declared in this scope
if (c & _BV(i)) {
^
make: *** [Adafruit_SSD1331.o] Error 1
Thanks for looking into this!
@huxlot, there was a missing definition for _BV() in Adafruit_SSD1331.h so I fixed it. Get the file from my repo again.
Hi peekay,
I still have trouble compiling + I don’t understand the error message:
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_GFX/Adafruit_GFX.h:4,
from Adafruit_GFX/Adafruit_GFX.cpp:34:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from Adafruit_GFX/Adafruit_GFX.h:4,
from Adafruit_SSD1331.cpp:14:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from actualtest.cpp:2:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
actualtest.cpp:51:26: fatal error: Adafruit_GFX.h: No such file or directory
#define mosi 11
^
compilation terminated.
make: *** [actualtest.o] Error 1
Ready.
Any Ideas?
@huxlot, can you post the code for actualtest.cpp? From the looks of it, I guess you are compiling on the web IDE. You may want to change your #include in actualtest.cpp to:
#include "Adafruit_GFX/Adafruit_GFX.h"
My apologies for the late repsonse, Yes, I’m compiling on the web IDE.
Here’s the actualtest.ino
// This #include statement was automatically added by the Spark IDE.
#include "glcdfont.h"
// This #include statement was automatically added by the Spark IDE.
#include "Adafruit_SSD1331.h"
// This #include statement was automatically added by the Spark IDE.
#include "Adafruit_GFX/Adafruit_GFX.h"
/***************************************************
This is a example sketch demonstrating the graphics
capabilities of the SSD1331 library for the 0.96"
16-bit Color OLED with SSD1331 driver chip
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/684
These displays use SPI to communicate, 4 or 5 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
// You can use any (4 or) 5 pins
#if defined (SPARK)
#define sclk A3
#define mosi A5
#define cs A2
#define rst D2
#define dc D3
#else
#define sclk 13
#define mosi 11
#define cs 10
#define rst 9
#define dc 8
#endif
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#if defined (SPARK)
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1331.h"
#else
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1331.h>
#include <SPI.h>
#endif
// Option 1: use any pins but a little slower
//Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, mosi, sclk, rst);
// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
/ (for Spark Core, cs = A2, dc = D3, rst = D2)
Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, rst);
float p = 3.1415926;
void setup(void) {
Serial.begin(9600);
#if defined (SPARK)
// Wait for key press on serial terminal
while (!Serial.available()) SPARK_WLAN_Loop();
#endif
Serial.print("hello!");
display.begin();
Serial.println("init");
uint16_t time = millis();
display.fillScreen(BLACK);
time = millis() - time;
Serial.println(time, DEC);
delay(500);
lcdTestPattern();
delay(1000);
display.fillScreen(BLACK);
display.setCursor(0,0);
display.print("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa");
delay(1000);
// tft print function!
tftPrintTest();
delay(2000);
//a single pixel
display.drawPixel(display.width()/2, display.height()/2, GREEN);
delay(500);
// line draw test
testlines(YELLOW);
delay(500);
// optimized lines
testfastlines(RED, BLUE);
delay(500);
testdrawrects(GREEN);
delay(1000);
testfillrects(YELLOW, MAGENTA);
delay(1000);
display.fillScreen(BLACK);
testfillcircles(10, BLUE);
testdrawcircles(10, WHITE);
delay(1000);
testroundrects();
delay(500);
testtriangles();
delay(500);
Serial.println("done");
delay(1000);
}
void loop() {
}
void testlines(uint16_t color) {
display.fillScreen(BLACK);
for (int16_t x=0; x < display.width()-1; x+=6) {
display.drawLine(0, 0, x, display.height()-1, color);
}
for (int16_t y=0; y < display.height()-1; y+=6) {
display.drawLine(0, 0, display.width()-1, y, color);
}
display.fillScreen(BLACK);
for (int16_t x=0; x < display.width()-1; x+=6) {
display.drawLine(display.width()-1, 0, x, display.height()-1, color);
}
for (int16_t y=0; y < display.height()-1; y+=6) {
display.drawLine(display.width()-1, 0, 0, y, color);
}
display.fillScreen(BLACK);
for (int16_t x=0; x < display.width()-1; x+=6) {
display.drawLine(0, display.height()-1, x, 0, color);
}
for (int16_t y=0; y < display.height()-1; y+=6) {
display.drawLine(0, display.height()-1, display.width()-1, y, color);
}
display.fillScreen(BLACK);
for (int16_t x=0; x < display.width()-1; x+=6) {
display.drawLine(display.width()-1, display.height()-1, x, 0, color);
}
for (int16_t y=0; y < display.height()-1; y+=6) {
display.drawLine(display.width()-1, display.height()-1, 0, y, color);
}
}
void testdrawtext(char *text, uint16_t color) {
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
for (uint8_t i=0; i < 168; i++) {
if (i == '\n') continue;
display.write(i);
if ((i > 0) && (i % 21 == 0))
display.println();
}
}
void testfastlines(uint16_t color1, uint16_t color2) {
display.fillScreen(BLACK);
for (int16_t y=0; y < display.height()-1; y+=5) {
display.drawFastHLine(0, y, display.width()-1, color1);
}
for (int16_t x=0; x < display.width()-1; x+=5) {
display.drawFastVLine(x, 0, display.height()-1, color2);
}
}
void testdrawrects(uint16_t color) {
display.fillScreen(BLACK);
for (int16_t x=0; x < display.height()-1; x+=6) {
display.drawRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color);
}
}
void testfillrects(uint16_t color1, uint16_t color2) {
display.fillScreen(BLACK);
for (int16_t x=display.height()-1; x > 6; x-=6) {
display.fillRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color1);
display.drawRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color2);
}
}
void testfillcircles(uint8_t radius, uint16_t color) {
for (uint8_t x=radius; x < display.width()-1; x+=radius*2) {
for (uint8_t y=radius; y < display.height()-1; y+=radius*2) {
display.fillCircle(x, y, radius, color);
}
}
}
void testdrawcircles(uint8_t radius, uint16_t color) {
for (int16_t x=0; x < display.width()-1+radius; x+=radius*2) {
for (int16_t y=0; y < display.height()-1+radius; y+=radius*2) {
display.drawCircle(x, y, radius, color);
}
}
}
void testtriangles() {
display.fillScreen(BLACK);
int color = 0xF800;
int t;
int w = display.width()/2;
int x = display.height();
int y = 0;
int z = display.width();
for(t = 0 ; t <= 15; t+=1) {
display.drawTriangle(w, y, y, x, z, x, color);
x-=4;
y+=4;
z-=4;
color+=100;
}
}
void testroundrects() {
display.fillScreen(BLACK);
int color = 100;
int i;
int t;
for(t = 0 ; t <= 4; t+=1) {
int x = 0;
int y = 0;
int w = display.width();
int h = display.height();
for(i = 0 ; i <= 24; i+=1) {
display.drawRoundRect(x, y, w, h, 5, color);
x+=2;
y+=3;
w-=4;
h-=6;
color+=1100;
}
color+=100;
}
}
void tftPrintTest() {
display.fillScreen(BLACK);
display.setCursor(0, 5);
display.setTextColor(RED);
display.setTextSize(1);
display.println("Hello World!");
display.setTextColor(YELLOW, GREEN);
display.setTextSize(2);
display.print("Hello Wo");
display.setTextColor(BLUE);
display.setTextSize(3);
display.print(1234.567);
delay(1500);
display.setCursor(0, 5);
display.fillScreen(BLACK);
display.setTextColor(WHITE);
display.setTextSize(0);
display.println("Hello World!");
display.setTextSize(1);
display.setTextColor(GREEN);
display.print(p, 5);
display.println(" Want pi?");
display.print(8675309, HEX); // print 8,675,309 out in HEX!
display.print(" Print HEX");
display.setTextColor(WHITE);
display.println("Sketch has been");
display.println("running for: ");
display.setTextColor(MAGENTA);
display.print(millis() / 1000);
display.setTextColor(WHITE);
display.print(" seconds.");
}
void mediabuttons() {
// play
display.fillScreen(BLACK);
display.fillRoundRect(25, 10, 78, 60, 8, WHITE);
display.fillTriangle(42, 20, 42, 60, 90, 40, RED);
delay(500);
// pause
display.fillRoundRect(25, 90, 78, 60, 8, WHITE);
display.fillRoundRect(39, 98, 20, 45, 5, GREEN);
display.fillRoundRect(69, 98, 20, 45, 5, GREEN);
delay(500);
// play color
display.fillTriangle(42, 20, 42, 60, 90, 40, BLUE);
delay(50);
// pause color
display.fillRoundRect(39, 98, 20, 45, 5, RED);
display.fillRoundRect(69, 98, 20, 45, 5, RED);
// play color
display.fillTriangle(42, 20, 42, 60, 90, 40, GREEN);
}
/**************************************************************************/
/*!
@brief Renders a simple test pattern on the LCD
*/
/**************************************************************************/
void lcdTestPattern(void)
{
uint32_t i,j;
display.goTo(0, 0);
for(i=0;i<64;i++)
{
for(j=0;j<96;j++)
{
if(i>55){display.writeData(WHITE>>8);display.writeData(WHITE);}
else if(i>47){display.writeData(BLUE>>8);display.writeData(BLUE);}
else if(i>39){display.writeData(GREEN>>8);display.writeData(GREEN);}
else if(i>31){display.writeData(CYAN>>8);display.writeData(CYAN);}
else if(i>23){display.writeData(RED>>8);display.writeData(RED);}
else if(i>15){display.writeData(MAGENTA>>8);display.writeData(MAGENTA);}
else if(i>7){display.writeData(YELLOW>>8);display.writeData(YELLOW);}
else {display.writeData(BLACK>>8);display.writeData(BLACK);}
}
}
}
It only contains the headers and the code from your libraries test.ino. As you see, I changed the Adafruit_GFX.h to
#include "Adafruit_GFX/Adafruit_GFX.h"
in the actualtest.ino. Also, as mentioned earlier in this thread. I changed the Adafruit_GFX header in the Adafruit_SSD1331.cpp file.
Thank you for your effort.
To give Paul (aka @peekay123) some slack, I try to chime in here
If I look at your code, I can see two #includes
for Adafruit_GFX
, the one at the top, added by the Web IDE and a bit further down here
...
#if defined (SPARK)
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1331.h"
#else
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1331.h>
#include <SPI.h>
#endif
...
I think you can either comment this one or the one above out, and/or you convert this one the same way as above, since double include is prevented inside the header anyway.
Thanks @ScruffR! You are correct, the top 3 includes inserted by the IDE can be commented out,