|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Monochrome RGB color picker. More...
#include <ColorPickerView.h>
Public Types | |
| using | SaveCallback = void(*)(uint8_t r, uint8_t g, uint8_t b) |
| Save callback. Values are pre-multiplied with brightness. | |
| using | CancelCallback = void(*)() |
| Cancel callback. The view pops itself before this fires. | |
Public Member Functions | |
| void | init (uint8_t r, uint8_t g, uint8_t b) |
| Initialize the picker with a starting color. | |
| void | setOnSave (SaveCallback cb) |
| Register a save callback (fired on Y). | |
| void | setOnCancel (CancelCallback cb) |
| Register a cancel callback (fired when dismissed with N). | |
| void | currentColor (uint8_t &r, uint8_t &g, uint8_t &b) const |
| Read the currently chosen color (post brightness scaling). | |
| void | render (bool partial) override |
| InputResult | onKey (char key) override |
| void | onTick (uint32_t nowMs) override |
| const char * | getName () const override |
| const char * | getFooterHint () const override |
| 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 |
Monochrome RGB color picker.
Pick an RGB color via barycentric coordinates inside an R/G/B triangle. A separate brightness slider scales the value. The chosen color is previewed as a Bayer-4-dithered box reflecting perceived luminance (Y = 0.299 R + 0.587 G + 0.114 B).
Keys: 2 / 4 / 6 / 8 move cursor inside triangle 7 / 9 brightness -/+ Y save (fires callback with chosen 0..255 R/G/B) N cancel (REQUEST_POP)
Definition at line 24 of file ColorPickerView.h.
| using cdc::ui::ColorPickerView::CancelCallback = void(*)() |
Cancel callback. The view pops itself before this fires.
Definition at line 30 of file ColorPickerView.h.
| using cdc::ui::ColorPickerView::SaveCallback = void(*)(uint8_t r, uint8_t g, uint8_t b) |
Save callback. Values are pre-multiplied with brightness.
Definition at line 27 of file ColorPickerView.h.
| void cdc::ui::ColorPickerView::currentColor | ( | uint8_t & | r, |
| uint8_t & | g, | ||
| uint8_t & | b ) const |
Read the currently chosen color (post brightness scaling).
Definition at line 195 of file ColorPickerView.cpp.
|
overridevirtual |
Get footer hint text (e.g., "[Y] OK [N] Back") Return nullptr for no footer
Reimplemented from cdc::ui::IView.
Definition at line 275 of file ColorPickerView.cpp.
References cdc::ui::ViewBase::customFooter_.
Referenced by render().
|
inlineoverridevirtual |
Get view name for debugging
Implements cdc::ui::IView.
Definition at line 53 of file ColorPickerView.h.
| void cdc::ui::ColorPickerView::init | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b ) |
Initialize the picker with a starting color.
| r | Initial red value (0..255). |
| g | Initial green value (0..255). |
| b | Initial blue value (0..255). |
Definition at line 94 of file ColorPickerView.cpp.
References cdc::ui::ViewBase::dirty_.
|
overridevirtual |
Handle key press
| key | Key character ('0'-'9', 'Y', 'N', etc.) |
Implements cdc::ui::IView.
Definition at line 221 of file ColorPickerView.cpp.
References cdc::ui::CONSUMED, currentColor(), 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 249 of file ColorPickerView.cpp.
References cdc::hal::getKeypadInstance(), REPEAT_INITIAL_MS, and REPEAT_PERIOD_MS.
|
overridevirtual |
Render view content to display buffer
| partial | True for partial update, false for full refresh |
Implements cdc::ui::IView.
Definition at line 280 of file ColorPickerView.cpp.
References currentColor(), cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::ui::render::drawFooterBar(), cdc::ui::layout::FOOTER_HEIGHT, cdc::hal::getDisplayInstance(), getFooterHint(), name, NAME_Y, cdc::ui::render::printText(), and cdc::ui::TEXT_Y.
|
inline |
Register a cancel callback (fired when dismissed with N).
Definition at line 44 of file ColorPickerView.h.
|
inline |
Register a save callback (fired on Y).
Definition at line 41 of file ColorPickerView.h.