MCPcopy Create free account
hub / github.com/FastLED/FastLED / onEndFrame

Method onEndFrame

src/fl/sensors/button.cpp.hpp:59–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 : mButton(pin, strategy), mListener(this), mPressedLastFrame(false), mClickedThisFrame(false) {}
58
59void Button::Listener::onEndFrame() {
60 const bool pressed_curr_frame = mOwner->mButton.isPressed();
61 const bool pressed_last_frame = mOwner->mPressedLastFrame;
62 // Rising edge of isPressed() == one click event for this frame.
63 // mClickedThisFrame must reflect only the current frame's transition;
64 // callers (UIDropdown::Listener, UIButton::clickedCount edge counter)
65 // rely on clicked() being transient, not latched.
66 const bool clicked_this_frame = pressed_curr_frame && !pressed_last_frame;
67 mOwner->mPressedLastFrame = pressed_curr_frame;
68 mOwner->mClickedThisFrame = clicked_this_frame;
69 if (clicked_this_frame) {
70 mOwner->mOnClickCallbacks.invoke();
71 }
72}
73
74Button::Listener::Listener(Button *owner) : mOwner(owner) {
75 addToEngineEventsOnce();

Callers

nothing calls this directly

Calls 2

isPressedMethod · 0.45
invokeMethod · 0.45

Tested by

no test coverage detected