-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
5 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
552d170
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 line is in error
bool buttonPressed = digitalRead(SIMPWR_PUSH) == LOW;
you're adding the value of SIMPWR_PUSH to buttonPressed then do a comparison to LOW ( == is a comparison check, = sets a value)
the == LOW should be removed as it's ambiguous at best
552d170
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.
Unrelated, we need to either use adafruit_neopixel library or fastled can not have code for both.
My preference is for the adafuit library as it's easier to work with and understand for most users.
you don't have to understand arrays or indexes and manipulate them as you do in fastled.
552d170
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.
So this is a boolean variable "called" buttonPressed with two possible values, true, and false. On the right-hand side, I'm comparing the SIMPWR_PUSH (D24) current state to LOW which indicates 0v (grounded circuit) since it is a digital pin (normally the pull-up resistor keeps it in a HIGH state). When the button is pushed the comparison becomes true, "true" gets stored in the buttonPressed bool and then used in the rest of the code to do something. When released the comparison becomes "false" and the condition is no longer applied.
552d170
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.
I'm using FastLED solely for the modes and effects otherwise everything is handled via the Adafruit library. I tried building the modes using Adafruit but it got very complicated very quickly to achieve some of the FastLED basic effects. This is the Backlight Controller after all and the backlight is its main function so we can use both if we have to, it won't impact any other function in the SIM. But I'm still working on refining the code after testing it so I will definitely look into that.
552d170
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.
You don't want to use both though, you only want one or the other on the buss at the same time as one will not know what the other has done on that buss and can throw things out of sync really easy.
one other the other, not both please.
552d170
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.
But why even do this when digitalRead returns a LOW or HIGH already as seen here
Also the defines for LOW, HIGH, TRUE FALSE are the same.
i.e.
LOW=FALSE=0
HGIH=TRUE=1
552d170
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 is the higher-level logic I opted for focusing on application specific logic rather than using the Arduino library to interact directly with the hardware and adapt the rest of the code to it, and in coding you can achieve the same thing in many ways, so both of the above lead to the same result. In this instance, I decided that booleans would be more efficient for the rest of my code structure.
552d170
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.
As I mentioned in the post in my build log, I have a couple of issues that I'm working on after testing, and checkButtonPress is one of them. So I might change it entirely but from my perspective I still prefer the higher-level logic for this purpose to simplify the rest of the code. We can have this discussion again soon when I submit the PR.