-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
P8: Mirror display for P8b variant #1200
Conversation
2264e55
to
2042cdf
Compare
4413597
to
9a2db73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good but... can we try to avoid #ifdef
s? I always try to use them as a last resort as I think they make the code more difficult to read and to maintain. Also, as the number of setting increases, the number of add_definitions
in CMake will also increase, making it difficult to ensure we'll set consistent values.
Another way to achieve this could be to extend the driver so that it support both modes (mirror and not mirror). The mode would be passed as a parameter of the constructor, and read from a constant (constexpr
) when calling the ctor(). constexpr
will allow the compiler to optimize (remove) the code that is not used.
Those constants could be listed in header files (1 for each supported variant) and included in main.cpp (the correct.h file will be included using CMake magic or #ifdef
).
I think this method will allow to more easily support and maintain multiple variants of the PineTime and the P8. What do you think about this?
@JF002 I like the idea of reducing How would you go about writing these variant-specific header files? A file (e.g. I dont think we can get rid of the CMake config completely, because it sets definitions for e.g. the NRF SDK as well. This could also be used for control of the touch driver behaviour (#1130 (comment)), where @Riksu9000 was rightfully hesitant on littering the code with The acceleration driver (#1132) is already abstracted and split into multiple classes, so a simple flag can be used to select which implementation to use. I believe link-time-optimization will then remove the unneded code. |
@StarGate01 Sorry for the late answer! I'll try to remember what I've already done (I mean... find the git stash with the code :D) and so we can move forward on that topic! |
@JF002 regarding encapsulation, what do you think of the approach of #1132 ? There I split the implementations of the device-specific drivers into two specifications of an abstract class. That would be quite a bit of overkill for this PR imho. I will prepare a |
I think altering a single line with #ifdefs is simple and acceptable. In the case of functions, two or more functions can be defined and #ifdefs only choose which one gets called, which is what I would do in #1130 for example. |
Yes, you are absolutely right @Riksu9000, those changes are pretty limited and harmless for the global architecture, and I think we can merge them. I'm pretty sure we can find a better design than this to support multiple hardware variants, but I unfortunately don't have the time to work on that right now. So, yeah, let's not block time any further. We'll still be able to improve the design in the future :) |
This PR has been broken out of #1050, and depends on / includes #1128 .
A new P8b hardware variant requires the display to be mirrored, and the colors to be inverted. Patch provided by @izzeho .
Related: StarGate01/p8b-infinitime#3