-
Notifications
You must be signed in to change notification settings - Fork 6
feat: replace TFT bitmap icons with colored text labels (#66) #73
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,84 +12,6 @@ | |
| // --------------------------------------------------------------------------- | ||
|
|
||
| // Generic NFC icon (concentric arcs suggesting radio waves) | ||
| static const uint8_t ICON_NFC_PLAIN[32][32] PROGMEM = { | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0}, | ||
| {0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0}, | ||
| {0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0}, | ||
| {0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0}, | ||
| {0,0,0,0,1,0,0,1,0,0,0,0,1,1,1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,0,0}, | ||
| {0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| }; | ||
|
|
||
| // OpenPrintTag icon: "OPT" text in a rounded box | ||
| // (placeholder — same structure, you can replace with a proper design) | ||
| static const uint8_t ICON_OPENPRINTTAG[32][32] PROGMEM = { | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0}, | ||
| {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, | ||
| {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, | ||
| {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, | ||
| {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, | ||
| {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, | ||
| {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, | ||
| {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, | ||
| {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, | ||
| {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, | ||
| {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, | ||
| {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, | ||
| {0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, | ||
| {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| }; | ||
|
|
||
| // Reuse NFC_PLAIN icon for TigerTag, OpenTag3D, Bambu for now. | ||
| // Replace with distinct designs as desired. | ||
| #define ICON_TIGERTAG ICON_NFC_PLAIN | ||
| #define ICON_OPENTAG3D ICON_NFC_PLAIN | ||
| #define ICON_BAMBU ICON_NFC_PLAIN | ||
|
|
||
| // --------------------------------------------------------------------------- | ||
| // Color constants | ||
| // --------------------------------------------------------------------------- | ||
|
|
@@ -612,46 +534,38 @@ void TFTManager::drawWeightBar(int x, int y, int w, int h, | |
| } | ||
|
|
||
| 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); | ||
| } | ||
|
Comment on lines
536
to
569
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a true right-edge anchor; At Line 568, anchoring to 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 |
||
|
|
||
| uint32_t TFTManager::hexToRgb(const char* hex) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add braces for the tag-format mapping chain.
Line 359 is in a single-line
if/else ifchain, and this is already flagged by static analysis. Please wrap each branch in braces to prevent future edit-time logic slips.Suggested fix
📝 Committable suggestion
🧰 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