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.h@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 | |
JojoS | 20:04822be0efcd | 5 | Adafruit invests time and resources providing this open source code, |
JojoS | 20:04822be0efcd | 6 | please support Adafruit and open-source hardware by purchasing |
JojoS | 20:04822be0efcd | 7 | products from Adafruit! |
JojoS | 20:04822be0efcd | 8 | |
JojoS | 20:04822be0efcd | 9 | Written by Limor Fried/Ladyada for Adafruit Industries. |
JojoS | 20:04822be0efcd | 10 | BSD license, check license.txt for more information |
JojoS | 20:04822be0efcd | 11 | All text above, and the splash screen must be included in any redistribution |
JojoS | 20:04822be0efcd | 12 | *********************************************************************/ |
JojoS | 20:04822be0efcd | 13 | |
JojoS | 20:04822be0efcd | 14 | /* |
JojoS | 20:04822be0efcd | 15 | * Modified by JojoS for use in mbed |
JojoS | 20:04822be0efcd | 16 | */ |
JojoS | 20:04822be0efcd | 17 | |
JojoS | 20:04822be0efcd | 18 | #ifndef _ADAFRUIT_UC1601S_H_ |
JojoS | 20:04822be0efcd | 19 | #define _ADAFRUIT_UC1601S_H_ |
JojoS | 20:04822be0efcd | 20 | |
JojoS | 20:04822be0efcd | 21 | #include "mbed.h" |
JojoS | 20:04822be0efcd | 22 | #include "Adafruit_GFX.h" |
JojoS | 20:04822be0efcd | 23 | |
JojoS | 20:04822be0efcd | 24 | #include <vector> |
JojoS | 20:04822be0efcd | 25 | #include <algorithm> |
JojoS | 20:04822be0efcd | 26 | |
JojoS | 20:04822be0efcd | 27 | /** The pure base class for the UC1601S display driver. |
JojoS | 20:04822be0efcd | 28 | * |
JojoS | 20:04822be0efcd | 29 | * You should derive from this for a new transport interface type, |
JojoS | 20:04822be0efcd | 30 | * such as the SPI and I2C drivers. |
JojoS | 20:04822be0efcd | 31 | */ |
JojoS | 20:04822be0efcd | 32 | |
JojoS | 20:04822be0efcd | 33 | #define LCD_SET_COLUMN_ADDR_LSB 0x00 |
JojoS | 20:04822be0efcd | 34 | #define LCD_SET_COLUMN_ADDR_MSB 0x10 |
JojoS | 20:04822be0efcd | 35 | #define LCD_SET_TEMP_COMP 0x24 |
JojoS | 20:04822be0efcd | 36 | #define LCD_SET_POWER_CTRL 0x28 |
JojoS | 20:04822be0efcd | 37 | #define LCD_SET_LINE_ADDR 0x40 |
JojoS | 20:04822be0efcd | 38 | #define LCD_SET_PAGE_ADDR 0xB0 |
JojoS | 20:04822be0efcd | 39 | #define LCD_SET_BIAS 0x81 |
JojoS | 20:04822be0efcd | 40 | #define LCD_SET_BIAS_RATIO 0xE8 |
JojoS | 20:04822be0efcd | 41 | #define LCD_SET_PARTITIAL_CTRL 0x84 |
JojoS | 20:04822be0efcd | 42 | #define LCD_ENABLE_DISPLAY 0xAE |
JojoS | 20:04822be0efcd | 43 | #define LCD_ENABLE_ALL 0xA5 |
JojoS | 20:04822be0efcd | 44 | #define LCD_INVERT_DISPLAY 0xA6 |
JojoS | 20:04822be0efcd | 45 | #define LCD_SYSTEM_RESET 0xE2 |
JojoS | 20:04822be0efcd | 46 | #define LCD_SET_RAM_ADDRESS_CTRL 0x88 |
JojoS | 20:04822be0efcd | 47 | #define LCD_SET_FRAME_RATE 0xA0 |
JojoS | 20:04822be0efcd | 48 | #define LCD_SET_MAPPING_CTRL 0xC0 |
JojoS | 20:04822be0efcd | 49 | #define LCD_SET_COM_END 0xF1 |
JojoS | 20:04822be0efcd | 50 | |
JojoS | 20:04822be0efcd | 51 | |
JojoS | 20:04822be0efcd | 52 | class Adafruit_UC1601S : public Adafruit_GFX |
JojoS | 20:04822be0efcd | 53 | { |
JojoS | 20:04822be0efcd | 54 | public: |
JojoS | 20:04822be0efcd | 55 | Adafruit_UC1601S(PinName reset, uint8_t rawHeight = 22, uint8_t rawWidth = 132, bool flipVertical=false); |
JojoS | 20:04822be0efcd | 56 | |
JojoS | 20:04822be0efcd | 57 | // start sequence |
JojoS | 20:04822be0efcd | 58 | void begin(); |
JojoS | 20:04822be0efcd | 59 | |
JojoS | 20:04822be0efcd | 60 | // These must be implemented in the derived transport driver |
JojoS | 20:04822be0efcd | 61 | virtual void command(uint8_t c) = 0; |
JojoS | 20:04822be0efcd | 62 | virtual void data(const uint8_t *c, int count) = 0; |
JojoS | 20:04822be0efcd | 63 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color); |
JojoS | 20:04822be0efcd | 64 | |
JojoS | 20:04822be0efcd | 65 | /// Clear the display buffer |
JojoS | 20:04822be0efcd | 66 | void clearDisplay(void); |
JojoS | 20:04822be0efcd | 67 | virtual void invertDisplay(bool i); |
JojoS | 20:04822be0efcd | 68 | void flipVertical(bool flip); |
JojoS | 20:04822be0efcd | 69 | |
JojoS | 20:04822be0efcd | 70 | /// Cause the display to be updated with the buffer content. |
JojoS | 20:04822be0efcd | 71 | void display(); |
JojoS | 20:04822be0efcd | 72 | /// Fill the buffer with the AdaFruit splash screen. |
JojoS | 20:04822be0efcd | 73 | virtual void splash(); |
JojoS | 20:04822be0efcd | 74 | |
JojoS | 20:04822be0efcd | 75 | protected: |
JojoS | 20:04822be0efcd | 76 | virtual void sendDisplayBuffer() = 0; |
JojoS | 20:04822be0efcd | 77 | DigitalOut _reset; |
JojoS | 20:04822be0efcd | 78 | bool _flipVertical; |
JojoS | 20:04822be0efcd | 79 | |
JojoS | 20:04822be0efcd | 80 | // the memory buffer for the LCD |
JojoS | 20:04822be0efcd | 81 | std::vector<uint8_t> buffer; |
JojoS | 20:04822be0efcd | 82 | }; |
JojoS | 20:04822be0efcd | 83 | |
JojoS | 20:04822be0efcd | 84 | |
JojoS | 20:04822be0efcd | 85 | |
JojoS | 20:04822be0efcd | 86 | /** This is the I2C UC1601S display driver transport class |
JojoS | 20:04822be0efcd | 87 | * |
JojoS | 20:04822be0efcd | 88 | */ |
JojoS | 20:04822be0efcd | 89 | |
JojoS | 20:04822be0efcd | 90 | #define I2C_ADDRESS_CMD (0x38 << 1) |
JojoS | 20:04822be0efcd | 91 | #define I2C_ADDRESS_DATA (0x39 << 1) |
JojoS | 20:04822be0efcd | 92 | |
JojoS | 20:04822be0efcd | 93 | class Adafruit_UC1601S_I2c : public Adafruit_UC1601S |
JojoS | 20:04822be0efcd | 94 | { |
JojoS | 20:04822be0efcd | 95 | public: |
JojoS | 20:04822be0efcd | 96 | /** Create a SSD1306 I2C transport display driver instance with the specified RST pin name, the I2C address, as well as the display dimensions |
JojoS | 20:04822be0efcd | 97 | * |
JojoS | 20:04822be0efcd | 98 | * Required parameters |
JojoS | 20:04822be0efcd | 99 | * @param i2c - A reference to an initialized I2C object |
JojoS | 20:04822be0efcd | 100 | * @param RST - The Reset pin name |
JojoS | 20:04822be0efcd | 101 | * |
JojoS | 20:04822be0efcd | 102 | * Optional parameters |
JojoS | 20:04822be0efcd | 103 | * @param i2cAddress - The i2c address of the display |
JojoS | 20:04822be0efcd | 104 | * @param rawHeight - The vertical number of pixels for the display, defaults to 22 |
JojoS | 20:04822be0efcd | 105 | * @param rawWidth - The horizonal number of pixels for the display, defaults to 128 |
JojoS | 20:04822be0efcd | 106 | */ |
JojoS | 20:04822be0efcd | 107 | Adafruit_UC1601S_I2c(I2C &i2c, PinName reset, uint8_t i2cAddress = I2C_ADDRESS_CMD, uint8_t rawHeight = 22, uint8_t rawWidth = 132, bool flipVertical = false); |
JojoS | 20:04822be0efcd | 108 | |
JojoS | 20:04822be0efcd | 109 | virtual void command(uint8_t c); |
JojoS | 20:04822be0efcd | 110 | virtual void data(const uint8_t *c, int count); |
JojoS | 20:04822be0efcd | 111 | |
JojoS | 20:04822be0efcd | 112 | protected: |
JojoS | 20:04822be0efcd | 113 | virtual void sendDisplayBuffer(); |
JojoS | 20:04822be0efcd | 114 | I2C &mi2c; |
JojoS | 20:04822be0efcd | 115 | uint8_t mi2cAddress; |
JojoS | 20:04822be0efcd | 116 | }; |
JojoS | 20:04822be0efcd | 117 | |
JojoS | 20:04822be0efcd | 118 | #endif |