-
-
Notifications
You must be signed in to change notification settings - Fork 745
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
Refactor display settings handling in BLE callback #1594
Comments
Here's three different ways to make that a little less grubby. I prefer the style of the first one, all other things being equal. switch (uuid_value) { Or keep it like this, but don't force common subexpression elimination to determine the mutual exclusivity of the paths: if (uuid_value == SettingsOptions::OLEDInversion) { You could possibly shave a few clock cycles off making PMFs to the three methods, masking the bottom two bits from uuid_value and jumping through a function dispatch table with the constant arguments andtesting explictly for the last one and doing something similar after a mask. A self-respecting optimizer MAY do this for you if it can determine these are pure functions (i.e. they're marked const and can be proven to not modify larger scope. If you need clock cycles this badly, you're probably living wrong, but I"m all about giving choices. Consider marking the functions const: static void setBrightness(uint8_t contrast) const; ... if you can. If you're not modifying any state of the OLED class (e.g. no globals, no honking on the invisible this*) that even further clarifies the code and exposes additional optimizationopportunities. |
@NeilHanlon |
@NeilHanlon of the new options for the code that GPSBabel suggested to make it better, which one are you going to Submit? it should be submitted asap though so that it can go into the 2.21 release yes? |
Yep, any of these would be fine for implementing. Was planning to get back to this soon, but thank you for taking it @discip ! |
No, this is not implemented yet. |
thanks @discip |
I wrote the following in #1592 , but it's not great.
IronOS/source/Core/BSP/Pinecilv2/ble_handlers.cpp
Lines 246 to 255 in 68d18a4
There is probably a better way to handle this than three if statements in a row :)
Open to suggestions
The text was updated successfully, but these errors were encountered: