ghtalpo / py_amazfit_tools

pack/unpack .bin for amazfit verge lite/gtr/gts
56 stars 53 forks source link

Coordinates and Array #19

Closed dpeddi closed 4 years ago

dpeddi commented 4 years ago

https://github.com/ghtalpo/py_amazfit_tools/blob/c60698659f33bfd5fb781e0bf0e3e26f661a6ecc/watchFaceParser/utils/parametersConverter.py#L93

Hi, I've seen that on GTS the coordinates sometime can be an Array/List.

I've tried to implement something to make unpack/pack to work correctly, but I can't figure out the best way to do that

I think the json should become something like this:

"Battery": { "Icons": { "FirtsImageIndex": 12, "Coordinates": [ { "X": 10, "Y": 20 }, { "X": 20, "Y": 10 }, ] } } },

Any hint?

Regards, Eddi

ghtalpo commented 4 years ago

let me have .bin that cause the problem.

dpeddi commented 4 years ago

here is it https://store-cdn.huami.com/market_app/20191023/fd891038012c5fd86d94679d6fc42c69.bin https://img-cdn.huami.com/20191023/8b4cf10975b112a02f7be8e915be9a52.png

I was able to produce such json... I'll commit later my fork some ideas: https://github.com/amazfitbip/py_amazfit_tools

sill working on repack...

dpeddi commented 4 years ago

I should have added something to process correctly the new structure... https://github.com/amazfitbip/py_amazfit_tools/commits/fix_array

I need some more debug and cleanup ... please give a look

probably need some more implementation on resourceloader

dpeddi commented 4 years ago

I've modified resourceloader as well.. now i can get a near-to-original packaged file. Should I pull request?

ghtalpo commented 4 years ago

sure. pull request is always welcomed.

andrewjswan commented 4 years ago

@dpeddi Now your script supports only GTS: https://github.com/amazfitbip/py_amazfit_tools/blob/fix_array/main.py#L17-L18 Plz add choise GTR or GTS like:

    if args.gtr is None and args.gts is False:
        print("GTR/GTS mode missing.")
        sys.exit()

    if args.gtr is not None:
        print("GTR %s Mode..." % (args.gtr))
        Config.setGtrMode(args.gtr)
    if args.gts is not False:
        print("GTS Mode...")
        Config.setGtsMode(args.gts)
dpeddi commented 4 years ago

@ghtalpo will prepare @andrewjswan fixed, however if you don't set both gtr and gts mode you should be in verge lite mode (no idea about what really differs)

andrewjswan commented 4 years ago

@dpeddi different screen size and headers :) but for verge it is better to add a separate parameter :)

andrewjswan commented 4 years ago

@dpeddi Changes in fix_array branch create the wrong preview image and animation. The battery charge arrow moves along with the seconds arrow. The hour, minute and second layer overlaps all the hands, hour, minute and second. And there should be such an order, an hour hand, an hour layer. Minute hand, minute layer. Second hand, second layer.

dpeddi commented 4 years ago

@andrewjswan the preview have lower priority for me. Is more important to pack and unpack the wf.

andrewjswan commented 4 years ago

@dpeddi If the pictures are numbered out of order, then the script throws an error saying that the files were not found...

andrewjswan commented 4 years ago

@dpeddi In the same way, the initial and final angle in the arrow of the battery charge indication is incomprehensibly transformed. Instead of 180* in JSON, we get the number 18000 ...

sykiat89 commented 4 years ago

Nice work dpeddi!

sykiat89 commented 4 years ago

@dpeddi In the same way, the initial and final angle in the arrow of the battery charge indication is incomprehensibly transformed. Instead of 180* in JSON, we get the number 18000 ...

The sector angle ie. 18000 is probably intended to make way for decimal points. Take for example analogDOW, starting angle needs to be in 51.43, or 5143 in this case.

andrewjswan commented 4 years ago

Take for example analogDOW, starting angle needs to be in 51.43, or 5143 in this case.

Why not use 51.43 instead 5143 in JSON. JSON support Real number ... StartAngel: 180 or 51.43 better than 18000 or 5143 ...

sykiat89 commented 4 years ago

Take for example analogDOW, starting angle needs to be in 51.43, or 5143 in this case.

Why not use 51.43 instead 5143 in JSON. JSON support Real number ... StartAngel: 180 or 51.43 better than 18000 or 5143 ...

You cant have decimal for integer parameter.

andrewjswan commented 4 years ago

You cant have decimal for integer parameter

Converting one to another is not a problem.

sykiat89 commented 4 years ago

@dpeddi The array seems to be working. Any plans to include parameter 12 (heart)?

dpeddi commented 4 years ago

@dpeddi The array seems to be working. Any plans to include parameter 12 (heart)?

