Seed I2C OLED library for mbed
SeeedGrayOLED.h@0:e14364aac2ca, 2017-01-25 (annotated)
- Committer:
- jacobjohnson
- Date:
- Wed Jan 25 18:33:22 2017 +0000
- Revision:
- 0:e14364aac2ca
Seeed OLED Library for mbed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jacobjohnson | 0:e14364aac2ca | 1 | /* |
jacobjohnson | 0:e14364aac2ca | 2 | * SeeedGrayOLED.h |
jacobjohnson | 0:e14364aac2ca | 3 | * SSD1327 Gray OLED Driver Library for SSD1327 |
jacobjohnson | 0:e14364aac2ca | 4 | * |
jacobjohnson | 0:e14364aac2ca | 5 | * Copyright (c) 2011 seeed technology inc. |
jacobjohnson | 0:e14364aac2ca | 6 | * Author : Visweswara R |
jacobjohnson | 0:e14364aac2ca | 7 | * Create Time : Dec 2011 |
jacobjohnson | 0:e14364aac2ca | 8 | * Change Log : |
jacobjohnson | 0:e14364aac2ca | 9 | * |
jacobjohnson | 0:e14364aac2ca | 10 | * This library is free software; you can redistribute it and/or |
jacobjohnson | 0:e14364aac2ca | 11 | * modify it under the terms of the GNU Lesser General Public |
jacobjohnson | 0:e14364aac2ca | 12 | * License as published by the Free Software Foundation; either |
jacobjohnson | 0:e14364aac2ca | 13 | * version 2.1 of the License, or (at your option) any later version. |
jacobjohnson | 0:e14364aac2ca | 14 | * |
jacobjohnson | 0:e14364aac2ca | 15 | * This library is distributed in the hope that it will be useful, |
jacobjohnson | 0:e14364aac2ca | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
jacobjohnson | 0:e14364aac2ca | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
jacobjohnson | 0:e14364aac2ca | 18 | * Lesser General Public License for more details. |
jacobjohnson | 0:e14364aac2ca | 19 | * |
jacobjohnson | 0:e14364aac2ca | 20 | * You should have received a copy of the GNU Lesser General Public |
jacobjohnson | 0:e14364aac2ca | 21 | * License along with this library; if not, write to the Free Software |
jacobjohnson | 0:e14364aac2ca | 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
jacobjohnson | 0:e14364aac2ca | 23 | */ |
jacobjohnson | 0:e14364aac2ca | 24 | |
jacobjohnson | 0:e14364aac2ca | 25 | #ifndef SeeedGrayOLED_data_H |
jacobjohnson | 0:e14364aac2ca | 26 | #define SeeedGrayOLED_data_H |
jacobjohnson | 0:e14364aac2ca | 27 | |
jacobjohnson | 0:e14364aac2ca | 28 | // SeeedGrayOLED Instruction set addresses |
jacobjohnson | 0:e14364aac2ca | 29 | |
jacobjohnson | 0:e14364aac2ca | 30 | // #include "Arduino.h" |
jacobjohnson | 0:e14364aac2ca | 31 | #include "mbed.h" |
jacobjohnson | 0:e14364aac2ca | 32 | #include <inttypes.h> |
jacobjohnson | 0:e14364aac2ca | 33 | |
jacobjohnson | 0:e14364aac2ca | 34 | |
jacobjohnson | 0:e14364aac2ca | 35 | #define VERTICAL_MODE 01 |
jacobjohnson | 0:e14364aac2ca | 36 | #define HORIZONTAL_MODE 02 |
jacobjohnson | 0:e14364aac2ca | 37 | |
jacobjohnson | 0:e14364aac2ca | 38 | #define SeeedGrayOLED_Address 0x3c |
jacobjohnson | 0:e14364aac2ca | 39 | #define SeeedGrayOLED_Command_Mode 0x80 |
jacobjohnson | 0:e14364aac2ca | 40 | #define SeeedGrayOLED_Data_Mode 0x40 |
jacobjohnson | 0:e14364aac2ca | 41 | |
jacobjohnson | 0:e14364aac2ca | 42 | #define SeeedGrayOLED_Display_Off_Cmd 0xAE |
jacobjohnson | 0:e14364aac2ca | 43 | #define SeeedGrayOLED_Display_On_Cmd 0xAF |
jacobjohnson | 0:e14364aac2ca | 44 | |
jacobjohnson | 0:e14364aac2ca | 45 | #define SeeedGrayOLED_Normal_Display_Cmd 0xA4 |
jacobjohnson | 0:e14364aac2ca | 46 | #define SeeedGrayOLED_Inverse_Display_Cmd 0xA7 |
jacobjohnson | 0:e14364aac2ca | 47 | #define SeeedGrayOLED_Activate_Scroll_Cmd 0x2F |
jacobjohnson | 0:e14364aac2ca | 48 | #define SeeedGrayOLED_Dectivate_Scroll_Cmd 0x2E |
jacobjohnson | 0:e14364aac2ca | 49 | #define SeeedGrayOLED_Set_ContrastLevel_Cmd 0x81 |
jacobjohnson | 0:e14364aac2ca | 50 | |
jacobjohnson | 0:e14364aac2ca | 51 | #define Scroll_Left 0x00 |
jacobjohnson | 0:e14364aac2ca | 52 | #define Scroll_Right 0x01 |
jacobjohnson | 0:e14364aac2ca | 53 | |
jacobjohnson | 0:e14364aac2ca | 54 | #define Scroll_2Frames 0x7 |
jacobjohnson | 0:e14364aac2ca | 55 | #define Scroll_3Frames 0x4 |
jacobjohnson | 0:e14364aac2ca | 56 | #define Scroll_4Frames 0x5 |
jacobjohnson | 0:e14364aac2ca | 57 | #define Scroll_5Frames 0x0 |
jacobjohnson | 0:e14364aac2ca | 58 | #define Scroll_25Frames 0x6 |
jacobjohnson | 0:e14364aac2ca | 59 | #define Scroll_64Frames 0x1 |
jacobjohnson | 0:e14364aac2ca | 60 | #define Scroll_128Frames 0x2 |
jacobjohnson | 0:e14364aac2ca | 61 | #define Scroll_256Frames 0x3 |
jacobjohnson | 0:e14364aac2ca | 62 | |
jacobjohnson | 0:e14364aac2ca | 63 | |
jacobjohnson | 0:e14364aac2ca | 64 | class SeeedGrayOLED { |
jacobjohnson | 0:e14364aac2ca | 65 | public: |
jacobjohnson | 0:e14364aac2ca | 66 | |
jacobjohnson | 0:e14364aac2ca | 67 | /** Create a new TDA7419 communication interface |
jacobjohnson | 0:e14364aac2ca | 68 | * |
jacobjohnson | 0:e14364aac2ca | 69 | * @param sda is the pin for I2C SDA |
jacobjohnson | 0:e14364aac2ca | 70 | * @param scl is the pin for I2C SCL |
jacobjohnson | 0:e14364aac2ca | 71 | */ |
jacobjohnson | 0:e14364aac2ca | 72 | SeeedGrayOLED(PinName sda, PinName scl); |
jacobjohnson | 0:e14364aac2ca | 73 | |
jacobjohnson | 0:e14364aac2ca | 74 | |
jacobjohnson | 0:e14364aac2ca | 75 | char addressingMode; |
jacobjohnson | 0:e14364aac2ca | 76 | |
jacobjohnson | 0:e14364aac2ca | 77 | void init(void); |
jacobjohnson | 0:e14364aac2ca | 78 | |
jacobjohnson | 0:e14364aac2ca | 79 | void setNormalDisplay(); |
jacobjohnson | 0:e14364aac2ca | 80 | void setInverseDisplay(); |
jacobjohnson | 0:e14364aac2ca | 81 | |
jacobjohnson | 0:e14364aac2ca | 82 | void sendCommand(unsigned char command); |
jacobjohnson | 0:e14364aac2ca | 83 | void sendData(unsigned char Data); |
jacobjohnson | 0:e14364aac2ca | 84 | void setGrayLevel(unsigned char grayLevel); |
jacobjohnson | 0:e14364aac2ca | 85 | |
jacobjohnson | 0:e14364aac2ca | 86 | void setVerticalMode(); |
jacobjohnson | 0:e14364aac2ca | 87 | void setHorizontalMode(); |
jacobjohnson | 0:e14364aac2ca | 88 | |
jacobjohnson | 0:e14364aac2ca | 89 | void setTextXY(unsigned char Row, unsigned char Column); |
jacobjohnson | 0:e14364aac2ca | 90 | void clearDisplay(); |
jacobjohnson | 0:e14364aac2ca | 91 | void setContrastLevel(unsigned char ContrastLevel); |
jacobjohnson | 0:e14364aac2ca | 92 | void putChar(unsigned char c); |
jacobjohnson | 0:e14364aac2ca | 93 | void putString(const char *String); |
jacobjohnson | 0:e14364aac2ca | 94 | unsigned char putNumber(long n); |
jacobjohnson | 0:e14364aac2ca | 95 | unsigned char putFloat(float floatNumber,unsigned char decimal); |
jacobjohnson | 0:e14364aac2ca | 96 | unsigned char putFloat(float floatNumber); |
jacobjohnson | 0:e14364aac2ca | 97 | |
jacobjohnson | 0:e14364aac2ca | 98 | void drawBitmap(unsigned char *bitmaparray,int bytes); |
jacobjohnson | 0:e14364aac2ca | 99 | |
jacobjohnson | 0:e14364aac2ca | 100 | void setHorizontalScrollProperties(bool direction,unsigned char startRow, unsigned char endRow,unsigned char startColumn, unsigned char endColumn, unsigned char scrollSpeed); |
jacobjohnson | 0:e14364aac2ca | 101 | void activateScroll(); |
jacobjohnson | 0:e14364aac2ca | 102 | void deactivateScroll(); |
jacobjohnson | 0:e14364aac2ca | 103 | |
jacobjohnson | 0:e14364aac2ca | 104 | private: |
jacobjohnson | 0:e14364aac2ca | 105 | |
jacobjohnson | 0:e14364aac2ca | 106 | // Signals related to I2C communication |
jacobjohnson | 0:e14364aac2ca | 107 | I2C _device; |
jacobjohnson | 0:e14364aac2ca | 108 | |
jacobjohnson | 0:e14364aac2ca | 109 | unsigned char grayH; |
jacobjohnson | 0:e14364aac2ca | 110 | unsigned char grayL; |
jacobjohnson | 0:e14364aac2ca | 111 | |
jacobjohnson | 0:e14364aac2ca | 112 | |
jacobjohnson | 0:e14364aac2ca | 113 | }; |
jacobjohnson | 0:e14364aac2ca | 114 | |
jacobjohnson | 0:e14364aac2ca | 115 | |
jacobjohnson | 0:e14364aac2ca | 116 | #endif |
jacobjohnson | 0:e14364aac2ca | 117 |