Skip to content

feat: replace TFT bitmap icons with colored text labels (#66)#73

Merged
sjordan0228 merged 1 commit into
devfrom
fix/tft-text-labels
Apr 1, 2026
Merged

feat: replace TFT bitmap icons with colored text labels (#66)#73
sjordan0228 merged 1 commit into
devfrom
fix/tft-text-labels

Conversation

@sjordan0228
Copy link
Copy Markdown
Contributor

@sjordan0228 sjordan0228 commented Apr 1, 2026

Summary

  • Replace unreadable 32x32 bitmap icons with crisp colored text labels on the TFT spool screen
  • Remove ~2KB of PROGMEM bitmap data (ICON_NFC_PLAIN, ICON_OPENPRINTTAG, aliases)
  • Wire up BambuTag → TAG_TYPE_BAMBU mapping in ApplicationManager

Labels

Tag Type Label Color
OpenPrintTag OPT Blue (#4FC3F7)
TigerTag TT Orange (#FF9800)
OpenTag3D OT3D Green (#4CAF50)
BambuTag Bambu Bambu green (#1DB954)
NFC+ NFC+ Cyan (#00BCD4)

Closes #66

Test Plan

  • Clean compile on esp32s3zero and esp32dev (verified)
  • Flash TFT build — scan each tag type, verify label shows in top-right
  • Verify label color matches tag format
  • Verify BambuTag label appears when Bambu tag detected

Summary by CodeRabbit

  • New Features
    • Added support for BambuTag spool tag format recognition.
    • Tag icons now display as text labels instead of bitmap graphics for improved efficiency.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

The changes implement text-based tag type labels in the TFT display to replace bitmap icons, and add BambuTag support to the tag type mapping system. Bitmap icon data is removed and the drawTagIcon function is reworked to render colored text labels corresponding to each tag type.

Changes

Cohort / File(s) Summary
Tag Type Display Refactoring
src/TFTManager.cpp
Removed 32×32 PROGMEM icon bitmaps and NFC-based macros; reworked drawTagIcon to render text labels ("OPT", "TT", "OT3D", "Bambu", "NFC+") with per-tag colors instead of bitmap pixels. Added early return in default switch branch.
BambuTag Support
src/ApplicationManager.cpp
Added mapping for "BambuTag" string to spool.tagType = 4 in spool detection handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing TFT bitmap icons with colored text labels, which is the primary focus of the changeset.
Description check ✅ Passed The description covers all required template sections: Summary, Changes, and Test Plan. It includes clear details on what was replaced, memory savings, color mappings, and testing steps.
Linked Issues check ✅ Passed All coding requirements from issue #66 are addressed: text labels replace bitmap icons in TFTManager, ~2KB of PROGMEM bitmaps removed, and BambuTag mapping added in ApplicationManager.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue objectives. The ApplicationManager.cpp change adds BambuTag mapping; TFTManager.cpp changes replace icons and remove bitmaps—no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tft-text-labels

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/ApplicationManager.cpp`:
- Around line 356-360: The single-line if/else-if chain setting spool.tagType
based on s.tag_format (checks like strcmp(s.tag_format, "OpenPrintTag") etc.)
needs braces added around each branch to avoid edit-time logic slips; update the
block that assigns spool.tagType so each if and else if and the final else use {
... } around their assignments (e.g., for the strcmp(...) == 0 branches and the
final else) while keeping the same comparisons and resulting spool.tagType
values.

In `@src/TFTManager.cpp`:
- Around line 536-569: The label is being drawn with a hardcoded x + 22 which
anchors it into the old icon slot and can clip longer labels; in
drawTagIcon(uint8_t tagType, int x, int y) replace the magic 22 with a true
right-edge x coordinate (e.g. x + TAG_ICON_WIDTH - PADDING) and keep TR_DATUM so
the text is right-aligned; define or use a constant like TAG_ICON_WIDTH (or
compute the icon box width) and a small PADDING, then call
_sprite.drawString(label, x + TAG_ICON_WIDTH - PADDING, y) so labels like
"Bambu" won't be truncated (refer to drawTagIcon, _sprite.drawString, TR_DATUM,
label).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d1531258-ebbb-4658-a9f3-80af0b7445a4

📥 Commits

Reviewing files that changed from the base of the PR and between ee113d9 and 7b2d768.

📒 Files selected for processing (2)
  • src/ApplicationManager.cpp
  • src/TFTManager.cpp

Comment on lines 356 to 360
if (strcmp(s.tag_format, "OpenPrintTag") == 0) spool.tagType = 1;
else if (strcmp(s.tag_format, "TigerTag") == 0) spool.tagType = 2;
else if (strcmp(s.tag_format, "OpenTag3D") == 0) spool.tagType = 3;
else if (strcmp(s.tag_format, "BambuTag") == 0) spool.tagType = 4;
else spool.tagType = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add braces for the tag-format mapping chain.

Line 359 is in a single-line if/else if chain, and this is already flagged by static analysis. Please wrap each branch in braces to prevent future edit-time logic slips.

Suggested fix
-        if (strcmp(s.tag_format, "OpenPrintTag") == 0) spool.tagType = 1;
-        else if (strcmp(s.tag_format, "TigerTag") == 0) spool.tagType = 2;
-        else if (strcmp(s.tag_format, "OpenTag3D") == 0) spool.tagType = 3;
-        else if (strcmp(s.tag_format, "BambuTag") == 0) spool.tagType = 4;
-        else spool.tagType = 0;
+        if (strcmp(s.tag_format, "OpenPrintTag") == 0) {
+            spool.tagType = 1;
+        } else if (strcmp(s.tag_format, "TigerTag") == 0) {
+            spool.tagType = 2;
+        } else if (strcmp(s.tag_format, "OpenTag3D") == 0) {
+            spool.tagType = 3;
+        } else if (strcmp(s.tag_format, "BambuTag") == 0) {
+            spool.tagType = 4;
+        } else {
+            spool.tagType = 0;
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (strcmp(s.tag_format, "OpenPrintTag") == 0) spool.tagType = 1;
else if (strcmp(s.tag_format, "TigerTag") == 0) spool.tagType = 2;
else if (strcmp(s.tag_format, "OpenTag3D") == 0) spool.tagType = 3;
else if (strcmp(s.tag_format, "BambuTag") == 0) spool.tagType = 4;
else spool.tagType = 0;
if (strcmp(s.tag_format, "OpenPrintTag") == 0) {
spool.tagType = 1;
} else if (strcmp(s.tag_format, "TigerTag") == 0) {
spool.tagType = 2;
} else if (strcmp(s.tag_format, "OpenTag3D") == 0) {
spool.tagType = 3;
} else if (strcmp(s.tag_format, "BambuTag") == 0) {
spool.tagType = 4;
} else {
spool.tagType = 0;
}
🧰 Tools
🪛 Clang (14.0.6)

[warning] 356-356: statement should be inside braces

(readability-braces-around-statements)


[warning] 357-357: statement should be inside braces

(readability-braces-around-statements)


[warning] 358-358: statement should be inside braces

(readability-braces-around-statements)


[warning] 359-359: statement should be inside braces

(readability-braces-around-statements)


[warning] 360-360: statement should be inside braces

(readability-braces-around-statements)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ApplicationManager.cpp` around lines 356 - 360, The single-line
if/else-if chain setting spool.tagType based on s.tag_format (checks like
strcmp(s.tag_format, "OpenPrintTag") etc.) needs braces added around each branch
to avoid edit-time logic slips; update the block that assigns spool.tagType so
each if and else if and the final else use { ... } around their assignments
(e.g., for the strcmp(...) == 0 branches and the final else) while keeping the
same comparisons and resulting spool.tagType values.

Comment thread src/TFTManager.cpp
Comment on lines 536 to 569
void TFTManager::drawTagIcon(uint8_t tagType, int x, int y) {
const uint8_t (*icon)[32] = nullptr;
uint32_t fgColor = COLOR_ACCENT;
const char* label = nullptr;
uint32_t color = COLOR_SUBTEXT;

switch (tagType) {
case TAG_TYPE_OPENPRINTTAG:
icon = ICON_OPENPRINTTAG;
fgColor = 0x00BFFF;
label = "OPT";
color = 0x4FC3F7;
break;
case TAG_TYPE_TIGERTAG:
icon = ICON_TIGERTAG;
fgColor = 0xFF8C00;
label = "TT";
color = 0xFF9800;
break;
case TAG_TYPE_OPENTAG3D:
icon = ICON_OPENTAG3D;
fgColor = 0x00CC66;
label = "OT3D";
color = 0x4CAF50;
break;
case TAG_TYPE_BAMBU:
icon = ICON_BAMBU;
fgColor = 0x1DB954;
label = "Bambu";
color = 0x1DB954;
break;
case TAG_TYPE_NFC_PLAIN:
default:
icon = ICON_NFC_PLAIN;
fgColor = COLOR_SUBTEXT;
label = "NFC+";
color = 0x00BCD4;
break;
default:
return;
}

if (!icon) return;

// Draw 32x32 bitmap from PROGMEM — scale to 22x22 by skipping every ~3rd pixel
for (int row = 0; row < 22; row++) {
int srcRow = (row * 32) / 22;
for (int col = 0; col < 22; col++) {
int srcCol = (col * 32) / 22;
uint8_t pixel = pgm_read_byte(&icon[srcRow][srcCol]);
if (pixel) {
_sprite.drawPixel(x + col, y + row, fgColor);
}
}
}
_sprite.setTextColor(color);
_sprite.setTextSize(1);
_sprite.setTextDatum(TR_DATUM);
_sprite.drawString(label, x + 22, y);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use a true right-edge anchor; x + 22 keeps label in the old icon slot and can clip longer text.

At Line 568, anchoring to x + 22 assumes the previous 22px icon box. With current call sites, this does not place labels top-right and can truncate longer labels like "Bambu".

Suggested fix
--- a/src/TFTManager.cpp
+++ b/src/TFTManager.cpp
@@
-    // Tag type icon top-left in header
-    drawTagIcon(spool.tagType, 4, 2);
+    // Tag type label top-right in header
+    drawTagIcon(spool.tagType, W - 4, 2);
@@
-    _sprite.drawString(label, x + 22, y);
+    _sprite.drawString(label, x, y);
🧰 Tools
🪛 Clang (14.0.6)

[warning] 536-536: method 'drawTagIcon' can be made static

(readability-convert-member-functions-to-static)


[warning] 536-536: 3 adjacent parameters of 'drawTagIcon' of similar type ('int') are easily swapped by mistake

(bugprone-easily-swappable-parameters)


[note] 536-536: the first parameter in the range is 'tagType'

(clang)


[note] 536-536: the last parameter in the range is 'y'

(clang)


[warning] 536-536: parameter name 'x' is too short, expected at least 3 characters

(readability-identifier-length)


[warning] 536-536: parameter name 'y' is too short, expected at least 3 characters

(readability-identifier-length)


[warning] 538-538: variable 'color' is not initialized

(cppcoreguidelines-init-variables)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/TFTManager.cpp` around lines 536 - 569, The label is being drawn with a
hardcoded x + 22 which anchors it into the old icon slot and can clip longer
labels; in drawTagIcon(uint8_t tagType, int x, int y) replace the magic 22 with
a true right-edge x coordinate (e.g. x + TAG_ICON_WIDTH - PADDING) and keep
TR_DATUM so the text is right-aligned; define or use a constant like
TAG_ICON_WIDTH (or compute the icon box width) and a small PADDING, then call
_sprite.drawString(label, x + TAG_ICON_WIDTH - PADDING, y) so labels like
"Bambu" won't be truncated (refer to drawTagIcon, _sprite.drawString, TR_DATUM,
label).

@sjordan0228 sjordan0228 merged commit c6c62a6 into dev Apr 1, 2026
2 checks passed
@sjordan0228 sjordan0228 deleted the fix/tft-text-labels branch April 2, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant