Main Content

Lamp

Display color that reflects signal value on lamp with customizable appearance

Since R2021b

  • Lamp block

Libraries:
Simulink / Dashboard / Customizable Blocks

Description

The Lamp block displays a color that reflects the value of the connected signal. When you use the Lamp block in the Customizable Blocks library, you can modify the appearance of the block so it looks like a real indicator lamp in your system. Use the Lamp block with other dashboard blocks to build an interactive dashboard of controls and indicators for your model.

To configure the Lamp block, specify one or more states. A state pairs a State Value with a color for the Lamp block to display. When the value of the connected signal is the same as the State Value, the Lamp block displays the color. You can also specify the State Value as a range, such that the block displays the color when the value of the connected signal falls into the specified range.

Customize Lamp Blocks

When you add a Lamp block to your model, the block is preconfigured with a default design. You can use the block with the default design or customize the appearance of the block.

To customize the appearance of the block, use design mode. After selecting the block, you can enter design mode in one of three ways:

  • On the Gauge tab, under Design, click Edit.

  • In the Property Inspector, on the Design tab, click Edit.

  • Pause on the ellipsis that appears over the block and click the Edit Custom Block button.

Customizable Lamp block in design mode with the toolbar and the Design tab in the Property Inspector visible.

In design mode, you can add any number of states to the block. To add or delete states, use the toolbar above the block.

For each state, you can:

  • Select a shape for the region that changes color to reflect the value of the connected signal.

  • Select the color of the shape in the state that you are configuring.

  • Select an icon from a built-in set of shapes, wireless icons, and automotive indicator lamps, or upload your own custom icon.

  • Specify how to combine the shape and the icon.

  • Specify the State Value as a number or a range.

You can also upload a foreground or a background image, or set a solid background color. The foreground and background apply to all states.

To specify the shape, shape color, icon, and shape-icon combination style, use the toolbar above the block.

To combine the shape and icon, in the third section of the toolbar from the left, choose one of these combination styles:

  • Simple — Overlay the icon on top of the shape.

  • Intersect — Retain the intersection of the shape and icon as the area that changes color to reflect the signal value.

  • Subtract — Subtract the icon from the shape, producing a cutout in the shape of the icon in the area that changes color to reflect the signal value.

Three Lamp blocks, each configured for one of the three ways you can combine the shape and icon: simple, intersect, or subtract.

Note

The intersect and subtract combination styles use transparency in the icon asset to produce the area that changes color. When you design a Lamp block that uses a custom icon, consider using an SVG or PNG file for the icon if you want your design to use the intersect or subtract options. Both formats support transparency, and SVG files also scale well in response to zoom operations.

You can use the Design tab in the Property Inspector for fine control over the block design and to enter exact values for design settings.

Use the Design tab to:

  • Specify the State Value.

  • Upload a foreground image.

  • Upload a background image.

  • Set a solid background color.

When you finish editing the design, to exit design mode, click the X in the upper right of the canvas.

Connect Dashboard Blocks

Dashboard blocks do not use ports to connect to model elements. To connect dashboard blocks to signals in your model, use connect mode. Connect mode facilitates the process of connecting dashboard blocks in your model, especially when you want to connect multiple blocks at once. To connect a single dashboard block, you can also use the Connection table in the block dialog box.

Tip

You can modify dashboard block connections during normal and accelerator mode simulations.

To enter connect mode, in the canvas, select the dashboard block to connect. On the Simulink® Toolstrip, a tab named after the type of the selected block appears. On the block tab, click Connect. In connect mode, when you select one or more signals or blocks, a list of signals that are available for connection appears. Select a signal from the list to connect to the selected dashboard block. To connect another dashboard block, pause on the block you want to connect and click the Connect button above it. Then, select one or more signals and blocks in the model and choose a signal to connect.

A Gauge block is in connect mode. To the right of the Gauge block is a Sine Wave block that connects to a Gain block that connects to an Outport block. To the right of the Outport block is the list of signals available for connection.

When you finish connecting the dashboard blocks in your model, on the block tab, click Done Connecting.

Tip

You can hide the message shown on unconnected blocks using the set_param function with the ShowInitialText block parameter. The message also disappears when you connect the block.

Limitations

  • Except for the Dashboard Scope block and the Display block, dashboard blocks can only connect to real scalar signals.

  • The toolstrip does not support blocks that are inside a panel.

  • You cannot use the Connection table in the block dialog to connect a dashboard block to a block that is commented out. When you connect a dashboard block to a commented block using connect mode, the dashboard block does not display the connected value until the you uncomment the block.

  • Dashboard blocks cannot connect to model elements inside referenced models.

  • When you simulate a model hierarchy, dashboard blocks inside referenced models do not update.

  • Dashboard blocks do not support rapid accelerator simulation.

  • You cannot connect a dashboard block to state activity or chart data in Stateflow® during simulation.

  • You cannot programmatically connect a dashboard block to state activity or chart data in Stateflow.

  • Some signals do not have data available during simulation due to block reduction or optimization for accelerator mode simulations. To view such a signal using a dashboard block, mark the signal for logging.

Parameters

expand all

Use the Property Inspector and the Block Parameters dialog box to specify the values of the block parameters. To set the core parameters of the dashboard block, use the Block Parameters dialog box or the Parameters tab in the Property Inspector. To customize the block, use the Design tab in the Property Inspector. To display the Block Parameters dialog box for a block, double-click the block. To display the Property Inspector, on the Modeling tab, under Design, select Property Inspector.

Parameters

To set the core parameters of the dashboard block, open the Property Inspector and click the Parameters tab.

Signal

Use the Connection table in the Block Parameters dialog box to select or change the signal that the block connects to. To connect the block to a signal:

  1. If the block is not connected, in the Property Inspector, on the Parameters tab, click Connect to open the Block Parameters dialog box. If the block is already connected and you want to change the signal to which it connects, click Change.

  2. Select a signal in the model.

  3. In the table, select the signal you want to connect.

  4. Click Apply.

To help understand and debug your model, you can connect dashboard blocks to signals in the model during simulation.

Tip

You can also use bind mode select or change the signal that the block connects to. To enter bind mode:

  • If you are in design mode, exit by clicking the Edit button on the Design tab of the Property Inspector.

  • Click the dashboard block in the canvas. If the dashboard block is not connected, the Connect button Connect button and an ellipsis appear over the dashboard block. If the dashboard block is already connected, only the ellipsis appears.

  • If the dashboard block is not connected, click Connect. If the dashboard block is connected, pause on the ellipsis. In the action menu that expands, click Connect. In either case, a list of signals that are available for connection appears.

The left image shows a selected dashboard block with the Connect button and the ellipsis hovering above it. The right image shows the same dashboard block with the action menu expanded above it, and the pointer hovering over the Connect button.

To connect the dashboard block in bind mode:

  • From the list, select the signal you want to connect.

  • To exit bind mode, click Done Connecting Done Connecting buttonover the dashboard block.

Programmatic Use

Block Parameter: Binding
Type: Simulink.HMI.SignalSpecification
Default: []
Main

You can display the name of the element to which the dashboard block connects in a label positioned at the top or at the bottom of the block, or you can hide the label. If you want the label to be visible, specify the position of the block. If you do not want the label to be visible, specify Hide.

Note

When the dashboard block is not connected to an element, the label is blank.

Programmatic Use

Block Parameter: LabelPosition
Type: character vector
Values: 'Hide' | 'Bottom' | 'Top'
Default: 'Hide'

Enable this option to maintain the aspect ratio when resizing the block in the Simulink canvas.

Tip

  • When the aspect ratio is locked, adding a new background image changes the aspect ratio of the block to match that of the background image.

  • When the aspect ratio is not locked, adding a new background image does not change the proportions of the block but instead stretches or scales the background image to fit the size of the block.

States

You can specify ranges of signal values that activate the Lamp block states. Select Specify State Values as Ranges and specify the minimum and maximum of the value range that activates each state.

Programmatic Use

To programmatically specify whether the states are each activated by a signal value or by a range of signal values, specify the StateValueType parameter as a string or a character vector. To activate each state with a signal value, set StateValueType to "Discrete". To activate each state with a range of signal values, set StateValueType to "Range".

