Skip to content

Commit 23e31b6

Browse files
committed
rtctime: expose set_rate to Lua
1 parent dadcd3f commit 23e31b6

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

app/modules/rtctime.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ static int rtctime_set (lua_State *L)
144144
return 0;
145145
}
146146

147+
static int rtctime_set_rate (lua_State *L)
148+
{
149+
rtc_time_set_rate(luaL_checkinteger(L, 1));
150+
return 0;
151+
}
152+
147153
// sec, usec = rtctime.get ()
148154
static int rtctime_get (lua_State *L)
149155
{
@@ -229,6 +235,7 @@ static int rtctime_epoch2cal (lua_State *L)
229235
// Module function map
230236
LROT_BEGIN(rtctime, NULL, 0)
231237
LROT_FUNCENTRY( set, rtctime_set )
238+
LROT_FUNCENTRY( set_rate, rtctime_set_rate )
232239
LROT_FUNCENTRY( get, rtctime_get )
233240
LROT_FUNCENTRY( adjust_delta, rtctime_adjust_delta )
234241
LROT_FUNCENTRY( dsleep, rtctime_dsleep )

docs/modules/rtctime.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ rtctime.set(1436430589, 0)
158158
#### See also
159159
[`sntp.sync()`](sntp.md#sntpsync)
160160

161+
## rtctime.set_rate()
162+
Adjust the RTC rate, as per [`rtctime.set()`](#rtctimeset), but without also setting the time.
163+
164+
#### Syntax
165+
`rtctime.set_rate(rate)`
166+
161167
## rtctime.adjust_delta()
162168

163169
This takes a time interval in 'system clock microseconds' based on the timestamps returned by `tmr.now` and returns

tools/luacheck_config.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ stds.nodemcu_libs = {
540540
dsleep_aligned = empty,
541541
epoch2cal = empty,
542542
get = empty,
543-
set = empty
543+
set = empty,
544+
set_rate = empty
544545
}
545546
},
546547
si7021 = {

0 commit comments

Comments
 (0)