This is a derived library, original authors' name is still in the scripts. Added some extra debug prints for internal use.
Fork of SFE_MicroOLED by
Diff: SFE_MicroOLED.h
- Revision:
- 1:9c140b4e9453
- Parent:
- 0:b7fc78d2b795
diff -r b7fc78d2b795 -r 9c140b4e9453 SFE_MicroOLED.h --- a/SFE_MicroOLED.h Thu Mar 19 03:37:35 2015 +0000 +++ b/SFE_MicroOLED.h Sat Dec 23 06:31:21 2017 +0000 @@ -1,31 +1,24 @@ /****************************************************************************** SFE_MicroOLED.h Header file for the MicroOLED mbed Library - Jim Lindblom @ SparkFun Electronics October 26, 2014 https://github.com/sparkfun/Micro_OLED_Breakout/tree/master/Firmware/Arduino/libraries/SFE_MicroOLED - Adapted for mbed by Nenad Milosevic March, 2015 - This file defines the hardware SPI interface for the Micro OLED Breakout. - Development environment specifics: Various suitable mbed platforms Micro OLED Breakout v1.0 - This code was heavily based around the MicroView library, written by GeekAmmo (https://github.com/geekammo/MicroView-Arduino-Library), and released under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ @@ -35,10 +28,7 @@ static inline void swap(uint8_t &a, uint8_t &b) { - uint8_t t = a; - - a = b; - b = t; + } #ifndef _BV @@ -49,13 +39,16 @@ #define WHITE 1 #define LCDWIDTH 64 -#define LCDHEIGHT 48 -#define LCDCOLUMNOFFSET 32 // Visible start column within SSD1306 controller memory +#define LCDHEIGHT 32 +#define LCDCOLUMNOFFSET 0 // Visible start column within SSD1306 controller memory #define FONTHEADERSIZE 6 #define LCDTOTALWIDTH 128 // Full width of SSD1306 controller memory #define LCDTOTALHEIGHT 64 // Full height of SSD1306 controller memory +#define LCDTOTALPAGES (LCDTOTALHEIGHT / 8) +#define LCDPAGES (LCDHEIGHT / 8) + #define NORM 0 #define XOR 1 @@ -76,28 +69,29 @@ #define SETPRECHARGE 0xD9 #define SETMULTIPLEX 0xA8 #define SETLOWCOLUMN 0x00 -#define SETHIGHCOLUMN 0x10 -#define SETSTARTLINE 0x40 +#define SETHIGHCOLUMN 0x12 +#define SETSTARTLINE 0x00 #define MEMORYMODE 0x20 #define SETCOLUMNBOUNDS 0x21 #define SETPAGEBOUNDS 0x22 +#define SETPAGE 0xB0 #define COMSCANINC 0xC0 #define COMSCANDEC 0xC8 -#define SEGREMAP 0xA0 +#define SEGREMAP 0xA1 #define CHARGEPUMP 0x8D #define EXTERNALVCC 0x01 #define SWITCHCAPVCC 0x02 // Scroll -#define ACTIVATESCROLL 0x2F -#define DEACTIVATESCROLL 0x2E -#define SETVERTICALSCROLLAREA 0xA3 -#define RIGHTHORIZONTALSCROLL 0x26 -#define LEFTHORIZONTALSCROLL 0x27 -#define VERTICALRIGHTHORIZONTALSCROLL 0x29 -#define VERTICALLEFTHORIZONTALSCROLL 0x2A +#define ACTIVATESCROLL 0x2F +#define DEACTIVATESCROLL 0x2E +#define SETVERTICALSCROLLAREA 0xA3 +#define RIGHTHORIZONTALSCROLL 0x26 +#define LEFTHORIZONTALSCROLL 0x27 +#define VERTICALRIGHTHORIZONTALSCROLL 0x29 +#define VERTICALLEFTHORIZONTALSCROLL 0x2A -typedef bool boolean; +typedef uint8_t boolean; class MicroOLED { public: @@ -123,7 +117,10 @@ void command(uint8_t c1, uint8_t c2); void command(uint8_t c1, uint8_t c2, uint8_t c3); void command(uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, uint8_t c6, uint8_t c7, uint8_t c8); - + void command(uint8_t cmds[],int length); + void setColumnAddress(uint8_t add); + void setPageAddress(uint8_t add); + // LCD Draw functions void clear(uint8_t mode); void clear(uint8_t mode, uint8_t c); @@ -179,4 +176,4 @@ uint16_t fontMapWidth; static const unsigned char *fontsPointer[]; }; -#endif +#endif \ No newline at end of file