-
Notifications
You must be signed in to change notification settings - Fork 356
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
Support for stable effects / palettes configuration #230
Comments
Isn't that a bit too much for just that purpose? Just wondering if one could just use an enumeration (with incrementing values) where the enumeration entry is the friendly name. So why would one need to calculate hashes and store strings? Cleaning the #ifdefs and simplifications in the number of patterns seems to be more useful? on the otherr hand, I would of course be interested in what you come up with ;-) |
I'm interested in the discussion, but I would be fine with just changing the "magic number" when new patterns are added (or any other change that would invalidate stored settings) and reverting to the defaults. Especially given that settings can be imported/exported, saved, etc (although that whole UI could use some improvement). |
@jasoncoon ... Two questions:
Of course, this issue is marked an enhancement. It was created to track my thoughts on how to avoid accidental bugs in future, which could be caught at compile-time. In particular, the following two cases were of particular interest: A. Adding a new pattern, shifting a product's default pattern to a new index, without updating the default pattern in that product's configuration. This is currently not detectable, and is a "surprise" when noticed. My current thinking, which I will now call Option3, avoids the complexities of the
@tobi01001 - YES, I will absolutely share results of static string header, if I get it working as a |
Currently, when the list of palettes or effects changes, any saved configuration is implicitly invalidated. This is because, currently, the value is stored as an integer index into the array. However, it is not currently detected as an invalid saved index. This is also true for the definition of the per-product default effect.
Goals:
Work-in-Progress
Solution is now written (but not yet tested on real hardware). Feedback on design is welcome on PR #234.
complex thoughts using constexpr, now moot
Note
Here, I use the term
string
to refer toconst char *
, typically stored in ROM. The termString
is an Arduino-specific construct, that unfortunately is not currentlyconstexpr
compliant. The termF-string
refers to the Arduino-specific flash string helper, which is also notconstexpr
compliant.Expected functionality required:
constexpr
class that can be constructed fromF-String
orconst char *
asconstexpr
, and supports the below functionalitiesconstexpr
case-sensitive comparisonconstexpr
case-sensitive equalityconstexpr
case-insensitive (US-EN, ASCII only) comparisonconstexpr
case-insensitive (US-EN, ASCII only) equalityconstexpr
case-sensitiveuint32_t
result hash functionconstexpr
conversion to lowercase (US-EN, ASCII only) version of stringThen, given constant arrays of const POD structures, where one member is a
const char *
null-terminated string...A
constexpr
function that, given that array and a hash of a target string, returns a first index to the matching string.A
constexpr
function that, given that array and a targetstring
orF-String
, returns an array index that contains a matching string.Psuedocode strawman
What the above could enable
Other considerations
Maybe there's already a library to do this?
See also:
The text was updated successfully, but these errors were encountered: