ssd1306 stm32l010
Dependents: oled_test7_16x24_010_1 i2c_HT16K33_test1_767_3 HAL_oled_16x24_010_1
SSD1308.h@0:5d70351255d1, 2022-08-02 (annotated)
- Committer:
- caa45040
- Date:
- Tue Aug 02 06:48:13 2022 +0000
- Revision:
- 0:5d70351255d1
- Child:
- 1:20e48680a5f8
ssd1306 stm32l010
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
caa45040 | 0:5d70351255d1 | 1 | /** @file SSD1308 I2C device class header file |
caa45040 | 0:5d70351255d1 | 2 | * Based on Solomon Systech SSD1308 datasheet, rev. 1, 10/2008 |
caa45040 | 0:5d70351255d1 | 3 | * The SSD1308 is used for example in the Seeed 128x64 OLED Display |
caa45040 | 0:5d70351255d1 | 4 | * http://www.seeedstudio.com/depot/grove-oled-display-12864-p-781.html?cPath=163_167 |
caa45040 | 0:5d70351255d1 | 5 | */ |
caa45040 | 0:5d70351255d1 | 6 | // The original code by Andrew Schamp is using (and has been submitted as a part of) Jeff Rowberg's I2Cdevlib library, |
caa45040 | 0:5d70351255d1 | 7 | // which should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib |
caa45040 | 0:5d70351255d1 | 8 | // Some parts also mashed up from Graphic Library for driving monochrome displays based on the PCD8544, |
caa45040 | 0:5d70351255d1 | 9 | // Copyright (c) 2011, Wim De Roeve, who in turn did partial port of code found on |
caa45040 | 0:5d70351255d1 | 10 | // http://serdisplib.sourceforge.net/ser/pcd8544.html#links and by Petras Saduikis <petras@petras.co.uk> |
caa45040 | 0:5d70351255d1 | 11 | // |
caa45040 | 0:5d70351255d1 | 12 | // Changelog: |
caa45040 | 0:5d70351255d1 | 13 | // 2011-08-25 - Initial release by Andrew Schamp <schamp@gmail.com> |
caa45040 | 0:5d70351255d1 | 14 | // 2012-06-19 - Ported to mbed and optimised (WH) |
caa45040 | 0:5d70351255d1 | 15 | // 2013-07-12 - Minor comment fix and placeholder for SSD1306 (WH) |
caa45040 | 0:5d70351255d1 | 16 | // 2015-01-01 - Switch for optimised I2C calls to test on F401 (WH) |
caa45040 | 0:5d70351255d1 | 17 | // 2017-12-18 - Fixed non-copyable issue (Thx kenjiArai) |
caa45040 | 0:5d70351255d1 | 18 | // |
caa45040 | 0:5d70351255d1 | 19 | /* |
caa45040 | 0:5d70351255d1 | 20 | ================================================================================ |
caa45040 | 0:5d70351255d1 | 21 | I2Cdev device library code is placed under the MIT license |
caa45040 | 0:5d70351255d1 | 22 | Copyright (c) 2011 Andrew Schamp |
caa45040 | 0:5d70351255d1 | 23 | Copyright (c) 2012,2013,2017 WH (mbed port) |
caa45040 | 0:5d70351255d1 | 24 | |
caa45040 | 0:5d70351255d1 | 25 | Permission is hereby granted, free of charge, to any person obtaining a copy |
caa45040 | 0:5d70351255d1 | 26 | of this software and associated documentation files (the "Software"), to deal |
caa45040 | 0:5d70351255d1 | 27 | in the Software without restriction, including without limitation the rights |
caa45040 | 0:5d70351255d1 | 28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
caa45040 | 0:5d70351255d1 | 29 | copies of the Software, and to permit persons to whom the Software is |
caa45040 | 0:5d70351255d1 | 30 | furnished to do so, subject to the following conditions: |
caa45040 | 0:5d70351255d1 | 31 | |
caa45040 | 0:5d70351255d1 | 32 | The above copyright notice and this permission notice shall be included in |
caa45040 | 0:5d70351255d1 | 33 | all copies or substantial portions of the Software. |
caa45040 | 0:5d70351255d1 | 34 | |
caa45040 | 0:5d70351255d1 | 35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
caa45040 | 0:5d70351255d1 | 36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
caa45040 | 0:5d70351255d1 | 37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
caa45040 | 0:5d70351255d1 | 38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
caa45040 | 0:5d70351255d1 | 39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
caa45040 | 0:5d70351255d1 | 40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
caa45040 | 0:5d70351255d1 | 41 | THE SOFTWARE. |
caa45040 | 0:5d70351255d1 | 42 | ================================================================================ |
caa45040 | 0:5d70351255d1 | 43 | */ |
caa45040 | 0:5d70351255d1 | 44 | |
caa45040 | 0:5d70351255d1 | 45 | #ifndef SSD1308_H |
caa45040 | 0:5d70351255d1 | 46 | #define SSD1308_H |
caa45040 | 0:5d70351255d1 | 47 | |
caa45040 | 0:5d70351255d1 | 48 | // This is the I2C address (8 bit) |
caa45040 | 0:5d70351255d1 | 49 | // There are two possible addresses: with D/C# (pin 13) grounded, the address is 0x78, |
caa45040 | 0:5d70351255d1 | 50 | // with D/C# tied high it is 0x7A. Assume grounded by default. |
caa45040 | 0:5d70351255d1 | 51 | #define SSD1308_SA0 0x78 |
caa45040 | 0:5d70351255d1 | 52 | #define SSD1308_SA1 0x7A |
caa45040 | 0:5d70351255d1 | 53 | #define SSD1308_DEF_SA SSD1308_SA0 |
caa45040 | 0:5d70351255d1 | 54 | |
caa45040 | 0:5d70351255d1 | 55 | // Display dimensions |
caa45040 | 0:5d70351255d1 | 56 | #define ROWS 64 |
caa45040 | 0:5d70351255d1 | 57 | #define COLUMNS 128 |
caa45040 | 0:5d70351255d1 | 58 | #define PAGES (ROWS / 8) |
caa45040 | 0:5d70351255d1 | 59 | #define MAX_PAGE (PAGES - 1) |
caa45040 | 0:5d70351255d1 | 60 | #define MAX_ROW (ROWS - 1) |
caa45040 | 0:5d70351255d1 | 61 | #define MAX_COL (COLUMNS - 1) |
caa45040 | 0:5d70351255d1 | 62 | |
caa45040 | 0:5d70351255d1 | 63 | // Character dimensions 8x8 font |
caa45040 | 0:5d70351255d1 | 64 | #define CHARS (COLUMNS / FONT8x8_WIDTH) |
caa45040 | 0:5d70351255d1 | 65 | |
caa45040 | 0:5d70351255d1 | 66 | // Command and Datamode |
caa45040 | 0:5d70351255d1 | 67 | #define COMMAND_MODE 0x80 // continuation bit is set! |
caa45040 | 0:5d70351255d1 | 68 | #define DATA_MODE 0x40 |
caa45040 | 0:5d70351255d1 | 69 | |
caa45040 | 0:5d70351255d1 | 70 | // Commands and Parameter defines |
caa45040 | 0:5d70351255d1 | 71 | #define SET_LOWER_COLUMN 0x00 // | with lower nibble (Page mode only) |
caa45040 | 0:5d70351255d1 | 72 | #define SET_HIGHER_COLUMN 0x10 // | with higher nibble (Page mode only) |
caa45040 | 0:5d70351255d1 | 73 | |
caa45040 | 0:5d70351255d1 | 74 | #define HORIZONTAL_ADDRESSING_MODE 0x00 |
caa45040 | 0:5d70351255d1 | 75 | #define VERTICAL_ADDRESSING_MODE 0x01 |
caa45040 | 0:5d70351255d1 | 76 | #define PAGE_ADDRESSING_MODE 0x02 |
caa45040 | 0:5d70351255d1 | 77 | #define SET_MEMORY_ADDRESSING_MODE 0x20 // takes one byte as given above |
caa45040 | 0:5d70351255d1 | 78 | |
caa45040 | 0:5d70351255d1 | 79 | #define SET_COLUMN_ADDRESS 0x21 // takes two bytes, start address and end address of display data RAM |
caa45040 | 0:5d70351255d1 | 80 | #define SET_PAGE_ADDRESS 0x22 // takes two bytes, start address and end address of display data RAM |
caa45040 | 0:5d70351255d1 | 81 | |
caa45040 | 0:5d70351255d1 | 82 | // Command maybe unsupported by SSD1308 |
caa45040 | 0:5d70351255d1 | 83 | #define FADE_INTERVAL_8_FRAMES 0x00 |
caa45040 | 0:5d70351255d1 | 84 | #define FADE_INTERVAL_16_FRAMES 0x01 |
caa45040 | 0:5d70351255d1 | 85 | #define FADE_INTERVAL_24_FRAMES 0x02 |
caa45040 | 0:5d70351255d1 | 86 | #define FADE_INTERVAL_32_FRAMES 0x03 |
caa45040 | 0:5d70351255d1 | 87 | #define FADE_INTERVAL_64_FRAMES 0x07 |
caa45040 | 0:5d70351255d1 | 88 | #define FADE_INTERVAL_128_FRAMES 0x0F |
caa45040 | 0:5d70351255d1 | 89 | #define FADE_BLINK_DISABLE 0x00 |
caa45040 | 0:5d70351255d1 | 90 | #define FADE_OUT_ENABLE 0x20 |
caa45040 | 0:5d70351255d1 | 91 | #define BLINK_ENABLE 0x30 |
caa45040 | 0:5d70351255d1 | 92 | #define SET_FADE_BLINK 0x23 // takes one byte |
caa45040 | 0:5d70351255d1 | 93 | // bit5-4 = 0, fade/blink mode |
caa45040 | 0:5d70351255d1 | 94 | // bit3-0 = Time interval in frames |
caa45040 | 0:5d70351255d1 | 95 | |
caa45040 | 0:5d70351255d1 | 96 | #define SET_DISPLAY_START_LINE 0x40 // | with a row number 0-63 to set start row. (Reset = 0) |
caa45040 | 0:5d70351255d1 | 97 | |
caa45040 | 0:5d70351255d1 | 98 | #define SET_CONTRAST 0x81 // takes one byte, 0x00 - 0xFF |
caa45040 | 0:5d70351255d1 | 99 | |
caa45040 | 0:5d70351255d1 | 100 | #define SET_SEGMENT_REMAP_0 0xA0 // column address 0 is mapped to SEG0 (Reset) |
caa45040 | 0:5d70351255d1 | 101 | #define SET_SEGMENT_REMAP_127 0xA1 // column address 127 is mapped to SEG0 |
caa45040 | 0:5d70351255d1 | 102 | |
caa45040 | 0:5d70351255d1 | 103 | #define SET_DISPLAY_GDDRAM 0xA4 // restores display to contents of RAM |
caa45040 | 0:5d70351255d1 | 104 | #define SET_ENTIRE_DISPLAY_ON 0xA5 // turns all pixels on, does not affect RAM |
caa45040 | 0:5d70351255d1 | 105 | |
caa45040 | 0:5d70351255d1 | 106 | #define SET_NORMAL_DISPLAY 0xA6 // a databit of 1 indicates pixel 'ON' |
caa45040 | 0:5d70351255d1 | 107 | #define SET_INVERSE_DISPLAY 0xA7 // a databit of 1 indicates pixel 'OFF' |
caa45040 | 0:5d70351255d1 | 108 | |
caa45040 | 0:5d70351255d1 | 109 | #define SET_MULTIPLEX_RATIO 0xA8 // takes one byte, from 16xMUX to 64xMUX (MUX Ratio = byte+1; Default 64) |
caa45040 | 0:5d70351255d1 | 110 | |
caa45040 | 0:5d70351255d1 | 111 | #define EXTERNAL_IREF 0x10 |
caa45040 | 0:5d70351255d1 | 112 | #define INTERNAL_IREF 0x00 |
caa45040 | 0:5d70351255d1 | 113 | #define SET_IREF_SELECTION 0xAD // sets internal or external Iref |
caa45040 | 0:5d70351255d1 | 114 | |
caa45040 | 0:5d70351255d1 | 115 | #define SET_DISPLAY_POWER_OFF 0xAE |
caa45040 | 0:5d70351255d1 | 116 | #define SET_DISPLAY_POWER_ON 0xAF |
caa45040 | 0:5d70351255d1 | 117 | |
caa45040 | 0:5d70351255d1 | 118 | #define PAGE0 0x00 |
caa45040 | 0:5d70351255d1 | 119 | #define PAGE1 0x01 |
caa45040 | 0:5d70351255d1 | 120 | #define PAGE2 0x02 |
caa45040 | 0:5d70351255d1 | 121 | #define PAGE3 0x03 |
caa45040 | 0:5d70351255d1 | 122 | #define PAGE4 0x04 |
caa45040 | 0:5d70351255d1 | 123 | #define PAGE5 0x05 |
caa45040 | 0:5d70351255d1 | 124 | #define PAGE6 0x06 |
caa45040 | 0:5d70351255d1 | 125 | #define PAGE7 0x07 |
caa45040 | 0:5d70351255d1 | 126 | #define SET_PAGE_START_ADDRESS 0xB0 // | with a page number to get start address (Page mode only) |
caa45040 | 0:5d70351255d1 | 127 | |
caa45040 | 0:5d70351255d1 | 128 | #define SET_COMMON_REMAP_0 0xC0 // row address 0 is mapped to COM0 (Reset) |
caa45040 | 0:5d70351255d1 | 129 | #define SET_COMMON_REMAP_63 0xC8 // row address 63 is mapped to COM0 |
caa45040 | 0:5d70351255d1 | 130 | |
caa45040 | 0:5d70351255d1 | 131 | #define SET_DISPLAY_OFFSET 0xD3 // takes one byte from 0-63 for vertical shift, Reset = 0 |
caa45040 | 0:5d70351255d1 | 132 | |
caa45040 | 0:5d70351255d1 | 133 | #define SET_DISPLAY_CLOCK 0xD5 // takes one byte |
caa45040 | 0:5d70351255d1 | 134 | // bit7-4 = Osc Freq DCLK (Reset = 1000b) |
caa45040 | 0:5d70351255d1 | 135 | // bit3-0 = Divide ration (Reset = oooob, Ratio = 1) |
caa45040 | 0:5d70351255d1 | 136 | |
caa45040 | 0:5d70351255d1 | 137 | #define SET_PRECHARGE_TIME 0xD9 // takes one byte |
caa45040 | 0:5d70351255d1 | 138 | // bit7-4 = Phase2, upto 15 DCLKs (Reset = 0010b) |
caa45040 | 0:5d70351255d1 | 139 | // bit3-0 = Phase1, upto 15 DCLKs (Reset = 0010b) |
caa45040 | 0:5d70351255d1 | 140 | |
caa45040 | 0:5d70351255d1 | 141 | |
caa45040 | 0:5d70351255d1 | 142 | #define COMMON_BASE 0x02 // |
caa45040 | 0:5d70351255d1 | 143 | #define COMMON_SEQUENTIAL 0x00 // Sequential common pins config |
caa45040 | 0:5d70351255d1 | 144 | #define COMMON_ALTERNATIVE 0x10 // Odd/Even common pins config (Reset) |
caa45040 | 0:5d70351255d1 | 145 | #define COMMON_LEFTRIGHT_NORMAL 0x00 // LeftRight Normal (Reset) |
caa45040 | 0:5d70351255d1 | 146 | #define COMMON_LEFTRIGHT_FLIP 0x20 // LeftRight Flip |
caa45040 | 0:5d70351255d1 | 147 | #define SET_COMMON_CONF 0xDA // takes one byte as given above |
caa45040 | 0:5d70351255d1 | 148 | |
caa45040 | 0:5d70351255d1 | 149 | |
caa45040 | 0:5d70351255d1 | 150 | #define VCOMH_DESELECT_0_65_CODE 0x00 |
caa45040 | 0:5d70351255d1 | 151 | #define VCOMH_DESELECT_0_77_CODE 0x20 |
caa45040 | 0:5d70351255d1 | 152 | #define VCOMH_DESELECT_0_83_CODE 0x30 |
caa45040 | 0:5d70351255d1 | 153 | #define SET_VCOMH_DESELECT_LEVEL 0xDB // takes one byte as given above |
caa45040 | 0:5d70351255d1 | 154 | |
caa45040 | 0:5d70351255d1 | 155 | #define NOP 0xE3 |
caa45040 | 0:5d70351255d1 | 156 | |
caa45040 | 0:5d70351255d1 | 157 | #define SCROLL_INTERVAL_5_FRAMES 0x00 |
caa45040 | 0:5d70351255d1 | 158 | #define SCROLL_INTERVAL_64_FRAMES 0x01 |
caa45040 | 0:5d70351255d1 | 159 | #define SCROLL_INTERVAL_128_FRAMES 0x02 |
caa45040 | 0:5d70351255d1 | 160 | #define SCROLL_INTERVAL_256_FRAMES 0x03 |
caa45040 | 0:5d70351255d1 | 161 | #define SCROLL_INTERVAL_3_FRAMES 0x04 |
caa45040 | 0:5d70351255d1 | 162 | #define SCROLL_INTERVAL_4_FRAMES 0x05 |
caa45040 | 0:5d70351255d1 | 163 | #define SCROLL_INTERVAL_25_FRAMES 0x06 |
caa45040 | 0:5d70351255d1 | 164 | #define SCROLL_INTERVAL_2_FRAMES 0x07 |
caa45040 | 0:5d70351255d1 | 165 | |
caa45040 | 0:5d70351255d1 | 166 | #define SET_RIGHT_HOR_SCROLL 0x26 // takes 6 bytes: 0x00, PageStart, Scroll_Interval, PageEnd, 0x00, 0xFF |
caa45040 | 0:5d70351255d1 | 167 | #define SET_LEFT_HOR_SCROLL 0x27 // takes 6 bytes: 0x00, PageStart, Scroll_Interval, PageEnd, 0x00, 0xFF |
caa45040 | 0:5d70351255d1 | 168 | |
caa45040 | 0:5d70351255d1 | 169 | #define SET_VERT_RIGHT_HOR_SCROLL 0x29 // takes 5 bytes: 0x00, PageStart, Scroll_Interval, PageEnd, VertOffset |
caa45040 | 0:5d70351255d1 | 170 | #define SET_VERT_LEFT_HOR_SCROLL 0x2A // takes 5 bytes: 0x00, PageStart, Scroll_Interval, PageEnd, VertOffset |
caa45040 | 0:5d70351255d1 | 171 | |
caa45040 | 0:5d70351255d1 | 172 | #define SET_DEACTIVATE_SCROLL 0x2E |
caa45040 | 0:5d70351255d1 | 173 | #define SET_ACTIVATE_SCROLL 0x2F |
caa45040 | 0:5d70351255d1 | 174 | |
caa45040 | 0:5d70351255d1 | 175 | #define SET_VERTICAL_SCROLL_AREA 0xA3 // takes 2 bytes: Rows in Top Area (Reset=0), Rows in Scroll Area (Reset=64) |
caa45040 | 0:5d70351255d1 | 176 | |
caa45040 | 0:5d70351255d1 | 177 | |
caa45040 | 0:5d70351255d1 | 178 | |
caa45040 | 0:5d70351255d1 | 179 | /** Class to control an SSD1308 based oled Display |
caa45040 | 0:5d70351255d1 | 180 | * |
caa45040 | 0:5d70351255d1 | 181 | * Example: |
caa45040 | 0:5d70351255d1 | 182 | * @code |
caa45040 | 0:5d70351255d1 | 183 | * #include "mbed.h" |
caa45040 | 0:5d70351255d1 | 184 | * #include "mbed_logo.h" |
caa45040 | 0:5d70351255d1 | 185 | * #include "SSD1308.h" |
caa45040 | 0:5d70351255d1 | 186 | |
caa45040 | 0:5d70351255d1 | 187 | * //Pin Defines for I2C Bus |
caa45040 | 0:5d70351255d1 | 188 | * #define D_SDA p28 |
caa45040 | 0:5d70351255d1 | 189 | * #define D_SCL p27 |
caa45040 | 0:5d70351255d1 | 190 | * I2C i2c(D_SDA, D_SCL); |
caa45040 | 0:5d70351255d1 | 191 | * |
caa45040 | 0:5d70351255d1 | 192 | * // Host PC Communication channels |
caa45040 | 0:5d70351255d1 | 193 | * Serial pc(USBTX, USBRX); // tx, rx |
caa45040 | 0:5d70351255d1 | 194 | * |
caa45040 | 0:5d70351255d1 | 195 | * // Instantiate OLED |
caa45040 | 0:5d70351255d1 | 196 | * SSD1308 oled = SSD1308(&i2c, SSD1308_SA0); |
caa45040 | 0:5d70351255d1 | 197 | * |
caa45040 | 0:5d70351255d1 | 198 | * int main() { |
caa45040 | 0:5d70351255d1 | 199 | * pc.printf("OLED test start\r"); |
caa45040 | 0:5d70351255d1 | 200 | * oled.writeString(0, 0, "Hello World !"); |
caa45040 | 0:5d70351255d1 | 201 | * // oled.printf("Hello World !"); |
caa45040 | 0:5d70351255d1 | 202 | * |
caa45040 | 0:5d70351255d1 | 203 | * oled.fillDisplay(0xAA); |
caa45040 | 0:5d70351255d1 | 204 | * oled.setDisplayOff(); |
caa45040 | 0:5d70351255d1 | 205 | * wait(1); |
caa45040 | 0:5d70351255d1 | 206 | * oled.setDisplayOn(); |
caa45040 | 0:5d70351255d1 | 207 | * |
caa45040 | 0:5d70351255d1 | 208 | * oled.clearDisplay(); |
caa45040 | 0:5d70351255d1 | 209 | * oled.setDisplayInverse(); |
caa45040 | 0:5d70351255d1 | 210 | * wait(0.5); |
caa45040 | 0:5d70351255d1 | 211 | * oled.setDisplayNormal(); |
caa45040 | 0:5d70351255d1 | 212 | * |
caa45040 | 0:5d70351255d1 | 213 | * oled.writeBitmap((uint8_t*) mbed_logo); |
caa45040 | 0:5d70351255d1 | 214 | * |
caa45040 | 0:5d70351255d1 | 215 | * pc.printf("OLED test done\r\n"); |
caa45040 | 0:5d70351255d1 | 216 | * } |
caa45040 | 0:5d70351255d1 | 217 | * |
caa45040 | 0:5d70351255d1 | 218 | * @endcode |
caa45040 | 0:5d70351255d1 | 219 | */ |
caa45040 | 0:5d70351255d1 | 220 | //class SSD1308 : public Stream { |
caa45040 | 0:5d70351255d1 | 221 | struct SSD1308 { |
caa45040 | 0:5d70351255d1 | 222 | |
caa45040 | 0:5d70351255d1 | 223 | |
caa45040 | 0:5d70351255d1 | 224 | // public: |
caa45040 | 0:5d70351255d1 | 225 | |
caa45040 | 0:5d70351255d1 | 226 | /** |
caa45040 | 0:5d70351255d1 | 227 | *@brief Constructor |
caa45040 | 0:5d70351255d1 | 228 | *@param I2C &i2c reference to i2c, |
caa45040 | 0:5d70351255d1 | 229 | *@param uint8_t deviceAddress slaveaddress (8bit to use for the controller (0x78 by default, assumes D/C# (pin 13) grounded) |
caa45040 | 0:5d70351255d1 | 230 | */ |
caa45040 | 0:5d70351255d1 | 231 | SSD1308( uint8_t address = SSD1308_DEF_SA); |
caa45040 | 0:5d70351255d1 | 232 | |
caa45040 | 0:5d70351255d1 | 233 | // High Level methods |
caa45040 | 0:5d70351255d1 | 234 | |
caa45040 | 0:5d70351255d1 | 235 | /** @brief High level Init, most settings remain at Power-On reset value |
caa45040 | 0:5d70351255d1 | 236 | */ |
caa45040 | 0:5d70351255d1 | 237 | void initialize(); |
caa45040 | 0:5d70351255d1 | 238 | |
caa45040 | 0:5d70351255d1 | 239 | /** @brief clear the display |
caa45040 | 0:5d70351255d1 | 240 | */ |
caa45040 | 0:5d70351255d1 | 241 | void clearDisplay(); |
caa45040 | 0:5d70351255d1 | 242 | |
caa45040 | 0:5d70351255d1 | 243 | |
caa45040 | 0:5d70351255d1 | 244 | /** @brief fill the display |
caa45040 | 0:5d70351255d1 | 245 | * @param uint8_t pattern fillpattern vertical patch or 8 bits |
caa45040 | 0:5d70351255d1 | 246 | * @param uint8_t start_page begin page (0..MAX_PAGE) |
caa45040 | 0:5d70351255d1 | 247 | * @param uint8_t end_page end page (start_page..MAX_PAGE) |
caa45040 | 0:5d70351255d1 | 248 | * @param uint8_t start_col begin column (0..MAX_COL) |
caa45040 | 0:5d70351255d1 | 249 | * @param uint8_t end_col end column (start_col..MAX_COL) |
caa45040 | 0:5d70351255d1 | 250 | */ |
caa45040 | 0:5d70351255d1 | 251 | void fillDisplay(uint8_t pattern = 0x00, |
caa45040 | 0:5d70351255d1 | 252 | uint8_t start_page=0, uint8_t end_page=MAX_PAGE, |
caa45040 | 0:5d70351255d1 | 253 | uint8_t start_col=0, uint8_t end_col=MAX_COL); |
caa45040 | 0:5d70351255d1 | 254 | |
caa45040 | 0:5d70351255d1 | 255 | |
caa45040 | 0:5d70351255d1 | 256 | /** @brief write a bitmap to the display |
caa45040 | 0:5d70351255d1 | 257 | * @param uint8_t* data pointer to bitmap |
caa45040 | 0:5d70351255d1 | 258 | * @param uint8_t start_page begin page (0..MAX_PAGE) |
caa45040 | 0:5d70351255d1 | 259 | * @param uint8_t end_page end page (start_page..MAX_PAGE) |
caa45040 | 0:5d70351255d1 | 260 | * @param uint8_t start_col begin column (0..MAX_COL) |
caa45040 | 0:5d70351255d1 | 261 | * @param uint8_t end_col end column (start_col..MAX_COL) |
caa45040 | 0:5d70351255d1 | 262 | */ |
caa45040 | 0:5d70351255d1 | 263 | void writeBitmap(uint8_t* data, |
caa45040 | 0:5d70351255d1 | 264 | uint8_t start_page=0, uint8_t end_page=MAX_PAGE, |
caa45040 | 0:5d70351255d1 | 265 | uint8_t start_col=0, uint8_t end_col=MAX_COL); |
caa45040 | 0:5d70351255d1 | 266 | |
caa45040 | 0:5d70351255d1 | 267 | // Select inverted or normal text |
caa45040 | 0:5d70351255d1 | 268 | //void setInverted(bool inverted) { _inverted = inverted; }; |
caa45040 | 0:5d70351255d1 | 269 | |
caa45040 | 0:5d70351255d1 | 270 | |
caa45040 | 0:5d70351255d1 | 271 | /** @brief Write large character (16x24 font) |
caa45040 | 0:5d70351255d1 | 272 | * @param uint8_t row row number (0...MAX_ROW) |
caa45040 | 0:5d70351255d1 | 273 | * @param uint8_t col column number (0...MAX_COL) |
caa45040 | 0:5d70351255d1 | 274 | * @param char chr Used for displaying numbers 0 - 9 and '+', '-', '.' |
caa45040 | 0:5d70351255d1 | 275 | */ |
caa45040 | 0:5d70351255d1 | 276 | void writeBigChar(uint8_t row, uint8_t col, char chr); |
caa45040 | 0:5d70351255d1 | 277 | |
caa45040 | 0:5d70351255d1 | 278 | |
caa45040 | 0:5d70351255d1 | 279 | |
caa45040 | 0:5d70351255d1 | 280 | |
caa45040 | 0:5d70351255d1 | 281 | |
caa45040 | 0:5d70351255d1 | 282 | // Medium Level methods |
caa45040 | 0:5d70351255d1 | 283 | |
caa45040 | 0:5d70351255d1 | 284 | /** @brief Set Horizontal Addressing Mode (cursor incr left-to-right, top-to-bottom) |
caa45040 | 0:5d70351255d1 | 285 | * |
caa45040 | 0:5d70351255d1 | 286 | */ |
caa45040 | 0:5d70351255d1 | 287 | void setHorizontalAddressingMode(); |
caa45040 | 0:5d70351255d1 | 288 | |
caa45040 | 0:5d70351255d1 | 289 | /** @brief Set Page Addressing Mode (cursor incr left-to-right) |
caa45040 | 0:5d70351255d1 | 290 | * |
caa45040 | 0:5d70351255d1 | 291 | */ |
caa45040 | 0:5d70351255d1 | 292 | void setPageAddressingMode(); |
caa45040 | 0:5d70351255d1 | 293 | |
caa45040 | 0:5d70351255d1 | 294 | /** @brief Set Addressing Mode |
caa45040 | 0:5d70351255d1 | 295 | * @param uint8_t mode |
caa45040 | 0:5d70351255d1 | 296 | */ |
caa45040 | 0:5d70351255d1 | 297 | void setMemoryAddressingMode(uint8_t mode); |
caa45040 | 0:5d70351255d1 | 298 | |
caa45040 | 0:5d70351255d1 | 299 | |
caa45040 | 0:5d70351255d1 | 300 | /** @param uint8_t start startcolumn (valid range 0..MAX_COL) |
caa45040 | 0:5d70351255d1 | 301 | * @param uint8_t end endcolumn (valid range start..MAX_COL) |
caa45040 | 0:5d70351255d1 | 302 | */ |
caa45040 | 0:5d70351255d1 | 303 | void setColumnAddress(uint8_t start, uint8_t end); |
caa45040 | 0:5d70351255d1 | 304 | |
caa45040 | 0:5d70351255d1 | 305 | /** @param uint8_t start startpage (valid range 0..MAX_PAGE) |
caa45040 | 0:5d70351255d1 | 306 | * @param uint8_t end endpage (valid range start..MAX_PAGE) |
caa45040 | 0:5d70351255d1 | 307 | */ |
caa45040 | 0:5d70351255d1 | 308 | void setPageAddress(uint8_t start, uint8_t end); |
caa45040 | 0:5d70351255d1 | 309 | |
caa45040 | 0:5d70351255d1 | 310 | |
caa45040 | 0:5d70351255d1 | 311 | /** @brief Enable Display |
caa45040 | 0:5d70351255d1 | 312 | */ |
caa45040 | 0:5d70351255d1 | 313 | void setDisplayOn(); |
caa45040 | 0:5d70351255d1 | 314 | |
caa45040 | 0:5d70351255d1 | 315 | /** @brief Disable Display |
caa45040 | 0:5d70351255d1 | 316 | */ |
caa45040 | 0:5d70351255d1 | 317 | void setDisplayOff(); |
caa45040 | 0:5d70351255d1 | 318 | |
caa45040 | 0:5d70351255d1 | 319 | /** @brief Display Flip (Left/Right, Up/Down) |
caa45040 | 0:5d70351255d1 | 320 | * @param bool left flip Left/Right |
caa45040 | 0:5d70351255d1 | 321 | * @param bool down flip Up/Down |
caa45040 | 0:5d70351255d1 | 322 | */ |
caa45040 | 0:5d70351255d1 | 323 | void setDisplayFlip(bool left, bool down); |
caa45040 | 0:5d70351255d1 | 324 | |
caa45040 | 0:5d70351255d1 | 325 | |
caa45040 | 0:5d70351255d1 | 326 | |
caa45040 | 0:5d70351255d1 | 327 | |
caa45040 | 0:5d70351255d1 | 328 | // private: |
caa45040 | 0:5d70351255d1 | 329 | |
caa45040 | 0:5d70351255d1 | 330 | |
caa45040 | 0:5d70351255d1 | 331 | // Low Level methods |
caa45040 | 0:5d70351255d1 | 332 | |
caa45040 | 0:5d70351255d1 | 333 | /** @brief Write command that has no parameters |
caa45040 | 0:5d70351255d1 | 334 | */ |
caa45040 | 0:5d70351255d1 | 335 | void _sendCommand(uint8_t command); |
caa45040 | 0:5d70351255d1 | 336 | |
caa45040 | 0:5d70351255d1 | 337 | /** @brief Write command that has one parameter |
caa45040 | 0:5d70351255d1 | 338 | */ |
caa45040 | 0:5d70351255d1 | 339 | void _sendCommand(uint8_t command, uint8_t param1); |
caa45040 | 0:5d70351255d1 | 340 | |
caa45040 | 0:5d70351255d1 | 341 | /** @brief Write command that has two parameters |
caa45040 | 0:5d70351255d1 | 342 | */ |
caa45040 | 0:5d70351255d1 | 343 | void _sendCommand(uint8_t command, uint8_t param1, uint8_t param2); |
caa45040 | 0:5d70351255d1 | 344 | // void sendCommands(uint8_t len, uint8_t* buf); |
caa45040 | 0:5d70351255d1 | 345 | |
caa45040 | 0:5d70351255d1 | 346 | /** @brief Write command that has five parameters |
caa45040 | 0:5d70351255d1 | 347 | */ |
caa45040 | 0:5d70351255d1 | 348 | void _sendCommand(uint8_t command, uint8_t param1, uint8_t param2, |
caa45040 | 0:5d70351255d1 | 349 | uint8_t param3, uint8_t param4, |
caa45040 | 0:5d70351255d1 | 350 | uint8_t param5); |
caa45040 | 0:5d70351255d1 | 351 | |
caa45040 | 0:5d70351255d1 | 352 | /** @brief Write command that has six parameters |
caa45040 | 0:5d70351255d1 | 353 | */ |
caa45040 | 0:5d70351255d1 | 354 | void _sendCommand(uint8_t command, uint8_t param1, uint8_t param2, |
caa45040 | 0:5d70351255d1 | 355 | uint8_t param3, uint8_t param4, |
caa45040 | 0:5d70351255d1 | 356 | uint8_t param5, uint8_t param6); |
caa45040 | 0:5d70351255d1 | 357 | |
caa45040 | 0:5d70351255d1 | 358 | /** @brief Write databyte to display |
caa45040 | 0:5d70351255d1 | 359 | * @brief Start at current cursor location |
caa45040 | 0:5d70351255d1 | 360 | * @param uint8_t data databyte to write |
caa45040 | 0:5d70351255d1 | 361 | */ |
caa45040 | 0:5d70351255d1 | 362 | void _sendData(uint8_t data); |
caa45040 | 0:5d70351255d1 | 363 | |
caa45040 | 0:5d70351255d1 | 364 | /** @brief Write len bytes from buffer data to display, |
caa45040 | 0:5d70351255d1 | 365 | * @brief Start at current cursor location |
caa45040 | 0:5d70351255d1 | 366 | * @param uint8_t len number of bytes to write |
caa45040 | 0:5d70351255d1 | 367 | * @param uint8_t* data pointer to data |
caa45040 | 0:5d70351255d1 | 368 | */ |
caa45040 | 0:5d70351255d1 | 369 | void _sendData(uint8_t len, uint8_t* data); |
caa45040 | 0:5d70351255d1 | 370 | |
caa45040 | 0:5d70351255d1 | 371 | |
caa45040 | 0:5d70351255d1 | 372 | //I2C *_i2c; // I2C bus reference |
caa45040 | 0:5d70351255d1 | 373 | uint8_t _readOpcode; // contains the I2C address of the device |
caa45040 | 0:5d70351255d1 | 374 | uint8_t _writeOpcode; // contains the I2C address of the device |
caa45040 | 0:5d70351255d1 | 375 | |
caa45040 | 0:5d70351255d1 | 376 | //bool _inverted; // inverted or normal text |
caa45040 | 0:5d70351255d1 | 377 | }; |
caa45040 | 0:5d70351255d1 | 378 | |
caa45040 | 0:5d70351255d1 | 379 | #endif |