Replies: 3 comments
-
I see scrolling in the video. Isn't it what you expecting? Please be a more specific describing the problem |
Beta Was this translation helpful? Give feedback.
0 replies
-
There is no scrolling in the following lines |
Beta Was this translation helpful? Give feedback.
0 replies
-
Let me continue working. I am sure I will find my mistake. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Scrolling works with the internal font.
But I couldn't scroll with the user font.
I also write fixed text in the user font.
Where am I making a mistake in scrolling with the user font?
Can you help me?
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
const int panelResX = 128; // Number of pixels wide of each INDIVIDUAL panel module.
const int panelResY = 64; // Number of pixels tall of each INDIVIDUAL panel module.
const int panel_chain = 1; // Total number of panels chained one to another
#define ENABLE_DOUBLE_BUFFER 1
MatrixPanel_I2S_DMA *dma_display = nullptr;
#include "FreeMono9pt7b.h"
//====================== Variables For scrolling Text==================================
unsigned long isAnimationDue;
int textXPosition = 128;
int textYPosition = panelResY / 2 - 7; // center of screen - 8 (half of the text height)
int currentScrollCount = 0; // To track the number of times the text has scrolled
//====================== Variables For scrolling Text==================================
uint16_t myBLACK = dma_display->color565(0, 0, 0);
uint16_t myWHITE = dma_display->color565(255, 255, 255);
uint16_t myRED = dma_display->color565(255, 0, 0);
uint16_t myGREEN = dma_display->color565(0, 255, 0);
uint16_t myBLUE = dma_display->color565(0, 0, 255);
uint16_t myYELLOW = dma_display->color565(255, 255, 0);
uint16_t myMAGENTA = dma_display->color565(255, 0, 255);
uint16_t myCYAN = dma_display->color565(0, 255, 255);
// Pointers to this variable will be passed into getTextBounds,
// they will be updated from inside the method
int16_t xOne, yOne;
uint16_t w, h;
uint8_t wheelval = 0;
String text1, text2;
void displaySetup() {
HUB75_I2S_CFG mxconfig(
panelResX, // module width
panelResY, // module height
panel_chain // Chain length
);
mxconfig.gpio.e = 0;
#ifdef ENABLE_DOUBLE_BUFFER
mxconfig.double_buff = true;
#endif
mxconfig.clkphase = false;
dma_display = new MatrixPanel_I2S_DMA(mxconfig);
dma_display->begin();
dma_display->setBrightness8(50); dma_display->setRotation(2);
dma_display->setTextWrap(false);
dma_display->clearScreen();
}
void scrollText(String text, int xPos, int yPos, int scrollSpeed, int scrollCount) {
unsigned long now = millis();
if (now > isAnimationDue && currentScrollCount < scrollCount)
{
isAnimationDue = now + scrollSpeed;
textXPosition -= 1;
dma_display->getTextBounds(text, textXPosition, yPos, &xOne, &yOne, &w, &h);
if (textXPosition + w <= 0) {textXPosition = xPos;currentScrollCount++; }
dma_display->fillRect(0, yPos - 1, panelResX, h + 2, myBLUE); //myBLACK
dma_display->setTextColor(myRED);
dma_display->setCursor(textXPosition, yPos);
dma_display->print(text);
dma_display->flipDMABuffer();
}
}
void setup() {
Serial.begin(115200);
displaySetup();
text1 = "1.Hello.";
text2 = "2.Hello..";
}
void loop() {
dma_display->fillRect(0, 0, panelResX, 15, myBLACK);
dma_display->setFont(&FreeMono9pt7b);
dma_display->setTextSize(1); dma_display->setTextColor(myGREEN);
dma_display->setCursor(5, 10); dma_display->print(text1);
dma_display->setFont();dma_display->setTextSize(1);
scrollText(text2, 128, 15, 5, 3); // X = 128, Y = 20, scrolling = 5, count=3
dma_display->setFont(&FreeMono9pt7b);dma_display->setTextSize(1);
scrollText(text2, 128, 30, 5, 3); // X = 128, Y = 20, scrolling = 5, count=3
delay(20);
}
Scrolling_video.mp4
Beta Was this translation helpful? Give feedback.
All reactions