i2c version has an offset due to wrong copy of temp buffer to display buffer, fixed in Adafruit_SSD1306.h
Dependents: ezSBC_MPU9250 Test_OLED_Display untodoenuno OledI2CDisplay ... more
Fork of Adafruit_GFX by
Adafruit_UC1601S.cpp@20:04822be0efcd, 2017-07-24 (annotated)
- Committer:
- JojoS
- Date:
- Mon Jul 24 11:09:33 2017 +0000
- Revision:
- 20:04822be0efcd
Added driver for UC1601S;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JojoS | 20:04822be0efcd | 1 | /********************************************************************* |
JojoS | 20:04822be0efcd | 2 | This is a library for our Monochrome OLEDs based on SSD1306 drivers |
JojoS | 20:04822be0efcd | 3 | |
JojoS | 20:04822be0efcd | 4 | Pick one up today in the adafruit shop! |
JojoS | 20:04822be0efcd | 5 | ------> http://www.adafruit.com/category/63_98 |
JojoS | 20:04822be0efcd | 6 | |
JojoS | 20:04822be0efcd | 7 | These displays use SPI to communicate, 4 or 5 pins are required to |
JojoS | 20:04822be0efcd | 8 | interface |
JojoS | 20:04822be0efcd | 9 | |
JojoS | 20:04822be0efcd | 10 | Adafruit invests time and resources providing this open source code, |
JojoS | 20:04822be0efcd | 11 | please support Adafruit and open-source hardware by purchasing |
JojoS | 20:04822be0efcd | 12 | products from Adafruit! |
JojoS | 20:04822be0efcd | 13 | |
JojoS | 20:04822be0efcd | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. |
JojoS | 20:04822be0efcd | 15 | BSD license, check license.txt for more information |
JojoS | 20:04822be0efcd | 16 | All text above, and the splash screen below must be included in any redistribution |
JojoS | 20:04822be0efcd | 17 | *********************************************************************/ |
JojoS | 20:04822be0efcd | 18 | |
JojoS | 20:04822be0efcd | 19 | /* |
JojoS | 20:04822be0efcd | 20 | * Modified by JojoS 03/07/2015 |
JojoS | 20:04822be0efcd | 21 | * add flipVertical option to constructor |
JojoS | 20:04822be0efcd | 22 | * add use of 'rst' is optional, maybe NC in constructor |
JojoS | 20:04822be0efcd | 23 | * add command SSD1306_SETPAGESTARTADDRESS to reset page start address (important when no hardware reset is uesed) |
JojoS | 20:04822be0efcd | 24 | */ |
JojoS | 20:04822be0efcd | 25 | |
JojoS | 20:04822be0efcd | 26 | #include "mbed.h" |
JojoS | 20:04822be0efcd | 27 | #include "Adafruit_UC1601S.h" |
JojoS | 20:04822be0efcd | 28 | |
JojoS | 20:04822be0efcd | 29 | Adafruit_UC1601S::Adafruit_UC1601S(PinName reset, uint8_t rawHeight, uint8_t rawWidth, bool flipVertical) |
JojoS | 20:04822be0efcd | 30 | : Adafruit_GFX(rawWidth, rawHeight) |
JojoS | 20:04822be0efcd | 31 | , _reset(reset, false) |
JojoS | 20:04822be0efcd | 32 | , _flipVertical(flipVertical) |
JojoS | 20:04822be0efcd | 33 | { |
JojoS | 20:04822be0efcd | 34 | // display memory is organized in 1 byte = 8 columns |
JojoS | 20:04822be0efcd | 35 | int heightBytes = rawHeight / 8; |
JojoS | 20:04822be0efcd | 36 | if (rawHeight % 8) // correction if height is not byte aligned |
JojoS | 20:04822be0efcd | 37 | heightBytes++; |
JojoS | 20:04822be0efcd | 38 | buffer.resize(rawWidth * heightBytes); |
JojoS | 20:04822be0efcd | 39 | } |
JojoS | 20:04822be0efcd | 40 | |
JojoS | 20:04822be0efcd | 41 | void Adafruit_UC1601S::begin() { |
JojoS | 20:04822be0efcd | 42 | if (_reset.is_connected()) {// reset input is not present on every UC1601S display board, so usage is optional |
JojoS | 20:04822be0efcd | 43 | _reset = 1; |
JojoS | 20:04822be0efcd | 44 | // VDD (3.3V) goes high at start, lets just chill for a ms |
JojoS | 20:04822be0efcd | 45 | wait_ms(1); |
JojoS | 20:04822be0efcd | 46 | // bring reset low |
JojoS | 20:04822be0efcd | 47 | _reset = 0; |
JojoS | 20:04822be0efcd | 48 | // wait 10ms |
JojoS | 20:04822be0efcd | 49 | wait_ms(10); |
JojoS | 20:04822be0efcd | 50 | // bring out of reset |
JojoS | 20:04822be0efcd | 51 | _reset = 1; |
JojoS | 20:04822be0efcd | 52 | // turn on VCC (9V?) |
JojoS | 20:04822be0efcd | 53 | } |
JojoS | 20:04822be0efcd | 54 | |
JojoS | 20:04822be0efcd | 55 | command(LCD_SET_TEMP_COMP | 0b00); // Set Temperature Comp. TC[1:0] |
JojoS | 20:04822be0efcd | 56 | command(LCD_SET_POWER_CTRL | 0b110); // Set Power Control PC[2:0] |
JojoS | 20:04822be0efcd | 57 | command(LCD_SET_LINE_ADDR | 0); // Set Scroll Line SL[5:0] |
JojoS | 20:04822be0efcd | 58 | command(LCD_SET_BIAS); // Set VBIAS Potentiometer (Double byte command) |
JojoS | 20:04822be0efcd | 59 | command(0xC0); // BIAS value |
JojoS | 20:04822be0efcd | 60 | command(LCD_SET_PARTITIAL_CTRL | 0); |
JojoS | 20:04822be0efcd | 61 | command(LCD_SET_RAM_ADDRESS_CTRL | 0b001); // |
JojoS | 20:04822be0efcd | 62 | command(LCD_SET_FRAME_RATE | 0); // Framerate 0: 80 fps 1: 100 fps |
JojoS | 20:04822be0efcd | 63 | command(LCD_SET_MAPPING_CTRL | (_flipVertical ? 0b000 : 0b100));// flip vertical / horizontal |
JojoS | 20:04822be0efcd | 64 | command(LCD_SET_BIAS_RATIO | 0); // 0: 6 1: 7 2: 8 3: 9 |
JojoS | 20:04822be0efcd | 65 | command(LCD_SET_COM_END); |
JojoS | 20:04822be0efcd | 66 | command(21); // Rows - 1 |
JojoS | 20:04822be0efcd | 67 | command(LCD_ENABLE_DISPLAY | 1); // enable display) |
JojoS | 20:04822be0efcd | 68 | } |
JojoS | 20:04822be0efcd | 69 | |
JojoS | 20:04822be0efcd | 70 | // Set a single pixel |
JojoS | 20:04822be0efcd | 71 | void Adafruit_UC1601S::drawPixel(int16_t x, int16_t y, uint16_t color) { |
JojoS | 20:04822be0efcd | 72 | if ((x < 0) || (x >= width()) || (y < 0) || (y >= height())) |
JojoS | 20:04822be0efcd | 73 | return; |
JojoS | 20:04822be0efcd | 74 | |
JojoS | 20:04822be0efcd | 75 | // check rotation, move pixel around if necessary |
JojoS | 20:04822be0efcd | 76 | switch (getRotation()) { |
JojoS | 20:04822be0efcd | 77 | case 1: |
JojoS | 20:04822be0efcd | 78 | swap(x, y); |
JojoS | 20:04822be0efcd | 79 | x = _rawWidth - x - 1; |
JojoS | 20:04822be0efcd | 80 | break; |
JojoS | 20:04822be0efcd | 81 | case 2: |
JojoS | 20:04822be0efcd | 82 | x = _rawWidth - x - 1; |
JojoS | 20:04822be0efcd | 83 | y = _rawHeight - y - 1; |
JojoS | 20:04822be0efcd | 84 | break; |
JojoS | 20:04822be0efcd | 85 | case 3: |
JojoS | 20:04822be0efcd | 86 | swap(x, y); |
JojoS | 20:04822be0efcd | 87 | y = _rawHeight - y - 1; |
JojoS | 20:04822be0efcd | 88 | break; |
JojoS | 20:04822be0efcd | 89 | } |
JojoS | 20:04822be0efcd | 90 | |
JojoS | 20:04822be0efcd | 91 | // x is which column |
JojoS | 20:04822be0efcd | 92 | if (color == WHITE) |
JojoS | 20:04822be0efcd | 93 | buffer[x + (y / 8) * _rawWidth] |= _BV((y % 8)); |
JojoS | 20:04822be0efcd | 94 | else |
JojoS | 20:04822be0efcd | 95 | // else black |
JojoS | 20:04822be0efcd | 96 | buffer[x + (y / 8) * _rawWidth] &= ~_BV((y % 8)); |
JojoS | 20:04822be0efcd | 97 | } |
JojoS | 20:04822be0efcd | 98 | |
JojoS | 20:04822be0efcd | 99 | void Adafruit_UC1601S::invertDisplay(bool i) { |
JojoS | 20:04822be0efcd | 100 | command(i ? LCD_INVERT_DISPLAY | 1 : LCD_INVERT_DISPLAY); |
JojoS | 20:04822be0efcd | 101 | } |
JojoS | 20:04822be0efcd | 102 | |
JojoS | 20:04822be0efcd | 103 | void Adafruit_UC1601S::flipVertical(bool flip) { |
JojoS | 20:04822be0efcd | 104 | _flipVertical = flip; |
JojoS | 20:04822be0efcd | 105 | if (flip) { |
JojoS | 20:04822be0efcd | 106 | command(LCD_SET_MAPPING_CTRL | 0b000);// flip vertical / horizontal |
JojoS | 20:04822be0efcd | 107 | command(LCD_SET_RAM_ADDRESS_CTRL | 0b101); // |
JojoS | 20:04822be0efcd | 108 | command(LCD_SET_COM_END); |
JojoS | 20:04822be0efcd | 109 | command(21); // Rows - 1 |
JojoS | 20:04822be0efcd | 110 | } else { |
JojoS | 20:04822be0efcd | 111 | command(LCD_SET_MAPPING_CTRL | 0b100);// flip vertical / horizontal |
JojoS | 20:04822be0efcd | 112 | command(LCD_SET_RAM_ADDRESS_CTRL | 0b001); // |
JojoS | 20:04822be0efcd | 113 | command(LCD_SET_COM_END); |
JojoS | 20:04822be0efcd | 114 | command(21); // Rows - 1 |
JojoS | 20:04822be0efcd | 115 | } |
JojoS | 20:04822be0efcd | 116 | } |
JojoS | 20:04822be0efcd | 117 | |
JojoS | 20:04822be0efcd | 118 | // Send the display buffer out to the display |
JojoS | 20:04822be0efcd | 119 | void Adafruit_UC1601S::display(void) { |
JojoS | 20:04822be0efcd | 120 | sendDisplayBuffer(); |
JojoS | 20:04822be0efcd | 121 | } |
JojoS | 20:04822be0efcd | 122 | |
JojoS | 20:04822be0efcd | 123 | // Clear the display buffer. Requires a display() call at some point afterwards |
JojoS | 20:04822be0efcd | 124 | void Adafruit_UC1601S::clearDisplay(void) { |
JojoS | 20:04822be0efcd | 125 | std::fill(buffer.begin(), buffer.end(), 0); |
JojoS | 20:04822be0efcd | 126 | } |
JojoS | 20:04822be0efcd | 127 | |
JojoS | 20:04822be0efcd | 128 | void Adafruit_UC1601S::splash(void) { |
JojoS | 20:04822be0efcd | 129 | #ifndef NO_SPLASH_ADAFRUIT |
JojoS | 20:04822be0efcd | 130 | const uint8_t adaFruitLogo[64 * 128 / 8] = { |
JojoS | 20:04822be0efcd | 131 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 132 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 133 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 134 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
JojoS | 20:04822be0efcd | 135 | 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 136 | 0x00, 0x80, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 137 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 138 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 139 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 140 | 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 141 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, |
JojoS | 20:04822be0efcd | 142 | 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0xFF, |
JojoS | 20:04822be0efcd | 143 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 144 | 0x80, 0xFF, 0xFF, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, |
JojoS | 20:04822be0efcd | 145 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x8C, 0x8E, 0x84, 0x00, 0x00, 0x80, 0xF8, |
JojoS | 20:04822be0efcd | 146 | 0xF8, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 147 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, |
JojoS | 20:04822be0efcd | 148 | 0x00, 0xE0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 149 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xC7, 0x01, 0x01, |
JojoS | 20:04822be0efcd | 150 | 0x01, 0x01, 0x83, 0xFF, 0xFF, 0x00, 0x00, 0x7C, 0xFE, 0xC7, 0x01, 0x01, 0x01, 0x01, 0x83, 0xFF, |
JojoS | 20:04822be0efcd | 151 | 0xFF, 0xFF, 0x00, 0x38, 0xFE, 0xC7, 0x83, 0x01, 0x01, 0x01, 0x83, 0xC7, 0xFF, 0xFF, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 152 | 0x01, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0xFF, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x7F, 0xFF, |
JojoS | 20:04822be0efcd | 153 | 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF, |
JojoS | 20:04822be0efcd | 154 | 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 155 | 0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC7, 0xC7, 0x8F, |
JojoS | 20:04822be0efcd | 156 | 0x8F, 0x9F, 0xBF, 0xFF, 0xFF, 0xC3, 0xC0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFC, |
JojoS | 20:04822be0efcd | 157 | 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x01, 0x03, 0x03, 0x03, |
JojoS | 20:04822be0efcd | 158 | 0x03, 0x03, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, |
JojoS | 20:04822be0efcd | 159 | 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 160 | 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, |
JojoS | 20:04822be0efcd | 161 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x03, |
JojoS | 20:04822be0efcd | 162 | 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 163 | // 128x32^^^ 128x64vvv |
JojoS | 20:04822be0efcd | 164 | 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F, |
JojoS | 20:04822be0efcd | 165 | 0x87, 0xC7, 0xF7, 0xFF, 0xFF, 0x1F, 0x1F, 0x3D, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0x7C, 0x7D, 0xFF, |
JojoS | 20:04822be0efcd | 166 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x00, 0x30, 0x30, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 167 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 168 | 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 169 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xC0, 0x00, |
JojoS | 20:04822be0efcd | 170 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 171 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 172 | 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, |
JojoS | 20:04822be0efcd | 173 | 0x0F, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, |
JojoS | 20:04822be0efcd | 174 | 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 175 | 0x00, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x0E, 0xFC, 0xF8, 0x00, 0x00, 0xF0, 0xF8, 0x1C, 0x0E, |
JojoS | 20:04822be0efcd | 176 | 0x06, 0x06, 0x06, 0x0C, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFC, |
JojoS | 20:04822be0efcd | 177 | 0xFE, 0xFC, 0x00, 0x18, 0x3C, 0x7E, 0x66, 0xE6, 0xCE, 0x84, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0x06, |
JojoS | 20:04822be0efcd | 178 | 0x06, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x06, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0xC0, 0xF8, |
JojoS | 20:04822be0efcd | 179 | 0xFC, 0x4E, 0x46, 0x46, 0x46, 0x4E, 0x7C, 0x78, 0x40, 0x18, 0x3C, 0x76, 0xE6, 0xCE, 0xCC, 0x80, |
JojoS | 20:04822be0efcd | 180 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 181 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x03, |
JojoS | 20:04822be0efcd | 182 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 183 | 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x07, 0x0E, 0x0C, |
JojoS | 20:04822be0efcd | 184 | 0x18, 0x18, 0x0C, 0x06, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x0F, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, |
JojoS | 20:04822be0efcd | 185 | 0x07, 0x01, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, |
JojoS | 20:04822be0efcd | 186 | 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x07, |
JojoS | 20:04822be0efcd | 187 | 0x07, 0x0C, 0x0C, 0x18, 0x1C, 0x0C, 0x06, 0x06, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07, |
JojoS | 20:04822be0efcd | 188 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 189 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 190 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 191 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 192 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 193 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 194 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
JojoS | 20:04822be0efcd | 195 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
JojoS | 20:04822be0efcd | 196 | }; |
JojoS | 20:04822be0efcd | 197 | |
JojoS | 20:04822be0efcd | 198 | std::copy( |
JojoS | 20:04822be0efcd | 199 | &adaFruitLogo[0] |
JojoS | 20:04822be0efcd | 200 | , &adaFruitLogo[0] + (_rawHeight == 32 ? sizeof(adaFruitLogo)/2 : sizeof(adaFruitLogo)) |
JojoS | 20:04822be0efcd | 201 | , buffer.begin() |
JojoS | 20:04822be0efcd | 202 | ); |
JojoS | 20:04822be0efcd | 203 | #endif |
JojoS | 20:04822be0efcd | 204 | } |
JojoS | 20:04822be0efcd | 205 | |
JojoS | 20:04822be0efcd | 206 | /* |
JojoS | 20:04822be0efcd | 207 | * |
JojoS | 20:04822be0efcd | 208 | * I2C specific implementation |
JojoS | 20:04822be0efcd | 209 | * |
JojoS | 20:04822be0efcd | 210 | */ |
JojoS | 20:04822be0efcd | 211 | |
JojoS | 20:04822be0efcd | 212 | Adafruit_UC1601S_I2c::Adafruit_UC1601S_I2c(I2C &i2c, PinName reset, |
JojoS | 20:04822be0efcd | 213 | uint8_t i2cAddress, uint8_t rawHeight, |
JojoS | 20:04822be0efcd | 214 | uint8_t rawWidth, bool flipVertical) : |
JojoS | 20:04822be0efcd | 215 | Adafruit_UC1601S(reset, rawHeight, rawWidth, flipVertical), mi2c(i2c), mi2cAddress( |
JojoS | 20:04822be0efcd | 216 | i2cAddress) { |
JojoS | 20:04822be0efcd | 217 | begin(); |
JojoS | 20:04822be0efcd | 218 | splash(); |
JojoS | 20:04822be0efcd | 219 | display(); |
JojoS | 20:04822be0efcd | 220 | } |
JojoS | 20:04822be0efcd | 221 | |
JojoS | 20:04822be0efcd | 222 | void Adafruit_UC1601S_I2c::sendDisplayBuffer() { |
JojoS | 20:04822be0efcd | 223 | command(LCD_SET_PAGE_ADDR | 0); |
JojoS | 20:04822be0efcd | 224 | command(LCD_SET_COLUMN_ADDR_LSB | 0); |
JojoS | 20:04822be0efcd | 225 | command(LCD_SET_COLUMN_ADDR_MSB | 0); |
JojoS | 20:04822be0efcd | 226 | |
JojoS | 20:04822be0efcd | 227 | data(&buffer[0], buffer.size()); |
JojoS | 20:04822be0efcd | 228 | } |
JojoS | 20:04822be0efcd | 229 | |
JojoS | 20:04822be0efcd | 230 | void Adafruit_UC1601S_I2c::command(uint8_t c) { |
JojoS | 20:04822be0efcd | 231 | mi2c.write(mi2cAddress, (const char*) &c, 1); |
JojoS | 20:04822be0efcd | 232 | } |
JojoS | 20:04822be0efcd | 233 | |
JojoS | 20:04822be0efcd | 234 | void Adafruit_UC1601S_I2c::data(const uint8_t *c, int count) { |
JojoS | 20:04822be0efcd | 235 | mi2c.write(mi2cAddress + 2, (const char*) c, count); |
JojoS | 20:04822be0efcd | 236 | } |
JojoS | 20:04822be0efcd | 237 |