Library for Adafruit OLED FeatherWing

Dependents:   FTHR_OLED FTHR_SensorHub MAXREFDES101_SOURCE DisplayBMI160_Oled ... more

Fork of Adafruit_GFX by Greg Steiert

Files at this revision

API Documentation at this revision

Comitter:
switches
Date:
Tue Feb 07 23:52:12 2017 +0000
Parent:
17:d32bc620f2b2
Commit message:
Library for Adafruit OLED Feather Wing

Changed in this revision

Adafruit_SSD1306.cpp Show annotated file Show diff for this revision Revisions of this file
Adafruit_SSD1306.h Show annotated file Show diff for this revision Revisions of this file
license.txt Show annotated file Show diff for this revision Revisions of this file
diff -r d32bc620f2b2 -r a267f00528be Adafruit_SSD1306.cpp
--- a/Adafruit_SSD1306.cpp	Tue Oct 20 00:22:57 2015 +0000
+++ b/Adafruit_SSD1306.cpp	Tue Feb 07 23:52:12 2017 +0000
@@ -47,18 +47,6 @@
 
 void Adafruit_SSD1306::begin(uint8_t vccstate)
 {
-    rst = 1;
-    // VDD (3.3V) goes high at start, lets just chill for a ms
-    wait_ms(1);
-    // bring reset low
-    rst = 0;
-    // wait 10ms
-    wait_ms(10);
-    // bring out of reset (enable power)
-    rst = 1;
-    // wait 10ms (wait for power to settle)
-    wait_ms(10);
-    // turn on VCC (9V?)
 
     command(SSD1306_DISPLAYOFF);
     command(SSD1306_SETDISPLAYCLOCKDIV);
diff -r d32bc620f2b2 -r a267f00528be Adafruit_SSD1306.h
--- a/Adafruit_SSD1306.h	Tue Oct 20 00:22:57 2015 +0000
+++ b/Adafruit_SSD1306.h	Tue Feb 07 23:52:12 2017 +0000
@@ -18,6 +18,7 @@
 
 /*
  *  Modified by Neal Horman 7/14/2012 for use in mbed
+ *  Modified by Greg Steiert 2/7/2017 for FeatherOLED
  */
 
 #ifndef _ADAFRUIT_SSD1306_H_
@@ -29,16 +30,6 @@
 #include <vector>
 #include <algorithm>
 
-// A DigitalOut sub-class that provides a constructed default state
-class DigitalOut2 : public DigitalOut
-{
-public:
-	DigitalOut2(PinName pin, bool active = false) : DigitalOut(pin) { write(active); };
-	DigitalOut2& operator= (int value) { write(value); return *this; };
-	DigitalOut2& operator= (DigitalOut2& rhs) { write(rhs.read()); return *this; };
-	operator int() { return read(); };
-};
-
 #define SSD1306_EXTERNALVCC 0x1
 #define SSD1306_SWITCHCAPVCC 0x2
 
@@ -50,9 +41,8 @@
 class Adafruit_SSD1306 : public Adafruit_GFX
 {
 public:
-	Adafruit_SSD1306(PinName RST, uint8_t rawHeight = 32, uint8_t rawWidth = 128)
+	Adafruit_SSD1306(uint8_t rawHeight = 32, uint8_t rawWidth = 128)
 		: Adafruit_GFX(rawWidth,rawHeight)
-		, rst(RST,false)
 	{
 		buffer.resize(rawHeight * rawWidth / 8);
 	};
@@ -75,83 +65,12 @@
     
 protected:
 	virtual void sendDisplayBuffer() = 0;
-	DigitalOut2 rst;
 
 	// the memory buffer for the LCD
 	std::vector<uint8_t> buffer;
 };
 
 
-/** This is the SPI SSD1306 display driver transport class
- *
- */
-class Adafruit_SSD1306_Spi : public Adafruit_SSD1306
-{
-public:
-	/** Create a SSD1306 SPI transport display driver instance with the specified DC, RST, and CS pins, as well as the display dimentions
-	 *
-	 * Required parameters
-	 * @param spi - a reference to an initialized SPI object
-	 * @param DC (Data/Command) pin name
-	 * @param RST (Reset) pin name
-	 * @param CS (Chip Select) pin name
-	 *
-	 * Optional parameters
-	 * @param rawHeight - the vertical number of pixels for the display, defaults to 32
-	 * @param rawWidth - the horizonal number of pixels for the display, defaults to 128
-	 */
-	Adafruit_SSD1306_Spi(SPI &spi, PinName DC, PinName RST, PinName CS, uint8_t rawHieght = 32, uint8_t rawWidth = 128)
-	    : Adafruit_SSD1306(RST, rawHieght, rawWidth)
-	    , cs(CS,true)
-	    , dc(DC,false)
-	    , mspi(spi)
-	    {
-		    begin();
-		    splash();
-		    display();
-	    };
-
-	virtual void command(uint8_t c)
-	{
-	    cs = 1;
-	    dc = 0;
-	    cs = 0;
-	    mspi.write(c);
-	    cs = 1;
-	};
-
-	virtual void data(uint8_t c)
-	{
-	    cs = 1;
-	    dc = 1;
-	    cs = 0;
-	    mspi.write(c);
-	    cs = 1;
-	};
-
-protected:
-	virtual void sendDisplayBuffer()
-	{
-		cs = 1;
-		dc = 1;
-		cs = 0;
-
-		for(uint16_t i=0, q=buffer.size(); i<q; i++)
-			mspi.write(buffer[i]);
-
-		if(height() == 32)
-		{
-			for(uint16_t i=0, q=buffer.size(); i<q; i++)
-				mspi.write(0);
-		}
-
-		cs = 1;
-	};
-
-	DigitalOut2 cs, dc;
-	SPI &mspi;
-};
-
 /** This is the I2C SSD1306 display driver transport class
  *
  */
@@ -170,8 +89,8 @@
 	 * @param rawHeight - The vertical number of pixels for the display, defaults to 32
 	 * @param rawWidth - The horizonal number of pixels for the display, defaults to 128
 	 */
-	Adafruit_SSD1306_I2c(I2C &i2c, PinName RST, uint8_t i2cAddress = SSD_I2C_ADDRESS, uint8_t rawHeight = 32, uint8_t rawWidth = 128)
-	    : Adafruit_SSD1306(RST, rawHeight, rawWidth)
+	Adafruit_SSD1306_I2c(I2C &i2c, uint8_t i2cAddress = SSD_I2C_ADDRESS, uint8_t rawHeight = 32, uint8_t rawWidth = 128)
+	    : Adafruit_SSD1306(rawHeight, rawWidth)
 	    , mi2c(i2c)
 	    , mi2cAddress(i2cAddress)
 	    {
diff -r d32bc620f2b2 -r a267f00528be license.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/license.txt	Tue Feb 07 23:52:12 2017 +0000
@@ -0,0 +1,24 @@
+Software License Agreement (BSD License)
+
+Copyright (c) 2012 Adafruit Industries.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.