On which original wf and for what whatch it can be found?

sykiat89 commented 4 years ago

@dpeddi The array seems to be working. Any plans to include parameter 12 (heart)?

On which original wf and for what whatch it can be found?

Classic Number on GTR47.

Json probably look something like this.

"Heart": { "Scale": { "StartImageIndex": 78, "Segments": [ { "X": 70, "Y": 215, "X2": 0, "Y2": 0, "X3": 0 }, { "X": 70, "Y": 215, "X2": 0, "Y2": 0, "X3": 0 }, { "X": 70, "Y": 215, "X2": 0, "Y2": 0, "X3": 0 }, { "X": 70, "Y": 215, "X2": 0, "Y2": 0, "X3": 0 }, { "X": 70, "Y": 215, "X2": 0, "Y2": 0, "X3": 0 } ] } }

sykiat89 commented 4 years ago

@dpeddi how do you manage to get direct download link straight from huami?

dpeddi commented 4 years ago

@dpeddi how do you manage to get direct download link straight from huami?

I developed a crawler but I keep it private to avoid changing of the api

sykiat89 commented 4 years ago

@dpeddi you managed to identify the bin files? I tried adding parameter 12 on the watchface.py and watchparser.elements but no avail.

sykiat89 commented 4 years ago

@dpeddi didnt realise its under Activity element! Thanks dpeddi for your hardwork.

sykiat89 commented 4 years ago

@dpeddi I've managed to unpacked the rainbowcircle.bin and managed to extract the files inside. Im interested with the kcal. Inspecting the json file, its categorised under StepsGoal. However, upon repacking and installed, the rest of the elements work except for the StepsGoal. Not too sure of the error here.

dpeddi commented 4 years ago

I suspect it can be the same issue like sports circle on gts. Still trying to figure out the issue.

kampanita commented 4 years ago

I also unpacked it and also get some other things like "Goal2" It can be unpacked but not repacked, tool does not understand new parameters:

