A first port of the excellent Adafruit ST7735 library Also supports the S6D02A1 controller (Use 1k resistors in series on all logic lines).
Fork of Adafruit_ST7735 by
Modified version of the ST7735 library to support the Samsung S6D02A1 controller. These 1.8" 128x160 displays can be purchased dirt cheap (under $5 on eBay or aliexpress with free shipping).
You must also import the Adafruit_GFX library, as this library is dependent upon it.
I've used up to 20 MHz SPI with no problem. That is hardcoded in the library, and is currently set to 4 MHz (unmodified from the original library).
The library is exactly the same for S6D02A1 and ST7735 except for the initialization routines.
Use 1k resistors in series on all 5 logic lines as 3V3 is required (display is not damaged by 5V logic, but it will not work)
Constructor pin names that match the S6D02A1: Adafruit_ST7735(DIN, NC, CLK, CD, D/C, RST) ;
Source of initialization codes for the S6D02A1: https://github.com/zigwart/Adafruit_QDTech/blob/master/Adafruit_QDTech.cpp
Revision 3:6c3a23e87409, committed 2014-11-19
- Comitter:
- daneast
- Date:
- Wed Nov 19 05:10:57 2014 +0000
- Parent:
- 2:18ecda534e06
- Commit message:
- Add support for S6D02A1 controller.; Works fine with 20 MHz SPI.; Use 1k resistors in series on all logic lines.
Changed in this revision
Adafruit_ST7735.cpp | Show annotated file Show diff for this revision Revisions of this file |
Adafruit_ST7735.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 18ecda534e06 -r 6c3a23e87409 Adafruit_ST7735.cpp --- a/Adafruit_ST7735.cpp Mon Mar 03 22:13:53 2014 +0000 +++ b/Adafruit_ST7735.cpp Wed Nov 19 05:10:57 2014 +0000 @@ -187,6 +187,38 @@ 100 }; // 100 ms delay +static unsigned char Scmd[] = { // Initialization commands for S6D02A1 screens + 29, + 0xf0, 2, 0x5a, 0x5a, // Excommand2 + 0xfc, 2, 0x5a, 0x5a, // Excommand3 + 0x26, 1, 0x01, // Gamma set + 0xfa, 15, 0x02, 0x1f, 0x00, 0x10, 0x22, 0x30, 0x38, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3d, 0x02, 0x01, // Positive gamma control + 0xfb, 15, 0x21, 0x00, 0x02, 0x04, 0x07, 0x0a, 0x0b, 0x0c, 0x0c, 0x16, 0x1e, 0x30, 0x3f, 0x01, 0x02, // Negative gamma control + 0xfd, 11, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x01, 0x01, 0x00, 0x1f, 0x1f, // Analog parameter control + 0xf4, 15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, // Power control + 0xf5, 13, 0x00, 0x70, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x66, 0x06, // VCOM control + 0xf6, 11, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x01, 0x00, // Source control + 0xf2, 17, 0x00, 0x01, 0x03, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x08, 0x08, //Display control + 0xf8, 1, 0x11, // Gate control + 0xf7, 4, 0xc8, 0x20, 0x00, 0x00, // Interface control + 0xf3, 2, 0x00, 0x00, // Power sequence control + 0x11, DELAY, 50, // Wake + 0xf3, 2+DELAY, 0x00, 0x01, 50, // Power sequence control + 0xf3, 2+DELAY, 0x00, 0x03, 50, // Power sequence control + 0xf3, 2+DELAY, 0x00, 0x07, 50, // Power sequence control + 0xf3, 2+DELAY, 0x00, 0x0f, 50, // Power sequence control + 0xf4, 15+DELAY, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, 50, // Power control + 0xf3, 2+DELAY, 0x00, 0x1f, 50, // Power sequence control + 0xf3, 2+DELAY, 0x00, 0x7f, 50, // Power sequence control + 0xf3, 2+DELAY, 0x00, 0xff, 50, // Power sequence control + 0xfd, 11, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x00, 0x01, 0x00, 0x16, 0x16, // Analog parameter control + 0xf4, 15, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, // Power control + 0x36, 1, 0x08, // Memory access data control + 0x35, 1, 0x00, // Tearing effect line on + 0x3a, 1+DELAY, 0x05, 150, // Interface pixel control + 0x29, 0, // Display on + 0x2c, 0 // Memory write +}; // Companion code to the above tables. Reads and issues // a series of LCD commands stored in byte array. @@ -263,6 +295,11 @@ commandList(Rcmd3); } +// Initialization for ST7735B screens +void Adafruit_ST7735::initS(void) +{ + commonInit(Scmd); +} void Adafruit_ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)
diff -r 18ecda534e06 -r 6c3a23e87409 Adafruit_ST7735.h --- a/Adafruit_ST7735.h Mon Mar 03 22:13:53 2014 +0000 +++ b/Adafruit_ST7735.h Wed Nov 19 05:10:57 2014 +0000 @@ -96,6 +96,7 @@ void initB(void); // for ST7735B displays void initR(uint8_t options = INITR_GREENTAB); // for ST7735R + void initS(void); // for S6D02A1 displays void setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1); void pushColor(uint16_t color);