Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Adafruit_GFX by
Adafruit_SSD1306.h
00001 /********************************************************************* 00002 This is a library for our Monochrome OLEDs based on SSD1306 drivers 00003 00004 Pick one up today in the adafruit shop! 00005 ------> http://www.adafruit.com/category/63_98 00006 00007 These displays use SPI to communicate, 4 or 5 pins are required to 00008 interface 00009 00010 Adafruit invests time and resources providing this open source code, 00011 please support Adafruit and open-source hardware by purchasing 00012 products from Adafruit! 00013 00014 Written by Limor Fried/Ladyada for Adafruit Industries. 00015 BSD license, check license.txt for more information 00016 All text above, and the splash screen must be included in any redistribution 00017 *********************************************************************/ 00018 00019 /* 00020 * Modified by Neal Horman 7/14/2012 for use in LPC1768 00021 */ 00022 00023 #ifndef _ADAFRUIT_SSD1306_H_ 00024 #define _ADAFRUIT_SSD1306_H_ 00025 00026 #include "mbed.h" 00027 #include "Adafruit_GFX.h" 00028 00029 /*========================================================================= 00030 SSD1306 Displays 00031 ----------------------------------------------------------------------- 00032 The driver is used in multiple displays (128x64, 128x32, etc.). 00033 Select the appropriate display below to create an appropriately 00034 sized framebuffer, etc. 00035 00036 SSD1306_128_64 128x64 pixel display 00037 00038 SSD1306_128_32 128x32 pixel display 00039 00040 You also need to set the LCDWIDTH and LCDHEIGHT defines to an 00041 appropriate size 00042 00043 -----------------------------------------------------------------------*/ 00044 #define SSD1306_128_64 00045 // #define SSD1306_128_32 00046 /*=========================================================================*/ 00047 00048 #if defined SSD1306_128_64 && defined SSD1306_128_32 00049 #error "Only one SSD1306 display can be specified at once in SSD1306.h" 00050 #endif 00051 #if !defined SSD1306_128_64 && !defined SSD1306_128_32 00052 #error "At least one SSD1306 display must be specified in SSD1306.h" 00053 #endif 00054 00055 #if defined SSD1306_128_64 00056 #define SSD1306_LCDWIDTH 128 00057 #define SSD1306_LCDHEIGHT 64 00058 #endif 00059 #if defined SSD1306_128_32 00060 #define SSD1306_LCDWIDTH 128 00061 #define SSD1306_LCDHEIGHT 32 00062 #endif 00063 00064 #define SSD1306_SETCONTRAST 0x81 00065 #define SSD1306_DISPLAYALLON_RESUME 0xA4 00066 #define SSD1306_DISPLAYALLON 0xA5 00067 #define SSD1306_NORMALDISPLAY 0xA6 00068 #define SSD1306_INVERTDISPLAY 0xA7 00069 #define SSD1306_DISPLAYOFF 0xAE 00070 #define SSD1306_DISPLAYON 0xAF 00071 #define SSD1306_SETDISPLAYOFFSET 0xD3 00072 #define SSD1306_SETCOMPINS 0xDA 00073 #define SSD1306_SETVCOMDETECT 0xDB 00074 #define SSD1306_SETDISPLAYCLOCKDIV 0xD5 00075 #define SSD1306_SETPRECHARGE 0xD9 00076 #define SSD1306_SETMULTIPLEX 0xA8 00077 #define SSD1306_SETLOWCOLUMN 0x00 00078 #define SSD1306_SETHIGHCOLUMN 0x10 00079 #define SSD1306_SETSTARTLINE 0x40 00080 #define SSD1306_MEMORYMODE 0x20 00081 #define SSD1306_COMSCANINC 0xC0 00082 #define SSD1306_COMSCANDEC 0xC8 00083 #define SSD1306_SEGREMAP 0xA0 00084 #define SSD1306_CHARGEPUMP 0x8D 00085 #define SSD1306_EXTERNALVCC 0x1 00086 #define SSD1306_SWITCHCAPVCC 0x2 00087 00088 // an DigitalOut sub-class that provides a constructed default state 00089 class DigitalOut2 : public DigitalOut 00090 { 00091 public: 00092 DigitalOut2(PinName pin, bool active = false) : DigitalOut(pin) { write(active); }; 00093 DigitalOut2& operator= (int value) { write(value); return *this; }; 00094 DigitalOut2& operator= (DigitalOut2& rhs) { write(rhs.read()); return *this; }; 00095 operator int() { return read(); }; 00096 }; 00097 00098 class Adafruit_SSD1306 : public Adafruit_GFX 00099 { 00100 public: 00101 Adafruit_SSD1306(SPI &spi, PinName DC, PinName RST, PinName CS); 00102 void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC); 00103 void ssd1306_command(uint8_t c); 00104 void ssd1306_data(uint8_t c); 00105 00106 void clearDisplay(void); 00107 virtual void invertDisplay(bool i); 00108 void display(); 00109 00110 virtual void drawPixel(int16_t x, int16_t y, uint16_t color); 00111 00112 private: 00113 DigitalOut2 rst,cs,dc; 00114 SPI &mspi; 00115 // the memory buffer for the LCD 00116 uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8]; 00117 }; 00118 00119 #endif
Generated on Thu Jul 14 2022 05:30:13 by
1.7.2
