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