Skip to content

Commit 5c051dc

Browse files
authored
Merge pull request #1 from kreier/bodmer
implemented issue 493 solution
2 parents dcc770c + bc23b9e commit 5c051dc

File tree

4 files changed

+28
-37
lines changed

4 files changed

+28
-37
lines changed

arduino/TFT_Matrix/TFT_Matrix.ino

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// then scroll smoothly
44

55
// Needs GLCD font
6+
// adapted for 135x240 screen from TTGO T-Display
7+
8+
// Here https://github.com/Bodmer/TFT_eSPI/issues/493 the comment ghostoy solved the problem
69

710
/*
811
Make sure all the display driver and pin comnenctions are correct by
@@ -19,12 +22,12 @@
1922
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
2023

2124
#define TEXT_HEIGHT 8 // Height of text to be printed and scrolled
22-
#define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
23-
#define TOP_FIXED_AREA 0 // Number of lines in top fixed area (lines counted from top of screen)
25+
#define BOT_FIXED_AREA 40 // Number of lines in bottom fixed area (lines counted from bottom of screen)
26+
#define TOP_FIXED_AREA 40 // Number of lines in top fixed area (lines counted from top of screen)
2427

2528
uint16_t yStart = TOP_FIXED_AREA;
26-
uint16_t yArea = 240 - TOP_FIXED_AREA - BOT_FIXED_AREA;
27-
uint16_t yDraw = 240 - BOT_FIXED_AREA - TEXT_HEIGHT;
29+
uint16_t yArea = 320 - TOP_FIXED_AREA - BOT_FIXED_AREA;
30+
uint16_t yDraw = 240 - TEXT_HEIGHT;
2831
byte pos[42];
2932
uint16_t xPos = 0;
3033

@@ -38,46 +41,36 @@ void setup() {
3841
}
3942

4043
void loop(void) {
41-
// First fill the screen with random streaks of characters
42-
for (int j = 0; j < 400; j += TEXT_HEIGHT) {
44+
// First fill the screen with random streaks of characters
45+
for (int j = 0; j < 600; j += TEXT_HEIGHT) {
4346
for (int i = 0; i < 40; i++) {
44-
// Rapid fade initially brightness values
45-
if (pos[i] > 20)
46-
pos[i] -= 3;
47-
// Slow fade later
48-
if (pos[i] > 0)
49-
pos[i] -= 1;
50-
// ~1 in 20 probability of a new character
51-
if ((random(20) == 1) && (j < 200))
52-
pos[i] = 63;
53-
// Set the green character brightness
54-
tft.setTextColor(pos[i] << 5, TFT_BLACK);
55-
// Draw white character
56-
if (pos[i] == 63)
57-
tft.setTextColor(TFT_WHITE, TFT_BLACK);
58-
// Draw the character
59-
xPos += tft.drawChar(random(32, 128), xPos, yDraw, 1);
47+
if (pos[i] > 20) pos[i] -= 3; // Rapid fade initially brightness values
48+
if (pos[i] > 0) pos[i] -= 1; // Slow fade later
49+
if ((random(20) == 1) && (j<400)) pos[i] = 63; // ~1 in 20 probability of a new character
50+
tft.setTextColor(pos[i] << 5, TFT_BLACK); // Set the green character brightness
51+
if (pos[i] == 63) tft.setTextColor(TFT_WHITE, TFT_BLACK); // Draw white character
52+
xPos += tft.drawChar(random(32, 128), xPos, yDraw, 1); // Draw the character
6053
}
61-
// Scroll, 14ms per pixel line
62-
yDraw = scroll_slow(TEXT_HEIGHT, 14);
54+
yDraw = scroll_slow(TEXT_HEIGHT, 14); // Scroll, 14ms per pixel line
6355
xPos = 0;
6456
}
6557

58+
//tft.setRotation(2);
59+
//tft.setTextColor(63 << 5, ILI9341_BLACK);
60+
//tft.drawCentreString("MATRIX",120,60,4);
61+
//tft.setRotation(0);
62+
6663
// Now scroll smoothly forever
67-
while (1) {
68-
yield();
69-
yDraw = scroll_slow(240, 5);
70-
} // Scroll 320 lines, 5ms per line
64+
while (1) {yield(); yDraw = scroll_slow(320,5); }// Scroll 320 lines, 5ms per line
7165

7266
}
7367

7468
void setupScrollArea(uint16_t TFA, uint16_t BFA) {
75-
// Vertical scroll definition
76-
tft.writecommand(ST7789_VSCRDEF);
69+
tft.writecommand(ST7789_VSCRDEF); // Vertical scroll definition
7770
tft.writedata(TFA >> 8);
7871
tft.writedata(TFA);
79-
tft.writedata((240 - TFA - BFA) >> 8);
80-
tft.writedata(240 - TFA - BFA);
72+
tft.writedata((320 - TFA - BFA) >> 8);
73+
tft.writedata(320 - TFA - BFA);
8174
tft.writedata(BFA >> 8);
8275
tft.writedata(BFA);
8376
}
@@ -86,17 +79,15 @@ int scroll_slow(int lines, int wait) {
8679
int yTemp = yStart;
8780
for (int i = 0; i < lines; i++) {
8881
yStart++;
89-
if (yStart == 240 - BOT_FIXED_AREA)
90-
yStart = TOP_FIXED_AREA;
82+
if (yStart == 320 - BOT_FIXED_AREA) yStart = TOP_FIXED_AREA;
9183
scrollAddress(yStart);
9284
delay(wait);
9385
}
94-
return yTemp;
86+
return yTemp - 40;
9587
}
9688

9789
void scrollAddress(uint16_t VSP) {
98-
// Vertical scrolling start address
99-
tft.writecommand(0x37); // ILI9341_VSCRSADD);
90+
tft.writecommand(0x37); // Vertical scrolling start address ILI9341_VSCRSADD
10091
tft.writedata(VSP >> 8);
10192
tft.writedata(VSP);
10293
}

docs/esptool.exe

3.33 MB
Binary file not shown.

docs/firmware.bin

1.44 MB
Binary file not shown.

docs/movies2020.png

-48.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)