Skip to content

Commit

Permalink
add 1.47" display
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed Dec 17, 2021
1 parent 5a1f17d commit f210c85
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Adafruit_ST7789.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,20 @@ void Adafruit_ST7789::init(uint16_t width, uint16_t height, uint8_t mode) {

commonInit(NULL);

if (width < 240) {
// 1.14" display
_rowstart = _rowstart2 = (int)((320 - height + 1) / 2);
_colstart = (int)((240 - width + 1) / 2);
_colstart2 = (int)((240 - width) / 2);
if (width == 174 && height == 320) {
// 1.47" display
_rowstart = _rowstart2 = 0;
_colstart = _colstart2 = 34;
} else if (width == 240 && height == 280) {
// 1.69" display
_rowstart = 20;
_rowstart2 = 0;
_colstart = _colstart2 = 0;
} else if (width < 240) {
// 1.14" display
_rowstart = _rowstart2 = (int)((320 - height + 1) / 2);
_colstart = (int)((240 - width + 1) / 2);
_colstart2 = (int)((240 - width) / 2);
} else {
// 1.3", 1.54", and 2.0" displays
_rowstart = (320 - height);
Expand Down
3 changes: 3 additions & 0 deletions examples/graphicstest/graphicstest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ void setup(void) {
// OR use this initializer (uncomment) if using a 1.14" 240x135 TFT:
//tft.init(135, 240); // Init ST7789 240x135

// OR use this initializer (uncomment) if using a 1.47" 174x320 TFT:
//tft.init(174, 320); // Init ST7789 174x320

// SPI speed defaults to SPI_DEFAULT_FREQ defined in the library, you can override it here
// Note that speed allowable depends on chip and quality of wiring, if you go too fast, you
// may end up with a black screen some times, or all the time.
Expand Down
3 changes: 3 additions & 0 deletions examples/rotationtest/rotationtest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ void setup(void) {
// OR use this initializer (uncomment) if using a 1.14" 240x135 TFT:
//tft.init(135, 240); // Init ST7789 240x135

// OR use this initializer (uncomment) if using a 1.47" 174x320 TFT:
tft.init(174, 320); // Init ST7789 174x320

// SPI speed defaults to SPI_DEFAULT_FREQ defined in the library, you can override it here
// Note that speed allowable depends on chip and quality of wiring, if you go too fast, you
// may end up with a black screen some times, or all the time.
Expand Down

0 comments on commit f210c85

Please sign in to comment.