Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
dd02faef
Commit
dd02faef
authored
May 20, 2018
by
dnc40085
Committed by
Marcel Stör
May 20, 2018
Browse files
Add function node.getcpufreq() (#2375)
parent
914a4afc
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/modules/node.c
View file @
dd02faef
...
...
@@ -386,6 +386,13 @@ static int node_setcpufreq(lua_State* L)
return
1
;
}
// Lua: freq = node.getcpufreq()
static
int
node_getcpufreq
(
lua_State
*
L
)
{
lua_pushinteger
(
L
,
system_get_cpu_freq
());
return
1
;
}
// Lua: code, reason [, exccause, epc1, epc2, epc3, excvaddr, depc ] = bootreason()
static
int
node_bootreason
(
lua_State
*
L
)
{
...
...
@@ -622,6 +629,7 @@ static const LUA_REG_TYPE node_map[] =
{
LSTRKEY
(
"CPU80MHZ"
),
LNUMVAL
(
CPU80MHZ
)
},
{
LSTRKEY
(
"CPU160MHZ"
),
LNUMVAL
(
CPU160MHZ
)
},
{
LSTRKEY
(
"setcpufreq"
),
LFUNCVAL
(
node_setcpufreq
)
},
{
LSTRKEY
(
"getcpufreq"
),
LFUNCVAL
(
node_getcpufreq
)
},
{
LSTRKEY
(
"bootreason"
),
LFUNCVAL
(
node_bootreason
)
},
{
LSTRKEY
(
"restore"
),
LFUNCVAL
(
node_restore
)
},
{
LSTRKEY
(
"random"
),
LFUNCVAL
(
node_random
)
},
...
...
docs/en/modules/node.md
View file @
dd02faef
...
...
@@ -185,6 +185,27 @@ none
#### Returns
flash size in bytes (integer)
## node.getcpufreq()
Get the current CPU Frequency.
#### Syntax
`node.getcpufreq()`
#### Parameters
none
#### Returns
Current CPU frequency (number)
#### Example
```
lua
do
local
cpuFreq
=
node
.
getcpufreq
()
print
(
"The current CPU frequency is "
..
cpuFreq
..
" MHz"
)
end
```
## node.heap()
Returns the current available heap size in bytes. Note that due to fragmentation, actual allocations of this size may not be possible.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment