Component: Display Manager (Graphical Library)

From Flowcode Help
Jump to navigationJump to search
Author MatrixTSL
Version 2.0
Category Graphical Library


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.

Detailed description

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.


The component can also create the following interactive buttons and sliders.

  • Button_Hidden - 0 - A hidden area with no graphics.
  • Button_Rectangle - 1 - A rectangular box with a shadow.
  • Button_RoundedRectangle - 2 - A rounded rectangular box with a shadow.
  • Button_Ellipse - 3 - A simple ellipse or circle with a shadow.
  • Button_VSlider - 4 - A vertical slider with a square thumb.
  • Button_HSlider - 5 - A horizontal slider with a square thumb.
  • Button_VSlider_Round - 6 - A vertical slider with a round thumb.
  • Button_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::Button_VSlider

Examples

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.

FC6 Icon.png Display Manager Demo

Macro reference

CheckForTouch

Fc9-comp-macro.png CheckForTouch
Uses the X and Y coordinates from a touch sensor to check for button presses. Returns 0 for no buttons pressed. Returns 1 for a valid button press. The ID of the pressed item can be found by calling GetButtonID macro. Any touched slider buttons will automatically move their thumb and value to the touch position.  
Fc9-u16-icon.png - UINT X
 
Fc9-u16-icon.png - UINT Y
 
Fc9-bool-icon.png - BOOL Return


ClearAll

Fc9-comp-macro.png ClearAll
Removes all objects and buttons from memory. Also clears the screen if required. 
Fc9-bool-icon.png - BOOL ClearScreen
0=Don't clear the screen, 1=Clear the screen 
Fc9-void-icon.png - VOID Return


CreateButton

Fc9-comp-macro.png CreateButton
Define an interactive button or slider. Returns the Button ID. 
Fc9-u8-icon.png - BYTE ButtonType
0=ButtonHidden, 1=ButtonRect, 2=ButtonRoundedRect, 3=ButtonEllipse, 4=VSlider, 5=HSlider, 6=VSliderRound, 7=HSliderRound 
Fc9-u16-icon.png - UINT X
X Pixel Coordinate 
Fc9-u16-icon.png - UINT Y
Y Pixel Coordinate 
Fc9-u16-icon.png - UINT Width
Pixel Width or X Radius 
Fc9-u16-icon.png - UINT Height
Pixel Height or Y Radius 
Fc9-u8-icon.png - BYTE Theme
Theme index to use to draw the button 
Fc9-bool-icon.png - BOOL DrawButton
0=Do not draw button yet, 1=Draw button now 
Fc9-u16-icon.png - UINT Return


CreateObject

Fc9-comp-macro.png CreateObject
Define a none touchable graphical object. Returns the Object ID. 
Fc9-u8-icon.png - BYTE ObjectType
0=Hidden, 1=Rect, 2=Line, 3=Ellipse, 4=FilledEllipse, 5=FilledRect 
Fc9-u16-icon.png - UINT X
X Pixel Coordinate 
Fc9-u16-icon.png - UINT Y
Y Pixel Coordinate 
Fc9-u16-icon.png - UINT Width
Pixel Width or X Radius 
Fc9-u16-icon.png - UINT Height
Pixel Height or Y Radius 
Fc9-u8-icon.png - BYTE Theme
Theme index to use to draw the object 
Fc9-bool-icon.png - BOOL DrawObject
0=Do not draw object yet, 1=Draw object now 
Fc9-u16-icon.png - UINT Return


DrawAll

Fc9-comp-macro.png DrawAll
Redraws all of the defined Objects and Buttons. Doesn't draw text, this is done using the SetText macro. 
Fc9-void-icon.png - VOID Return


DrawItem

Fc9-comp-macro.png DrawItem
Draws a single object or button onto the display without clearing the display. Doesn't draw a textfield component, this is done using the SetObjectText macro. 
Fc9-u16-icon.png - UINT ID
Unique ID of the Object or Button 
Fc9-void-icon.png - VOID Return


