Create an LCD screen with the HTML Canvas

This example shows how to create an LCD screen on a dashboard by using the HTML Canvas widget.

HTML:

<div id="image_background">
<p>Last value:</p>
<span id="image_background_text">No data</span>
</div>

CSS:

@import url('https://fonts.googleapis.com/css?family=VT323');

#image_background {
background: url('https://i.imgur.com/uuYygjz.png') 0 / contain no-repeat;
font-family: "VT323";
font-size: 25px;
letter-spacing: 10.5px;
height: 220px;
width: 450px;
}

#image_background p, #image_background_text {
margin: 0;
left: 75px;
position: absolute;
}

#image_background p {
top: 88px;
font-size: 25px !important;
}

#image_background_text {
top: 121px;
}

JavaScript:

In the following code, the VAR_ID variable must be set according to the variable that should be displayed:

Once the settings are saved, it will look like this:

Adjusting the screen's contrast

Modify the HTML to:

Modify the CSS code to:

Modify the JavaScript code to:

Lastly, add another 3rd party library needed for this implementation:

This is the result:

Last updated

Was this helpful?