Skip to content

Commit

Permalink
rtctime: expose set_rate to Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
nwf committed Jun 13, 2020
1 parent dadcd3f commit 23e31b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/modules/rtctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ static int rtctime_set (lua_State *L)
return 0;
}

static int rtctime_set_rate (lua_State *L)
{
rtc_time_set_rate(luaL_checkinteger(L, 1));
return 0;
}

// sec, usec = rtctime.get ()
static int rtctime_get (lua_State *L)
{
Expand Down Expand Up @@ -229,6 +235,7 @@ static int rtctime_epoch2cal (lua_State *L)
// Module function map
LROT_BEGIN(rtctime, NULL, 0)
LROT_FUNCENTRY( set, rtctime_set )
LROT_FUNCENTRY( set_rate, rtctime_set_rate )
LROT_FUNCENTRY( get, rtctime_get )
LROT_FUNCENTRY( adjust_delta, rtctime_adjust_delta )
LROT_FUNCENTRY( dsleep, rtctime_dsleep )
Expand Down
6 changes: 6 additions & 0 deletions docs/modules/rtctime.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ rtctime.set(1436430589, 0)
#### See also
[`sntp.sync()`](sntp.md#sntpsync)

## rtctime.set_rate()
Adjust the RTC rate, as per [`rtctime.set()`](#rtctimeset), but without also setting the time.

#### Syntax
`rtctime.set_rate(rate)`

## rtctime.adjust_delta()

This takes a time interval in 'system clock microseconds' based on the timestamps returned by `tmr.now` and returns
Expand Down
3 changes: 2 additions & 1 deletion tools/luacheck_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ stds.nodemcu_libs = {
dsleep_aligned = empty,
epoch2cal = empty,
get = empty,
set = empty
set = empty,
set_rate = empty
}
},
si7021 = {
Expand Down

0 comments on commit 23e31b6

Please sign in to comment.