GetLastTouchID

Fc9-comp-macro.png GetLastTouchID
Gets the ID of the last button that returned a valid press via the CheckForTouch macro. Returns -1 for valid touch recorded. 
Fc9-s16-icon.png - INT Return


GetSliderValue

Fc9-comp-macro.png GetSliderValue
Reads the value of one of the sliders ranging between 0 and 1. 
Fc9-u16-icon.png - UINT ButtonID
 
Fc9-f32-icon.png - FLOAT Return


Initialise

Fc9-comp-macro.png Initialise
Initialises the object and button control variables and sets up the default themes. 
Fc9-void-icon.png - VOID Return


ModifyPosition

Fc9-comp-macro.png ModifyPosition
Moves an existing object or button to absolute coordinates on the screen. 
Fc9-u16-icon.png - UINT ID
Unique ID of the object or button 
Fc9-s16-icon.png - INT X
 
Fc9-s16-icon.png - INT Y
 
Fc9-bool-icon.png - BOOL Relative
0=Absolute Positioning, 1=Relative Positioning 
Fc9-void-icon.png - VOID Return


ModifyScale

Fc9-comp-macro.png ModifyScale
Changes the width and height of the selected Object or Button. 
Fc9-u16-icon.png - UINT ID
Unique ID of the object or button 
Fc9-u16-icon.png - UINT Width
 
Fc9-u16-icon.png - UINT Height
 
Fc9-void-icon.png - VOID Return


ModifyTheme

Fc9-comp-macro.png ModifyTheme
Changes the theme index of the selected Object or Button. 
Fc9-u16-icon.png - UINT ID
Unique ID of the object or button 
Fc9-u8-icon.png - BYTE Theme
Theme index of the button or object 
Fc9-void-icon.png - VOID Return


NoTouch

Fc9-comp-macro.png NoTouch
Called when no touch is present, Allows the repeat rate counter to be cleared allowing for better responses to fast touches. 
Fc9-void-icon.png - VOID Return


OverrideButtonTheme

Fc9-comp-macro.png OverrideButtonTheme
Overrides the colour of a button theme, used by the draw button macro.  
Fc9-u8-icon.png - BYTE ThemeIndex
Index of the object colour theme 
Fc9-u8-icon.png - BYTE FG_R
Foreground colour channel value 
Fc9-u8-icon.png - BYTE FG_G
Foreground colour channel value 
Fc9-u8-icon.png - BYTE FG_B
Foreground colour channel value 
Fc9-u8-icon.png - BYTE BG_R
Background colour channel value 
Fc9-u8-icon.png - BYTE BG_G
Background colour channel value 
Fc9-u8-icon.png - BYTE BG_B
Background colour channel value 
Fc9-u8-icon.png - BYTE HL_R
Highlight colour channel value 
Fc9-u8-icon.png - BYTE HL_G
Highlight colour channel value 
Fc9-u8-icon.png - BYTE HL_B
Highlight colour channel value 
Fc9-u8-icon.png - BYTE LL_R
Lowlight colour channel value 
Fc9-u8-icon.png - BYTE LL_G
Lowlight colour channel value 
Fc9-u8-icon.png - BYTE LL_B
Lowlight colour channel value 
Fc9-void-icon.png - VOID Return


OverrideObjectTheme

Fc9-comp-macro.png OverrideObjectTheme
Overrides the colour of an object theme, used by the draw object macro.  
Fc9-u8-icon.png - BYTE ThemeIndex
Index of the object colour theme 
Fc9-u8-icon.png - BYTE FG_R
Foreground colour channel value 
Fc9-u8-icon.png - BYTE FG_G
Foreground colour channel value 
Fc9-u8-icon.png - BYTE FG_B
Foreground colour channel value 
Fc9-u8-icon.png - BYTE BG_R
Background colour channel value 
Fc9-u8-icon.png - BYTE BG_G
Background colour channel value 
Fc9-u8-icon.png - BYTE BG_B
Background colour channel value 
Fc9-void-icon.png - VOID Return


