Difference between revisions of "Component: Display Manager (Graphical Library)"
(17 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
|- | |- | ||
| width="20%" style="color:gray;" | Version | | width="20%" style="color:gray;" | Version | ||
− | | | + | | 23.0 |
|- | |- | ||
| width="20%" style="color:gray;" | Category | | width="20%" style="color:gray;" | Category | ||
Line 20: | Line 20: | ||
13, 2.0, 22-05-24, BR, Added text alignment options | 13, 2.0, 22-05-24, BR, Added text alignment options | ||
14, 2.1, 14-06-24, BR, Renamed Button to Widget to better include things like sliders | 14, 2.1, 14-06-24, BR, Renamed Button to Widget to better include things like sliders | ||
+ | 15, 2.1, 26-07-24, BR, Added SetTextFloat and AddTextNumber macros | ||
+ | 16, 2.1, 29-07-24, BR, Renamed Themes to ObjectThemes and WidgetThemes | ||
+ | 17, 2.1, 29-07-24, BR, Added CreateTextField macro which automates creating a simple textbox | ||
+ | 18, 2.1, 06-08-24, BR, Fixed a problem with updating values, theme, text on IDs | ||
+ | 19, 2.1, 06-08-24, BR, Textfield now uses hidden object type instead of rectangle | ||
+ | 20, 2.1, 06-08-24, BR, Fixed a problem where slider value could be set with out of range value | ||
+ | 21, 2.1, 06-08-24, BR, Fixed problem where SetTextNumber would reset an ESP32 | ||
+ | 22, 22.0, 19-03-25, MW, Added Widget Array function to easily create keypads | ||
+ | 23, 23.0, 03-06-25, BR, Added Object Array function to easily create data tables | ||
==Detailed description== | ==Detailed description== | ||
Line 34: | Line 43: | ||
*'''Object_RectangeFilled''' - 5 - A filled rectangular box. | *'''Object_RectangeFilled''' - 5 - A filled rectangular box. | ||
+ | |||
+ | ===TextField=== | ||
+ | |||
+ | There is also an additional TextField object which consists of an Object_Rectangle that is pre-populated with text. | ||
===Widgets=== | ===Widgets=== | ||
Line 56: | Line 69: | ||
===Touch Repeat Rate for Button Widgets=== | ===Touch Repeat Rate for Button Widgets=== | ||
− | The Touch Repeat Rate property applies to button based widgets and sets the frequency that a valid touch will be detected. This is similar to holding down a key on a keyboard and | + | The Touch Repeat Rate property applies to button based widgets and sets the frequency that a valid touch will be detected for a held button. This is similar to holding down a single key on a keyboard and acts to reduce the frequency of positive button detections when touching the button. For example if you had a button that incremented a value, without the repeat rate the value would increment much faster then anticipated in an uncontrollable manner. When no touch is detected it is recommended to call the NoTouch macro to clear the touch counters and allow a more responsive user experience. |
+ | |||
+ | Example of implementing touch repeat rate | ||
+ | |||
+ | [[File:ButtonRepeatRate.jpg]] | ||
==Examples== | ==Examples== | ||
− | An example showing how to use the display manager with a | + | ===Basic Example=== |
+ | |||
+ | An example showing how to use the display manager with a gLCD and a touch interface to create a full HMI. | ||
The example shows how to create a simple menu system as well as a toggle switch and a slider used to control a PWM output. | The example shows how to create a simple menu system as well as a toggle switch and a slider used to control a PWM output. | ||
{{Fcfile|DisplayManagerDemo.fcfx|Display Manager Demo}} | {{Fcfile|DisplayManagerDemo.fcfx|Display Manager Demo}} | ||
+ | |||
+ | ===Keypad Example=== | ||
+ | |||
+ | An example showing how you can use the CreateWigitArray component to create a touch keypad for your gLCD. | ||
+ | |||
+ | [[File:Updated__Display_Manager1.png]] | ||
+ | |||
+ | The CreateWidgetArray function macro has a number of parameters to allow high flexibility in what you can create: | ||
+ | |||
+ | [[File:Updated__Display_Manager2.png]] | ||
+ | |||
+ | There are also tooltips for each parameter to help. | ||
+ | |||
+ | [[File:Updated__Display_Manager3.png]] | ||
+ | |||
+ | Note: if you get a unable to run simulation error then make sure you have the latest components downloaded. | ||
+ | |||
+ | |||
+ | How the key touch is detected | ||
+ | |||
+ | The first widget is automatically assigned a unique widget ID e.g. the first widget with text 1 on it is assigned 24. | ||
+ | |||
+ | All the following widgets ID is then incremented from 24, e.g. widget with text 6 on is assigned 24+ 5 = 29. | ||
+ | |||
+ | The widget button pressed can then be calculated from 29 – 24 + 1 = 6. | ||
+ | |||
+ | |||
+ | {{Fcfile|DisplayManager_WidgetArray_Keypad_Example.fcfx|Display Manager Widget Array Keypad Example}} | ||
==Macro reference== | ==Macro reference== | ||
Line 74: | Line 121: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckForTouch''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckForTouch''' | ||
|- | |- | ||
− | | colspan="2" | Uses the X and Y coordinates from a touch sensor to check for Widget presses. Returns 0 for no Widgets pressed. Returns | + | | colspan="2" | Uses the X and Y coordinates from a touch sensor to check for Widget presses. Returns 0 for no Widgets pressed. Returns ID for a valid Widget press. Any touched slider Widgets will automatically move their thumb and value to the touch position. |
|- | |- | ||
|- | |- | ||
Line 87: | Line 134: | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
Line 146: | Line 193: | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | ObjectTheme |
|- | |- | ||
| colspan="2" | Theme index to use to draw the object | | colspan="2" | Theme index to use to draw the object | ||
Line 153: | Line 200: | ||
| width="90%" | DrawObject | | width="90%" | DrawObject | ||
|- | |- | ||
− | | colspan="2" | 0=Do not draw object yet, 1=Draw object now | + | | colspan="2" | 0=Do not draw object yet, 1=Draw object now (Does not apply to hidden objects) |
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===CreateObjectArray=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateObjectArray''' | ||
+ | |- | ||
+ | | colspan="2" | Creates a 2d array of objects that can be used to create things like tables. Returns the ID of the first object, the following objects have incremental IDs going column by column and then row by row. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | ObjectType | ||
+ | |- | ||
+ | | colspan="2" | 0=Hidden, 1=Rect, 2=Line, 3=Ellipse, 4=FilledEllipse, 5=FilledRect | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumColumns | ||
+ | |- | ||
+ | | colspan="2" | Number of columns of buttons in the array | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumRows | ||
+ | |- | ||
+ | | colspan="2" | Number of rows of buttons in the array | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | InitialPositionX | ||
+ | |- | ||
+ | | colspan="2" | X location of the initial button | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | InitialPositionY | ||
+ | |- | ||
+ | | colspan="2" | Y location of the initial button | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | ObjectHeight | ||
+ | |- | ||
+ | | colspan="2" | Object height in pixels | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | ObjectWidth | ||
+ | |- | ||
+ | | colspan="2" | Object width in pixels | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | SpacingX | ||
+ | |- | ||
+ | | colspan="2" | Horizontal spacing between the widgets | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | SpacingY | ||
+ | |- | ||
+ | | colspan="2" | Vertical spacing between the widgets | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | ObjectTheme | ||
+ | |- | ||
+ | | colspan="2" | Object theme index to control the colour of the widgets text | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Font | ||
+ | |- | ||
+ | | colspan="2" | Font used for the widgets text | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | ObjectText | ||
+ | |- | ||
+ | | colspan="2" | A comma seperated text field with the text for each object e.g. "1,2,3,.." | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===CreateTextField=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateTextField''' | ||
+ | |- | ||
+ | | colspan="2" | Creates a text field consisting of a rectangular border containing a single line of text | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | Text | ||
+ | |- | ||
+ | | colspan="2" | Text string to set as the label | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | X | ||
+ | |- | ||
+ | | colspan="2" | X Pixel Coordinate | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Y | ||
+ | |- | ||
+ | | colspan="2" | Y Pixel Coordinate | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Width | ||
+ | |- | ||
+ | | colspan="2" | Pixel Width | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Height | ||
+ | |- | ||
+ | | colspan="2" | Pixel Height | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Font | ||
+ | |- | ||
+ | | colspan="2" | GLCD Font Index to use | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | ObjectTheme | ||
+ | |- | ||
+ | | colspan="2" | Theme index to use to draw the object | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | HAlignment | ||
+ | |- | ||
+ | | colspan="2" | 0=Left, 1=Center, 2=Right | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | VAlignment | ||
+ | |- | ||
+ | | colspan="2" | 0=Top, 1=Middle, 2=Bottom | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
Line 195: | Line 375: | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | WidgetTheme |
|- | |- | ||
| colspan="2" | Theme index to use to draw the Widget | | colspan="2" | Theme index to use to draw the Widget | ||
Line 202: | Line 382: | ||
| width="90%" | DrawWidget | | width="90%" | DrawWidget | ||
|- | |- | ||
− | | colspan="2" | 0=Do not draw Widget yet, 1=Draw Widget now | + | | colspan="2" | 0=Do not draw Widget yet, 1=Draw Widget now (Does not apply to hidden widgets) |
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===CreateWidgetArray=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateWidgetArray''' | ||
+ | |- | ||
+ | | colspan="2" | Creates a 2d array of buttons that can be used to create things like keypads. Returns the ID of the first button, the following buttons have incremental IDs going column by column and then row by row. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | WidgetType | ||
+ | |- | ||
+ | | colspan="2" | 0=WidgetHidden, 1=WidgetRect, 2=WidgetRoundedRect, 3=WidgetEllipse, 4=VSlider, 5=HSlider, 6=VSliderRound, 7=HSliderRound | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumColumns | ||
+ | |- | ||
+ | | colspan="2" | Number of columns of buttons in the array | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumRows | ||
+ | |- | ||
+ | | colspan="2" | Number of rows of buttons in the array | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | InitialPositionX | ||
+ | |- | ||
+ | | colspan="2" | X location of the initial button | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | InitialPositionY | ||
+ | |- | ||
+ | | colspan="2" | Y location of the initial button | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | WidgetHeight | ||
+ | |- | ||
+ | | colspan="2" | Widget height in pixels | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | WidgetWidth | ||
+ | |- | ||
+ | | colspan="2" | Widget width in pixels | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | SpacingX | ||
+ | |- | ||
+ | | colspan="2" | Horizontal spacing between the widgets | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | SpacingY | ||
+ | |- | ||
+ | | colspan="2" | Vertical spacing between the widgets | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | ObjectTheme | ||
+ | |- | ||
+ | | colspan="2" | Object theme index to control the colour of the widgets text | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | WidgetTheme | ||
+ | |- | ||
+ | | colspan="2" | Widget theme index to control the colour of the widgets | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Font | ||
+ | |- | ||
+ | | colspan="2" | Font used for the widgets text | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | WidgetText | ||
+ | |- | ||
+ | | colspan="2" | A comma seperated text field with the text for each widget e.g. "1,2,3,.." | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
Line 215: | Line 474: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DrawAll''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DrawAll''' | ||
|- | |- | ||
− | | colspan="2" | Redraws all of the defined Objects and Widgets. Doesn't draw text, this is done using the SetText | + | | colspan="2" | Redraws all of the defined Objects and Widgets. Doesn't draw text, this is done using the SetText macros. |
|- | |- | ||
|- | |- | ||
Line 229: | Line 488: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DrawItem''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DrawItem''' | ||
|- | |- | ||
− | | colspan="2" | Draws a single object or Widget onto the display without clearing the display. Doesn't draw | + | | colspan="2" | Draws a single object or Widget onto the display without clearing the display. Doesn't draw text, this is done using the SetText macros. |
|- | |- | ||
|- | |- | ||
Line 248: | Line 507: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLastTouchID''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLastTouchID''' | ||
|- | |- | ||
− | | colspan="2" | Gets the ID of the last Widget that returned a valid press via the CheckForTouch macro. Returns | + | | colspan="2" | Gets the ID of the last Widget that returned a valid press via the CheckForTouch macro. Returns 0 for no valid touch recorded. |
|- | |- | ||
|- | |- | ||
Line 547: | Line 806: | ||
− | === | + | ===SetTextFloat=== |
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
− | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | ''' | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTextFloat''' |
|- | |- | ||
− | | colspan="2" | Draws a single line of text onto an object or Widget location. Useful for labelling Widgets or having name, value statistics. Drawn using the object themes. | + | | colspan="2" | Draws a numerical value onto an object or Widget location. Useful for displaying, value statistics. Drawn using the object themes. |
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | ID | ||
+ | |- | ||
+ | | colspan="2" | Unique identifier of object or Widget. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:]] - | ||
+ | | width="90%" | Number | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumDP | ||
+ | |- | ||
+ | | colspan="2" | Number of decimal points to display | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | Unit | ||
+ | |- | ||
+ | | colspan="2" | Unit string to add after the numeric value. e.g. "g" or "s" | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Font | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | HAlignment | ||
+ | |- | ||
+ | | colspan="2" | 0=Left, 1=Center, 2=Right | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | VAlignment | ||
+ | |- | ||
+ | | colspan="2" | 0=Top, 1=Middle, 2=Bottom | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | ObjectTheme | ||
+ | |- | ||
+ | | colspan="2" | Object theme index to control the colour of the text | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | Transparent | ||
+ | |- | ||
+ | | colspan="2" | 0=Background Colour Drawn, 1=Don't Draw Background Colour | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===SetTextLabel=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTextLabel''' | ||
+ | |- | ||
+ | | colspan="2" | Draws a single line of text onto an object or Widget location. Useful for labelling Widgets such as buttons or having name, value statistics. Drawn using the object themes. | ||
|- | |- | ||
|- | |- | ||
Line 563: | Line 881: | ||
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
| width="90%" | Text | | width="90%" | Text | ||
+ | |- | ||
+ | | colspan="2" | Text string to set as the label | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Font | ||
+ | |- | ||
+ | | colspan="2" | GLCD Font Index to use | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | HAlignment | ||
+ | |- | ||
+ | | colspan="2" | 0=Left, 1=Center, 2=Right | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | VAlignment | ||
+ | |- | ||
+ | | colspan="2" | 0=Top, 1=Middle, 2=Bottom | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | ObjectTheme | ||
+ | |- | ||
+ | | colspan="2" | Object theme index to control the colour of the text | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | Transparent | ||
+ | |- | ||
+ | | colspan="2" | 0=Background Colour Drawn, 1=Don't Draw Background Colour | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===SetTextNumber=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTextNumber''' | ||
+ | |- | ||
+ | | colspan="2" | Draws a numerical value onto an object or Widget location. Useful for displaying, value statistics. Drawn using the object themes. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | ID | ||
+ | |- | ||
+ | | colspan="2" | Unique identifier of object or Widget. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:]] - | ||
+ | | width="90%" | Number | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | Unit | ||
+ | |- | ||
+ | | colspan="2" | Unit string to add after the numeric value. e.g. "g" or "s" | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
Line 582: | Line 954: | ||
|- | |- | ||
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
− | | width="90%" | | + | | width="90%" | ObjectTheme |
|- | |- | ||
| colspan="2" | Object theme index to control the colour of the text | | colspan="2" | Object theme index to control the colour of the text | ||
Line 622: | Line 994: | ||
| width="90%" | Text Align Offset | | width="90%" | Text Align Offset | ||
|- | |- | ||
− | | colspan="2" | Number of pixels to move away from an edge when calling | + | | colspan="2" | Number of pixels to move away from an edge when calling |
|- | |- | ||
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | ||
Line 639: | Line 1,011: | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | ||
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Theme 0 | + | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Object & Text Theme 0 |
|- | |- | ||
|- | |- | ||
Line 653: | Line 1,025: | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | ||
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Theme 1 | + | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Object & Text Theme 1 |
|- | |- | ||
|- | |- | ||
Line 696: | Line 1,068: | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | ||
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Theme 0 | + | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Widget Theme 0 |
|- | |- | ||
|- | |- | ||
Line 720: | Line 1,092: | ||
|- | |- | ||
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | ||
− | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Theme 1 | + | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Widget Theme 1 |
|- | |- | ||
|- | |- |
Latest revision as of 08:59, 9 June 2025
Author | MatrixTSL |
Version | 23.0 |
Category | Graphical Library |
Contents
- 1 Display Manager component
- 2 Version information
- 3 Detailed description
- 4 Examples
- 5 Macro reference
- 5.1 CheckForTouch
- 5.2 ClearAll
- 5.3 CreateObject
- 5.4 CreateObjectArray
- 5.5 CreateTextField
- 5.6 CreateWidget
- 5.7 CreateWidgetArray
- 5.8 DrawAll
- 5.9 DrawItem
- 5.10 GetLastTouchID
- 5.11 GetSliderValue
- 5.12 Initialise
- 5.13 ModifyPosition
- 5.14 ModifyScale
- 5.15 ModifyTheme
- 5.16 NoTouch
- 5.17 OverrideObjectTheme
- 5.18 OverrideWidgetTheme
- 5.19 SetSliderValue
- 5.20 SetTextFloat
- 5.21 SetTextLabel
- 5.22 SetTextNumber
- 6 Property reference
- 7 Component Source Code
Display Manager component
A component designed to simplify the process of drawing primitives and text onto a graphical display. Keeps track of coordinates so you don't have to. Also works great as a base layer for gLCD based games as it will check for collisions and perform movement.
Version information
Library Version, Component Version, Date, Author, Info 13, 2.0, 22-05-24, BR, Added text alignment options 14, 2.1, 14-06-24, BR, Renamed Button to Widget to better include things like sliders 15, 2.1, 26-07-24, BR, Added SetTextFloat and AddTextNumber macros 16, 2.1, 29-07-24, BR, Renamed Themes to ObjectThemes and WidgetThemes 17, 2.1, 29-07-24, BR, Added CreateTextField macro which automates creating a simple textbox 18, 2.1, 06-08-24, BR, Fixed a problem with updating values, theme, text on IDs 19, 2.1, 06-08-24, BR, Textfield now uses hidden object type instead of rectangle 20, 2.1, 06-08-24, BR, Fixed a problem where slider value could be set with out of range value 21, 2.1, 06-08-24, BR, Fixed problem where SetTextNumber would reset an ESP32 22, 22.0, 19-03-25, MW, Added Widget Array function to easily create keypads 23, 23.0, 03-06-25, BR, Added Object Array function to easily create data tables
Detailed description
Objects
The component can create the following objects.
- Object_Hidden - 0 - A hidden area with no graphics.
- Object_Rectangle - 1 - A simple rectangular box.
- Object_Line - 2 - A simple straight line.
- Object_Ellipse - 3 - A simple ellipse or circle.
- Object_EllipseFilled - 4 - A filled ellipse or circle.
- Object_RectangeFilled - 5 - A filled rectangular box.
TextField
There is also an additional TextField object which consists of an Object_Rectangle that is pre-populated with text.
Widgets
The component can also create the following interactive buttons and sliders.
- Widget_Hidden - 0 - A hidden area with no graphics.
- Widget_Rectangle - 1 - A rectangular box with a shadow.
- Widget_RoundedRectangle - 2 - A rounded rectangular box with a shadow.
- Widget_Ellipse - 3 - A simple ellipse or circle with a shadow.
- Widget_VSlider - 4 - A vertical slider with a square thumb.
- Widget_HSlider - 5 - A horizontal slider with a square thumb.
- Widget_VSlider_Round - 6 - A vertical slider with a round thumb.
- Widget_HSlider_Round - 7 - A horizontal slider with a round thumb.
The type can be entered by using the component's public constants. Begin with the Display Manager handle name followed by :: and the list of the public variables will be displayed.
For example... DisplayManager1::Object_Rectangle or DisplayManager1::Widget_VSlider
Touch Repeat Rate for Button Widgets
The Touch Repeat Rate property applies to button based widgets and sets the frequency that a valid touch will be detected for a held button. This is similar to holding down a single key on a keyboard and acts to reduce the frequency of positive button detections when touching the button. For example if you had a button that incremented a value, without the repeat rate the value would increment much faster then anticipated in an uncontrollable manner. When no touch is detected it is recommended to call the NoTouch macro to clear the touch counters and allow a more responsive user experience.
Example of implementing touch repeat rate
Examples
Basic Example
An example showing how to use the display manager with a gLCD and a touch interface to create a full HMI.
The example shows how to create a simple menu system as well as a toggle switch and a slider used to control a PWM output.
Keypad Example
An example showing how you can use the CreateWigitArray component to create a touch keypad for your gLCD.
The CreateWidgetArray function macro has a number of parameters to allow high flexibility in what you can create:
There are also tooltips for each parameter to help.
Note: if you get a unable to run simulation error then make sure you have the latest components downloaded.
How the key touch is detected
The first widget is automatically assigned a unique widget ID e.g. the first widget with text 1 on it is assigned 24.
All the following widgets ID is then incremented from 24, e.g. widget with text 6 on is assigned 24+ 5 = 29.
The widget button pressed can then be calculated from 29 – 24 + 1 = 6.
Display Manager Widget Array Keypad Example
Macro reference
CheckForTouch
ClearAll
![]() |
ClearAll |
Removes all objects and Widgets from memory. Also clears the screen if required. | |
![]() |
ClearScreen |
0=Don't clear the screen, 1=Clear the screen | |
![]() |
Return |
CreateObject
CreateObjectArray
CreateTextField
CreateWidget
CreateWidgetArray
DrawAll
![]() |
DrawAll |
Redraws all of the defined Objects and Widgets. Doesn't draw text, this is done using the SetText macros. | |
![]() |
Return |
DrawItem
GetLastTouchID
![]() |
GetLastTouchID |
Gets the ID of the last Widget that returned a valid press via the CheckForTouch macro. Returns 0 for no valid touch recorded. | |
![]() |
Return |
GetSliderValue
![]() |
GetSliderValue |
Reads the value of one of the sliders ranging between 0 and 1. | |
![]() |
WidgetID |
![]() |
Return |
Initialise
![]() |
Initialise |
Initialises the object and Widget control variables and sets up the default themes. | |
![]() |
Return |
ModifyPosition
ModifyScale
![]() |
ModifyScale |
Changes the width and height of the selected Object or Widget. | |
![]() |
ID |
Unique ID of the object or Widget | |
![]() |
Width |
![]() |
Height |
![]() |
Return |
ModifyTheme
![]() |
ModifyTheme |
Changes the theme index of the selected Object or Widget. | |
![]() |
ID |
Unique ID of the object or Widget | |
![]() |
Theme |
Theme index of the Widget or object | |
![]() |
Return |
NoTouch
![]() |
NoTouch |
Called when no touch is present, Allows the repeat rate counter to be cleared allowing for better responses to fast touches. | |
![]() |
Return |
OverrideObjectTheme
OverrideWidgetTheme
SetSliderValue
SetTextFloat
SetTextLabel
SetTextNumber
Property reference
Component Source Code
Please click here to download the component source project: FC_Comp_Source_Lib_DisplayManager.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_Lib_DisplayManager.fcfx