Skip to content

Commit 36138a6

Browse files
Fix TFT rotation, color, mirroring and offset and update Adafruit_TFT example
1 parent 64d4e73 commit 36138a6

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

libraries/Fri3dBadge/examples/Adafruit_ST7789/graphicstest_st7789/graphicstest_st7789.ino

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,16 @@
3333
#include <SPI.h>
3434
#include <Fri3dBadge_Adafruit_ST7789.h>
3535

36-
Fri3dBadge_Adafruit_ST7789 tft = Fri3dBadge_Adafruit_ST7789();
36+
Fri3dBadge_Adafruit_ST7789 tft = Fri3dBadge_Adafruit_ST7789(); // Modified for Fri3dBadge_Adafruit_ST7789
3737

3838
float p = 3.1415926;
3939

4040
void setup(void) {
4141
Serial.begin(9600);
4242
Serial.print(F("Hello! ST77xx TFT Test"));
4343

44-
tft.init(); // Init ST7789 240x240
44+
tft.init(); // Modified for Fri3dBadge_Adafruit_ST7789
4545

46-
// SPI speed defaults to SPI_DEFAULT_FREQ defined in the library, you can override it here
47-
// Note that speed allowable depends on chip and quality of wiring, if you go too fast, you
48-
// may end up with a black screen some times, or all the time.
49-
//tft.setSPISpeed(40000000);
5046
Serial.println(F("Initialized"));
5147

5248
uint16_t time = millis();
@@ -58,7 +54,7 @@ void setup(void) {
5854

5955
// large block of text
6056
tft.fillScreen(ST77XX_BLACK);
61-
testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST77XX_WHITE);
57+
testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST77XX_WHITE);
6258
delay(1000);
6359

6460
// tft print function!

libraries/Fri3dBadge/src/Fri3dBadge_Adafruit_ST7789.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,14 @@ void Fri3dBadge_Adafruit_ST7789::init()
99
{
1010
// Call the parent class's begin method to initialize the display
1111
Adafruit_ST7789::init(X_LCD_WIDTH, X_LCD_HEIGHT);
12+
this->setSPISpeed(80000000);
13+
14+
this->sendCommand(ST77XX_INVOFF); // Fix Black vs white
15+
16+
Adafruit_ST7789::setColRowStart(0, 0); // Fix offset
17+
18+
this->setRotation(1); // Set initial rotation
19+
20+
uint8_t madctl = ST77XX_MADCTL_MV | ST77XX_MADCTL_BGR; // Fix Mirroring & Blue vs White
21+
this->sendCommand(ST77XX_MADCTL, &madctl, 1);
1222
}

libraries/Fri3dBadge/src/Fri3dBadge_Adafruit_ST7789.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
66
#include <SPI.h>
77

8+
#define ST77XX_MADCTL_BGR 0x08
9+
810
class Fri3dBadge_Adafruit_ST7789 : public Adafruit_ST7789 {
911
public:
1012
Fri3dBadge_Adafruit_ST7789();

0 commit comments

Comments
 (0)