Replies: 5 comments 7 replies
-
I'm definitely for reducing the decoders' sizes in any way possible. There will only ever be more decoders in the future, not less ;) While I find abbreviating as much as possible, especially with reucrring "servicedata", "manufacturerdata", "value_from_hex_data" and the likes, I also think it very important to clearly state this in the docs, so as to avoid confusing people or even making the start into getting into creating new decoders more of a hurdle. For me everything being completely written out definitely helped in getting started. Other than that I also very much like to push the binary-bit decoder option, as this will make such a big impact on compressing decoder sizes. I started thinking and testing it while working more on the SwicthBot decoders, with, you wouldn't have guessed it, the simple sounding motion sensor being a real beast. Not even open for discussion in submitting it anywhere close to what it is now. https://github.com/DigiH/decoder/blob/switchbot-motion/src/devices/SBMS_json.h Even with some, possibly not so necessary, properties removed it would still be huge. This is how I then started testing a binary-bit implementation. I think all that is needed is for a single hex-byte digit to be tested for values of any of its corresponding 4-bit binary. This would allow for nearly all the current multi-OR conditions to only have a single such condition. Even when most of the part of 2 hex bytes are used, as in @1technophile's example of the SwitchBots' battery 7 binary bits, instead of creating an additional hex-to-binary-to-decimal decoding routine this can also easily, and quite briefly be substituted as currently with an underscore variant and subtraction (-128) by checking bit[3] of digit[1] of the 2 byte hex, so
would turn into
and much the same with all other multi-OR conditions. Just a thought in also getting the decoder sizes down. |
Beta Was this translation helpful? Give feedback.
-
Yes, that is another addition to the overall efficiency improvement going forward. We should focus on the low hanging fruit first and tackle the harder to reach stuff once that's done. Any suggestions for the abbreviations? Other ideas? |
Beta Was this translation helpful? Give feedback.
-
I like your suggestions of
also
with the functions I would drop the d(ata) at the end, and maybe use the saved letter for an extra written out hex at the end for clarity?!?
|
Beta Was this translation helpful? Give feedback.
-
Apologies for coming back to this, but please have a look at my 4-bit binary condition testing test, and the included changed SwitchBot S1 decoder with quite a bit of saving through the direct 4-bit binary evaluations. Existing S1 tests running fine. Still a bit messy though, with I'm just worried that without such direct binary bit condition possibility any further SwitchBot decoders won't really be feasible. But as per the topic, I think we should start with shortening definitions as much as possible :) Thanks |
Beta Was this translation helpful? Give feedback.
-
For interest I started abbreviating these and figured I'd put a bit of performance into it as well. I pushed the branch here, there's more that can be done but this is a start. OMG code size before:
After:
So far it's saved ~1100 bytes, not as much as hoped but it's something 😄 |
Beta Was this translation helpful? Give feedback.
-
Seems the decoders are getting larger and larger, one way we could compress these a bit would be to abbreviate certain terms.
For instance we could abbreviate the word "service data" to "svcd" and "manufacturerdata" to "mfrd" or something similar.
The functions could be abbreviated also "value_from_hex_data" could just be "vfhd".
Interested to hear thoughts on this. I think it would be a large size improvement and help performance.
Beta Was this translation helpful? Give feedback.
All reactions