|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <SliderView.h>
Public Types | |
| using | SaveCallback = void(*)(uint16_t value) |
| using | ChangeCallback = void(*)(uint16_t value) |
| using | StepCallback = uint16_t(*)(uint16_t currentValue, bool increasing) |
| using | CancelCallback = void(*)() |
Public Member Functions | |
| void | init (const char *title, uint16_t minVal, uint16_t maxVal, uint16_t initial, uint16_t step, const char *unit=nullptr) |
| Initializes slider bounds, value, and display options. | |
| void | setOnSave (SaveCallback callback) |
| void | setOnChange (ChangeCallback callback) |
| void | setStepCallback (StepCallback callback) |
| void | setOnCancel (CancelCallback callback) |
| uint16_t | getValue () const |
| void | setValue (uint16_t value) |
| Sets slider value with range clamping. | |
| void | setDisplayOffset (int16_t offset) |
| void | setZeroLabel (const char *label) |
| void | render (bool partial) override |
| Renders slider title, value text, progress bar, and footer. | |
| InputResult | onKey (char key) override |
| Handles key input for slider adjustment and confirmation. | |
| void | onTick (uint32_t nowMs) override |
| const char * | getName () const override |
| const char * | getFooterHint () const override |
| Returns localized footer hint text. | |
| Public Member Functions inherited from cdc::ui::ViewBase | |
| virtual | ~ViewBase ()=default |
| void | onEnter (void *context) override |
| void | onExit () override |
| void | onResume () override |
| void | onPause () override |
| void | setLifecycleHooks (void(*onHide)(void *), void(*onShow)(void *), void *userData) override |
| bool | needsRender () const override |
| void | markDirty () override |
| void | clearDirty () override |
| void | setFooterHint (const char *hint) override |
| const char * | getFooterHint () const override |
| Public Member Functions inherited from cdc::ui::IView | |
| virtual | ~IView ()=default |
| virtual bool | prefersLightRefresh () const |
| virtual InputResult | onLongPress (char key) |
Additional Inherited Members | |
| Protected Member Functions inherited from cdc::ui::ViewBase | |
| void | setTitle (const char *title) |
| const char * | getTitle () const |
| Protected Attributes inherited from cdc::ui::ViewBase | |
| bool | dirty_ = true |
| const char * | title_ = nullptr |
| const char * | customFooter_ = nullptr |
| void(* | onHide_ )(void *) = nullptr |
| void(* | onShow_ )(void *) = nullptr |
| void * | lifecycleUserData_ = nullptr |
SliderView - Value adjustment with visual bar
Displays a slider bar with current value. Supports min/max/step configuration.
Keys: 4 = Decrease (left) 6 = Increase (right) Y = Save (triggers callback) N = Cancel (REQUEST_POP)
Definition at line 20 of file SliderView.h.
| using cdc::ui::SliderView::CancelCallback = void(*)() |
Cancel callback (called when the user dismisses the view with N). The view pops itself before this fires, so do not call pop() in the handler.
Definition at line 46 of file SliderView.h.
| using cdc::ui::SliderView::ChangeCallback = void(*)(uint16_t value) |
Change callback (called on every value change for real-time updates)
| value | Current value |
Definition at line 32 of file SliderView.h.
| using cdc::ui::SliderView::SaveCallback = void(*)(uint16_t value) |
Save callback (called when Y is pressed)
| value | Final value |
Definition at line 26 of file SliderView.h.
| using cdc::ui::SliderView::StepCallback = uint16_t(*)(uint16_t currentValue, bool increasing) |
Dynamic step callback (returns step size based on current value)
| currentValue | Current slider value |
| increasing | True if increasing, false if decreasing |
Definition at line 40 of file SliderView.h.
|
overridevirtual |
Returns localized footer hint text.
Reimplemented from cdc::ui::IView.
Definition at line 167 of file SliderView.cpp.
References cdc::ui::tr().
Referenced by render().
|
inlineoverridevirtual |
|
inline |
Get current value
Definition at line 84 of file SliderView.h.
| void cdc::ui::SliderView::init | ( | const char * | title, |
| uint16_t | minVal, | ||
| uint16_t | maxVal, | ||
| uint16_t | initial, | ||
| uint16_t | step, | ||
| const char * | unit = nullptr ) |
Initializes slider bounds, value, and display options.
Initialize slider view
| title | Slider title |
| minVal | Minimum value |
| maxVal | Maximum value |
| initial | Initial value |
| step | Step size for adjustments |
| unit | Unit string (e.g., "%", "min") |
| title | Title text shown in the view. |
| minVal | Minimum slider value. |
| maxVal | Maximum slider value. |
| initial | Initial slider value. |
| step | Default step size. |
| unit | Optional value unit suffix. |
Definition at line 45 of file SliderView.cpp.
References cdc::ui::ViewBase::dirty_.
|
overridevirtual |
Handles key input for slider adjustment and confirmation.
| key | Pressed key code. |
Implements cdc::ui::IView.
Definition at line 107 of file SliderView.cpp.
References cdc::ui::CONSUMED, cdc::ui::IGNORED, cdc::ui::ViewStack::instance(), cdc::ui::KEY_NO, cdc::ui::KEY_YES, and cdc::ui::ViewStack::pop().
|
overridevirtual |
Called periodically for animations/timers
| nowMs | Current time in milliseconds |
Reimplemented from cdc::ui::IView.
Definition at line 138 of file SliderView.cpp.
References cdc::hal::getKeypadInstance(), cdc::hal::KEY_4, cdc::hal::KEY_6, REPEAT_INITIAL_MS, and REPEAT_PERIOD_MS.
|
overridevirtual |
Renders slider title, value text, progress bar, and footer.
| partial | Indicates partial/full redraw mode. |
Implements cdc::ui::IView.
Definition at line 176 of file SliderView.cpp.
References BAR_HEIGHT, BAR_MARGIN, BAR_Y, cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::ui::render::drawFooterBar(), cdc::ui::render::drawHeaderCentered(), cdc::hal::getDisplayInstance(), getFooterHint(), cdc::ui::TITLE_Y, and VALUE_Y.
|
inline |
Set display offset (added to value for display only) Useful when internal value differs from displayed value
Definition at line 95 of file SliderView.h.
|
inline |
Set cancel callback (called when the view is dismissed without saving)
Definition at line 79 of file SliderView.h.
|
inline |
Set change callback (called on every value adjustment for real-time updates)
Definition at line 68 of file SliderView.h.
|
inline |
Set save callback (called on Y key)
Definition at line 63 of file SliderView.h.
|
inline |
Set dynamic step callback (overrides fixed step size) For example: brightness uses smaller steps at low values
Definition at line 74 of file SliderView.h.
| void cdc::ui::SliderView::setValue | ( | uint16_t | value | ) |
Sets slider value with range clamping.
Set current value
| value | Target slider value. |
Definition at line 64 of file SliderView.cpp.
References cdc::ui::ViewBase::dirty_.
|
inline |
Set special label for zero value (e.g., "Never" instead of "0")
Definition at line 100 of file SliderView.h.