Building a warning dash / howto: Icon LEDs

What you can basically find in this article is how to create a flashing LED with an icon, changing state based on one or more conditions.

Let’s start:

Everybody knows (and fears) the engine light coming on on your car dash… Simple icon with a clear message. When enhancing my screen during the last few days, I implemented something similar in simCNC.

The meaning of my icons from left to right

  • Thermometer: If the machine was started up initially, this LED will flash to remind the operator to run the warmup cycle.
  • Gauge: Sensor to check the minimum air pressure. Below 7.0 bar, the ATC will not function properly
  • Warning: Axis error. My motor drive alarm signals are wired to my CSMIO. If 1 or more go into error, this LED will be lit
  • EStop: Will be activated on external EStop from my safety relais. Helpful to understand why you cannot activate the machine
  • Ref: Lights up if the machine is not referenced
  • Softlimits: On, if the softlimits are ignored. A gentle reminder 🙂

The dash consits of some more functions, which I will create a separate post on shortly (tool display with tool specific icons, info on work coordinate system, clock).
This article concentrates on the warning icons only.

How to

My icons

All my icons were created in PowerPoint and saved as transparent PNG.

Sounds silly and yes, I do have actually better software to create icons (Vectornator, Inkscape, etc.), but its a fast way to get things done.

On the screen

Basically a horizontal layout. The separation lines are PNG images I added as labels, set to „icon only“. The „custom LEDs“ are actually tool buttons, again with a transparent PNG icon created in PowerPoint.


Let’s start simple. The „custom LED“ lit up in red is my drive alarm warning which I have wired into the CSMIO and added to a specific axis in the simCNC motion kit config.

With the „or“ statement, the LED will light up in case any drive is currently in fault. Of course simCNC will also throw a warning message, but the LED is a permanent hint on why the machine is no longer moving (or cannot be recovered from EStop mode).

# Pin settings for drive alert set as NO
in_drive_fault_x1 = 11
in_drive_fault_x2 = 12
in_drive_fault_Y = 13
in_drive_fault_Z = 14

# Axis warning
if getPinStatus(in_drive_fault_x1) == True or getPinStatus(in_drive_fault_x2) == True or  getPinStatus(in_drive_fault_y) == True or  getPinStatus(in_drive_fault_z) == True:
    gui.led_dash_err_axis.setAttribute("styleSheet", f"background-color: '#8a0606';")
    gui.led_dash_err_axis.setAttribute("styleSheet", f"background-color: none;")

Flashing LED

The standard „LED button“ from the GUI elements has a interval setting built in. Regular LEDs do not. But of course, our „custom LED“ wouldn’t be complete without this feature.

Inspired by the CsLab script for the flashing signal tower lights, you can use a similar setup to cycle through color values. I used a nice red, #8a0606 to draw some attention but set a 2000ms interval to not disturb the user too much.

import time
timeLast = time.time()

in_pressure = 9 # input pin for pressure sensor, false when pressure too low for atc

flashInterval = 2000 #time in ms!

# function to set alternating colors to variable bgcolor
def cycle(interval):
	global timeLast
	interval = interval / 1000
	timeCurr = time.time()
	bgcolor = ""
	if timeCurr > (timeLast  + interval / 2):
		bgcolor = "#8a0606" # "even" color
	if timeCurr > (timeLast  + interval):
		timeLast  = timeCurr
		bgcolor = "none"; # "uneven" color

	return bgcol

# loop to run the script endless
while True :	
	bgColor = cycle(flashInterval) 
        # Air pressure too low
        if getPinStatus(in_pressure) == False: # if pressure is too low, set color of cycle
            gui.led_dash_err_pressure.setAttribute("styleSheet", f"background-color:{bgColor}")	
        else: # reset if pressure is back to normal
            gui.led_dash_err_pressure.setAttribute("styleSheet", f"background-color: none;")	

Within the while loop you can now add additional logic for the other LEDs. Just copy the air pressure block and change the reference to the GUI element and your inputs / simCNC provided variables.


  1. Save the above script and give it an easy to understand name. Store it under profiles/<yourprofile>/scripts or screens/<yourscreen>/scripts.
  2. In the settings, go to PyActions and create a new action
  3. Set it to event „timer“ and interval „1 second“ to trigger your script automatically.
  4. That’s it. Press OK and your custom LEDs will start flashing

Schreibe einen Kommentar 0

Your email address will not be published. Required fields are marked *