Block Parameter: StateValueType
Type: character vector | string
Values: "Discrete" | "Range"
Default: "Discrete"

States pair a lamp color with a value of the connected signal. Each state consists of a Color and a State.

  • State — Connected signal value or range of signal values that cause the Lamp block to display the specified color. To specify a range of values, select Specify State Values as Ranges and specify the minimum and maximum of the range of values that activates each state.

  • Color — Lamp color when the connected signal value matches the corresponding State value. You can select from a palette of standard colors or specify a custom color with RGB values.

The [undefined] state specifies the color of the Lamp block when the connected signal value does not match any of the values specified in the States table. Click the + button to add another state.

Programmatic Use

To programmatically specify the State and Color parameter values for a Lamp block, use an array of structures that contain these fields:

  • Value — Scalar double signal value or vector specifying the minimum and maximum of a range of double signal values that cause the Lamp block to display the specified color indication.

    Note

    Specifying a vector enables the Specify State Values as Ranges option.

  • Color1-by-3 [r g b] vector with values between 0 and 1 that specifies the color for the Lamp block to display.

lampState1.Value = [1 2];
lampState1.Color = [0 0 1];
lampState2.Value = [2 3];
lampState2.Color = [1 0 0];
lampStates = [lampState1 lampState2];
Block Parameter: StateColors
Type: structure array
Default: structure

The ColorDefault parameter specifies the color for the Lamp block when the value of the connected signal does not match any of the specified state values. Specify the ColorDefault parameter as a 1-by-3 [r g b] vector with values between 0 and 1.

Block Parameter: ColorDefault
Type: [r g b] vector
Default: [0.7529 0.7529 0.7529]

Design

To customize the dashboard block, open the Property Inspector, click the Design tab, and click Edit.

Lamp

Enable this option to maintain the aspect ratio when resizing the block in the Simulink canvas.

Tip

  • When the aspect ratio is locked, adding a new background image changes the aspect ratio of the block to match that of the background image.

  • When the aspect ratio is not locked, adding a new background image does not change the proportions of the block but instead stretches or scales the background image to fit the size of the block.

States

Select a state that you want to configure from the drop-down menu in the Select State section of the States component. You can use a customizable Lamp block to design a lamp with any number of states greater than or equal to 1. Click + to add another state. Click X to delete the current state.

States match a display color to the value of the connected signal. Each state consists of a State and a Color.

  • State — Connected signal value or range of signal values that cause the Lamp block to display the specified color. To specify a range of values, select Specify State Values as Ranges and specify the minimum and maximum of the range of values that activates each state.

  • Color — Lamp color when the connected signal value matches the corresponding State value. You can select from a palette of standard colors or specify a custom color with RGB values.

The [default] state specifies the color of the Lamp block when the connected signal value does not match any of the values specified in the States table.

Note

You can configure more than the value and color of a state: you can configure all of the parameters in the States component of the Design tab for a state. For example, you can select an icon that will appear on the lamp when it is in the state. When you configure any of the parameters in the States component, the changes are applied to the state that is selected in the Select State section of the States component.

Tips

You can also configure the values and colors of the states for the block using the Parameters tab in the Property Inspector.

Programmatic Use

To programmatically specify the State and Color parameter values for a Lamp block, use an array of structures that contain these fields:

  • Value — Scalar double signal value or vector specifying the minimum and maximum of a range of double signal values that cause the Lamp block to display the specified color indication.

    Note

    Specifying a vector enables the Specify State Values as Ranges option.

  • Color1-by-3 [r g b] vector with values between 0 and 1 that specifies the color for the Lamp block to display.

lampState1.Value = [1 2];
lampState1.Color = [0 0 1];
lampState2.Value = [2 3];
lampState2.Color = [1 0 0];
lampStates = [lampState1 lampState2];
Block Parameter: StateColors
Type: structure array
Default: structure

The ColorDefault parameter specifies the color for the Lamp block when the value of the connected signal does not match any of the specified state values. Specify the ColorDefault parameter as a 1-by-3 [r g b] vector with values between 0 and 1.

Block Parameter: ColorDefault
Type: [r g b] vector
Default: [0.7529 0.7529 0.7529]

