ThingPulse OLED SSD1306

Dependents:   Turtle_RadioShuttle mbed-os5-F303-18650-Manager-tp4056 Kretanje_kroz_izbornike_OLED128x64_4tipke

Committer:
Helmut Tschemernjak
Date:
Sun Apr 14 18:00:54 2019 +0200
Revision:
1:9270c15c6aea
Parent:
0:56dd5df33ab4
Child:
2:4ed55dfe5be7
Updated updated problem for single buffer operation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Helmut64 0:56dd5df33ab4 1 /**
Helmut64 0:56dd5df33ab4 2 * The MIT License (MIT)
Helmut64 0:56dd5df33ab4 3 *
Helmut64 0:56dd5df33ab4 4 * Copyright (c) 2018 by ThingPulse, Daniel Eichhorn
Helmut64 0:56dd5df33ab4 5 * Copyright (c) 2018 by Fabrice Weinberg
Helmut64 0:56dd5df33ab4 6 * Copyright (c) 2019 by Helmut Tschemernjak - www.radioshuttle.de
Helmut64 0:56dd5df33ab4 7 *
Helmut64 0:56dd5df33ab4 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
Helmut64 0:56dd5df33ab4 9 * of this software and associated documentation files (the "Software"), to deal
Helmut64 0:56dd5df33ab4 10 * in the Software without restriction, including without limitation the rights
Helmut64 0:56dd5df33ab4 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Helmut64 0:56dd5df33ab4 12 * copies of the Software, and to permit persons to whom the Software is
Helmut64 0:56dd5df33ab4 13 * furnished to do so, subject to the following conditions:
Helmut64 0:56dd5df33ab4 14 *
Helmut64 0:56dd5df33ab4 15 * The above copyright notice and this permission notice shall be included in all
Helmut64 0:56dd5df33ab4 16 * copies or substantial portions of the Software.
Helmut64 0:56dd5df33ab4 17 *
Helmut64 0:56dd5df33ab4 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Helmut64 0:56dd5df33ab4 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Helmut64 0:56dd5df33ab4 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Helmut64 0:56dd5df33ab4 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Helmut64 0:56dd5df33ab4 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Helmut64 0:56dd5df33ab4 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Helmut64 0:56dd5df33ab4 24 * SOFTWARE.
Helmut64 0:56dd5df33ab4 25 *
Helmut64 0:56dd5df33ab4 26 * ThingPulse invests considerable time and money to develop these open source libraries.
Helmut64 0:56dd5df33ab4 27 * Please support us by buying our products (and not the clones) from
Helmut64 0:56dd5df33ab4 28 * https://thingpulse.com
Helmut64 0:56dd5df33ab4 29 *
Helmut64 0:56dd5df33ab4 30 */
Helmut64 0:56dd5df33ab4 31
Helmut64 0:56dd5df33ab4 32 #ifndef OLEDDISPLAY_h
Helmut64 0:56dd5df33ab4 33 #define OLEDDISPLAY_h
Helmut64 0:56dd5df33ab4 34
Helmut64 0:56dd5df33ab4 35 #ifdef ARDUINO
Helmut64 0:56dd5df33ab4 36 #include <Arduino.h>
Helmut64 0:56dd5df33ab4 37 #elif __MBED__
Helmut64 0:56dd5df33ab4 38 #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
Helmut64 0:56dd5df33ab4 39
Helmut64 0:56dd5df33ab4 40 #include <mbed.h>
Helmut64 0:56dd5df33ab4 41 #define delay(x) wait_ms(x)
Helmut64 0:56dd5df33ab4 42 #define yield() void()
Helmut64 0:56dd5df33ab4 43
Helmut64 0:56dd5df33ab4 44 /*
Helmut64 0:56dd5df33ab4 45 * This is a little Arduino String emulation to keep the OLEDDisplay
Helmut64 0:56dd5df33ab4 46 * library code in common between Arduino and mbed-os
Helmut64 0:56dd5df33ab4 47 */
Helmut64 0:56dd5df33ab4 48 class String {
Helmut64 0:56dd5df33ab4 49 public:
Helmut64 0:56dd5df33ab4 50 String(const char *s) { _str = s; };
Helmut64 0:56dd5df33ab4 51 int length() { return strlen(_str); };
Helmut64 0:56dd5df33ab4 52 const char *c_str() { return _str; };
Helmut64 0:56dd5df33ab4 53 void toCharArray(char *buf, unsigned int bufsize, unsigned int index = 0) const {
Helmut64 0:56dd5df33ab4 54 memcpy(buf, _str + index, std::min(bufsize, strlen(_str)));
Helmut64 0:56dd5df33ab4 55 };
Helmut64 0:56dd5df33ab4 56 private:
Helmut64 0:56dd5df33ab4 57 const char *_str;
Helmut64 0:56dd5df33ab4 58 };
Helmut64 0:56dd5df33ab4 59
Helmut64 0:56dd5df33ab4 60 #else
Helmut64 0:56dd5df33ab4 61 #error "Unkown operating system"
Helmut64 0:56dd5df33ab4 62 #endif
Helmut64 0:56dd5df33ab4 63
Helmut64 0:56dd5df33ab4 64 #include "OLEDDisplayFonts.h"
Helmut64 0:56dd5df33ab4 65
Helmut64 0:56dd5df33ab4 66 //#define DEBUG_OLEDDISPLAY(...) Serial.printf( __VA_ARGS__ )
Helmut64 0:56dd5df33ab4 67 //#define DEBUG_OLEDDISPLAY(...) dprintf("%s", __VA_ARGS__ )
Helmut64 0:56dd5df33ab4 68
Helmut64 0:56dd5df33ab4 69 #ifndef DEBUG_OLEDDISPLAY
Helmut64 0:56dd5df33ab4 70 #define DEBUG_OLEDDISPLAY(...)
Helmut64 0:56dd5df33ab4 71 #endif
Helmut64 0:56dd5df33ab4 72
Helmut64 0:56dd5df33ab4 73 // Use DOUBLE BUFFERING by default
Helmut64 0:56dd5df33ab4 74 #ifndef OLEDDISPLAY_REDUCE_MEMORY
Helmut64 0:56dd5df33ab4 75 #define OLEDDISPLAY_DOUBLE_BUFFER
Helmut64 0:56dd5df33ab4 76 #endif
Helmut64 0:56dd5df33ab4 77
Helmut64 0:56dd5df33ab4 78 // Header Values
Helmut64 0:56dd5df33ab4 79 #define JUMPTABLE_BYTES 4
Helmut64 0:56dd5df33ab4 80
Helmut64 0:56dd5df33ab4 81 #define JUMPTABLE_LSB 1
Helmut64 0:56dd5df33ab4 82 #define JUMPTABLE_SIZE 2
Helmut64 0:56dd5df33ab4 83 #define JUMPTABLE_WIDTH 3
Helmut64 0:56dd5df33ab4 84 #define JUMPTABLE_START 4
Helmut64 0:56dd5df33ab4 85
Helmut64 0:56dd5df33ab4 86 #define WIDTH_POS 0
Helmut64 0:56dd5df33ab4 87 #define HEIGHT_POS 1
Helmut64 0:56dd5df33ab4 88 #define FIRST_CHAR_POS 2
Helmut64 0:56dd5df33ab4 89 #define CHAR_NUM_POS 3
Helmut64 0:56dd5df33ab4 90
Helmut64 0:56dd5df33ab4 91
Helmut64 0:56dd5df33ab4 92 // Display commands
Helmut64 0:56dd5df33ab4 93 #define CHARGEPUMP 0x8D
Helmut64 0:56dd5df33ab4 94 #define COLUMNADDR 0x21
Helmut64 0:56dd5df33ab4 95 #define COMSCANDEC 0xC8
Helmut64 0:56dd5df33ab4 96 #define COMSCANINC 0xC0
Helmut64 0:56dd5df33ab4 97 #define DISPLAYALLON 0xA5
Helmut64 0:56dd5df33ab4 98 #define DISPLAYALLON_RESUME 0xA4
Helmut64 0:56dd5df33ab4 99 #define DISPLAYOFF 0xAE
Helmut64 0:56dd5df33ab4 100 #define DISPLAYON 0xAF
Helmut64 0:56dd5df33ab4 101 #define EXTERNALVCC 0x1
Helmut64 0:56dd5df33ab4 102 #define INVERTDISPLAY 0xA7
Helmut64 0:56dd5df33ab4 103 #define MEMORYMODE 0x20
Helmut64 0:56dd5df33ab4 104 #define NORMALDISPLAY 0xA6
Helmut64 0:56dd5df33ab4 105 #define PAGEADDR 0x22
Helmut64 0:56dd5df33ab4 106 #define SEGREMAP 0xA0
Helmut64 0:56dd5df33ab4 107 #define SETCOMPINS 0xDA
Helmut64 0:56dd5df33ab4 108 #define SETCONTRAST 0x81
Helmut64 0:56dd5df33ab4 109 #define SETDISPLAYCLOCKDIV 0xD5
Helmut64 0:56dd5df33ab4 110 #define SETDISPLAYOFFSET 0xD3
Helmut64 0:56dd5df33ab4 111 #define SETHIGHCOLUMN 0x10
Helmut64 0:56dd5df33ab4 112 #define SETLOWCOLUMN 0x00
Helmut64 0:56dd5df33ab4 113 #define SETMULTIPLEX 0xA8
Helmut64 0:56dd5df33ab4 114 #define SETPRECHARGE 0xD9
Helmut64 0:56dd5df33ab4 115 #define SETSEGMENTREMAP 0xA1
Helmut64 0:56dd5df33ab4 116 #define SETSTARTLINE 0x40
Helmut64 0:56dd5df33ab4 117 #define SETVCOMDETECT 0xDB
Helmut64 0:56dd5df33ab4 118 #define SWITCHCAPVCC 0x2
Helmut64 0:56dd5df33ab4 119
Helmut64 0:56dd5df33ab4 120 #ifndef _swap_int16_t
Helmut64 0:56dd5df33ab4 121 #define _swap_int16_t(a, b) { int16_t t = a; a = b; b = t; }
Helmut64 0:56dd5df33ab4 122 #endif
Helmut64 0:56dd5df33ab4 123
Helmut64 0:56dd5df33ab4 124 enum OLEDDISPLAY_COLOR {
Helmut64 0:56dd5df33ab4 125 BLACK = 0,
Helmut64 0:56dd5df33ab4 126 WHITE = 1,
Helmut64 0:56dd5df33ab4 127 INVERSE = 2
Helmut64 0:56dd5df33ab4 128 };
Helmut64 0:56dd5df33ab4 129
Helmut64 0:56dd5df33ab4 130 enum OLEDDISPLAY_TEXT_ALIGNMENT {
Helmut64 0:56dd5df33ab4 131 TEXT_ALIGN_LEFT = 0,
Helmut64 0:56dd5df33ab4 132 TEXT_ALIGN_RIGHT = 1,
Helmut64 0:56dd5df33ab4 133 TEXT_ALIGN_CENTER = 2,
Helmut64 0:56dd5df33ab4 134 TEXT_ALIGN_CENTER_BOTH = 3
Helmut64 0:56dd5df33ab4 135 };
Helmut64 0:56dd5df33ab4 136
Helmut64 0:56dd5df33ab4 137
Helmut64 0:56dd5df33ab4 138 enum OLEDDISPLAY_GEOMETRY {
Helmut64 0:56dd5df33ab4 139 GEOMETRY_128_64 = 0,
Helmut64 0:56dd5df33ab4 140 GEOMETRY_128_32 = 1
Helmut64 0:56dd5df33ab4 141 };
Helmut64 0:56dd5df33ab4 142
Helmut64 0:56dd5df33ab4 143 typedef char (*FontTableLookupFunction)(const char ch);
Helmut64 0:56dd5df33ab4 144 char DefaultFontTableLookup(const char ch);
Helmut64 0:56dd5df33ab4 145
Helmut64 0:56dd5df33ab4 146
Helmut64 0:56dd5df33ab4 147 #ifdef ARDUINO
Helmut64 0:56dd5df33ab4 148 class OLEDDisplay : public Print {
Helmut64 0:56dd5df33ab4 149 #elif __MBED__
Helmut64 0:56dd5df33ab4 150 class OLEDDisplay : public Stream {
Helmut64 0:56dd5df33ab4 151 #else
Helmut64 0:56dd5df33ab4 152 #error "Unkown operating system"
Helmut64 0:56dd5df33ab4 153 #endif
Helmut64 0:56dd5df33ab4 154
Helmut64 0:56dd5df33ab4 155 public:
Helmut64 0:56dd5df33ab4 156 OLEDDisplay();
Helmut64 0:56dd5df33ab4 157 virtual ~OLEDDisplay();
Helmut64 0:56dd5df33ab4 158
Helmut64 0:56dd5df33ab4 159 uint16_t width(void) const { return displayWidth; };
Helmut64 0:56dd5df33ab4 160 uint16_t height(void) const { return displayHeight; };
Helmut64 0:56dd5df33ab4 161
Helmut64 0:56dd5df33ab4 162 // Initialize the display
Helmut64 0:56dd5df33ab4 163 bool init();
Helmut64 0:56dd5df33ab4 164
Helmut64 0:56dd5df33ab4 165 // Free the memory used by the display
Helmut64 0:56dd5df33ab4 166 void end();
Helmut64 0:56dd5df33ab4 167
Helmut64 0:56dd5df33ab4 168 // Cycle through the initialization
Helmut64 0:56dd5df33ab4 169 void resetDisplay(void);
Helmut64 0:56dd5df33ab4 170
Helmut64 0:56dd5df33ab4 171 /* Drawing functions */
Helmut64 0:56dd5df33ab4 172 // Sets the color of all pixel operations
Helmut64 0:56dd5df33ab4 173 void setColor(OLEDDISPLAY_COLOR color);
Helmut64 0:56dd5df33ab4 174
Helmut64 0:56dd5df33ab4 175 // Returns the current color.
Helmut64 0:56dd5df33ab4 176 OLEDDISPLAY_COLOR getColor();
Helmut64 0:56dd5df33ab4 177
Helmut64 0:56dd5df33ab4 178 // Draw a pixel at given position
Helmut64 0:56dd5df33ab4 179 void setPixel(int16_t x, int16_t y);
Helmut64 0:56dd5df33ab4 180
Helmut64 0:56dd5df33ab4 181 // Draw a line from position 0 to position 1
Helmut64 0:56dd5df33ab4 182 void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1);
Helmut64 0:56dd5df33ab4 183
Helmut64 0:56dd5df33ab4 184 // Draw the border of a rectangle at the given location
Helmut64 0:56dd5df33ab4 185 void drawRect(int16_t x, int16_t y, int16_t width, int16_t height);
Helmut64 0:56dd5df33ab4 186
Helmut64 0:56dd5df33ab4 187 // Fill the rectangle
Helmut64 0:56dd5df33ab4 188 void fillRect(int16_t x, int16_t y, int16_t width, int16_t height);
Helmut64 0:56dd5df33ab4 189
Helmut64 0:56dd5df33ab4 190 // Draw the border of a circle
Helmut64 0:56dd5df33ab4 191 void drawCircle(int16_t x, int16_t y, int16_t radius);
Helmut64 0:56dd5df33ab4 192
Helmut64 0:56dd5df33ab4 193 // Draw all Quadrants specified in the quads bit mask
Helmut64 0:56dd5df33ab4 194 void drawCircleQuads(int16_t x0, int16_t y0, int16_t radius, uint8_t quads);
Helmut64 0:56dd5df33ab4 195
Helmut64 0:56dd5df33ab4 196 // Fill circle
Helmut64 0:56dd5df33ab4 197 void fillCircle(int16_t x, int16_t y, int16_t radius);
Helmut64 0:56dd5df33ab4 198
Helmut64 0:56dd5df33ab4 199 // Draw a line horizontally
Helmut64 0:56dd5df33ab4 200 void drawHorizontalLine(int16_t x, int16_t y, int16_t length);
Helmut64 0:56dd5df33ab4 201
Helmut64 0:56dd5df33ab4 202 // Draw a line vertically
Helmut64 0:56dd5df33ab4 203 void drawVerticalLine(int16_t x, int16_t y, int16_t length);
Helmut64 0:56dd5df33ab4 204
Helmut64 0:56dd5df33ab4 205 // Draws a rounded progress bar with the outer dimensions given by width and height. Progress is
Helmut64 0:56dd5df33ab4 206 // a unsigned byte value between 0 and 100
Helmut64 0:56dd5df33ab4 207 void drawProgressBar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t progress);
Helmut64 0:56dd5df33ab4 208
Helmut64 0:56dd5df33ab4 209 // Draw a bitmap in the internal image format
Helmut64 0:56dd5df33ab4 210 void drawFastImage(int16_t x, int16_t y, int16_t width, int16_t height, const uint8_t *image);
Helmut64 0:56dd5df33ab4 211
Helmut64 0:56dd5df33ab4 212 // Draw a XBM
Helmut64 0:56dd5df33ab4 213 void drawXbm(int16_t x, int16_t y, int16_t width, int16_t height, const uint8_t *xbm);
Helmut64 0:56dd5df33ab4 214
Helmut64 0:56dd5df33ab4 215 /* Text functions */
Helmut64 0:56dd5df33ab4 216
Helmut64 0:56dd5df33ab4 217 // Draws a string at the given location
Helmut64 0:56dd5df33ab4 218 void drawString(int16_t x, int16_t y, String text);
Helmut64 0:56dd5df33ab4 219
Helmut64 0:56dd5df33ab4 220 // Draws a String with a maximum width at the given location.
Helmut64 0:56dd5df33ab4 221 // If the given String is wider than the specified width
Helmut64 0:56dd5df33ab4 222 // The text will be wrapped to the next line at a space or dash
Helmut64 0:56dd5df33ab4 223 void drawStringMaxWidth(int16_t x, int16_t y, uint16_t maxLineWidth, String text);
Helmut64 0:56dd5df33ab4 224
Helmut64 0:56dd5df33ab4 225 // Returns the width of the const char* with the current
Helmut64 0:56dd5df33ab4 226 // font settings
Helmut64 0:56dd5df33ab4 227 uint16_t getStringWidth(const char* text, uint16_t length);
Helmut64 0:56dd5df33ab4 228
Helmut64 0:56dd5df33ab4 229 // Convencience method for the const char version
Helmut64 0:56dd5df33ab4 230 uint16_t getStringWidth(String text);
Helmut64 0:56dd5df33ab4 231
Helmut64 0:56dd5df33ab4 232 // Specifies relative to which anchor point
Helmut64 0:56dd5df33ab4 233 // the text is rendered. Available constants:
Helmut64 0:56dd5df33ab4 234 // TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER_BOTH
Helmut64 0:56dd5df33ab4 235 void setTextAlignment(OLEDDISPLAY_TEXT_ALIGNMENT textAlignment);
Helmut64 0:56dd5df33ab4 236
Helmut64 0:56dd5df33ab4 237 // Sets the current font. Available default fonts
Helmut64 0:56dd5df33ab4 238 // ArialMT_Plain_10, ArialMT_Plain_16, ArialMT_Plain_24
Helmut64 0:56dd5df33ab4 239 void setFont(const uint8_t *fontData);
Helmut64 0:56dd5df33ab4 240
Helmut64 0:56dd5df33ab4 241 // Set the function that will convert utf-8 to font table index
Helmut64 0:56dd5df33ab4 242 void setFontTableLookupFunction(FontTableLookupFunction function);
Helmut64 0:56dd5df33ab4 243
Helmut64 0:56dd5df33ab4 244 /* Display functions */
Helmut64 0:56dd5df33ab4 245
Helmut64 0:56dd5df33ab4 246 // Turn the display on
Helmut64 0:56dd5df33ab4 247 void displayOn(void);
Helmut64 0:56dd5df33ab4 248
Helmut64 0:56dd5df33ab4 249 // Turn the display offs
Helmut64 0:56dd5df33ab4 250 void displayOff(void);
Helmut64 0:56dd5df33ab4 251
Helmut64 0:56dd5df33ab4 252 // Inverted display mode
Helmut64 0:56dd5df33ab4 253 void invertDisplay(void);
Helmut64 0:56dd5df33ab4 254
Helmut64 0:56dd5df33ab4 255 // Normal display mode
Helmut64 0:56dd5df33ab4 256 void normalDisplay(void);
Helmut64 0:56dd5df33ab4 257
Helmut64 0:56dd5df33ab4 258 // Set display contrast
Helmut64 0:56dd5df33ab4 259 // really low brightness & contrast: contrast = 10, precharge = 5, comdetect = 0
Helmut64 0:56dd5df33ab4 260 // normal brightness & contrast: contrast = 100
Helmut64 0:56dd5df33ab4 261 void setContrast(uint8_t contrast, uint8_t precharge = 241, uint8_t comdetect = 64);
Helmut64 0:56dd5df33ab4 262
Helmut64 0:56dd5df33ab4 263 // Convenience method to access
Helmut64 0:56dd5df33ab4 264 void setBrightness(uint8_t);
Helmut64 0:56dd5df33ab4 265
Helmut64 0:56dd5df33ab4 266 // Reset display rotation or mirroring
Helmut64 0:56dd5df33ab4 267 void resetOrientation();
Helmut64 0:56dd5df33ab4 268
Helmut64 0:56dd5df33ab4 269 // Turn the display upside down
Helmut64 0:56dd5df33ab4 270 void flipScreenVertically();
Helmut64 0:56dd5df33ab4 271
Helmut64 0:56dd5df33ab4 272 // Mirror the display (to be used in a mirror or as a projector)
Helmut64 0:56dd5df33ab4 273 void mirrorScreen();
Helmut64 0:56dd5df33ab4 274
Helmut64 0:56dd5df33ab4 275 // Write the buffer to the display memory
Helmut64 0:56dd5df33ab4 276 virtual void display(void) = 0;
Helmut64 0:56dd5df33ab4 277
Helmut64 0:56dd5df33ab4 278 // Clear the local pixel buffer
Helmut64 0:56dd5df33ab4 279 void clear(void);
Helmut64 0:56dd5df33ab4 280
Helmut64 0:56dd5df33ab4 281 // Log buffer implementation
Helmut64 0:56dd5df33ab4 282
Helmut64 0:56dd5df33ab4 283 // This will define the lines and characters you can
Helmut64 0:56dd5df33ab4 284 // print to the screen. When you exeed the buffer size (lines * chars)
Helmut64 0:56dd5df33ab4 285 // the output may be truncated due to the size constraint.
Helmut64 0:56dd5df33ab4 286 bool setLogBuffer(uint16_t lines, uint16_t chars);
Helmut64 0:56dd5df33ab4 287
Helmut64 0:56dd5df33ab4 288 // Draw the log buffer at position (x, y)
Helmut64 0:56dd5df33ab4 289 void drawLogBuffer(uint16_t x, uint16_t y);
Helmut64 0:56dd5df33ab4 290
Helmut64 0:56dd5df33ab4 291 // Get screen geometry
Helmut64 0:56dd5df33ab4 292 uint16_t getWidth(void);
Helmut64 0:56dd5df33ab4 293 uint16_t getHeight(void);
Helmut64 0:56dd5df33ab4 294
Helmut64 0:56dd5df33ab4 295 // Implement needed function to be compatible with Print class
Helmut64 0:56dd5df33ab4 296 size_t write(uint8_t c);
Helmut64 0:56dd5df33ab4 297 size_t write(const char* s);
Helmut64 0:56dd5df33ab4 298
Helmut64 0:56dd5df33ab4 299 // Implement needed function to be compatible with Stream class
Helmut64 0:56dd5df33ab4 300 #ifdef __MBED__
Helmut64 0:56dd5df33ab4 301 int _putc(int c);
Helmut64 0:56dd5df33ab4 302 int _getc() { return -1; };
Helmut64 0:56dd5df33ab4 303 #endif
Helmut64 0:56dd5df33ab4 304
Helmut64 0:56dd5df33ab4 305
Helmut64 0:56dd5df33ab4 306 uint8_t *buffer;
Helmut64 0:56dd5df33ab4 307
Helmut64 0:56dd5df33ab4 308 #ifdef OLEDDISPLAY_DOUBLE_BUFFER
Helmut64 0:56dd5df33ab4 309 uint8_t *buffer_back;
Helmut64 0:56dd5df33ab4 310 #endif
Helmut64 0:56dd5df33ab4 311
Helmut64 0:56dd5df33ab4 312 protected:
Helmut64 0:56dd5df33ab4 313
Helmut64 0:56dd5df33ab4 314 OLEDDISPLAY_GEOMETRY geometry;
Helmut64 0:56dd5df33ab4 315
Helmut64 0:56dd5df33ab4 316 uint16_t displayWidth;
Helmut64 0:56dd5df33ab4 317 uint16_t displayHeight;
Helmut64 0:56dd5df33ab4 318 uint16_t displayBufferSize;
Helmut64 0:56dd5df33ab4 319
Helmut64 0:56dd5df33ab4 320 // Set the correct height, width and buffer for the geometry
Helmut64 0:56dd5df33ab4 321 void setGeometry(OLEDDISPLAY_GEOMETRY g);
Helmut64 0:56dd5df33ab4 322
Helmut64 0:56dd5df33ab4 323 OLEDDISPLAY_TEXT_ALIGNMENT textAlignment;
Helmut64 0:56dd5df33ab4 324 OLEDDISPLAY_COLOR color;
Helmut64 0:56dd5df33ab4 325
Helmut64 0:56dd5df33ab4 326 const uint8_t *fontData;
Helmut64 0:56dd5df33ab4 327
Helmut64 0:56dd5df33ab4 328 // State values for logBuffer
Helmut64 0:56dd5df33ab4 329 uint16_t logBufferSize;
Helmut64 0:56dd5df33ab4 330 uint16_t logBufferFilled;
Helmut64 0:56dd5df33ab4 331 uint16_t logBufferLine;
Helmut64 0:56dd5df33ab4 332 uint16_t logBufferMaxLines;
Helmut64 0:56dd5df33ab4 333 char *logBuffer;
Helmut64 0:56dd5df33ab4 334
Helmut64 0:56dd5df33ab4 335
Helmut64 0:56dd5df33ab4 336 // the header size of the buffer used, e.g. for the SPI command header
Helmut64 0:56dd5df33ab4 337 virtual int getBufferOffset(void) = 0;
Helmut64 0:56dd5df33ab4 338
Helmut64 0:56dd5df33ab4 339 // Send a command to the display (low level function)
Helmut64 0:56dd5df33ab4 340 virtual void sendCommand(uint8_t com) {(void)com;};
Helmut64 0:56dd5df33ab4 341
Helmut64 0:56dd5df33ab4 342 // Connect to the display
Helmut64 0:56dd5df33ab4 343 virtual bool connect() { return false; };
Helmut64 0:56dd5df33ab4 344
Helmut64 0:56dd5df33ab4 345 // Send all the init commands
Helmut64 0:56dd5df33ab4 346 void sendInitCommands();
Helmut64 0:56dd5df33ab4 347
Helmut64 0:56dd5df33ab4 348 // converts utf8 characters to extended ascii
Helmut64 0:56dd5df33ab4 349 char* utf8ascii(String s);
Helmut64 0:56dd5df33ab4 350
Helmut64 0:56dd5df33ab4 351 void inline drawInternal(int16_t xMove, int16_t yMove, int16_t width, int16_t height, const uint8_t *data, uint16_t offset, uint16_t bytesInData) __attribute__((always_inline));
Helmut64 0:56dd5df33ab4 352
Helmut64 0:56dd5df33ab4 353 void drawStringInternal(int16_t xMove, int16_t yMove, char* text, uint16_t textLength, uint16_t textWidth);
Helmut64 0:56dd5df33ab4 354
Helmut64 0:56dd5df33ab4 355 FontTableLookupFunction fontTableLookupFunction;
Helmut64 0:56dd5df33ab4 356 };
Helmut64 0:56dd5df33ab4 357
Helmut64 0:56dd5df33ab4 358 #endif