🚸 Update ProUI Plot graph - part 2 (#26563)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
@@ -76,23 +76,19 @@ class DWIN_ICO_File():
|
||||
self._parseHeader(infile)
|
||||
self._splitEntryData(infile, outDir)
|
||||
|
||||
return
|
||||
|
||||
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
|
||||
# Special case: treat missing numbers as valid
|
||||
if (entry.offset > 0) or count not in icon_nums:
|
||||
self.entries.append(entry)
|
||||
count += 1
|
||||
return
|
||||
|
||||
def _splitEntryData(self, infile, outDir):
|
||||
print('Splitting Entry Data...')
|
||||
@@ -110,18 +106,16 @@ class DWIN_ICO_File():
|
||||
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, _iconNames7[count]))
|
||||
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
|
||||
|
||||
def createFile(self, iconDir, filename):
|
||||
'''Create a new .ico file from the contents of iconDir.
|
||||
@@ -179,7 +173,6 @@ class DWIN_ICO_File():
|
||||
offset += e.length
|
||||
#print('%03d: (%d x %d) len=%d off=%d' %
|
||||
# (i, e.width, e.height, e.length, e.offset))
|
||||
return
|
||||
|
||||
def _combineAndWriteIcoFile(self, filename):
|
||||
"""Write out final .ico file.
|
||||
@@ -198,7 +191,6 @@ class DWIN_ICO_File():
|
||||
if 0 == e.length: continue
|
||||
guts = self._getFileContents(e.filename, e.length)
|
||||
outfile.write(guts)
|
||||
return
|
||||
|
||||
def _getFileContents(self, filename, length):
|
||||
"""Read contents of filename, and return bytes"""
|
||||
@@ -232,7 +224,6 @@ class Entry():
|
||||
self.height = h
|
||||
self.offset = off
|
||||
self.length = len3 * 65536 + len21
|
||||
return
|
||||
|
||||
def serialize(self):
|
||||
"""Convert this Entry's information into a 16-byte
|
||||
@@ -245,97 +236,112 @@ class Entry():
|
||||
0, 0, 0, 0, 0)
|
||||
return rawdata
|
||||
|
||||
_iconNames7 = {
|
||||
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"
|
||||
_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",
|
||||
92 : "DegreesC",
|
||||
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"
|
||||
}
|
||||
|
Reference in New Issue
Block a user