I have a grove photon starter board, but want to make the connections more direct. I have looked at other community comments but I am not sure if I can just use the Adafruit include files.
I have a simple .ino but it dies on the include. Any suggestions:
#include <SeeedOLED.h>
// using Grove 128x64 OLED
// http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_0.96%22#With_Arduino
// black GND
// red 3v3
// white SDA D0 needs resistors 1.5K to 10K since 5V serial
// yellow SCL D1 needs resistors 1.5K to 10K since 5V serial
void setup()
{
//Wire.begin();
if ( !Wire.isEnabled() ) {
Wire.begin();
}
SeeedOled.init(); //initialze SEEED OLED display
DDRB|=0x21;
PORTB |= 0x21;
SeeedOled.clearDisplay(); //clear the screen and set start position to top left corner
SeeedOled.setNormalDisplay(); //Set display to normal mode (i.e non-inverse mode)
SeeedOled.setPageMode(); //Set addressing mode to Page Mode
SeeedOled.setTextXY(0,0); //Set the cursor to Xth Page, Yth Column
SeeedOled.putString("Hello World!"); //Print the String
}
void loop()
{
}
These are the registers of an Atmel AVR chip to set multiple pin modes for a whole port at once DDRB is the Data Direction Register for port B.
DDRB |= 0x21; is short for DDRB = DDRB | 0b00100001; (binary OR - not to be mixed up with the boolean OR operator ||).
This sets the two bits (refering to the respective pins and set them as OUTPUT) and leaves the others untouched.
And PORTB sets the actual values of the pins HIGH or LOW for all OUTPUT pins or attaches/detaches PULLUP resistors for INPUT pins.
@peekay123 is awesome. I tried porting the Grove file and it compiled but did not work. @peekay123 ported files at
worked immediately. Very fancy what the display can do. Remember to include the extra 4 files both .h and .cpp versions.
P.S. I never found the pins for the I2C format so guessed at it from my other file.
SDA D0
SCL D1
Never did figure out the reset Pin D4 but things worked so I am happy. I also did not use the protective resistors since the OLED works with 3V3.
I have re-writeen the .ino for beginners.
/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/category/63_98
This example is for a 128x64 size display using I2C to communicate
3 pins are required to interface (2 I2C and one reset)
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, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
// Added by Jeremy Ellis
// using Grove 128x64 OLED
// http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_0.96%22#With_Arduino
// black GND
// red 3v3 so do not need the protective resistors below
// white SDA D0 needs resistors 1.5K to 10K since 5V serial
// yellow SCL D1 needs resistors 1.5K to 10K since 5V serial
//used pkourany github site
//https://github.com/pkourany/Adafruit_SSD1306
// you must include the following files and the coresponding .cpp files
// total 4 files
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#define OLED_RESET D4
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup() {
Serial.begin(9600);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
// init done
//display.display(); // show splashscreen
// delay(2000);
display.clearDisplay(); // clears the screen and buffer
display.setTextSize(2); // from 1-9 sensible actually can be bigger but useless
display.setTextColor(BLACK, WHITE); // 'inverted' text
display.setCursor(0,30); // 128,64 pixels
display.clearDisplay();
display.println("Hello OLED");
display.display();
delay(4000);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK); // Normal text
display.setCursor(0,0);
display.clearDisplay();
display.println("size 1");
display.println("size 1, line 2");
display.display();
delay(4000);
display.clearDisplay();
display.println("size 2");
display.display();
delay(1000);
display.setTextSize(3);
display.clearDisplay();
display.setCursor(50,4);
display.println("size 3");
display.display();
delay(1000);
display.setTextSize(9);
display.setCursor(0,0);
display.clearDisplay();
display.println("9");
display.display();
delay(2000);
display.setTextSize(1);
display.setCursor(0,0);
display.clearDisplay();
display.println("Good Bye");
display.display();
delay(2000);
display.clearDisplay();
display.display();
}
and it also has an issue with the following includes. Lots of information about porting these just wondering what the up-to-date view is on porting these.
If you are building in Web IDE (which I guess from the include path), then you have to import OneWire library seperately as the include alone does not trigger a file-copy of the required files into your project folder.
Edit: @rocksetta, sorry I didn't answer all of your questions.
These are already available for Particle. Wire.h and stdio.h are already included via Particle.h (should be used instead of application.h) and should not be included again, math.h is available for each platform and can be included as is.
Just thought I’d add here, I ported a more specific version of the Grove 128x64 OLED Display library that uses Seeedstudio’s more lightweight library, if you don’t need all the functions that come with Adafruit_GFX.
@vibha, also Digole makes a number of mono and color OLED and LCD “intelligent” displays that work at 3.3v (2.2v to 9v for some). They cost a little more but are great to work with.