Skip to content

Commit

Permalink
AP_Scripting: Examples: message_interval: give checker a hint about t…
Browse files Browse the repository at this point in the history
…ypes
  • Loading branch information
IamPete1 authored and rmackay9 committed Dec 7, 2024
1 parent 9d21b33 commit e4de4c9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/AP_Scripting/examples/message_interval.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4de4c9

Please sign in to comment.