Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REQUEST: Add compatibility with Mi Band 4? #61

Open
g0wfv opened this issue Jul 3, 2019 · 3 comments
Open

REQUEST: Add compatibility with Mi Band 4? #61

g0wfv opened this issue Jul 3, 2019 · 3 comments

Comments

@g0wfv
Copy link

g0wfv commented Jul 3, 2019

Is it possible for dial2img.py to be modified to work with Mi Band 4 .bin file?

@dpeddi
Copy link
Contributor

dpeddi commented Jul 3, 2019

Maybe but I have few spare time now... If someone could help I can add him/her to this project as developer

@g0wfv
Copy link
Author

g0wfv commented Jul 4, 2019

Done it!

The fix was very simple in the end ....

306c306,323
< 		PLTE_len='\x00\x00\x00'+chr(len(PLTE_chunk))
---
>                 char1=len(PLTE_chunk)
>                 char2=0
>                 char3=0
>                 char4=0
> 
>                 while char1>16777216:
>                         char4=char4+1
>                         char1=char1-16777216
> 
>                 while char1>65536:
>                         char3=char3+1
>                         char1=char1-65536
> 
>                 while char1>256:
>                         char2=char2+1
>                         char1=char1-256
> 
>                 PLTE_len=chr(char4)+chr(char3)+chr(char2)+chr(char1)

Although this is overkill (handles more colours than the Mi Band 4 can use apparently!) it should be future proof to a certain degree, and there's probably a more elegant way to do it!

@paduel
Copy link

paduel commented Jul 31, 2019

This code does the same thing, but it's more compact.

char_r=len(PLTE_chunk)
PLTE_len = ''
for p in range(3,-1,-1):
    char_d, char_r = divmod(char_r, 256**p)
    PLTE_len = PLTE_len + chr(char_d)

But in any case, when I try to unpack a Mi Band 4 bin file, it determines the number of resources, throws a 0 version and a negative resoffset, and finally tells me for all resources ERROR: 83 isn't a bitmap resource

@g0wfv how did you get it to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants