From b1aa56bd5d5c5c03160f5c68ce95196588ce8c77 Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Fri, 29 Dec 2023 02:12:46 -0500 Subject: [PATCH] Update - DWIN_ICO.py --- buildroot/share/dwin/bin/DWIN_ICO.py | 231 +++++++++-------- .../Icon Tools/Scripts/DWIN_ICO.py | 235 +++++++++--------- 2 files changed, 230 insertions(+), 236 deletions(-) diff --git a/buildroot/share/dwin/bin/DWIN_ICO.py b/buildroot/share/dwin/bin/DWIN_ICO.py index 469d880cee..9f44267564 100644 --- a/buildroot/share/dwin/bin/DWIN_ICO.py +++ b/buildroot/share/dwin/bin/DWIN_ICO.py @@ -81,16 +81,15 @@ def splitFile(self, filename, outDir): def _parseHeader(self, infile): maxEntries = 256 count = 0 - validEntries = 0 + icon_nums = _iconNames.keys() while count < maxEntries: rawBytes = infile.read(16) entry = Entry() entry.parseRawData(rawBytes) # check that it is valid: is offset nonzero? - # Special case: treat 39 as valid - #if (entry.offset > 0) or (count == 39): - validEntries += 1 - self.entries.append(entry) + # Special case: treat missing numbers as valid + if (entry.offset > 0) or count not in icon_nums: + self.entries.append(entry) count += 1 return @@ -110,15 +109,14 @@ def _splitEntryData(self, infile, outDir): if entry.length == 0: count += 1 continue - # Seek file position, read length bytes, and write to new output file. - print('%02d: offset: 0x%06x len: 0x%04x width: %d height: %d' % - (count, entry.offset, entry.length, entry.width, entry.height)) outfilename = os.path.join(outDir, '%03d-ICON_%s.jpg' % (count, _iconNames.get(count, "UNKNOWN"))) with open(outfilename, 'wb') as outfile: infile.seek(entry.offset) blob = infile.read(entry.length) outfile.write(blob) - print('Wrote %d bytes to %s' % (entry.length, outfilename)) + # Seek file position, read length bytes, and write to new output file. + print('(%3d: width=%3d height=%3d offset=%6d len=%4d) ... %s' % + (count, entry.width, entry.height, entry.offset, entry.length, os.path.basename(outfilename))) count += 1 return @@ -143,7 +141,7 @@ def createFile(self, iconDir, filename): # process each file: try: index = int(dirEntry.name[0:3]) - if (index < 0) or (index > 255): + if not (0 <= index <= 255): print('...Ignoring invalid index on', dirEntry.path) continue #dirEntry.path is iconDir/name @@ -246,111 +244,110 @@ def serialize(self): return rawdata _iconNames = { - 0 : "LOGO_Creality", - 1 : "Print_0", - 2 : "Print_1", - 3 : "Prepare_0", - 4 : "Prepare_1", - 5 : "Control_0", - 6 : "Control_1", - 7 : "Leveling_0", - 8 : "Leveling_1", - 9 : "HotendTemp", - 10 : "BedTemp", - 11 : "Speed", - 12 : "Zoffset", - 13 : "Back", - 14 : "File", - 15 : "PrintTime", - 16 : "RemainTime", - 17 : "Setup_0", - 18 : "Setup_1", - 19 : "Pause_0", - 20 : "Pause_1", - 21 : "Continue_0", - 22 : "Continue_1", - 23 : "Stop_0", - 24 : "Stop_1", - 25 : "Bar", - 26 : "More", - 27 : "Axis", - 28 : "CloseMotor", - 29 : "Homing", - 30 : "SetHome", - 31 : "PLAPreheat", - 32 : "ABSPreheat", - 33 : "Cool", - 34 : "Language", - 35 : "MoveX", - 36 : "MoveY", - 37 : "MoveZ", - 38 : "Extruder", - # Skip 39 - 40 : "Temperature", - 41 : "Motion", - 42 : "WriteEEPROM", - 43 : "ReadEEPROM", - 44 : "ResetEEPROM", - 45 : "Info", - 46 : "SetEndTemp", - 47 : "SetBedTemp", - 48 : "FanSpeed", - 49 : "SetPLAPreheat", - 50 : "SetABSPreheat", - 51 : "MaxSpeed", - 52 : "MaxAccelerated", - 53 : "MaxJerk", - 54 : "Step", - 55 : "PrintSize", - 56 : "Version", - 57 : "Contact", - 58 : "StockConfiguraton", - 59 : "MaxSpeedX", - 60 : "MaxSpeedY", - 61 : "MaxSpeedZ", - 62 : "MaxSpeedE", - 63 : "MaxAccX", - 64 : "MaxAccY", - 65 : "MaxAccZ", - 66 : "MaxAccE", - 67 : "MaxSpeedJerkX", - 68 : "MaxSpeedJerkY", - 69 : "MaxSpeedJerkZ", - 70 : "MaxSpeedJerkE", - 71 : "StepX", - 72 : "StepY", - 73 : "StepZ", - 74 : "StepE", - 75 : "Setspeed", - 76 : "SetZOffset", - 77 : "Rectangle", - 78 : "BLTouch", - 79 : "TempTooLow", - 80 : "AutoLeveling", - 81 : "TempTooHigh", - 82 : "NoTips_C", - 83 : "NoTips_E", - 84 : "Continue_C", - 85 : "Continue_E", - 86 : "Cancel_C", - 87 : "Cancel_E", - 88 : "Confirm_C", - 89 : "Confirm_E", - 90 : "Info_0", - 91 : 'Info_1', - 93 : 'Printer_0', - #94 : 'Printer_1', - 200 : 'Checkbox_F', - 201 : 'Checkbox_T', - 202 : 'Fade', - 203 : 'Mesh', - 204 : 'Tilt', - 205 : 'Brightness', - 206 : 'Probe', - 249 : 'AxisD', - 250 : 'AxisBR', - 251 : 'AxisTR', - 252 : 'AxisBL', - 253 : 'AxisTL', - 254 : 'AxisC' + 0 : "LOGO_Creality", + 1 : "Print_0", + 2 : "Print_1", + 3 : "Prepare_0", + 4 : "Prepare_1", + 5 : "Control_0", + 6 : "Control_1", + 7 : "Leveling_0", + 8 : "Leveling_1", + 9 : "HotendTemp", + 10 : "BedTemp", + 11 : "Speed", + 12 : "Zoffset", + 13 : "Back", + 14 : "File", + 15 : "PrintTime", + 16 : "RemainTime", + 17 : "Setup_0", + 18 : "Setup_1", + 19 : "Pause_0", + 20 : "Pause_1", + 21 : "Continue_0", + 22 : "Continue_1", + 23 : "Stop_0", + 24 : "Stop_1", + 25 : "Bar", + 26 : "More", + 27 : "Axis", + 28 : "CloseMotor", + 29 : "Homing", + 30 : "SetHome", + 31 : "PLAPreheat", + 32 : "ABSPreheat", + 33 : "Cool", + 34 : "Language", + 35 : "MoveX", + 36 : "MoveY", + 37 : "MoveZ", + 38 : "Extruder", + # Skip 39 + 40 : "Temperature", + 41 : "Motion", + 42 : "WriteEEPROM", + 43 : "ReadEEPROM", + 44 : "ResetEEPROM", + 45 : "Info", + 46 : "SetEndTemp", + 47 : "SetBedTemp", + 48 : "FanSpeed", + 49 : "SetPLAPreheat", + 50 : "SetABSPreheat", + 51 : "MaxSpeed", + 52 : "MaxAccelerated", + 53 : "MaxJerk", + 54 : "Step", + 55 : "PrintSize", + 56 : "Version", + 57 : "Contact", + 58 : "StockConfiguraton", + 59 : "MaxSpeedX", + 60 : "MaxSpeedY", + 61 : "MaxSpeedZ", + 62 : "MaxSpeedE", + 63 : "MaxAccX", + 64 : "MaxAccY", + 65 : "MaxAccZ", + 66 : "MaxAccE", + 67 : "MaxSpeedJerkX", + 68 : "MaxSpeedJerkY", + 69 : "MaxSpeedJerkZ", + 70 : "MaxSpeedJerkE", + 71 : "StepX", + 72 : "StepY", + 73 : "StepZ", + 74 : "StepE", + 75 : "Setspeed", + 76 : "SetZOffset", + 77 : "Rectangle", + 78 : "BLTouch", + 79 : "TempTooLow", + 80 : "AutoLeveling", + 81 : "TempTooHigh", + 82 : "NoTips_C", + 83 : "NoTips_E", + 84 : "Continue_C", + 85 : "Continue_E", + 86 : "Cancel_C", + 87 : "Cancel_E", + 88 : "Confirm_C", + 89 : "Confirm_E", + 90 : "Info_0", + 91 : "Info_1", + 93 : "Printer_0", + 200 : "Checkbox_F", + 201 : "Checkbox_T", + 202 : "Fade", + 203 : "Mesh", + 204 : "Tilt", + 205 : "Brightness", + 206 : "Probe", + 249 : "AxisD", + 250 : "AxisBR", + 251 : "AxisTR", + 252 : "AxisBL", + 253 : "AxisTL", + 254 : "AxisC" } diff --git a/display assets/Aquila Display Firmware/Icon Tools/Scripts/DWIN_ICO.py b/display assets/Aquila Display Firmware/Icon Tools/Scripts/DWIN_ICO.py index 14f0c31b66..5fef7155a1 100644 --- a/display assets/Aquila Display Firmware/Icon Tools/Scripts/DWIN_ICO.py +++ b/display assets/Aquila Display Firmware/Icon Tools/Scripts/DWIN_ICO.py @@ -81,16 +81,15 @@ def splitFile(self, filename, outDir): def _parseHeader(self, infile): maxEntries = 256 count = 0 - validEntries = 0 + icon_nums = _iconNames.keys() while count < maxEntries: rawBytes = infile.read(16) entry = Entry() entry.parseRawData(rawBytes) # check that it is valid: is offset nonzero? - # Special case: treat 39 as valid - #if (entry.offset > 0) or (count == 39): - validEntries += 1 - self.entries.append(entry) + # Special case: treat missing numbers as valid + if (entry.offset > 0) or count not in icon_nums: + self.entries.append(entry) count += 1 return @@ -110,16 +109,14 @@ def _splitEntryData(self, infile, outDir): if entry.length == 0: count += 1 continue - # Seek file position, read length bytes, and write to new output file. - print('%02d: offset: 0x%06x len: 0x%04x width: %d height: %d' % - (count, entry.offset, entry.length, entry.width, entry.height)) - outfilename = os.path.join(outDir, - '%03d-%s.jpg' % (count, _iconNames.get(count, "UNKNOWN"))) + outfilename = os.path.join(outDir, '%03d-ICON_%s.jpg' % (count, _iconNames.get(count, "UNKNOWN"))) with open(outfilename, 'wb') as outfile: infile.seek(entry.offset) blob = infile.read(entry.length) outfile.write(blob) - print('Wrote %d bytes to %s' % (entry.length, outfilename)) + # Seek file position, read length bytes, and write to new output file. + print('(%3d: width=%3d height=%3d offset=%6d len=%4d) ... %s' % + (count, entry.width, entry.height, entry.offset, entry.length, os.path.basename(outfilename))) count += 1 return @@ -144,7 +141,7 @@ def createFile(self, iconDir, filename): # process each file: try: index = int(dirEntry.name[0:3]) - if (index < 0) or (index > 255): + if not (0 <= index <= 255): print('...Ignoring invalid index on', dirEntry.path) continue #dirEntry.path is iconDir/name @@ -247,111 +244,111 @@ def serialize(self): return rawdata _iconNames = { - 0 : 'ICON_LOGO', - 1 : 'ICON_Print_0', - 2 : 'ICON_Print_1', - 3 : 'ICON_Prepare_0', - 4 : 'ICON_Prepare_1', - 5 : 'ICON_Control_0', - 6 : 'ICON_Control_1', - 7 : 'ICON_Leveling_0', - 8 : 'ICON_Leveling_1', - 9 : 'ICON_HotendTemp', - 10 : 'ICON_BedTemp', - 11 : 'ICON_Speed', - 12 : 'ICON_Zoffset', - 13 : 'ICON_Back', - 14 : 'ICON_File', - 15 : 'ICON_PrintTime', - 16 : 'ICON_RemainTime', - 17 : 'ICON_Setup_0', - 18 : 'ICON_Setup_1', - 19 : 'ICON_Pause_0', - 20 : 'ICON_Pause_1', - 21 : 'ICON_Continue_0', - 22 : 'ICON_Continue_1', - 23 : 'ICON_Stop_0', - 24 : 'ICON_Stop_1', - 25 : 'ICON_Bar', - 26 : 'ICON_More', - 27 : 'ICON_Axis', - 28 : 'ICON_CloseMotor', - 29 : 'ICON_Homing', - 30 : 'ICON_SetHome', - 31 : 'ICON_PLAPreheat', - 32 : 'ICON_ABSPreheat', - 33 : 'ICON_Cool', - 34 : 'ICON_Language', - 35 : 'ICON_MoveX', - 36 : 'ICON_MoveY', - 37 : 'ICON_MoveZ', - 38 : 'ICON_Extruder', - # no 39 - 40 : 'ICON_Temperature', - 41 : 'ICON_Motion', - 42 : 'ICON_WriteEEPROM', - 43 : 'ICON_ReadEEPROM', - 44 : 'ICON_ResetEEPROM', - 45 : 'ICON_Info', - 46 : 'ICON_SetEndTemp', - 47 : 'ICON_SetBedTemp', - 48 : 'ICON_FanSpeed', - 49 : 'ICON_SetPLAPreheat', - 50 : 'ICON_SetABSPreheat', - 51 : 'ICON_MaxSpeed', - 52 : 'ICON_MaxAccelerated', - 53 : 'ICON_MaxJerk', - 54 : 'ICON_Step', - 55 : 'ICON_PrintSize', - 56 : 'ICON_Version', - 57 : 'ICON_Contact', - 58 : 'ICON_StockConfiguraton', - 59 : 'ICON_MaxSpeedX', - 60 : 'ICON_MaxSpeedY', - 61 : 'ICON_MaxSpeedZ', - 62 : 'ICON_MaxSpeedE', - 63 : 'ICON_MaxAccX', - 64 : 'ICON_MaxAccY', - 65 : 'ICON_MaxAccZ', - 66 : 'ICON_MaxAccE', - 67 : 'ICON_MaxSpeedJerkX', - 68 : 'ICON_MaxSpeedJerkY', - 69 : 'ICON_MaxSpeedJerkZ', - 70 : 'ICON_MaxSpeedJerkE', - 71 : 'ICON_StepX', - 72 : 'ICON_StepY', - 73 : 'ICON_StepZ', - 74 : 'ICON_StepE', - 75 : 'ICON_Setspeed', - 76 : 'ICON_SetZOffset', - 77 : 'ICON_Rectangle', - 78 : 'ICON_BLTouch', - 79 : 'ICON_TempTooLow', - 80 : 'ICON_AutoLeveling', - 81 : 'ICON_TempTooHigh', - 82 : 'ICON_NoTips_C', - 83 : 'ICON_NoTips_E', - 84 : 'ICON_Continue_C', - 85 : 'ICON_Continue_E', - 86 : 'ICON_Cancel_C', - 87 : 'ICON_Cancel_E', - 88 : 'ICON_Confirm_C', - 89 : 'ICON_Confirm_E', - 90 : 'ICON_Info_0', - 91 : 'ICON_Info_1', - 93 : 'ICON_Printer_0', - #94 : 'ICON_Printer_1', - 200 : 'ICON_Checkbox_F', - 201 : 'ICON_Checkbox_T', - 202 : 'ICON_Fade', - 203 : 'ICON_Mesh', - 204 : 'ICON_Tilt', - 205 : 'ICON_Brightness', - 206 : 'ICON_Probe', - 249 : 'ICON_AxisD', - 250 : 'ICON_AxisBR', - 251 : 'ICON_AxisTR', - 252 : 'ICON_AxisBL', - 253 : 'ICON_AxisTL', - 254 : 'ICON_AxisC' + 0 : "LOGO_Creality", + 1 : "Print_0", + 2 : "Print_1", + 3 : "Prepare_0", + 4 : "Prepare_1", + 5 : "Control_0", + 6 : "Control_1", + 7 : "Leveling_0", + 8 : "Leveling_1", + 9 : "HotendTemp", + 10 : "BedTemp", + 11 : "Speed", + 12 : "Zoffset", + 13 : "Back", + 14 : "File", + 15 : "PrintTime", + 16 : "RemainTime", + 17 : "Setup_0", + 18 : "Setup_1", + 19 : "Pause_0", + 20 : "Pause_1", + 21 : "Continue_0", + 22 : "Continue_1", + 23 : "Stop_0", + 24 : "Stop_1", + 25 : "Bar", + 26 : "More", + 27 : "Axis", + 28 : "CloseMotor", + 29 : "Homing", + 30 : "SetHome", + 31 : "PLAPreheat", + 32 : "ABSPreheat", + 33 : "Cool", + 34 : "Language", + 35 : "MoveX", + 36 : "MoveY", + 37 : "MoveZ", + 38 : "Extruder", + # Skip 39 + 40 : "Temperature", + 41 : "Motion", + 42 : "WriteEEPROM", + 43 : "ReadEEPROM", + 44 : "ResetEEPROM", + 45 : "Info", + 46 : "SetEndTemp", + 47 : "SetBedTemp", + 48 : "FanSpeed", + 49 : "SetPLAPreheat", + 50 : "SetABSPreheat", + 51 : "MaxSpeed", + 52 : "MaxAccelerated", + 53 : "MaxJerk", + 54 : "Step", + 55 : "PrintSize", + 56 : "Version", + 57 : "Contact", + 58 : "StockConfiguraton", + 59 : "MaxSpeedX", + 60 : "MaxSpeedY", + 61 : "MaxSpeedZ", + 62 : "MaxSpeedE", + 63 : "MaxAccX", + 64 : "MaxAccY", + 65 : "MaxAccZ", + 66 : "MaxAccE", + 67 : "MaxSpeedJerkX", + 68 : "MaxSpeedJerkY", + 69 : "MaxSpeedJerkZ", + 70 : "MaxSpeedJerkE", + 71 : "StepX", + 72 : "StepY", + 73 : "StepZ", + 74 : "StepE", + 75 : "Setspeed", + 76 : "SetZOffset", + 77 : "Rectangle", + 78 : "BLTouch", + 79 : "TempTooLow", + 80 : "AutoLeveling", + 81 : "TempTooHigh", + 82 : "NoTips_C", + 83 : "NoTips_E", + 84 : "Continue_C", + 85 : "Continue_E", + 86 : "Cancel_C", + 87 : "Cancel_E", + 88 : "Confirm_C", + 89 : "Confirm_E", + 90 : "Info_0", + 91 : "Info_1", + 93 : "Printer_0", + #94 : "Printer_1", + 200 : "Checkbox_F", + 201 : "Checkbox_T", + 202 : "Fade", + 203 : "Mesh", + 204 : "Tilt", + 205 : "Brightness", + 206 : "Probe", + 249 : "AxisD", + 250 : "AxisBR", + 251 : "AxisTR", + 252 : "AxisBL", + 253 : "AxisTL", + 254 : "AxisC" }