Experimenting with bigger face values

I just submitted a working experiment to my custom Blinklib. You can now, per-project, decide what do you want the size of face values to be. The official Blinklid supports values 0-64 (6 bits). My custom Blinklib without the recent changes, supports values form 0 to 255 (8 bits).

Now with the experiment, you can use any unsigned integer types. Just moving from byte to uint16_t moves you from 256 possible values (8 bits) to 65535 possible values (16 bits). And you do not need to stop there.

The idea is to allow the same tried and trusted face value algorithms but now with the possibility of exchanging a lot more data.

This change has no impact on storage in Blinklib and uses extra bytes proportional to the new size used (going from byte to uint16_t will use 12 extra bytes).

If anyone is interested in trying this out, let me know and I will explain how.

1 Like

I think many people will find this functionality very useful! For example I can see using a struct with bitfields as the data type to make code much cleaner in many cases.

So the type is defined in blinklib_config.h in the sketch directory?

Do you think it would be possible to define this type inline with c++ templates?

Thanks!

1 Like

Yep. You can use structs if you have a copy constructor for them as this method does not support pointer types as it is (but this might be something to be considered).

Yep. Currently you just add this (for example) to config/blinklib_config.h:

#define BGA_CUSTOM_BLINKLIB_FACE_VALUE_TYPE uint16_t

And that basically triggers every relevant part of blinklib to adjust to that.

Yep, I can see this working. For Blinks projects I prefer to not use any more advanced C++ feature simply because it is a bit more complicated to reason about. If the compiler is smart and does what you expect, you might end up with very compact code. If it does not, then figuring out why will take more time. I am this close to using some inline assembly on Hexxagon because of that (now at 99% storage use and needing another 5% or so to do something).