Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always scroll #2

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@

# Created by https://www.gitignore.io/api/platformio,visualstudiocode
# Edit at https://www.gitignore.io/?templates=platformio,visualstudiocode
# Created by https://www.gitignore.io/api/platformio,visualstudiocode,c++
# Edit at https://www.gitignore.io/?templates=platformio,visualstudiocode,c++

### C++ ###
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

### PlatformIO ###
.pio
Expand All @@ -10,7 +44,7 @@

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
#!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
Expand All @@ -19,4 +53,5 @@
# Ignore all local history of files
.history

# End of https://www.gitignore.io/api/platformio,visualstudiocode
# End of https://www.gitignore.io/api/platformio,visualstudiocode,c++

6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

24 changes: 17 additions & 7 deletions src/LedMatrixHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const uint8_t *iaActiveFont = ActiveFontInfo->Bitmap;
const FONT_CHAR_INFO *ActiveFontCharInfo = ActiveFontInfo->Descriptors;

String strCurMsg = "";
bool bMsgScrolling = false;
unsigned long ulLastScrollStep = 0;
unsigned long ulScrollStepInterval = 800;
uint iScrollCurrentFirstChar = 0;
Expand All @@ -40,7 +39,7 @@ void MatrixDisplayLoop()

void HandleScrollingText()
{
if (!bMsgScrolling || millis() - ulLastScrollStep < ulScrollStepInterval)
if (millis() - ulLastScrollStep < ulScrollStepInterval)
{
return;
}
Expand Down Expand Up @@ -161,13 +160,9 @@ void UpdateMessage(String strMsg)
{
matrix.clear();
ESP_LOGD(TAG, "Updating display: %s", strMsg.c_str());
strCurMsg = PadMessageString(strMsg);
String strTempMsg = TruncateStringForDisplay(strMsg);
strCurMsg = strMsg;
DrawASCII(strTempMsg);
if (strCurMsg.length() != strTempMsg.length())
{
bMsgScrolling = true;
}
}

String TruncateStringForDisplay(String strInput)
Expand Down Expand Up @@ -201,6 +196,21 @@ String TruncateStringForDisplay(String strInput)
return strOutput;
}

String PadMessageString(String input)
{
String strOutput = "";
for (int i = 0; i < LED_MATRIX_WIDTH - iDigitPos; i++)
{
strOutput += " ";
}
strOutput += input;
for (int i = 0; i < LED_MATRIX_WIDTH - iDigitPos; i++)
{
strOutput += " ";
}
return strOutput;
}

void SetScrollInterval(unsigned long interval)
{
ulScrollStepInterval = interval;
Expand Down