set32l010 oled

Dependents:   oled_test8_16x24_010_1

Committer:
caa45040
Date:
Sat Aug 06 06:42:04 2022 +0000
Revision:
1:ad63de2ea3ff
Parent:
0:e65e15783b26
stm32l010 oled cut

Who changed what in which revision?

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