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 0000000..eaf25f8 Binary files /dev/null and b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor (Aspect 1).bin differ diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor (Aspect 1).yml b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor (Aspect 1).yml new file mode 100644 index 0000000..eae5cae --- /dev/null +++ b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor (Aspect 1).yml @@ -0,0 +1,19 @@ +bed_temp_c: 0.0 +colors: +- 0xFFDDE5ED +- 0xFF1E90FF +diameter_mm: 1.75 +drying_temp_c: 50.0 +drying_time_hours: 8.0 +hotend_max_temp_c: 230.0 +hotend_min_temp_c: 210.0 +manufacturer: eSun +manufacturing_date: '2025-11-12' +modifiers: +- Bicolor +- Basic +source_processor: TigerTagProcessor +td: 0.0 +type: PLA +unique_id: 2a1b203b21bab0e5f1d1b7d1f905705ad35c35a0cf4a21c03530c082e6d33465 +weight_grams: 1000.0 diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor and Tricolor.bin b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor and Tricolor.bin new file mode 100644 index 0000000..bebf67f Binary files /dev/null and b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor and Tricolor.bin differ diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor and Tricolor.yml b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor and Tricolor.yml new file mode 100644 index 0000000..78b9d82 --- /dev/null +++ b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor and Tricolor.yml @@ -0,0 +1,20 @@ +bed_temp_c: 0.0 +colors: +- 0xFFDDE5ED +- 0xFF1E90FF +- 0xFFFF4500 +diameter_mm: 1.75 +drying_temp_c: 50.0 +drying_time_hours: 8.0 +hotend_max_temp_c: 230.0 +hotend_min_temp_c: 210.0 +manufacturer: eSun +manufacturing_date: '2025-11-12' +modifiers: +- Bicolor +- Tricolor +source_processor: TigerTagProcessor +td: 0.0 +type: PLA +unique_id: 037707719b2099739fba91970970075f5f8f21cbb42734ccf8a5c4a12a1742da +weight_grams: 1000.0 diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor.bin b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor.bin new file mode 100644 index 0000000..3fbe5ba Binary files /dev/null and b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor.bin differ diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor.yml b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor.yml new file mode 100644 index 0000000..f5101b7 --- /dev/null +++ b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Bicolor.yml @@ -0,0 +1,19 @@ +bed_temp_c: 0.0 +colors: +- 0xFFDDE5ED +- 0xFF1E90FF +diameter_mm: 1.75 +drying_temp_c: 50.0 +drying_time_hours: 8.0 +hotend_max_temp_c: 230.0 +hotend_min_temp_c: 210.0 +manufacturer: eSun +manufacturing_date: '2025-11-12' +modifiers: +- Basic +- Bicolor +source_processor: TigerTagProcessor +td: 0.0 +type: PLA +unique_id: 2a1b203b21bab0e5f1d1b7d1f905705ad35c35a0cf4a21c03530c082e6d33465 +weight_grams: 1000.0 diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Rainbow (Aspect 1).bin b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Rainbow (Aspect 1).bin new file mode 100644 index 0000000..0528008 Binary files /dev/null and b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Rainbow (Aspect 1).bin differ diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Rainbow (Aspect 1).yml b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Rainbow (Aspect 1).yml new file mode 100644 index 0000000..611220a --- /dev/null +++ b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Rainbow (Aspect 1).yml @@ -0,0 +1,19 @@ +bed_temp_c: 0.0 +colors: +- 0xFFDDE5ED +- 0xFF1E90FF +- 0xFFFF4500 +diameter_mm: 1.75 +drying_temp_c: 50.0 +drying_time_hours: 8.0 +hotend_max_temp_c: 230.0 +hotend_min_temp_c: 210.0 +manufacturer: eSun +manufacturing_date: '2025-11-12' +modifiers: +- Rainbow +source_processor: TigerTagProcessor +td: 0.0 +type: PLA +unique_id: 037707719b2099739fba91970970075f5f8f21cbb42734ccf8a5c4a12a1742da +weight_grams: 1000.0 diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Tricolor.bin b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Tricolor.bin new file mode 100644 index 0000000..6e271d1 Binary files /dev/null and b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Tricolor.bin differ diff --git a/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Tricolor.yml b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Tricolor.yml new file mode 100644 index 0000000..0af60cf --- /dev/null +++ b/test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+ Tricolor.yml @@ -0,0 +1,20 @@ +bed_temp_c: 0.0 +colors: +- 0xFFDDE5ED +- 0xFF1E90FF +- 0xFFFF4500 +diameter_mm: 1.75 +drying_temp_c: 50.0 +drying_time_hours: 8.0 +hotend_max_temp_c: 230.0 +hotend_min_temp_c: 210.0 +manufacturer: eSun +manufacturing_date: '2025-11-12' +modifiers: +- Basic +- Tricolor +source_processor: TigerTagProcessor +td: 0.0 +type: PLA +unique_id: 037707719b2099739fba91970970075f5f8f21cbb42734ccf8a5c4a12a1742da +weight_grams: 1000.0