diff --git a/libraries/AP_Scripting/generator/description/bindings.desc b/libraries/AP_Scripting/generator/description/bindings.desc index 77c69341bd..6482ee7984 100644 --- a/libraries/AP_Scripting/generator/description/bindings.desc +++ b/libraries/AP_Scripting/generator/description/bindings.desc @@ -54,6 +54,7 @@ singleton AP_BattMonitor method pack_capacity_mah int32_t uint8_t 0 ud->num_inst singleton AP_BattMonitor method has_failsafed boolean singleton AP_BattMonitor method overpower_detected boolean uint8_t 0 ud->num_instances() singleton AP_BattMonitor method get_temperature boolean float'Null uint8_t 0 ud->num_instances() +singleton AP_BattMonitor method get_cycle_count boolean uint8_t 0 ud->num_instances() uint16_t'Null include AP_GPS/AP_GPS.h diff --git a/libraries/AP_Scripting/lua_generated_bindings.cpp b/libraries/AP_Scripting/lua_generated_bindings.cpp index cf13f8d1d8..88d3a6903c 100644 --- a/libraries/AP_Scripting/lua_generated_bindings.cpp +++ b/libraries/AP_Scripting/lua_generated_bindings.cpp @@ -1203,6 +1203,29 @@ static int AP_GPS_num_sensors(lua_State *L) { return 1; } +static int AP_BattMonitor_get_cycle_count(lua_State *L) { + AP_BattMonitor * ud = AP_BattMonitor::get_singleton(); + if (ud == nullptr) { + return luaL_argerror(L, 1, "battery not supported on this firmware"); + } + + binding_argcheck(L, 2); + const lua_Integer raw_data_2 = luaL_checkinteger(L, 2); + luaL_argcheck(L, ((raw_data_2 >= MAX(0, 0)) && (raw_data_2 <= MIN(ud->num_instances(), UINT8_MAX))), 2, "argument out of range"); + const uint8_t data_2 = static_cast(raw_data_2); + uint16_t data_5003 = {}; + const bool data = ud->get_cycle_count( + data_2, + data_5003); + + if (data) { + lua_pushinteger(L, data_5003); + } else { + lua_pushnil(L); + } + return 1; +} + static int AP_BattMonitor_get_temperature(lua_State *L) { AP_BattMonitor * ud = AP_BattMonitor::get_singleton(); if (ud == nullptr) { @@ -1764,6 +1787,7 @@ const luaL_Reg AP_GPS_meta[] = { }; const luaL_Reg AP_BattMonitor_meta[] = { + {"get_cycle_count", AP_BattMonitor_get_cycle_count}, {"get_temperature", AP_BattMonitor_get_temperature}, {"overpower_detected", AP_BattMonitor_overpower_detected}, {"has_failsafed", AP_BattMonitor_has_failsafed},