| 38 | } |
| 39 | |
| 40 | bool ButtonLowLevel::isPressed() { |
| 41 | switch (mStrategy) { |
| 42 | case ButtonStrategy::kHighLowFloating: |
| 43 | return highLowFloating(); |
| 44 | case ButtonStrategy::kPullUp: |
| 45 | // Active-low: Button pulls pin to ground when pressed |
| 46 | return !mPin.high(); |
| 47 | case ButtonStrategy::kPullDown: |
| 48 | // Active-high: Button pulls pin to VCC when pressed |
| 49 | return mPin.high(); |
| 50 | default: |
| 51 | FASTLED_ASSERT(false, "Unknown ButtonLowLevel strategy"); |
| 52 | return false; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | Button::Button(int pin, ButtonStrategy strategy) |
| 57 | : mButton(pin, strategy), mListener(this), mPressedLastFrame(false), mClickedThisFrame(false) {} |
no test coverage detected