Mission Planner HUD text display with Lua

Hoping someone can help me with with some Lua scripts im writing.
I’m trying to display some custom messages based on the PWM in of certain channels, all of which is working apart from the fact that the text on the GCS always overlaps each other.
Im using the command

gcs:send_text(0, string.format(“Some Custom Message”))

This always display the text in red in the middle of the screen.

I’ve seen suggestions of changing the “severity” parameter i.e the 0 at the start of the command, but anything other than 0 i.e

gcs:send_text(1, string.format(“Some Custom Message”))
results in no text at all being displayed by the HUD.

Any help appreciated!

Somewhat counterintuitively, the “Planner” tab under “CONFIG” for Mission Planner has an option for this under “Speech.”

image

The dropdown affects both spoken messages as well as those displayed in the HUD, even if text to speech is disabled.

Here’s a quick script you can use to test:

local MAV_TEXT = {
    [0] = 'EMERGENCY',
    [1] = 'ALERT',
    [2] = 'CRITICAL',
    [3] = 'ERROR',
    [4] = 'WARNING',
    [5] = 'NOTICE',
    [6] = 'INFO',
    [7] = 'DEBUG'
}

local severity = 0

function update()
    gcs:send_text(severity, 'Severity: ' .. MAV_TEXT[severity])
    severity = (severity + 1) % 8
    return update, 5000
end

return update()

Hi Yuri

Thanks so much for this, that did the trick for the printing and colours, is there any control over the position of the screen that you know of? I’ve set the low warning all the way to debug so my prints are all coming through, but still get overlap for position on screen, i.e severity 4 and 5 will toggle and ideally i’d like them both to be on screen at once, is this possible?

I don’t think you can adjust screen position without modifying source code (not recommended).