AP_Scripting: Examples: message_interval: give checker a hint about types

This commit is contained in:
Iampete1 2024-12-06 22:40:41 +00:00 committed by Randy Mackay
parent 9d21b3396e
commit e4de4c9b41
1 changed files with 6 additions and 0 deletions

View File

@ -44,6 +44,12 @@ gcs:send_text(MAV_SEVERITY.INFO, "Loaded message_interval.lua")
function update() -- this is the loop which periodically runs
for i = 1, #intervals do -- we want to iterate over every specified interval
local channel, message, interval_hz = table.unpack(intervals[i]) -- this extracts the channel, MAVLink ID, and interval
-- Lua checks get the unpacked types wrong, these are the correct types
---@cast channel integer
---@cast message uint32_t_ud
---@cast interval_hz number
local interval_us = -1
if interval_hz > 0 then
interval_us = math.floor(1000000 / interval_hz) -- convert the interval to microseconds