36#ifdef LV_LVGL_H_INCLUDE_SIMPLE
47static std::string eventNames[_LV_EVENT_LAST];
80 lvppBase(
const char* fName,
const char* oType);
134 virtual void setSize(lv_coord_t width, lv_coord_t height);
145 void align(lv_align_t
align, lv_coord_t x_ofs, lv_coord_t y_ofs);
163 void setFont(
const lv_font_t* pF);
179 void setColorGradient(lv_color_t col1, lv_color_t col2, lv_grad_dir_t direction);
185 virtual void setText(
const char* pText);
233 virtual void setAdjText(
const char* pText, lv_coord_t x_ofs=-10000, lv_coord_t y_ofs=-10000);
394 void createAdjLabel();
436 virtual void setValue(int16_t value,
bool animate=
true);
457 void enableValueLabel(lv_coord_t xoff, lv_coord_t yoff, lv_align_t alignment=LV_ALIGN_CENTER);
528 virtual void baseSetter(int16_t nVal,
bool animate=
true) = 0;
535 void createValueLabel();
560 virtual void setOptions(std::vector<std::string>& _opts);
568 virtual void setOptionsWithIDs(std::vector<std::pair<std::string, uint64_t>>& valIDs);
574 virtual void addOption(
const char* pOpt);
588 virtual void addOption(std::string& _opt);
lvppBase is the root of the C++ library LVGLPlusPlus. It strives to create consistent ways to manipul...
Definition: lvppBase.h:70
virtual void onValueChanged()
Callback that derived objects can use to get notification when the value changes of an object.
Definition: lvppBase.h:282
void setFriendlyName(const char *pName)
Set the Friendly Name of the object. This is the name given in the constructor's fName parameter and ...
Definition: lvppBase.cpp:346
static bool isUnknownCode(lv_event_code_t code)
Check to see if an event code is valid or not. Utility function.
Definition: lvppBase.cpp:398
static void initEventNames(void)
One-time initialization of the event names array.
Definition: lvppBase.cpp:364
void setFont(const lv_font_t *pF)
Set the Font to be used. This is a more complete/complex version of setFontSize()....
Definition: lvppBase.cpp:97
const char * whoAmI(void)
Utility useful for dumping the friendly name and object type if needed.
Definition: lvppBase.cpp:352
std::string getText()
Get the Text from the object/label and put it in a std::string.
Definition: lvppBase.cpp:200
void align(lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs)
Change the x/y location of the object.
Definition: lvppBase.cpp:185
void setObjType(const char *pType)
Definition: lvppBase.h:364
lv_obj_t * getLabelObj(void)
Get the label object.
Definition: lvppBase.h:124
std::function< void()> cbOnClicked
Start without a lambda callback.
Definition: lvppBase.h:357
void setCallbackOnClicked(std::function< void()> cbF)
Uses a lambda callback for when an object is clicked.
Definition: lvppBase.h:326
lv_obj_t * objParent
Any parent object (following same principle as LVGL here)
Definition: lvppBase.h:360
virtual void onClicked()
Callback that derived objects can use to get notification when the object is clicked.
Definition: lvppBase.h:271
lv_obj_t * label
Primary label.
Definition: lvppBase.h:355
void setFontSize(uint8_t points)
Set the Font Size for the object in simple 'points'.
Definition: lvppBase.cpp:57
void setAdjFont(const lv_font_t *pF)
Set the Font to be used for the adjacent text.
Definition: lvppBase.cpp:266
std::string friendlyName
Definition: lvppBase.h:362
static bool bEventNamesInitComplete
Status of the event names table to avoid re-processing.
Definition: lvppBase.h:391
virtual void internalOnValueChanged()
Internal version of the onValueChanged() callback which is used for other derived internal objects in...
Definition: lvppBase.h:288
void setLabelJustificationAlignment(lv_text_align_t _align)
Set the Label's text alignment (left/right/center)
Definition: lvppBase.cpp:223
std::string getFriendlyName()
Get the Friendly Name of the object.
Definition: lvppBase.h:301
void setAdjBGColor(lv_color_t color)
set the background color for the adjacent text
Definition: lvppBase.cpp:251
std::string objType
Definition: lvppBase.h:361
void setCallbackOnValueChanged(std::function< void()> cbF)
Uses a lambda callback for when an object value changes.
Definition: lvppBase.h:341
lv_obj_t * obj
The LVGL object that was created for this widget.
Definition: lvppBase.h:359
void setBGColor(lv_color_t color)
Set the background color of the object.
Definition: lvppBase.cpp:105
void setAdjColorGradient(lv_color_t col1, lv_color_t col2, lv_grad_dir_t direction)
Sets a Color Gradient from col1 to col2 in a vertical or horizontal direction.
Definition: lvppBase.cpp:258
std::function< void()> cbOnValueChanged
Start without a lambda callback.
Definition: lvppBase.h:358
virtual void setSize(lv_coord_t width, lv_coord_t height)
Set the Size object. Most of the time, LVGL does a great job of setting a sane size,...
Definition: lvppBase.cpp:339
virtual void setAdjText(const char *pText, lv_coord_t x_ofs=-10000, lv_coord_t y_ofs=-10000)
Set the text for the adjacent text label. This label is not enabled by default. Setting this text wil...
Definition: lvppBase.cpp:235
static const char * getEventName(lv_event_code_t code)
Get the Event Name from a given event code. Translate it to text, essentially.
Definition: lvppBase.cpp:402
virtual void setNewParent(lv_obj_t *pNewParent)
Changes the parent object on the fly. Used primarily for lvppScreen::addObject(). Sets parents of adj...
Definition: lvppBase.cpp:419
virtual void eventHandler(lv_event_t *event)
Any events not handled by baseEventHandler come here. Can be overridden by a derived class.
Definition: lvppBase.h:377
std::string getObjType()
Get the Obj Type.
Definition: lvppBase.h:309
void createObj(lv_obj_t *o)
Create the handlers and store the newly created object.
Definition: lvppBase.cpp:278
void setAdjTextColor(lv_color_t newColor)
Set the Adjacent text color.
Definition: lvppBase.cpp:245
void setTextColor(lv_color_t newColor)
Set the Text Color of the primary label object.
Definition: lvppBase.cpp:215
virtual void internalOnClicked()
Internal version of the onClicked() callback which is used for other derived internal objects in the ...
Definition: lvppBase.h:277
void setColorGradient(lv_color_t col1, lv_color_t col2, lv_grad_dir_t direction)
Sets a Color Gradient from col1 to col2 in a vertical or horizontal direction. The gradient is place ...
Definition: lvppBase.cpp:116
static void lvCallback(lv_event_t *event)
Static member to handle all inbound callback events. Used to "route" event handling to the appropriat...
Definition: lvppBase.cpp:295
void setAdjJustificationAlignment(lv_text_align_t _align)
Set the adjacent Label's text alignment (left/right/center)
Definition: lvppBase.cpp:272
void setTextAlign(lv_align_t align, lv_coord_t xoff, lv_coord_t yoff)
Set the Text Alignment. This allows the object's primary label to be moved from its 'center' position...
Definition: lvppBase.cpp:209
lv_style_t style_obj
Main style object - unsure if I'm handling all of the style bit correctly.
Definition: lvppBase.h:363
lv_obj_t * adjLabel
For items that have a label 'nearby' (adjacent label)
Definition: lvppBase.h:356
~lvppBase()
Definition: lvppBase.cpp:153
virtual void setText(const char *pText)
Set the Text for the primary text label. For a button, for instance, this is the text on top of the b...
Definition: lvppBase.cpp:190
void setLabelColorizationEnabled(bool bEnable=true)
Turn on or off inline text colorization. To use colors inline, simply use #RRGGBB in the text where t...
Definition: lvppBase.cpp:229
lv_obj_t * getObj(void)
Get the Obj object.
Definition: lvppBase.h:116
void baseEventHandler(lv_event_t *event)
Main event handler loop for all events. This handler makes calls for onClicked() and onValueChanged()
Definition: lvppBase.cpp:303
Derivation from lvppBase. Those widgets which have an inherant 'value' to show are based on this slig...
Definition: lvppBase.h:408
virtual void setValue(int16_t value, bool animate=true)
Set the Value associated with the object. This is a pure virtual function and must be overridden and ...
Definition: lvppBase.cpp:452
virtual int16_t baseGetter()=0
Derived classes must implement this pure virtual by getting the current value from the widget itself....
int16_t min
Definition: lvppBase.h:533
virtual void baseSetter(int16_t nVal, bool animate=true)=0
Derived classes must implement this pure virtual which sets the current value of the widget itself....
lv_obj_t * valueLabel
The label that receives the formatted value if the label is enabled.
Definition: lvppBase.h:531
std::string valueLabelFormat
The format to use when the value changes.
Definition: lvppBase.h:532
uint16_t getValuePercentage(void)
Get the 'percentage' Value from the object. This is the percentage represented from min to max of the...
Definition: lvppBase.h:449
int16_t getValue(void)
Get the Value from the object.
Definition: lvppBase.h:442
void setValueRange(int16_t _min, int16_t _max)
Set the Value Range allowed. NOTE: This enforcement needs to happen in the derived setValue() functio...
Definition: lvppBase.h:505
void enableValueLabel(lv_coord_t xoff, lv_coord_t yoff, lv_align_t alignment=LV_ALIGN_CENTER)
In the case where a label is desired to be shown for the value, enable it and align it here.
Definition: lvppBase.cpp:467
void setValueLabelFormat(const char *fmt)
Set the Value Label Format. This 'format' allows the label to be more than simply a number....
Definition: lvppBase.cpp:481
int16_t max
The allowable range of the value.
Definition: lvppBase.h:533
void setValueLabelBGColor(lv_color_t newColor)
Set the Value Label's background Color.
Definition: lvppBase.cpp:496
void internalOnValueChanged()
Internal handler for value change. Does the formatting as well.
Definition: lvppBase.cpp:525
virtual void setNewParent(lv_obj_t *pNewParent)
Changes the parent object on the fly. Used primarily for lvppScreen::addObject(). Sets parents of adj...
Definition: lvppBase.cpp:534
int16_t curValue
The value we're keeping and handling in this class.
Definition: lvppBase.h:530
void setValueLabelFont(const lv_font_t *pF)
Set the Value Label Font.
Definition: lvppBase.cpp:472
void setValueLabelColorGradient(lv_color_t col1, lv_color_t col2, lv_grad_dir_t direction)
Sets a Color Gradient from col1 to col2 in a vertical or horizontal direction.
Definition: lvppBase.cpp:506
void setValueLabelJustificationAlignment(lv_text_align_t _align)
Set the value Label's text alignment (left/right/center)
Definition: lvppBase.cpp:516
void setValueLabelColor(lv_color_t newColor)
Set the Value Label's text Color.
Definition: lvppBase.cpp:487
Utility class to aid in consistent handling of all lv_ widgets which have a list of choices....
Definition: lvppBase.h:547
std::vector< uint64_t > idList
The vector of associated ID values (if used)
Definition: lvppBase.h:633
virtual void addOption(const char *pOpt)
Add a single option to the options list.
Definition: lvppBase.cpp:606
virtual void setOptionsWithIDs(std::vector< std::pair< std::string, uint64_t > > &valIDs)
Set the Options along with a related ID. This is intended to give the user a more meaningful item to ...
Definition: lvppBase.cpp:587
const char * getNewlineSepOptions()
Packs all the option strings into a single newline separated pointer.
Definition: lvppBase.cpp:643
virtual uint16_t lvOptionGetIndex()=0
This is the pure virtual method which must be implemented by any class that utilizes lvppOptions....
virtual void lvOptionSetter(const char *pOpts)=0
This is the pure virtual which must be implemented by any class that utilizes lvppOptions....
virtual uint64_t getSelectedID()
Get the ID associated with the currently selected item. Using this method only makes sense if the lis...
Definition: lvppBase.cpp:639
std::vector< std::string > options
The vector of options kept locally.
Definition: lvppBase.h:632
std::string oneString
Temp area for getNewlineSepOptions()
Definition: lvppBase.h:631
virtual void clearOptions()
Removes all entries from the options list. NOTE: Method does not clear the LVGL widget....
Definition: lvppBase.cpp:634
virtual void addOptionWithID(const char *pOpt, uint64_t id)
Add a single option to the options list and pair it with a meaningful ID. To be used in conjunction w...
Definition: lvppBase.cpp:620
virtual void setOptions(const char *pOpts)
Set the Options all in one shot from a const char*.
Definition: lvppBase.cpp:550