2020-01-09 10:08:34,645 - root - DEBUG - Reading config... 2020-01-09 10:08:34,646 - root - DEBUG - t: { "Background": { "Image": { "X": 0, "Y": 0, "ImageIndex": 0 }, "Preview": { "X": 0, "Y": 0, "ImageIndex": 1 } }, "Activity": { "Calories": { "TopLeftX": 313, "TopLeftY": 235, "BottomRightX": 353, "BottomRightY": 257, "Alignment": "TopCenter", "Spacing": 0, "ImageIndex": 2, "ImagesCount": 10 }, "Pulse": { "TopLeftX": 212, "TopLeftY": 331, "BottomRightX": 242, "BottomRightY": 353, "Alignment": "TopCenter", "Spacing": 0, "ImageIndex": 12, "ImagesCount": 10 }, "Steps": { "Step": { "TopLeftX": 96, "TopLeftY": 235, "BottomRightX": 146, "BottomRightY": 257, "Alignment": "TopCenter", "Spacing": 0, "ImageIndex": 23, "ImagesCount": 10 } }, "Goal2": { "CenterX": 227, "CenterY": 323, "RadiusX": 61, "RadiusY": 61, "StartAngle": 0, "EndAngle": 360, "Width": 10, "Color": "0xFF0A1101", "Flatness": 180, "ImageIndex": 33 }, "NoDataImageIndex": 22, "Unknown17": { "BottomRightY": null }, "StepsGoal": { "CenterX": 333, "CenterY": 227, "RadiusX": 61, "RadiusY": 61, "StartAngle": 0, "EndAngle": 360, "Width": 10, "Color": "0xFF10B0A1", "Flatness": 180, "ImageIndex": 34 } }, "StepsProgress": { "Circle": { "CenterX": 121, "CenterY": 227, "RadiusX": 61, "RadiusY": 61, "StartAngle": 0, "EndAngle": 360, "Width": 10, "Color": "0xFF0370A1", "Flatness": 180, "ImageIndex": 35 }, "ClockHand": { "OnlyBorder": false, "Color": "0x00000000", "CenterOffset": { "X": 0, "Y": 0 }, "Shape": { "X": 0, "Y": 0 } } }, "Battery": { "Text": { "TopLeftX": 204, "TopLeftY": 139, "BottomRightX": 250, "BottomRightY": 161, "Alignment": "TopCenter", "Spacing": 0, "ImageIndex": 36, "ImagesCount": 10 }, "Unknown4": { "OnlyBorder": false, "Color": "0x00000000", "CenterOffset": { "X": 0, "Y": 0 }, "Shape": { "X": 0, "Y": 0 } }, "Percent": { "X": 0, "Y": 0, "ImageIndex": 46 }, "Scale": { "CenterX": 227, "CenterY": 131, "RadiusX": 61, "RadiusY": 61, "StartAngle": 0, "EndAngle": 360, "Width": 10, "Color": "0xFF0A1041", "Flatness": 180, "ImageIndex": 47 } }, "AnalogDialFace": { "Hours": { "OnlyBorder": false, "Color": "0x00000000", "CenterOffset": { "X": 0, "Y": 0 }, "Shape": { "X": 0, "Y": 0 }, "Image": { "X": 13, "Y": 141, "ImageIndex": 48 } }, "Minutes": { "OnlyBorder": false, "Color": "0x00000000", "CenterOffset": { "X": 0, "Y": 0 }, "Shape": { "X": 0, "Y": 0 }, "Image": { "X": 9, "Y": 183, "ImageIndex": 49 } }, "Seconds": { "OnlyBorder": false, "Color": "0x00000000", "CenterOffset": { "X": 0, "Y": 0 }, "Shape": { "X": 0, "Y": 0 }, "Image": { "X": 6, "Y": 190, "ImageIndex": 50 } } }, "DaysProgress": { "AnalogMonth": { "OnlyBorder": false, "Color": "0x00000000", "CenterOffset": { "X": 0, "Y": 0 }, "Shape": { "X": 0, "Y": 0 } }, "UnknownField2": { "OnlyBorder": false, "Color": "0x00000000", "CenterOffset": { "X": 0, "Y": 0 }, "Shape": { "X": 0, "Y": 0 } }, "AnalogDOW": { "OnlyBorder": false, "Color": "0x00000000", "CenterOffset": { "X": 0, "Y": 0 }, "Shape": { "X": 0, "Y": 0 } } } } 2020-01-09 10:08:34,646 - root - DEBUG - Reading referenced images from './Amazfit_RainbowCircle' 2020-01-09 10:08:34,647 - root - DEBUG - Loading resources for 2 '<class 'watchFaceParser.elements.background.Background'>' 2020-01-09 10:08:34,647 - root - DEBUG - Loading resources for 2.1 '<class 'watchFaceParser.elements.basicElements.image.Image'>' 2020-01-09 10:08:34,647 - root - DEBUG - Loading image 0... 2020-01-09 10:08:34,719 - PIL.PngImagePlugin - DEBUG - STREAM b'IHDR' 16 13 2020-01-09 10:08:34,719 - PIL.PngImagePlugin - DEBUG - STREAM b'IDAT' 41 62526 2020-01-09 10:08:34,719 - root - DEBUG - Loading resources for 2.3 '<class 'watchFaceParser.elements.basicElements.image.Image'>' 2020-01-09 10:08:34,719 - root - DEBUG - Loading image 1... 2020-01-09 10:08:34,720 - PIL.PngImagePlugin - DEBUG - STREAM b'IHDR' 16 13 2020-01-09 10:08:34,720 - PIL.PngImagePlugin - DEBUG - STREAM b'IDAT' 41 50218 2020-01-09 10:08:34,720 - root - DEBUG - Loading resources for 4 '<class 'watchFaceParser.elements.activity.Activity'>' 2020-01-09 10:08:34,721 - root - DEBUG - Loading resources for 4.1 '<class 'watchFaceParser.elements.basicElements.number.Number'>' 2020-01-09 10:08:34,721 - root - DEBUG - Loading image 2... 2020-01-09 10:08:34,721 - PIL.PngImagePlugin - DEBUG - STREAM b'IHDR' 16 13 2020-01-09 10:08:34,721 - PIL.PngImagePlugin - DEBUG - STREAM b'IDAT' 41 8606 2020-01-09 10:08:34,722 - root - CRITICAL - unsupported operand type(s) for +: 'int' and 'NoneType' Traceback (most recent call last): File "C:\amazfit\py_amazfit_tools-dev_gtr\program.py", line 61, in writeWatchFace imagesReader.process(WatchFace, watchFace) File "C:\amazfit\py_amazfit_tools-dev_gtr\watchFaceParser\utils\resourcesLoader.py", line 94, in process self.process(propertyType, propertyValue, currentPath) File "C:\amazfit\py_amazfit_tools-dev_gtr\watchFaceParser\utils\resourcesLoader.py", line 94, in process self.process(propertyType, propertyValue, currentPath) File "C:\amazfit\py_amazfit_tools-dev_gtr\watchFaceParser\utils\resourcesLoader.py", line 89, in process for i in range(lastImageIndexValue + 1, lastImageIndexValue + imagesCount): TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

dpeddi commented 4 years ago

Closing this issue... Is going out of the main scope. I'm trying to merge back your latest Change on my tree. When ready I will pull request.

dpeddi commented 4 years ago

I merged your commit into mine but the packed resource doesn't work... need more rework on my fork to pull request...