Apply the settings of the default state to all other states. This option applies to all settings in the States component except for the settings in the Value and Color section.

You can specify ranges of signal values that activate the states. Select Specify State Values as Ranges and specify the minimum and maximum of the value range that activates each state.

Programmatic Use

To programmatically specify whether the states are each activated by a signal value or by a range of signal values, specify the StateValueType parameter as a string or a character vector. To activate each state with a signal value, set StateValueType to "Discrete". To activate each state with a range of signal values, set StateValueType to "Range".

Block Parameter: StateValueType
Type: character vector | string
Values: "Discrete" | "Range"
Default: "Discrete"

Each state pairs a Value with a Color. Specify the Value that activates the state selected in the Design tab.

Note

When the Specify State Values as Ranges option is enabled, the Value parameter changes to the parameters Minimum and Maximum, which allow you to define a range by specifying its minimum and maximum values.

Example: 0

Each state pairs a Value with a Color. Choose the Color of the state selected in the Design tab from the palette of standard colors, or specify a custom color.

Example: [1 0 0]

Specify the opacity of the state Color as a scalar value from 0 to 1.

Example: 0.5

A lamp can show up to three different colors:

  • State Color

  • Color of the selected icon in the Property Inspector

  • Background color or the background image, depending on which is activated

The colors that show on the lamp depend on how the shape and icon layers of the Lamp block are combined. Select how to combine the layers:

  • In the Intersect style, the area where the shape and icon overlap has the state Color. The area where the shape and icon do not overlap has the background color or image.

  • In the Simple style, the area of the shape that is not covered by the icon has the state Color. The icon on the lamp has the same colors as its counterpart in the Property Inspector. The remaining area has the background color or image.

  • In the Subtract style, the area of the shape that is not covered by the icon has the state Color. The remaining area has the background color or image.

Three Lamp blocks, each configured for one of the three ways you can combine the shape and icon: simple, intersect, or subtract.

Example: 'Simple'

Select a shape that, in combination with the icon, determines the area on the lamp to which the state Color is applied. Choose a circle, a square, or a triangle.

Use an icon to configure the appearance of the Lamp block in the model. You can choose from built-in shape, automotive, and wireless icons, or you can upload your own custom SVG file as an icon.

To view icon options, in the Icon section, select an Icon Type. To use your own SVG file as the block icon, in the Icon section, select Custom as the Icon Type, and in the Custom Icon section, click the plus button to upload the SVG file.

Shape Icons

IconIcon NameProgrammatic Use Value

Lamp icon: a solid gray circle

LampDefault

Check1 icon: a check mark

Check1Check1

Check2 icon: a check mark with slightly curved lines

Check2Check2

Check3 icon: the outline of a check mark

Check3Check3

Check4 icon: a check mark with a divot along its outline

Check4Check4

Circle icon: a solid black circle

CircleCircle

Ex1 icon: a cross mark

Ex1Ex1

Ex2 icon: a cross mark with one curved line

Ex2Ex2

Ex3 icon: the outline of a cross mark

Ex3Ex3

Ex4 icon: a cross mark with a divot along the outline

Ex4Ex4

Face icon: the outline of a face with a closed mouth in a straight line

FaceFace

Frown1 icon: the outline of a face with an open downturned mouth

Frown1Frown1

Frown2 icon: the outline of a face with a closed downturned mouth

Frown2Frown2

Hexagon icon: a solid hexagon

HexagonHexagon

L-shaped membrane icon: the silhouette of the L-shaped membrane

L-shaped MembraneMembrane

Pentagon icon: a solid pentagon

PentagonPentagon

Rectangle icon: a solid rectangle

RectangleRectangle

Smile1 icon: the outline of a face with an open upturned mouth

Smile1Smile1

Smile2 icon: the outline of a face with a closed upturned mouth

Smile2Smile2

Solid Face icon: a solid face with a closed mouth in a straight line

Solid FaceSolidFace

Solid Frown1 icon: a solid face with an open downturned mouth

Solid Frown1SolidFrown1

Solid Frown2 icon: a closed downturned mouth

Solid Frown2SolidFrown2

Solid Smile1 icon: a solid face with an open upturned mouth

