mirror of https://github.com/ArduPilot/ardupilot
AP_Scripting: add bindings for the AP_TemperatureSensor
This commit is contained in:
parent
0020cf5fe8
commit
83c9b32093
|
@ -3140,6 +3140,14 @@ function BattMonitorScript_State_ud:voltage(value) end
|
|||
---@param value boolean
|
||||
function BattMonitorScript_State_ud:healthy(value) end
|
||||
|
||||
-- The temperature library provides access to information about the currently connected temperature sensors on the vehicle.
|
||||
temperature_sensor = {}
|
||||
|
||||
-- Returns the temperature from this sensor in degrees Celsius
|
||||
---@param instance integer -- temperature instance
|
||||
---@return number|nil -- temperature if available
|
||||
function temperature_sensor:get_temperature(instance) end
|
||||
|
||||
-- The battery library provides access to information about the currently connected batteries on the vehicle.
|
||||
battery = {}
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
--[[
|
||||
simple example of reading a temperature sensor
|
||||
--]]
|
||||
|
||||
local MAV_SEVERITY = {EMERGENCY=0, ALERT=1, CRITICAL=2, ERROR=3, WARNING=4, NOTICE=5, INFO=6, DEBUG=7}
|
||||
|
||||
--[[
|
||||
main update function, called at 1Hz
|
||||
--]]
|
||||
function update()
|
||||
local temperature_C = temperature_sensor:get_temperature(0)
|
||||
gcs:send_text(MAV_SEVERITY.INFO, string.format("Temperature: %f", temperature_C))
|
||||
return update, 1000
|
||||
end
|
||||
|
||||
-- start running update loop
|
||||
return update, 1000
|
||||
|
|
@ -977,3 +977,9 @@ singleton AP_VisualOdom depends HAL_VISUALODOM_ENABLED
|
|||
singleton AP_VisualOdom rename visual_odom
|
||||
singleton AP_VisualOdom method healthy boolean
|
||||
singleton AP_VisualOdom method quality int8_t
|
||||
|
||||
-- ----AP_TemperatureSensor Library----
|
||||
include AP_TemperatureSensor/AP_TemperatureSensor.h
|
||||
singleton AP_TemperatureSensor depends AP_TEMPERATURE_SENSOR_ENABLED
|
||||
singleton AP_TemperatureSensor rename temperature_sensor
|
||||
singleton AP_TemperatureSensor method get_temperature boolean float'Null uint8_t'skip_check
|
||||
|
|
Loading…
Reference in New Issue