Class DashObject
DashObject class.
Functions of DashObjects which are created with dash.create_label etc. Not all functions can be used for all types of DashObjects.
See also:
Usage:
-- create label DashObject local label1 = dash.create_label(dash.get_current_page(), {x=5, y=10, text="text1", color=0xff0000, font=dash.font.bold_24}) -- show label on screen dash.update() label1:set_color("text", 0x0000ff) label1:set_position(label1:get_x() + 10, label1:get_y() + 10) -- label has changed text color and position dash.update()-- create new class inherited from label local TelemetryLabel = dash.create_class_inherit_from_label("TelemetryLabel") TelemetryLabel.default_properties_meta = { __index={ font=dash.font.Bold_24, align="top_left", text_align="left", update_rate=30, color=0x00ff00}} function TelemetryLabel:new(parent, properties) -- get default values from TelemetryLabel.default_properties_meta setmetatable(properties, self.default_properties_meta) local w = self:__new_base(parent, properties) setmetatable(w, self) w._telemetry = properties.telemetry w:set_telemetry_update_hook(properties.update_rate, self.update, properties.telemetry) return w end function TelemetryLabel:update() self:set_text(string.format("%d", self._telemetry:value())) end -- create instance of the class local telemetrylabel = TelemetryLabel:new(dash.get_current_page(), {telemetry=dash.telemetry.engine_rpm})
Functions
Functions
- DashObject:set_position (x, y)
-
Set position.
Parameters:
- x int X coordinate
- y int Y coordinate
- DashObject:set_visible (visible)
-
Set visible.
Parameters:
- visible bool true if object is visible
- DashObject:set_size (w, h)
-
Set size.
Parameters:
- w int width
- h int Y height
- DashObject:set_color (colortype, color)
-
Set color.
Parameters:
- colortype string color type. One of "text", "background", "border", "line".
- color int color value
- DashObject:set_recolor (color)
-
Set recolor.
Sets color of alpha-channel-only image
Parameters:
- color int color value
- DashObject:set_text (text)
-
Set text.
Parameters:
- text string label text
- DashObject:set_align (align)
-
Set alignment.
Parameters:
- align string alignment of this object on its parent. One of "default", "top\_left", "top\_mid", "top\_right", "bottom\_left", "bottom\_mid", "bottom\_right", "center\_left", "center\_right", "center"
- DashObject:set_image (image)
-
Set image.
Parameters:
- image image handle, e.g. "dash.image.background_image"
- DashObject:set_source_x (offset_x)
-
Set source x coordinate.
Sets x offset of image.
Parameters:
- offset_x int x offset value
- DashObject:set_source_y (offset_y)
-
Set source y coordinate.
Sets y offset of image.
Parameters:
- offset_y int y offset value
- DashObject:set_point (point, x, y)
-
Set point of line or triangle.
Parameters:
- point int point of line or triangle to set
- x int X coordinate of point
- y int Y coordinate of point
- DashObject:set_parent (parent)
-
Set parent.
Parameters:
- parent DashObject new parent object
- DashObject:get_position ()
-
Get position relative to parent.
Returns:
- int X coordinate
- int Y coordinate
- DashObject:set_telemetry_update_hook (update_rate, callback, telemetryhandle[, telemetryhandle2[, telemetryhandle3[, telemetryhandle4[, telemetryhandle5]]]])
-
Set hook to call when a telemetry value has changed.
Parameters:
- update_rate int how many times per second the values will be checked
- callback function the function which is called when a telemetryvalue changes
- telemetryhandle telemetry handle
- telemetryhandle2 telemetry handle (optional)
- telemetryhandle3 telemetry handle (optional)
- telemetryhandle4 telemetry handle (optional)
- telemetryhandle5 telemetry handle (optional)
- DashObject:set_graph_next_value (value)
-
Set next value of graph.
Parameters:
- value int the new value. If graph is full, the oldest value is dropped.
- DashObject:get_x ()
-
Get X position relative to parent.
Returns:
-
int
X coordinate
- DashObject:get_y ()
-
Get Y position relative to parent.
Returns:
-
int
Y coordinate
- DashObject:get_visible ()
-
Get object visible status.
Returns:
-
bool
true if object is visible
- DashObject:get_size ()
-
Get size.
Returns:
- int width
- int height
- DashObject:get_width ()
-
Get width.
Returns:
-
int
width
- DashObject:get_height ()
-
Get height.
Returns:
-
int
height
- DashObject:get_parent ()
-
Get parent.
Returns:
-
DashObject
parent object
- DashObject:get_children ()
-
Get children.
Returns:
-
{DashObject,
...} table of child objects
- DashObject:get_children ()
-
Get children.
Returns:
-
{DashObject,
...} table of child objects
- DashObject:get_source_x ()
-
Get source X coordinate.
Get X offset of image.
Returns:
-
int
X offset value
- DashObject:get_source_y ()
-
Get source Y coordinate.
Get Y offset of image.
Returns:
-
int
Y offset value
- DashObject:get_point_x (point)
-
Get X coordinate of line or triangle point.
Parameters:
- point int point of line or triangle
Returns:
-
int
X coordinate of point
- DashObject:get_point_y (point)
-
Get Y coordinate of line or triangle point.
Parameters:
- point int point of line or triangle
Returns:
-
int
Y coordinate of point
- DashObject:clear ()
- Clear values from graph.
- DashObject:destroy ()
-
Destroy this DashObject and all child objects.
Returns:
-
int
number of objects destroyed