Solid Smile1SolidSmile1

Solid Smile2 icon: a solid face with a closed upturned mouth

Solid Smile2SolidSmile2

Square icon: a solid square

SquareSquare

Triangle icon: a solid triangle

TriangleTriangle

Automotive Icons

IconIcon NameProgrammatic Use Value

Adaptive Cruise Control icon: a speedometer with an arrow pointing to a tickmark, and the silhouette of a car in the background

Adaptive Cruise ControlAdaptiveCruiseControl

Adaptive Cruise Control Failure icon: a speedometer with an exclamation mark next to it, and the silhouette of a car in the background

Adaptive Cruise Control FailureAdaptiveCruiseControlFailure

Antilock Brake System icon: a circle labeled "ABS" in a set of parentheses

Antilock Brake SystemAntilockBrakeSystem

Battery icon: the outline of a battery, with a + symbol on the positive pole, and a - symbol on the negative pole

BatteryBattery

Check Engine icon: the outline of an engine labeled "Check Engine"

Check EngineCheckEngine

Check Engine2 icon: the outline of an engine with the silhouette of a lightning rod on it, and the word "CHECK" underneath it

Check Engine2CheckEngine2

Cruise Control icon: a speedometer with an arrow pointing to one of the tickmarks

Cruise ControlCruiseControl

Eco Mode icon: a solid leaf shape labeled "ECO"

Eco ModeEcoMode

Electronic Stability icon: a circle labeled "ESP" in a set of parentheses

Electronic StabilityElectronicStability

Engine icon: the silhouette of an engine

EngineEngine

Engine Coolant Temp icon: a thermometer with waves in the background

Engine Coolant TempEngineCoolantTemp

Engine Failure icon: the silhouette of an engine with an exclamation mark on it

Engine FailureEngineFailure

Engine Heating icon: the silhouette of an engine with three wavy arrows pointing upwards on it

Engine HeatingEngineHeating

Engine Oil icon: the silhouette of an oil can

Engine OilEngineOil

Exterior Bulb Failure icon: the silhouette of a glowing light bulb with an exclamation mark on it

Exterior Bulb FailureExteriorBulbFailure

Front Fog Light icon: the outline of a fog light lamp emitting rays of light to the left that are depicted as diagonal lines on top of a wavy vertical line that represents the fog

Front Fog LightFrontFogLight

Fuel icon: the silhouette of a gas pump with an arrow pointing left on it

FuelFuel

Hazards icon: the outline of a warning triangle

HazardsHazards

Headlamp Leveling icon: the outline of a lamp emitting rays of light with an arrow pointing clockwise above them and an arrow pointing counterclockwise below them to indicate that the lamp can be turned to level the light rays

Headlamp LevelingHeadlampLeveling

High Beams icon: the outline of a lamp emitting horizontal rays of light

High BeamsHighBeams

Hill Descent Control icon: the outline of a car driving down a slope

Hill Descent ControlHillDescentControl

Lighting Switch icon: the silhouette of a glowing light bulb

Lighting SwitchLightingSwitch

High Beams icon: the outline of a lamp emitting rays of light that run diagonally downward

Low BeamsLowBeams

Parking Assistance icon: the letter "P" next to a solid triangle that represents an obstacle, and the "P" emits a detection signal represented as three curved lines aimed at the triangle

Parking AssistanceParkingAssistance

Rear Fog Light icon: the outline of a fog light lamp emitting rays of light to the right that are depicted as horizontal lines on top of a wavy vertical line that represents the fog

Rear Fog LightRearFogLight

Side Lights icon: the outline two lamps emitting rays of light to the left and right

Side LightsSideLights

Stability Control icon: the silhouette of a car with wavy lines behind it to represent the car slipping

Stability ControlStabilityControl

Stability Control Off icon: the silhouette of a car with wavy lines behind it to represent the car slipping, and the word "OFF" underneath

Stability Control OffStabilityControlOff

Tire Monitor icon: the outline of the cross-section of a tire with an exclamation mark on it

Tire MonitorTireMonitor

Traction Control icon: the outline of the cross-section of a tire with the label "TC"

Traction ControlTractionControl