SetSliderValue

Fc9-comp-macro.png SetSliderValue
Sets the value of one of the sliders and optionally redraws the slider to reflect the value change. 
Fc9-u16-icon.png - UINT ButtonID
 
Fc9-f32-icon.png - FLOAT Value
Range: 0 to 1 
Fc9-bool-icon.png - BOOL RedrawSlider
0=Do not redraw, 1=Redraw 
Fc9-void-icon.png - VOID Return


SetText

Fc9-comp-macro.png SetText
Draws a single line of text onto an object or button location. Useful for labelling buttons or having name, value statistics. Drawn using the object themes. 
Fc9-u16-icon.png - UINT ID
Unique identifier of object or button. 
Fc9-string-icon.png - STRING Text
 
Fc9-u8-icon.png - BYTE Font
 
Fc9-u8-icon.png - BYTE HAlignment
0=Left, 1=Center, 2=Right 
Fc9-u8-icon.png - BYTE VAlignment
0=Top, 1=Middle, 2=Bottom 
Fc9-u8-icon.png - BYTE Theme
Object theme index to control the colour of the text 
Fc9-bool-icon.png - BOOL Transparent
0=Background Colour Drawn, 1=Don't Draw Background Colour 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png LinkTo
 
Fc9-type-21-icon.png Ram Usage Bytes
The calculated number of bytes of RAM required by the display manager. 
Fc9-type-21-icon.png Text Align Offset
Number of pixels to move away from an edge when calling SetText 
Fc9-conn-icon.png Objects
Fc9-type-21-icon.png Max Objects
The total number of primitive objects allowed on the screen at once. Sets the size of the RAM buffers used to track the various screen elements. Each object requires 10 bytes of RAM to stores things like size, location and type. 
Fc9-type-16-icon.png Object Theme Count
Sets the number of themes available when drawing primitive objects. Each object theme requires 6 bytes of RAM to store the colour channels. 
Fc9-conn-icon.png Theme 0
Fc9-type-1-icon.png Foreground
Foreground colour of the theme 
Fc9-type-1-icon.png Background
Background colour of the theme 
Fc9-conn-icon.png Theme 1
Fc9-type-1-icon.png Foreground
Foreground colour of the theme 
Fc9-type-1-icon.png Background
Background colour of the theme 
Fc9-conn-icon.png Buttons
Fc9-type-21-icon.png Max Buttons
The total number of touchable interactibe objects allowed on the screen at once e.g. buttons and sliders. Sets the size of the RAM buffers used to track the various screen elements Each button requires 18 bytes of RAM to stores things like size, location, value and type. 
Fc9-type-21-icon.png Touch Repeat Rate
Sets the period for touch repeats in terms of calls of the CheckForTouch macro. Buttons will only register a repeat touch after x calls if continually held down. Sliders will always register a touch. The touch count can be cleared using the NoTouch macro if no touch is detected. 
Fc9-type-21-icon.png Slider Thumb Width
Number of pixels wide to make a slider thumb marker, 
Fc9-type-21-icon.png Slider Center Line Thickness
Number of pixels thick to draw the slider central line 
Fc9-type-16-icon.png Button Theme Count
Sets the number of themes available for drawng buttons. Each button theme requires 12 bytes of RAM to store the colour channels. 
Fc9-conn-icon.png Theme 0
Fc9-type-1-icon.png Foreground
Foreground colour of the theme 
Fc9-type-1-icon.png Background
Background colour of the theme 
Fc9-type-1-icon.png Highlight
Highlight colour of the theme 
Fc9-type-1-icon.png Lowlight
Lowlight colour of the theme 
Fc9-conn-icon.png Theme 1
Fc9-type-1-icon.png Foreground
Foreground colour of the theme 
Fc9-type-1-icon.png Background
Background colour of the theme 
Fc9-type-1-icon.png Highlight
Highlight colour of the theme 
Fc9-type-1-icon.png Lowlight
Lowlight colour of the theme 

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