From 27e4cd930630d752e62bbcaff2131e22d0129d16 Mon Sep 17 00:00:00 2001 From: TigerTag-Project <206083157+TigerTag-Project@users.noreply.github.com> Date: Wed, 14 Oct 2026 01:03:52 +0200 Subject: [PATCH] TigerTag: read colors 2 and 3 for multi-color filaments When Aspect 1 or Aspect 2 is Bicolor, Tricolor or Rainbow, also read Color 2 (+36) and Color 3 (+40), as described in section 2.5 of the TigerTag spec. A multi-color aspect can be on either aspect, so both are checked and the highest color count wins. The aspects are matched by id (252, 24, 145), not by label, so renaming a label in id_aspect.json cannot break it. Colors 2 and 3 are stored as RGB and reuse the alpha of color 1. All colors are included in the unique id, so two multi-color spools that only differ by a secondary color get different ids. Single-color ids are unchanged. Tests: copies of the eSun TigerTag+ dump with Bicolor and Tricolor on Aspect 2, Bicolor and Rainbow on Aspect 1, and Bicolor + Tricolor on both aspects. The bytes changed are outside the signed region. --- src/tag/tigertag/constants.py | 10 +++++++++ src/tag/tigertag/processor.py | 16 +++++++++++--- ...old White TigerTag+ Bicolor (Aspect 1).bin | Bin 0 -> 180 bytes ...old White TigerTag+ Bicolor (Aspect 1).yml | 19 +++++++++++++++++ ...d White TigerTag+ Bicolor and Tricolor.bin | Bin 0 -> 180 bytes ...d White TigerTag+ Bicolor and Tricolor.yml | 20 ++++++++++++++++++ ...ic Refill Cold White TigerTag+ Bicolor.bin | Bin 0 -> 180 bytes ...ic Refill Cold White TigerTag+ Bicolor.yml | 19 +++++++++++++++++ ...old White TigerTag+ Rainbow (Aspect 1).bin | Bin 0 -> 180 bytes ...old White TigerTag+ Rainbow (Aspect 1).yml | 19 +++++++++++++++++ ...c Refill Cold White TigerTag+ Tricolor.bin | Bin 0 -> 180 bytes ...c Refill Cold White TigerTag+ Tricolor.yml | 20 ++++++++++++++++++ 12 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor (Aspect 1).bin create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor (Aspect 1).yml create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor and Tricolor.bin create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor and Tricolor.yml create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor.bin create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor.yml create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Rainbow (Aspect 1).bin create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Rainbow (Aspect 1).yml create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Tricolor.bin create mode 100644 test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Tricolor.yml diff --git a/src/tag/tigertag/constants.py b/src/tag/tigertag/constants.py index 75cdd52..0dcfece 100644 --- a/src/tag/tigertag/constants.py +++ b/src/tag/tigertag/constants.py @@ -20,10 +20,20 @@ OFF_BED_TEMP_MIN = 30 OFF_BED_TEMP_MAX = 31 OFF_TIMESTAMP = 32 +OFF_COLOR2_RGB = 36 +OFF_COLOR3_RGB = 40 OFF_TD = 44 OFF_METADATA = 48 OFF_SIGNATURE = 80 +# Multi-color aspects, matched by id (not by label, which may be renamed in +# id_aspect.json): aspect id -> number of colors on the chip. +MULTICOLOR_ASPECT_COLOR_COUNT = { + 252: 2, # Bicolor + 24: 3, # Tricolor + 145: 3, # Rainbow +} + MIN_DATA_LENGTH = 96 USER_DATA_PAGE_OFFSET = 4 USER_DATA_BYTE_OFFSET = USER_DATA_PAGE_OFFSET * 4 diff --git a/src/tag/tigertag/processor.py b/src/tag/tigertag/processor.py index 975670b..640a354 100644 --- a/src/tag/tigertag/processor.py +++ b/src/tag/tigertag/processor.py @@ -47,6 +47,16 @@ def __parse_tigertag(self, scan_result: ScanResult, user_data: bytes, tag_id: in a = user_data[Constants.OFF_COLOR_RGBA + 3] argb_color = (a << 24) | (r << 16) | (g << 8) | b + # Multi-color: a multi-color aspect can be on Aspect 1 or Aspect 2, so + # both are checked and the highest color count wins (spec section 2.5). + # Colors 2 and 3 are stored as RGB and reuse the alpha of color 1. + color_count = max(Constants.MULTICOLOR_ASPECT_COLOR_COUNT.get(aspect1_id, 1), + Constants.MULTICOLOR_ASPECT_COLOR_COUNT.get(aspect2_id, 1)) + colors = [argb_color] + for offset in (Constants.OFF_COLOR2_RGB, Constants.OFF_COLOR3_RGB)[:color_count - 1]: + if len(user_data) >= offset + 3: + colors.append((a << 24) | (user_data[offset] << 16) | (user_data[offset + 1] << 8) | user_data[offset + 2]) + weight_bytes = user_data[Constants.OFF_WEIGHT:Constants.OFF_WEIGHT + 3] measure_value = (weight_bytes[0] << 16) | (weight_bytes[1] << 8) | weight_bytes[2] unit_id = user_data[Constants.OFF_UNIT_ID] @@ -93,7 +103,7 @@ def __parse_tigertag(self, scan_result: ScanResult, user_data: bytes, tag_id: in self.logger.debug(" Brand: %s (ID: %d)", brand_name, brand_id) self.logger.debug(" Diameter: %.2f mm (ID: %d)", diameter_mm, diameter_id) self.logger.debug(" Aspect1: %s, Aspect2: %s", aspect1_label, aspect2_label) - self.logger.debug(" Color (ARGB): 0x%08X", argb_color) + self.logger.debug(" Colors (ARGB): %s", " ".join(f"0x{color:08X}" for color in colors)) self.logger.debug(" Measure: %d %s (%.1f g)", measure_value, unit_label, weight_grams) self.logger.debug(" Nozzle Temp: %d-%d °C", temp_min, temp_max) self.logger.debug(" Dry: %d °C for %d hours", dry_temp, dry_time) @@ -104,13 +114,13 @@ def __parse_tigertag(self, scan_result: ScanResult, user_data: bytes, tag_id: in return GenericFilament( source_processor=self.name, unique_id=GenericFilament.generate_unique_id( - "TigerTag", brand_name, resolved_material_type, argb_color, + "TigerTag", brand_name, resolved_material_type, *colors, product_id, timestamp_raw ), manufacturer=brand_name, type=resolved_material_type, modifiers=modifiers, - colors=[argb_color], + colors=colors, diameter_mm=diameter_mm, weight_grams=weight_grams, hotend_min_temp_c=float(temp_min), diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor (Aspect 1).bin b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor (Aspect 1).bin new file mode 100644 index 0000000000000000000000000000000000000000..eaf25f884e96df573e6217ba78459f8985747f21 GIT binary patch literal 180 zcmb3BDpHaxB+&5i00YBA0U?Gx{HLc+TPt{bs`sCaK8xK}cb~rf&%pdbl;IM?Gb0XN zM}uX5Udv7R&+y-sfhdsmu8_yPXNGK8xK}cb~rf&%pdbl;IM?Gb0XN zM}uX5Udv7R&+y-sfhdsmu8_yPXNGe?-zD<9?Z4*BC%|ELxy`*&RKLT2^7l{8OTLu97#W=