Traction Control Off icon: the outline of the cross-section of a tire with the label "TC" and a diagonal slash through the whole image

Traction Control OffTractionControlOff

Traction Control Failure icon: the outline of the cross-section of a tire with the label "TC" and an exclamation mark next to it

Traction Control FailureTractionControlFailure

Turn Signal Left icon: a solid arrow pointing left

Turn Signal LeftTurnSignalLeft

Turn Signal Right icon: a solid arrow pointing right

Turn Signal RightTurnSignalRight

Wireless Icons

IconIcon NameProgrammatic Use Value

Network icon: the wireless internet connection icon

NetworkNetwork

Network No Signal icon: the wireless internet connection icon grayed out, with a crossed-out circle next to it

Network No SignalNetworkNoSignal

Network Transmission icon: a wireless internet tower

Network TransmissionNetworkTransmission

Network3G icon: the wireless internet connection icon with "3G" next to it

Network3GNetwork3G

Network4G icon: the wireless internet connection icon with "4G" next to it

Network4GNetwork4G

Network5G icon: the wireless internet connection icon with "4G" next to it

Network5GNetwork5G

Tip

The Dashboard library has libraries with a preconfigured Lamp block for each icon.

Programmatic Use

Block Parameter: Icon
Type: string | character vector
Default: 'Default'

Specify the horizontal offset of the left edge of the bounding box of the shape and icon combination from the left edge of the block as a ratio of the block width. Relative to the position of the shape and icon combination when the offset is 0, an offset with a negative value moves the combination left and an offset with a positive value moves the combination right.

Example: 1

Specify the vertical offset of the top edge of the bounding box of the shape and icon combination from the top edge of the block as a ratio of the block height. Relative to the position of the shape and icon combination when the offset is 0, an offset with a negative value moves the combination up and an offset with a positive value moves the combination down.

Example: 1

Specify the width of the bounding box of the shape and icon combination as a ratio of the block width.

Example: 0.5

Specify the height of the bounding box of the shape and icon combination as a ratio of the block height.

Example: 0.5

You can modify how the icon is shown on the lamp by zooming in or out on its center. Specify the zoom level as a scalar value from 0 to 2. When the Icon Size is 1, the icon is zoomed to show the whole image as large as is possible within the limits of the bounding box of the shape and icon combination. When the Icon Size is larger than 1, the image is cut off at the limits of the bounding box.

Example: 0.5

Background Image

For the block background, you can provide a background image or select a solid color. To select a solid background color, select this parameter. To provide a background image, clear this parameter.

Note

Changing the background color using the Format tab of the Simulink Toolstrip removes the background image and enables the Use Background Color parameter.

Example: on

To select a solid background color, enable the Use Background Color parameter. Then, choose a background color from the palette of standard colors, or specify a custom color.

Tip

You can also specify the Background Color in the Format tab of the Simulink Toolstrip.

To specify the color of the block text, use the Font Color parameter.

Programmatic Use

Specify the BackgroundColor parameter for the block as a 1-by-3 [r g b] vector with values between 0 and 1 that is formatted as a string or a character vector.

Block Parameter: BackgroundColor
Type: character vector | string
Values: [r g b] vector

Specify the block background opacity as a scalar value from 0 to 1.

Example: 0.5

Specify the corner radius of the area covered by the block background color as a ratio of half of the smaller of the two block dimensions, width or height.

Example: 0.25

Foreground Image

Specify the horizontal offset of the left edge of the image from the left edge of the block as a ratio of the block width. Relative to the position of the image when the offset is 0, an offset with a negative value moves the image left, and an offset with a positive value moves the image right.

Example: 1

Specify the vertical offset of the top edge of the image from the top edge of the block as a ratio of the block height. Relative to the position of the image when the offset is 0, an offset with a negative value moves the image up, and a positive value moves the image down.

Example: 1

Specify the image width as a ratio of the block width.

Example: 0.5

Specify the image height as a ratio of the block height.

Example: 0.5

Enable this option to maintain the aspect ratio when resizing the image using the Property Inspector.

Block Characteristics

Data Types

Boolean | double | enumerated | fixed point | half | integer | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

Version History

Introduced in R2021b

expand all