Skip to content

Commit 364957b

Browse files
Cleaned up inline comments and formatting in multiple files
1 parent 42ff978 commit 364957b

19 files changed

+98
-201
lines changed

src/DisplayUI.cpp

Lines changed: 37 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void DisplayUI::drawAlbumArt(int32_t x, int32_t y, String filename)
360360

361361
Monitor::start(MONITOR_ID_SPOTIFY_IMAGE_FILE_LOAD, LOGTAG_METRICS, "drawFsJpg(...)");
362362
drawFsJpg(x, y, filename.c_str(), LittleFS);
363-
//drawFsJpg((_tft->width() - w) / 2, 10, filename.c_str(), LittleFS);
363+
364364
Monitor::stop(MONITOR_ID_SPOTIFY_IMAGE_FILE_LOAD);
365365

366366
}
@@ -509,10 +509,9 @@ void DisplayUI::drawButton(int32_t x, int32_t y, bool isPressed)
509509
void DisplayUI::drawBlankButton(int32_t x, int32_t y, int32_t width, int32_t height, uint8_t margin, TFTColor borderColor, bool isPressed)
510510
{
511511

512-
// const TFTColor borderColor = TFTColor::White;
513-
TFTColor bodyColor = getBackground();
514-
// Invert the color
515-
TFTColor pressColor = static_cast<TFTColor>(~static_cast<uint16_t>(bodyColor));
512+
TFTColor bodyColor = getBackground();
513+
// Invert the color
514+
TFTColor pressColor = static_cast<TFTColor>(~static_cast<uint16_t>(bodyColor));
516515

517516
if (xSemaphoreTake(xSemaphoreDisplay, portMAX_DELAY))
518517
{
@@ -547,11 +546,11 @@ void DisplayUI::drawSkipTrackIcon(int32_t x, int32_t y, int32_t width, int32_t h
547546
if (xSemaphoreTake(xSemaphoreDisplay, portMAX_DELAY))
548547
{
549548
// Define basic geometry
550-
const int32_t centerX = x + width / 2;
551-
const int32_t centerY = y + height / 2;
552-
const int32_t triangleSize = 20;
553-
const int32_t lineThickness = 5; // Thickness of the vertical line
554-
const int32_t offsetX = 20; // Offset to adjust positioning
549+
const int32_t centerX = x + width / 2;
550+
const int32_t centerY = y + height / 2;
551+
const int32_t triangleSize = 20;
552+
const int32_t lineThickness = 5; // Thickness of the vertical line
553+
const int32_t offsetX = 20; // Offset to adjust positioning
555554

556555
// Determine positions based on isReversed
557556
const int32_t lineX = isReversed ? centerX - offsetX : centerX + offsetX - lineThickness;
@@ -569,7 +568,7 @@ void DisplayUI::drawSkipTrackIcon(int32_t x, int32_t y, int32_t width, int32_t h
569568
_tft->fillTriangle(
570569
triangleX + 15, triangleY, // Top point
571570
triangleX + 15, triangleY + 30, // Bottom point
572-
triangleX - triangleSize, centerY, // Leftmost point
571+
triangleX - triangleSize, centerY, // Leftmost point
573572
toValue(symbolColor)
574573
);
575574
}
@@ -579,7 +578,7 @@ void DisplayUI::drawSkipTrackIcon(int32_t x, int32_t y, int32_t width, int32_t h
579578
_tft->fillTriangle(
580579
triangleX - 15, triangleY, // Top point
581580
triangleX - 15, triangleY + 30, // Bottom point
582-
triangleX + triangleSize, centerY, // Rightmost point
581+
triangleX + triangleSize, centerY, // Rightmost point
583582
toValue(symbolColor)
584583
);
585584
}
@@ -603,11 +602,11 @@ void DisplayUI::drawPlayTrackIcon(int32_t x, int32_t y, int32_t width, int32_t h
603602
if (xSemaphoreTake(xSemaphoreDisplay, portMAX_DELAY))
604603
{
605604
// Define basic geometry
606-
const int32_t centerX = x + width / 2;
607-
const int32_t centerY = y + height / 2;
608-
const int32_t triangleSize = 20;
609-
const int32_t lineThickness = 0; // Thickness of the vertical line
610-
const int32_t offsetX = 20; // Offset to adjust positioning
605+
const int32_t centerX = x + width / 2;
606+
const int32_t centerY = y + height / 2;
607+
const int32_t triangleSize = 20;
608+
const int32_t lineThickness = 0; // Thickness of the vertical line
609+
const int32_t offsetX = 20; // Offset to adjust positioning
611610

612611
// Determine positions based on isReversed
613612
const int32_t lineX = centerX + offsetX - lineThickness;
@@ -619,7 +618,7 @@ void DisplayUI::drawPlayTrackIcon(int32_t x, int32_t y, int32_t width, int32_t h
619618
_tft->fillTriangle(
620619
triangleX - 15, triangleY, // Top point
621620
triangleX - 15, triangleY + 30, // Bottom point
622-
triangleX + triangleSize, centerY, // Rightmost point
621+
triangleX + triangleSize, centerY, // Rightmost point
623622
toValue(symbolColor)
624623
);
625624

@@ -642,10 +641,10 @@ void DisplayUI::drawPauseTrackIcon(int32_t x, int32_t y, int32_t width, int32_t
642641
if (xSemaphoreTake(xSemaphoreDisplay, portMAX_DELAY))
643642
{
644643
// Define basic geometry
645-
const int32_t centerX = x + width / 2;
646-
const int32_t centerY = y + height / 2;
644+
const int32_t centerX = x + width / 2;
645+
const int32_t centerY = y + height / 2;
647646
const int32_t lineThickness = 5; // Thickness of the vertical line
648-
const TFTColor symbolColor = TFTColor::White;
647+
const TFTColor symbolColor = TFTColor::White;
649648

650649
// Draw vertical line '|'
651650
_tft->fillRect(centerX - lineThickness * 2, centerY - 15, lineThickness, 30, toValue(symbolColor));
@@ -670,12 +669,12 @@ void DisplayUI::drawBackIcon(int32_t x, int32_t y, int32_t width, int32_t height
670669
if (xSemaphoreTake(xSemaphoreDisplay, portMAX_DELAY))
671670
{
672671
// Define basic geometry
673-
const int32_t centerX = x + width / 2;
674-
const int32_t centerY = y + height / 2;
675-
const int32_t arrowWidth = 20;
676-
const int32_t arrowHeight = 10;
672+
const int32_t centerX = x + width / 2;
673+
const int32_t centerY = y + height / 2;
674+
const int32_t arrowWidth = 20;
675+
const int32_t arrowHeight = 10;
677676
const int32_t lineThickness = 5;
678-
const TFTColor symbolColor = TFTColor::SC_NetworkSuccess; //::White;
677+
const TFTColor symbolColor = TFTColor::SC_NetworkSuccess; //::White;
679678

680679
// Draw left-facing arrow '<-'
681680
// Draw the line part of the arrow
@@ -717,7 +716,7 @@ uint16_t DisplayUI::read16(fs::File &f)
717716

718717
/*
719718
** ===================================================================
720-
** draw32()
719+
** read32()
721720
** ===================================================================
722721
*/
723722
uint32_t DisplayUI::read32(fs::File &f)
@@ -904,9 +903,9 @@ void DisplayUI::drawTextToLCD(const char *text, int posY)
904903
{
905904

906905
int pbWidth = _tft->width() - 100;
907-
int pbX = (_tft->width() - pbWidth)/2;
908-
int pbY = 260;
909-
int textY = posY;
906+
int pbX = (_tft->width() - pbWidth)/2;
907+
int pbY = 260;
908+
int textY = posY;
910909

911910
if (xSemaphoreTake(xSemaphoreDisplay, portMAX_DELAY))
912911
{
@@ -936,8 +935,6 @@ void DisplayUI::drawTextToLCD(const char *text, int posY, int fontSize, bool ig
936935
{
937936
_ofr->setFontSize(fontSize);
938937

939-
//_tft->setTextDatum(TL_DATUM);
940-
//_ofr->setAlignment(Align::BottomLeft);
941938
if (ignoreText)
942939
{
943940
_tft->fillRect(0, posY, _tft->width(), fontSize + 10, toValue(getBackground()));
@@ -1080,32 +1077,16 @@ void DisplayUI::drawText(const char *text, int posX, int posY, int fontSize, TFT
10801077
{
10811078
_ofr->setFontSize(fontSize);
10821079
_ofr->setAlignment(Align::BottomLeft);
1083-
1084-
// strlen(text) * 16
1085-
// _tft->fillRect(posX, posY, 100, fontSize + 10, toValue(TFTColor::Black)); // toValue(getBackground()));
1086-
// _ofr->cdrawString(text, posX, posY, toValue(getBackground()), toValue(color));
1087-
1088-
_tft->fillRect(posX - 70, posY, 140, fontSize + 10, toValue(TFTColor::Black)); // //toValue(getBackground())); // toValue(TFTColor::Black)); //
1089-
// _ofr->setFontColor(toValue(color));
1090-
// _ofr->cdrawString(text, posX, posY, rgb565(0xFF0000), rgb565(0x000000)); //, toValue(color), toValue(color));
1091-
// _ofr->cdrawString(text, posX, posY, rgb888_to_rgb565(toValue(color)), rgb888_to_rgb565(toValue(getBackground()))); //, toValue(color), toValue(color));
1092-
// _ofr->cdrawString(text, posX, posY, convertColorForILI9488(toValue(color)), convertColorForILI9488(toValue(TFTColor::Black))); //, toValue(color), toValue(color));
1080+
_tft->fillRect(posX - 70, posY, 140, fontSize + 10, toValue(TFTColor::Black));
10931081
_ofr->cdrawString(text, posX, posY, toRGB565(color), toRGB565(TFTColor::Black));
10941082

1095-
// _tft->fillRect(10, posY, 270, fontSize + 10, toValue(TFTColor::Black));
1096-
// _ofr->cdrawString("RED", 50, posY, rgb888_to_rgb565(0xFF0000), rgb888_to_rgb565(0x000000)); // Red on Black
1097-
// _ofr->cdrawString("GREEN", 125, posY, rgb888_to_rgb565(0x00FF00), rgb888_to_rgb565(0x000000)); // Green on Black
1098-
// _ofr->cdrawString("BLUE", 200, posY, rgb888_to_rgb565(0x0000FF), rgb888_to_rgb565(0x000000)); // Blue on Black
1099-
11001083
xSemaphoreGive(xSemaphoreDisplay);
11011084
}
11021085
else
11031086
{
11041087
spLogI(LOGTAG_MULTITASK,"Unable to take xSemaphoreDisplay.");
11051088
}
11061089

1107-
1108-
11091090
}
11101091

11111092
/*
@@ -1124,8 +1105,6 @@ void DisplayUI::drawString(const char *str,
11241105
Align alignment,
11251106
const char *clearMask)
11261107
{
1127-
// _tft->fillRect(0, _tft->height() - 10, _tft->width() , 10, toValue(TFTColor::DarkGrey));
1128-
11291108
_ofr->setAlignment(alignment);
11301109
_ofr->setFontSize(fontSize);
11311110
uint16_t fgColor = toRGB565(fg);
@@ -1201,10 +1180,6 @@ void DisplayUI::rDrawString( const char *str,
12011180
TFTColor bg,
12021181
const char *clearMask)
12031182
{
1204-
// _tft->fillRect(0, _tft->height() - 10, _tft->width() , 10, toValue(TFTColor::DarkGrey));
1205-
1206-
// drawString(str, x, y, fontSize, fg, bg, Align::Right, clearMask);
1207-
12081183
_ofr->setAlignment(Align::Right);
12091184
_ofr->setFontSize(fontSize);
12101185
uint16_t fgColor = toRGB565(fg);
@@ -1348,9 +1323,9 @@ void DisplayUI::drawClockString(
13481323
*/
13491324
std::string DisplayUI::formatTime(long millis) {
13501325
long totalSeconds = millis / 1000;
1351-
int hours = totalSeconds / 3600;
1352-
int minutes = (totalSeconds % 3600) / 60;
1353-
int seconds = totalSeconds % 60;
1326+
int hours = totalSeconds / 3600;
1327+
int minutes = (totalSeconds % 3600) / 60;
1328+
int seconds = totalSeconds % 60;
13541329

13551330
std::string result;
13561331

@@ -1681,7 +1656,10 @@ bool DisplayUI::jpgCalculateAverageColorCallback(int16_t x, int16_t y, uint16_t
16811656
// Calculate average color of JPEG file
16821657
TFTColor DisplayUI::calculateAverageColor(const char* filename)
16831658
{
1684-
totalR = totalG = totalB = pixelCount = 0;
1659+
totalR = 0;
1660+
totalG = 0;
1661+
totalB = 0;
1662+
pixelCount = 0;
16851663

16861664
spLogV(LOGTAG_PLAYER, "Entering calculateAverageColor(%s)", filename);
16871665

src/DisplayUI.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#pragma once
2121

2222
#include <FS.h>
23-
// #include <LittleFS.h>
2423
#include <OpenFontRender.h>
2524
#include <TFT_eSPI.h>
2625

@@ -116,13 +115,13 @@ class DisplayUI {
116115
void drawPauseTrackIcon(int32_t x, int32_t y, int32_t width, int32_t height);
117116
void drawBackIcon(int32_t x, int32_t y, int32_t width, int32_t height);
118117

119-
void setBackground(TFTColor color, bool bRepaint=true);
120-
TFTColor getBackground() const;
121-
bool isSplitBackground() const;
122-
void setSplitBackground(bool isSplitBackground = false);
123-
void clearScreen();
124-
void clearScreenKeepArt();
125-
void clearScreenHome();
118+
void setBackground(TFTColor color, bool bRepaint=true);
119+
TFTColor getBackground() const;
120+
bool isSplitBackground() const;
121+
void setSplitBackground(bool isSplitBackground = false);
122+
void clearScreen();
123+
void clearScreenKeepArt();
124+
void clearScreenHome();
126125
std::string formatTime(long millis);
127126

128127
void drawTextToLCD(const char *text, int posY);
@@ -139,12 +138,12 @@ class DisplayUI {
139138
const char *clearMask);
140139

141140
void cDrawString(const char *str,
142-
int32_t x,
143-
int32_t y,
144-
unsigned int fontSize,
145-
TFTColor fg,
146-
TFTColor bg,
147-
const char *clearMask);
141+
int32_t x,
142+
int32_t y,
143+
unsigned int fontSize,
144+
TFTColor fg,
145+
TFTColor bg,
146+
const char *clearMask);
148147

149148
void lDrawString(const char *str,
150149
int32_t x,
@@ -195,7 +194,6 @@ class DisplayUI {
195194
OpenFontRender *_clockFont;
196195
TFTColor _bgColor = TFTColor::BlueThinkPulse;
197196
bool _isSplitBackground = false;
198-
// ViewID _viewID = ViewID::Home;
199197
bool _isUIDirty = false;
200198
bool _isPainting = true;
201199
SemaphoreHandle_t xSemaphoreDisplay = xSemaphoreCreateMutex();

src/SCFileIO.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ bool SCFileIO::initialize()
9595
return false;
9696
}
9797

98-
9998
}
10099

101100
/*
@@ -466,17 +465,16 @@ void SCFileIO::hexDump(const char* tag, const char* filePath)
466465
Serial.printf("Hex Dump of file: %s\n", filePath);
467466
Serial.printf("-----------------------------------------------------------------------------\n");
468467

469-
uint8_t buffer[16]; // Buffer to hold 16 bytes per line
470-
size_t fileOffset = 0; // Tracks current offset in the file
471-
472-
char hexLine[50]; // 16 bytes * 3 chars (hex) + 1 space after 8th byte + null terminator
473-
char asciiLine[17]; // 16 bytes + null terminator
468+
uint8_t buffer[16]; // Buffer to hold 16 bytes per line
469+
size_t fileOffset = 0; // Tracks current offset in the file
470+
char hexLine[50]; // 16 bytes * 3 chars (hex) + 1 space after 8th byte + null terminator
471+
char asciiLine[17]; // 16 bytes + null terminator
474472

475473
while (file.available())
476474
{
477475
size_t bytesRead = file.read(buffer, sizeof(buffer)); // Read up to 16 bytes
478-
memset(hexLine, ' ', sizeof(hexLine)); // Initialize with spaces for alignment
479-
memset(asciiLine, '\0', sizeof(asciiLine)); // Null-terminate ASCII buffer
476+
memset(hexLine, ' ', sizeof(hexLine)); // Initialize with spaces for alignment
477+
memset(asciiLine, '\0', sizeof(asciiLine)); // Null-terminate ASCII buffer
480478

481479
for (size_t i = 0; i < bytesRead; ++i)
482480
{

src/SCLogger.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ class SCLogger {
7676
void logError(const char* tag, const char* format, ...);
7777

7878
private:
79-
SCLogger() = default; // Private constructor
80-
SCLogger(const SCLogger&) = delete; // Prevent copy
81-
SCLogger& operator=(const SCLogger&) = delete; // Prevent assignment
79+
SCLogger() = default; // Private constructor
80+
SCLogger(const SCLogger&) = delete; // Prevent copy
81+
SCLogger& operator=(const SCLogger&) = delete; // Prevent assignment
8282
void logMessage(esp_log_level_t level, const char* tag, const char* format, va_list args);
8383
std::map<std::string, esp_log_level_t> tagLevels; // Map to store log levels per tag
84-
std::mutex mutex; // Mutex to protect the map
84+
std::mutex mutex; // Mutex to protect the map
8585
};
8686
// Define this to enable logging; comment out to disable
8787
#define ENABLE_SCLOGGING

0 commit comments

Comments
 (0)