mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 20:35:17 +03:00
added getRtcTime() LUA function (#5524)
This allows for retrieving the UNIX timestamp kept internally.
This commit is contained in:
parent
4df64695c7
commit
e63a877ed6
1 changed files with 22 additions and 0 deletions
|
@ -167,6 +167,25 @@ static int luaGetDateTime(lua_State * L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*luadoc
|
||||||
|
@function getRtcTime()
|
||||||
|
|
||||||
|
Return current RTC system date as unix timstamp (in seconds since 1. Jan 1970)
|
||||||
|
|
||||||
|
Please note the RTC timestamp is kept internally as a 32bit integer, which will overflow
|
||||||
|
in 2038.
|
||||||
|
|
||||||
|
@retval number Number of seconds elapsed since 1. Jan 1970
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(RTCLOCK)
|
||||||
|
static int luaGetRtcTime(lua_State * L)
|
||||||
|
{
|
||||||
|
lua_pushunsigned(L, g_rtcTime);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void luaPushLatLon(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
|
static void luaPushLatLon(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
|
||||||
/* result is lua table containing members ["lat"] and ["lon"] as lua_Number (doubles) in decimal degrees */
|
/* result is lua table containing members ["lat"] and ["lon"] as lua_Number (doubles) in decimal degrees */
|
||||||
{
|
{
|
||||||
|
@ -1206,6 +1225,9 @@ static int luaGetUsage(lua_State * L)
|
||||||
const luaL_Reg opentxLib[] = {
|
const luaL_Reg opentxLib[] = {
|
||||||
{ "getTime", luaGetTime },
|
{ "getTime", luaGetTime },
|
||||||
{ "getDateTime", luaGetDateTime },
|
{ "getDateTime", luaGetDateTime },
|
||||||
|
#if defined(RTCLOCK)
|
||||||
|
{ "getRtcTime", luaGetRtcTime },
|
||||||
|
#endif
|
||||||
{ "getVersion", luaGetVersion },
|
{ "getVersion", luaGetVersion },
|
||||||
{ "getGeneralSettings", luaGetGeneralSettings },
|
{ "getGeneralSettings", luaGetGeneralSettings },
|
||||||
{ "getValue", luaGetValue },
|
{ "getValue", luaGetValue },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue