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
606f9166
Unverified
Commit
606f9166
authored
Aug 29, 2020
by
Philip Gladstone
Committed by
GitHub
Aug 29, 2020
Browse files
First phase of number to integer conversion (#3221)
parent
0e02c0e5
Changes
30
Show whitespace changes
Inline
Side-by-side
app/modules/switec.c
View file @
606f9166
...
@@ -152,8 +152,8 @@ static int lswitec_getpos( lua_State* L )
...
@@ -152,8 +152,8 @@ static int lswitec_getpos( lua_State* L )
if
(
switec_getpos
(
id
,
&
pos
,
&
dir
,
&
target
))
{
if
(
switec_getpos
(
id
,
&
pos
,
&
dir
,
&
target
))
{
return
luaL_error
(
L
,
"Unable to get position."
);
return
luaL_error
(
L
,
"Unable to get position."
);
}
}
lua_push
numb
er
(
L
,
pos
);
lua_push
integ
er
(
L
,
pos
);
lua_push
numb
er
(
L
,
dir
);
lua_push
integ
er
(
L
,
dir
);
return
2
;
return
2
;
}
}
...
...
app/modules/tsl2561.c
View file @
606f9166
...
@@ -51,7 +51,7 @@ static int ICACHE_FLASH_ATTR tsl2561_init(lua_State* L) {
...
@@ -51,7 +51,7 @@ static int ICACHE_FLASH_ATTR tsl2561_init(lua_State* L) {
tsl2561SetPackage
(
package
);
tsl2561SetPackage
(
package
);
}
}
}
}
lua_push
numb
er
(
L
,
error
);
lua_push
integ
er
(
L
,
error
);
return
1
;
return
1
;
}
}
/* Sets the integration time and gain settings of the device
/* Sets the integration time and gain settings of the device
...
@@ -71,7 +71,7 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_settiming(lua_State* L) {
...
@@ -71,7 +71,7 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_settiming(lua_State* L) {
return
luaL_error
(
L
,
"Invalid argument: gain"
);
return
luaL_error
(
L
,
"Invalid argument: gain"
);
}
}
lua_push
numb
er
(
L
,
tsl2561SetTiming
(
integration
,
gain
));
lua_push
integ
er
(
L
,
tsl2561SetTiming
(
integration
,
gain
));
return
1
;
return
1
;
}
}
/* Reads sensor values from device and return calculated lux
/* Reads sensor values from device and return calculated lux
...
@@ -80,11 +80,11 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_settiming(lua_State* L) {
...
@@ -80,11 +80,11 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_settiming(lua_State* L) {
static
int
ICACHE_FLASH_ATTR
tsl2561_lua_calclux
(
lua_State
*
L
)
{
static
int
ICACHE_FLASH_ATTR
tsl2561_lua_calclux
(
lua_State
*
L
)
{
uint8_t
error
=
tsl2561GetLuminosity
(
&
ch0
,
&
ch1
);
uint8_t
error
=
tsl2561GetLuminosity
(
&
ch0
,
&
ch1
);
if
(
error
)
{
if
(
error
)
{
lua_push
numb
er
(
L
,
0
);
lua_push
integ
er
(
L
,
0
);
lua_push
numb
er
(
L
,
error
);
lua_push
integ
er
(
L
,
error
);
}
else
{
}
else
{
lua_push
numb
er
(
L
,
tsl2561CalculateLux
(
ch0
,
ch1
));
lua_push
integ
er
(
L
,
tsl2561CalculateLux
(
ch0
,
ch1
));
lua_push
numb
er
(
L
,
error
);
lua_push
integ
er
(
L
,
error
);
}
}
return
2
;
return
2
;
}
}
...
@@ -93,9 +93,9 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_calclux(lua_State* L) {
...
@@ -93,9 +93,9 @@ static int ICACHE_FLASH_ATTR tsl2561_lua_calclux(lua_State* L) {
*/
*/
static
int
ICACHE_FLASH_ATTR
tsl2561_lua_getchannels
(
lua_State
*
L
)
{
static
int
ICACHE_FLASH_ATTR
tsl2561_lua_getchannels
(
lua_State
*
L
)
{
uint8_t
error
=
tsl2561GetLuminosity
(
&
ch0
,
&
ch1
);
uint8_t
error
=
tsl2561GetLuminosity
(
&
ch0
,
&
ch1
);
lua_push
numb
er
(
L
,
ch0
);
lua_push
integ
er
(
L
,
ch0
);
lua_push
numb
er
(
L
,
ch1
);
lua_push
integ
er
(
L
,
ch1
);
lua_push
numb
er
(
L
,
error
);
lua_push
integ
er
(
L
,
error
);
return
3
;
return
3
;
}
}
...
...
app/modules/websocket.c
View file @
606f9166
...
@@ -60,7 +60,7 @@ static void websocketclient_onReceiveCallback(ws_info *ws, int len, char *messag
...
@@ -60,7 +60,7 @@ static void websocketclient_onReceiveCallback(ws_info *ws, int len, char *messag
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
onReceive
);
// load the callback function
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
onReceive
);
// load the callback function
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
self_ref
);
// pass itself, #1 callback argument
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
self_ref
);
// pass itself, #1 callback argument
lua_pushlstring
(
L
,
message
,
len
);
// #2 callback argument
lua_pushlstring
(
L
,
message
,
len
);
// #2 callback argument
lua_push
numb
er
(
L
,
opCode
);
// #3 callback argument
lua_push
integ
er
(
L
,
opCode
);
// #3 callback argument
luaL_pcallx
(
L
,
3
,
0
);
luaL_pcallx
(
L
,
3
,
0
);
}
}
}
}
...
@@ -79,7 +79,7 @@ static void websocketclient_onCloseCallback(ws_info *ws, int errorCode) {
...
@@ -79,7 +79,7 @@ static void websocketclient_onCloseCallback(ws_info *ws, int errorCode) {
if
(
data
->
onClose
!=
LUA_NOREF
)
{
if
(
data
->
onClose
!=
LUA_NOREF
)
{
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
onClose
);
// load the callback function
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
onClose
);
// load the callback function
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
self_ref
);
// pass itself, #1 callback argument
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
self_ref
);
// pass itself, #1 callback argument
lua_push
numb
er
(
L
,
errorCode
);
// pass the error code, #2 callback argument
lua_push
integ
er
(
L
,
errorCode
);
// pass the error code, #2 callback argument
luaL_pcallx
(
L
,
2
,
0
);
luaL_pcallx
(
L
,
2
,
0
);
}
}
...
@@ -284,7 +284,7 @@ static int websocketclient_gc(lua_State *L) {
...
@@ -284,7 +284,7 @@ static int websocketclient_gc(lua_State *L) {
if
(
ws
->
connectionState
!=
4
)
{
// only call if connection open
if
(
ws
->
connectionState
!=
4
)
{
// only call if connection open
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
onClose
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
data
->
onClose
);
lua_push
numb
er
(
L
,
-
100
);
lua_push
integ
er
(
L
,
-
100
);
luaL_pcallx
(
L
,
1
,
0
);
luaL_pcallx
(
L
,
1
,
0
);
}
}
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
data
->
onClose
);
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
data
->
onClose
);
...
...
app/modules/wifi.c
View file @
606f9166
...
@@ -228,15 +228,15 @@ static int wifi_getcountry( lua_State* L ){
...
@@ -228,15 +228,15 @@ static int wifi_getcountry( lua_State* L ){
lua_rawset
(
L
,
-
3
);
lua_rawset
(
L
,
-
3
);
lua_pushstring
(
L
,
"start_ch"
);
lua_pushstring
(
L
,
"start_ch"
);
lua_push
numb
er
(
L
,
cfg
.
schan
);
lua_push
integ
er
(
L
,
cfg
.
schan
);
lua_rawset
(
L
,
-
3
);
lua_rawset
(
L
,
-
3
);
lua_pushstring
(
L
,
"end_ch"
);
lua_pushstring
(
L
,
"end_ch"
);
lua_push
numb
er
(
L
,
(
cfg
.
schan
+
cfg
.
nchan
)
-
1
);
lua_push
integ
er
(
L
,
(
cfg
.
schan
+
cfg
.
nchan
)
-
1
);
lua_rawset
(
L
,
-
3
);
lua_rawset
(
L
,
-
3
);
lua_pushstring
(
L
,
"policy"
);
lua_pushstring
(
L
,
"policy"
);
lua_push
numb
er
(
L
,
cfg
.
policy
);
lua_push
integ
er
(
L
,
cfg
.
policy
);
lua_rawset
(
L
,
-
3
);
lua_rawset
(
L
,
-
3
);
return
1
;
return
1
;
...
@@ -276,7 +276,7 @@ static int wifi_setcountry( lua_State* L ){
...
@@ -276,7 +276,7 @@ static int wifi_setcountry( lua_State* L ){
lua_getfield
(
L
,
1
,
"start_ch"
);
lua_getfield
(
L
,
1
,
"start_ch"
);
if
(
!
lua_isnil
(
L
,
-
1
)){
if
(
!
lua_isnil
(
L
,
-
1
)){
if
(
lua_isnumber
(
L
,
-
1
)){
if
(
lua_isnumber
(
L
,
-
1
)){
start_ch
=
(
uint8
)
luaL_check
numb
er
(
L
,
-
1
);
start_ch
=
(
uint8
)
luaL_check
integ
er
(
L
,
-
1
);
luaL_argcheck
(
L
,
(
start_ch
>=
1
&&
start_ch
<=
14
),
1
,
"start_ch: Range:1-14"
);
luaL_argcheck
(
L
,
(
start_ch
>=
1
&&
start_ch
<=
14
),
1
,
"start_ch: Range:1-14"
);
cfg
.
schan
=
start_ch
;
cfg
.
schan
=
start_ch
;
}
}
...
@@ -291,7 +291,7 @@ static int wifi_setcountry( lua_State* L ){
...
@@ -291,7 +291,7 @@ static int wifi_setcountry( lua_State* L ){
lua_getfield
(
L
,
1
,
"end_ch"
);
lua_getfield
(
L
,
1
,
"end_ch"
);
if
(
!
lua_isnil
(
L
,
-
1
)){
if
(
!
lua_isnil
(
L
,
-
1
)){
if
(
lua_isnumber
(
L
,
-
1
)){
if
(
lua_isnumber
(
L
,
-
1
)){
end_ch
=
(
uint8
)
luaL_check
numb
er
(
L
,
-
1
);
end_ch
=
(
uint8
)
luaL_check
integ
er
(
L
,
-
1
);
luaL_argcheck
(
L
,
(
end_ch
>=
1
&&
end_ch
<=
14
),
1
,
"end_ch: Range:1-14"
);
luaL_argcheck
(
L
,
(
end_ch
>=
1
&&
end_ch
<=
14
),
1
,
"end_ch: Range:1-14"
);
luaL_argcheck
(
L
,
(
end_ch
>=
cfg
.
schan
),
1
,
"end_ch: can't be less than start_ch"
);
luaL_argcheck
(
L
,
(
end_ch
>=
cfg
.
schan
),
1
,
"end_ch: can't be less than start_ch"
);
cfg
.
nchan
=
(
end_ch
-
cfg
.
schan
)
+
1
;
//cfg.nchan must equal total number of channels
cfg
.
nchan
=
(
end_ch
-
cfg
.
schan
)
+
1
;
//cfg.nchan must equal total number of channels
...
@@ -306,7 +306,7 @@ static int wifi_setcountry( lua_State* L ){
...
@@ -306,7 +306,7 @@ static int wifi_setcountry( lua_State* L ){
lua_getfield
(
L
,
1
,
"policy"
);
lua_getfield
(
L
,
1
,
"policy"
);
if
(
!
lua_isnil
(
L
,
-
1
)){
if
(
!
lua_isnil
(
L
,
-
1
)){
if
(
lua_isnumber
(
L
,
-
1
)){
if
(
lua_isnumber
(
L
,
-
1
)){
uint8
policy
=
(
uint8
)
luaL_check
numb
er
(
L
,
-
1
);
uint8
policy
=
(
uint8
)
luaL_check
integ
er
(
L
,
-
1
);
luaL_argcheck
(
L
,
(
policy
==
WIFI_COUNTRY_POLICY_AUTO
||
policy
==
WIFI_COUNTRY_POLICY_MANUAL
),
1
,
"policy: must be 0 or 1"
);
luaL_argcheck
(
L
,
(
policy
==
WIFI_COUNTRY_POLICY_AUTO
||
policy
==
WIFI_COUNTRY_POLICY_MANUAL
),
1
,
"policy: must be 0 or 1"
);
cfg
.
policy
=
policy
;
cfg
.
policy
=
policy
;
}
}
...
@@ -465,7 +465,7 @@ static int wifi_suspend(lua_State* L)
...
@@ -465,7 +465,7 @@ static int wifi_suspend(lua_State* L)
if
(
lua_isnone
(
L
,
1
))
if
(
lua_isnone
(
L
,
1
))
{
{
// Return current WiFi suspension state
// Return current WiFi suspension state
lua_push
numb
er
(
L
,
pmSleep_get_state
());
lua_push
integ
er
(
L
,
pmSleep_get_state
());
return
1
;
// Return WiFi suspension state
return
1
;
// Return WiFi suspension state
}
}
...
@@ -670,7 +670,7 @@ static int wifi_station_get_ap_info4lua( lua_State* L )
...
@@ -670,7 +670,7 @@ static int wifi_station_get_ap_info4lua( lua_State* L )
char
debug_temp
[
128
];
char
debug_temp
[
128
];
#endif
#endif
lua_newtable
(
L
);
lua_newtable
(
L
);
lua_push
numb
er
(
L
,
number_of_aps
);
lua_push
integ
er
(
L
,
number_of_aps
);
lua_setfield
(
L
,
-
2
,
"qty"
);
lua_setfield
(
L
,
-
2
,
"qty"
);
WIFI_DBG
(
"
\n\t
# of APs stored in flash:%d
\n
"
,
number_of_aps
);
WIFI_DBG
(
"
\n\t
# of APs stored in flash:%d
\n
"
,
number_of_aps
);
WIFI_DBG
(
" %-6s %-32s %-64s %-17s
\n
"
,
"index:"
,
"ssid:"
,
"password:"
,
"bssid:"
);
WIFI_DBG
(
" %-6s %-32s %-64s %-17s
\n
"
,
"index:"
,
"ssid:"
,
"password:"
,
"bssid:"
);
...
@@ -709,7 +709,7 @@ static int wifi_station_get_ap_info4lua( lua_State* L )
...
@@ -709,7 +709,7 @@ static int wifi_station_get_ap_info4lua( lua_State* L )
#if defined(WIFI_DEBUG)
#if defined(WIFI_DEBUG)
WIFI_DBG
(
"%s%-17s
\n
"
,
debug_temp
,
temp
);
WIFI_DBG
(
"%s%-17s
\n
"
,
debug_temp
,
temp
);
#endif
#endif
lua_push
numb
er
(
L
,
i
+
1
);
//Add one, so that AP index follows Lua Conventions
lua_push
integ
er
(
L
,
i
+
1
);
//Add one, so that AP index follows Lua Conventions
lua_insert
(
L
,
-
2
);
lua_insert
(
L
,
-
2
);
lua_settable
(
L
,
-
3
);
lua_settable
(
L
,
-
3
);
}
}
...
@@ -737,7 +737,7 @@ static int wifi_station_change_ap( lua_State* L )
...
@@ -737,7 +737,7 @@ static int wifi_station_change_ap( lua_State* L )
// Lua: wifi.setapnumber(number_of_aps_to_save)
// Lua: wifi.setapnumber(number_of_aps_to_save)
static
int
wifi_station_get_ap_index
(
lua_State
*
L
)
static
int
wifi_station_get_ap_index
(
lua_State
*
L
)
{
{
lua_push
numb
er
(
L
,
wifi_station_get_current_ap_id
()
+
1
);
lua_push
integ
er
(
L
,
wifi_station_get_current_ap_id
()
+
1
);
return
1
;
return
1
;
}
}
...
@@ -978,7 +978,7 @@ static int wifi_station_config( lua_State* L )
...
@@ -978,7 +978,7 @@ static int wifi_station_config( lua_State* L )
if
(
lua_isfunction
(
L
,
-
1
))
if
(
lua_isfunction
(
L
,
-
1
))
{
{
L_temp
=
lua_newthread
(
L
);
L_temp
=
lua_newthread
(
L
);
lua_push
numb
er
(
L
,
EVENT_STAMODE_CONNECTED
);
lua_push
integ
er
(
L
,
EVENT_STAMODE_CONNECTED
);
lua_pushvalue
(
L
,
-
3
);
lua_pushvalue
(
L
,
-
3
);
lua_xmove
(
L
,
L_temp
,
2
);
lua_xmove
(
L
,
L_temp
,
2
);
wifi_event_monitor_register
(
L_temp
);
wifi_event_monitor_register
(
L_temp
);
...
@@ -996,7 +996,7 @@ static int wifi_station_config( lua_State* L )
...
@@ -996,7 +996,7 @@ static int wifi_station_config( lua_State* L )
if
(
lua_isfunction
(
L
,
-
1
))
if
(
lua_isfunction
(
L
,
-
1
))
{
{
L_temp
=
lua_newthread
(
L
);
L_temp
=
lua_newthread
(
L
);
lua_push
numb
er
(
L
,
EVENT_STAMODE_DISCONNECTED
);
lua_push
integ
er
(
L
,
EVENT_STAMODE_DISCONNECTED
);
lua_pushvalue
(
L
,
-
3
);
lua_pushvalue
(
L
,
-
3
);
lua_xmove
(
L
,
L_temp
,
2
);
lua_xmove
(
L
,
L_temp
,
2
);
wifi_event_monitor_register
(
L_temp
);
wifi_event_monitor_register
(
L_temp
);
...
@@ -1014,7 +1014,7 @@ static int wifi_station_config( lua_State* L )
...
@@ -1014,7 +1014,7 @@ static int wifi_station_config( lua_State* L )
if
(
lua_isfunction
(
L
,
-
1
))
if
(
lua_isfunction
(
L
,
-
1
))
{
{
L_temp
=
lua_newthread
(
L
);
L_temp
=
lua_newthread
(
L
);
lua_push
numb
er
(
L
,
EVENT_STAMODE_AUTHMODE_CHANGE
);
lua_push
integ
er
(
L
,
EVENT_STAMODE_AUTHMODE_CHANGE
);
lua_pushvalue
(
L
,
-
3
);
lua_pushvalue
(
L
,
-
3
);
lua_xmove
(
L
,
L_temp
,
2
);
lua_xmove
(
L
,
L_temp
,
2
);
wifi_event_monitor_register
(
L_temp
);
wifi_event_monitor_register
(
L_temp
);
...
@@ -1032,7 +1032,7 @@ static int wifi_station_config( lua_State* L )
...
@@ -1032,7 +1032,7 @@ static int wifi_station_config( lua_State* L )
if
(
lua_isfunction
(
L
,
-
1
))
if
(
lua_isfunction
(
L
,
-
1
))
{
{
L_temp
=
lua_newthread
(
L
);
L_temp
=
lua_newthread
(
L
);
lua_push
numb
er
(
L
,
EVENT_STAMODE_GOT_IP
);
lua_push
integ
er
(
L
,
EVENT_STAMODE_GOT_IP
);
lua_pushvalue
(
L
,
-
3
);
lua_pushvalue
(
L
,
-
3
);
lua_xmove
(
L
,
L_temp
,
2
);
lua_xmove
(
L
,
L_temp
,
2
);
wifi_event_monitor_register
(
L_temp
);
wifi_event_monitor_register
(
L_temp
);
...
@@ -1050,7 +1050,7 @@ static int wifi_station_config( lua_State* L )
...
@@ -1050,7 +1050,7 @@ static int wifi_station_config( lua_State* L )
if
(
lua_isfunction
(
L
,
-
1
))
if
(
lua_isfunction
(
L
,
-
1
))
{
{
L_temp
=
lua_newthread
(
L
);
L_temp
=
lua_newthread
(
L
);
lua_push
numb
er
(
L
,
EVENT_STAMODE_DHCP_TIMEOUT
);
lua_push
integ
er
(
L
,
EVENT_STAMODE_DHCP_TIMEOUT
);
lua_pushvalue
(
L
,
-
3
);
lua_pushvalue
(
L
,
-
3
);
lua_xmove
(
L
,
L_temp
,
2
);
lua_xmove
(
L
,
L_temp
,
2
);
wifi_event_monitor_register
(
L_temp
);
wifi_event_monitor_register
(
L_temp
);
...
@@ -1111,7 +1111,7 @@ static int wifi_station_connect4lua( lua_State* L )
...
@@ -1111,7 +1111,7 @@ static int wifi_station_connect4lua( lua_State* L )
{
{
#ifdef WIFI_SDK_EVENT_MONITOR_ENABLE
#ifdef WIFI_SDK_EVENT_MONITOR_ENABLE
if
(
lua_isfunction
(
L
,
1
)){
if
(
lua_isfunction
(
L
,
1
)){
lua_push
numb
er
(
L
,
EVENT_STAMODE_CONNECTED
);
lua_push
integ
er
(
L
,
EVENT_STAMODE_CONNECTED
);
lua_pushvalue
(
L
,
1
);
lua_pushvalue
(
L
,
1
);
lua_remove
(
L
,
1
);
lua_remove
(
L
,
1
);
wifi_event_monitor_register
(
L
);
wifi_event_monitor_register
(
L
);
...
@@ -1126,7 +1126,7 @@ static int wifi_station_disconnect4lua( lua_State* L )
...
@@ -1126,7 +1126,7 @@ static int wifi_station_disconnect4lua( lua_State* L )
{
{
#ifdef WIFI_SDK_EVENT_MONITOR_ENABLE
#ifdef WIFI_SDK_EVENT_MONITOR_ENABLE
if
(
lua_isfunction
(
L
,
1
)){
if
(
lua_isfunction
(
L
,
1
)){
lua_push
numb
er
(
L
,
EVENT_STAMODE_DISCONNECTED
);
lua_push
integ
er
(
L
,
EVENT_STAMODE_DISCONNECTED
);
lua_pushvalue
(
L
,
1
);
lua_pushvalue
(
L
,
1
);
lua_remove
(
L
,
1
);
lua_remove
(
L
,
1
);
wifi_event_monitor_register
(
L
);
wifi_event_monitor_register
(
L
);
...
@@ -1214,7 +1214,7 @@ static int wifi_station_listap( lua_State* L )
...
@@ -1214,7 +1214,7 @@ static int wifi_station_listap( lua_State* L )
{
{
if
(
lua_isnumber
(
L
,
-
1
)
)
// deal with the ssid string
if
(
lua_isnumber
(
L
,
-
1
)
)
// deal with the ssid string
{
{
channel
=
luaL_check
numb
er
(
L
,
-
1
);
channel
=
luaL_check
integ
er
(
L
,
-
1
);
if
(
!
(
channel
>=
0
&&
channel
<=
13
))
if
(
!
(
channel
>=
0
&&
channel
<=
13
))
return
luaL_error
(
L
,
"channel: 0 or 1-13"
);
return
luaL_error
(
L
,
"channel: 0 or 1-13"
);
scan_cfg
.
channel
=
channel
;
scan_cfg
.
channel
=
channel
;
...
@@ -1231,7 +1231,7 @@ static int wifi_station_listap( lua_State* L )
...
@@ -1231,7 +1231,7 @@ static int wifi_station_listap( lua_State* L )
{
{
if
(
lua_isnumber
(
L
,
-
1
)
)
// deal with the ssid string
if
(
lua_isnumber
(
L
,
-
1
)
)
// deal with the ssid string
{
{
show_hidden
=
luaL_check
numb
er
(
L
,
-
1
);
show_hidden
=
luaL_check
integ
er
(
L
,
-
1
);
if
(
show_hidden
!=
0
&&
show_hidden
!=
1
)
if
(
show_hidden
!=
0
&&
show_hidden
!=
1
)
return
luaL_error
(
L
,
"show_hidden: 0 or 1"
);
return
luaL_error
(
L
,
"show_hidden: 0 or 1"
);
scan_cfg
.
show_hidden
=
show_hidden
;
scan_cfg
.
show_hidden
=
show_hidden
;
...
@@ -1457,15 +1457,15 @@ static int wifi_ap_getconfig( lua_State* L, bool get_flash_cfg)
...
@@ -1457,15 +1457,15 @@ static int wifi_ap_getconfig( lua_State* L, bool get_flash_cfg)
lua_pushstring
(
L
,
temp
);
lua_pushstring
(
L
,
temp
);
lua_setfield
(
L
,
-
2
,
"pwd"
);
lua_setfield
(
L
,
-
2
,
"pwd"
);
}
}
lua_push
numb
er
(
L
,
config
.
authmode
);
lua_push
integ
er
(
L
,
config
.
authmode
);
lua_setfield
(
L
,
-
2
,
"auth"
);
lua_setfield
(
L
,
-
2
,
"auth"
);
lua_push
numb
er
(
L
,
config
.
channel
);
lua_push
integ
er
(
L
,
config
.
channel
);
lua_setfield
(
L
,
-
2
,
"channel"
);
lua_setfield
(
L
,
-
2
,
"channel"
);
lua_pushboolean
(
L
,
(
bool
)
config
.
ssid_hidden
);
lua_pushboolean
(
L
,
(
bool
)
config
.
ssid_hidden
);
lua_setfield
(
L
,
-
2
,
"hidden"
);
lua_setfield
(
L
,
-
2
,
"hidden"
);
lua_push
numb
er
(
L
,
config
.
max_connection
);
lua_push
integ
er
(
L
,
config
.
max_connection
);
lua_setfield
(
L
,
-
2
,
"max"
);
lua_setfield
(
L
,
-
2
,
"max"
);
lua_push
numb
er
(
L
,
config
.
beacon_interval
);
lua_push
integ
er
(
L
,
config
.
beacon_interval
);
lua_setfield
(
L
,
-
2
,
"beacon"
);
lua_setfield
(
L
,
-
2
,
"beacon"
);
return
1
;
return
1
;
}
}
...
@@ -1696,7 +1696,7 @@ static int wifi_ap_config( lua_State* L )
...
@@ -1696,7 +1696,7 @@ static int wifi_ap_config( lua_State* L )
if
(
lua_isfunction
(
L
,
-
1
))
if
(
lua_isfunction
(
L
,
-
1
))
{
{
L_temp
=
lua_newthread
(
L
);
L_temp
=
lua_newthread
(
L
);
lua_push
numb
er
(
L
,
EVENT_SOFTAPMODE_STACONNECTED
);
lua_push
integ
er
(
L
,
EVENT_SOFTAPMODE_STACONNECTED
);
lua_pushvalue
(
L
,
-
3
);
lua_pushvalue
(
L
,
-
3
);
lua_xmove
(
L
,
L_temp
,
2
);
lua_xmove
(
L
,
L_temp
,
2
);
wifi_event_monitor_register
(
L_temp
);
wifi_event_monitor_register
(
L_temp
);
...
@@ -1714,7 +1714,7 @@ static int wifi_ap_config( lua_State* L )
...
@@ -1714,7 +1714,7 @@ static int wifi_ap_config( lua_State* L )
if
(
lua_isfunction
(
L
,
-
1
))
if
(
lua_isfunction
(
L
,
-
1
))
{
{
L_temp
=
lua_newthread
(
L
);
L_temp
=
lua_newthread
(
L
);
lua_push
numb
er
(
L
,
EVENT_SOFTAPMODE_STADISCONNECTED
);
lua_push
integ
er
(
L
,
EVENT_SOFTAPMODE_STADISCONNECTED
);
lua_pushvalue
(
L
,
-
3
);
lua_pushvalue
(
L
,
-
3
);
lua_xmove
(
L
,
L_temp
,
2
);
lua_xmove
(
L
,
L_temp
,
2
);
wifi_event_monitor_register
(
L_temp
);
wifi_event_monitor_register
(
L_temp
);
...
@@ -1732,7 +1732,7 @@ static int wifi_ap_config( lua_State* L )
...
@@ -1732,7 +1732,7 @@ static int wifi_ap_config( lua_State* L )
if
(
lua_isfunction
(
L
,
-
1
))
if
(
lua_isfunction
(
L
,
-
1
))
{
{
L_temp
=
lua_newthread
(
L
);
L_temp
=
lua_newthread
(
L
);
lua_push
numb
er
(
L
,
EVENT_SOFTAPMODE_PROBEREQRECVED
);
lua_push
integ
er
(
L
,
EVENT_SOFTAPMODE_PROBEREQRECVED
);
lua_pushvalue
(
L
,
-
3
);
lua_pushvalue
(
L
,
-
3
);
lua_xmove
(
L
,
L_temp
,
2
);
lua_xmove
(
L
,
L_temp
,
2
);
wifi_event_monitor_register
(
L_temp
);
wifi_event_monitor_register
(
L_temp
);
...
...
app/modules/wifi_eventmon.c
View file @
606f9166
...
@@ -35,7 +35,7 @@ void wifi_event_monitor_register_hook(int (*fn)(System_Event_t*)) {
...
@@ -35,7 +35,7 @@ void wifi_event_monitor_register_hook(int (*fn)(System_Event_t*)) {
// wifi.eventmon.register()
// wifi.eventmon.register()
int
wifi_event_monitor_register
(
lua_State
*
L
)
int
wifi_event_monitor_register
(
lua_State
*
L
)
{
{
uint8
id
=
(
uint8
)
luaL_check
numb
er
(
L
,
1
);
uint8
id
=
(
uint8
)
luaL_check
integ
er
(
L
,
1
);
if
(
id
>
EVENT_MAX
)
//Check if user is trying to register a callback for a valid event.
if
(
id
>
EVENT_MAX
)
//Check if user is trying to register a callback for a valid event.
{
{
return
luaL_error
(
L
,
"valid wifi events:0-%d"
,
EVENT_MAX
);
return
luaL_error
(
L
,
"valid wifi events:0-%d"
,
EVENT_MAX
);
...
@@ -87,8 +87,8 @@ static void wifi_event_monitor_handle_event_cb(System_Event_t *evt)
...
@@ -87,8 +87,8 @@ static void wifi_event_monitor_handle_event_cb(System_Event_t *evt)
size_t
queue_len
=
lua_objlen
(
L
,
-
1
);
size_t
queue_len
=
lua_objlen
(
L
,
-
1
);
//add event to queue
//add event to queue
lua_push
numb
er
(
L
,
queue_len
+
1
);
lua_push
integ
er
(
L
,
queue_len
+
1
);
lua_push
numb
er
(
L
,
evt_ud_ref
);
lua_push
integ
er
(
L
,
evt_ud_ref
);
lua_rawset
(
L
,
-
3
);
lua_rawset
(
L
,
-
3
);
if
(
queue_len
==
0
){
//if queue was empty, post task
if
(
queue_len
==
0
){
//if queue was empty, post task
...
@@ -109,7 +109,7 @@ static void wifi_event_monitor_process_event_queue(task_param_t param, uint8 pri
...
@@ -109,7 +109,7 @@ static void wifi_event_monitor_process_event_queue(task_param_t param, uint8 pri
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
event_queue_ref
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
event_queue_ref
);
int
index
=
1
;
int
index
=
1
;
lua_rawgeti
(
L
,
1
,
index
);
lua_rawgeti
(
L
,
1
,
index
);
sint32
event_ref
=
lua_to
numb
er
(
L
,
-
1
);
sint32
event_ref
=
lua_to
integ
er
(
L
,
-
1
);
lua_pop
(
L
,
1
);
lua_pop
(
L
,
1
);
//remove event reference from queue
//remove event reference from queue
...
...
app/modules/ws2812.c
View file @
606f9166
...
@@ -463,7 +463,7 @@ static int ws2812_buffer_power(lua_State* L) {
...
@@ -463,7 +463,7 @@ static int ws2812_buffer_power(lua_State* L) {
total
+=
buffer
->
values
[
i
];
total
+=
buffer
->
values
[
i
];
}
}
lua_push
numb
er
(
L
,
total
);
lua_push
integ
er
(
L
,
total
);
return
1
;
return
1
;
}
}
...
@@ -477,7 +477,7 @@ static int ws2812_buffer_get(lua_State* L) {
...
@@ -477,7 +477,7 @@ static int ws2812_buffer_get(lua_State* L) {
int
i
;
int
i
;
for
(
i
=
0
;
i
<
buffer
->
colorsPerLed
;
i
++
)
for
(
i
=
0
;
i
<
buffer
->
colorsPerLed
;
i
++
)
{
{
lua_push
numb
er
(
L
,
buffer
->
values
[
buffer
->
colorsPerLed
*
led
+
i
]);
lua_push
integ
er
(
L
,
buffer
->
values
[
buffer
->
colorsPerLed
*
led
+
i
]);
}
}
return
buffer
->
colorsPerLed
;
return
buffer
->
colorsPerLed
;
...
@@ -499,7 +499,7 @@ static int ws2812_buffer_set(lua_State* L) {
...
@@ -499,7 +499,7 @@ static int ws2812_buffer_set(lua_State* L) {
lua_rawgeti
(
L
,
3
,
i
+
1
);
lua_rawgeti
(
L
,
3
,
i
+
1
);
// Convert it as int and store them in buffer
// Convert it as int and store them in buffer
buffer
->
values
[
buffer
->
colorsPerLed
*
led
+
i
]
=
lua_to
numb
er
(
L
,
-
1
);
buffer
->
values
[
buffer
->
colorsPerLed
*
led
+
i
]
=
lua_to
integ
er
(
L
,
-
1
);
}
}
// Clean up the stack
// Clean up the stack
...
@@ -533,7 +533,7 @@ static int ws2812_buffer_set(lua_State* L) {
...
@@ -533,7 +533,7 @@ static int ws2812_buffer_set(lua_State* L) {
static
int
ws2812_buffer_size
(
lua_State
*
L
)
{
static
int
ws2812_buffer_size
(
lua_State
*
L
)
{
ws2812_buffer
*
buffer
=
(
ws2812_buffer
*
)
luaL_checkudata
(
L
,
1
,
"ws2812.buffer"
);
ws2812_buffer
*
buffer
=
(
ws2812_buffer
*
)
luaL_checkudata
(
L
,
1
,
"ws2812.buffer"
);
lua_push
numb
er
(
L
,
buffer
->
size
);
lua_push
integ
er
(
L
,
buffer
->
size
);
return
1
;
return
1
;
}
}
...
...
app/modules/ws2812_effects.c
View file @
606f9166
...
@@ -206,7 +206,7 @@ static int ws2812_effects_set_color(lua_State* L) {
...
@@ -206,7 +206,7 @@ static int ws2812_effects_set_color(lua_State* L) {
static
int
ws2812_effects_get_speed
(
lua_State
*
L
)
{
static
int
ws2812_effects_get_speed
(
lua_State
*
L
)
{
luaL_argcheck
(
L
,
state
!=
NULL
,
1
,
LIBRARY_NOT_INITIALIZED_ERROR_MSG
);
luaL_argcheck
(
L
,
state
!=
NULL
,
1
,
LIBRARY_NOT_INITIALIZED_ERROR_MSG
);
lua_push
numb
er
(
L
,
state
->
speed
);
lua_push
integ
er
(
L
,
state
->
speed
);
return
1
;
return
1
;
}
}
...
@@ -221,7 +221,7 @@ static int ws2812_effects_set_speed(lua_State* L) {
...
@@ -221,7 +221,7 @@ static int ws2812_effects_set_speed(lua_State* L) {
static
int
ws2812_effects_get_delay
(
lua_State
*
L
)
{
static
int
ws2812_effects_get_delay
(
lua_State
*
L
)
{
luaL_argcheck
(
L
,
state
!=
NULL
,
1
,
LIBRARY_NOT_INITIALIZED_ERROR_MSG
);
luaL_argcheck
(
L
,
state
!=
NULL
,
1
,
LIBRARY_NOT_INITIALIZED_ERROR_MSG
);
lua_push
numb
er
(
L
,
state
->
mode_delay
);
lua_push
integ
er
(
L
,
state
->
mode_delay
);
return
1
;
return
1
;
}
}
...
...
app/pcm/pcm_core.c
View file @
606f9166
...
@@ -36,7 +36,7 @@ void pcm_data_vu( task_param_t param, uint8 prio )
...
@@ -36,7 +36,7 @@ void pcm_data_vu( task_param_t param, uint8 prio )
if
(
cfg
->
cb_vu_ref
!=
LUA_NOREF
)
{
if
(
cfg
->
cb_vu_ref
!=
LUA_NOREF
)
{
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
cfg
->
cb_vu_ref
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
cfg
->
cb_vu_ref
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
cfg
->
self_ref
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
cfg
->
self_ref
);
lua_push
numb
er
(
L
,
(
LUA_NUMBER
)(
cfg
->
vu_peak
)
);
lua_push
integ
er
(
L
,
cfg
->
vu_peak
);
luaL_pcallx
(
L
,
2
,
0
);
luaL_pcallx
(
L
,
2
,
0
);
}
}
}
}
...
...
app/pm/swtimer.c
View file @
606f9166
...
@@ -350,9 +350,8 @@ void swtmr_cb_register(void* timer_cb_ptr, uint8 suspend_policy){
...
@@ -350,9 +350,8 @@ void swtmr_cb_register(void* timer_cb_ptr, uint8 suspend_policy){
}
}
lua_pushstring
(
L
,
CB_LIST_STR
);
lua_pushstring
(
L
,
CB_LIST_STR
);
lua_rawget
(
L
,
-
2
);
if
(
lua_
istable
(
L
,
-
1
)
){
if
(
lua_
rawget
(
L
,
-
2
)
==
LUA_TTABLE
){
//cb_list exists, get length of list
//cb_list exists, get length of list
cb_list_last_idx
=
lua_objlen
(
L
,
-
1
);
cb_list_last_idx
=
lua_objlen
(
L
,
-
1
);
}
}
...
@@ -366,7 +365,7 @@ void swtmr_cb_register(void* timer_cb_ptr, uint8 suspend_policy){
...
@@ -366,7 +365,7 @@ void swtmr_cb_register(void* timer_cb_ptr, uint8 suspend_policy){
}
}
//append new timer cb ptr to table
//append new timer cb ptr to table
lua_push
numb
er
(
L
,
cb_list_last_idx
+
1
);
lua_push
integ
er
(
L
,
(
lua_Integer
)
(
cb_list_last_idx
+
1
)
)
;
cb_registry_item_t
*
reg_item
=
lua_newuserdata
(
L
,
sizeof
(
cb_registry_item_t
));
cb_registry_item_t
*
reg_item
=
lua_newuserdata
(
L
,
sizeof
(
cb_registry_item_t
));
reg_item
->
tmr_cb_ptr
=
timer_cb_ptr
;
reg_item
->
tmr_cb_ptr
=
timer_cb_ptr
;
reg_item
->
suspend_policy
=
suspend_policy
;
reg_item
->
suspend_policy
=
suspend_policy
;
...
...
docs/modules/rotary.md
View file @
606f9166
...
@@ -98,7 +98,7 @@ If an invalid `eventtype` is supplied, then an error will be thrown.
...
@@ -98,7 +98,7 @@ If an invalid `eventtype` is supplied, then an error will be thrown.
Gets the current position and press status of the switch
Gets the current position and press status of the switch
#### Syntax
#### Syntax
`pos, press
, queue
= rotary.getpos(channel)`
`pos, press = rotary.getpos(channel)`
#### Parameters
#### Parameters
-
`channel`
The rotary module supports three switches. The channel is either 0, 1 or 2.
-
`channel`
The rotary module supports three switches. The channel is either 0, 1 or 2.
...
@@ -106,7 +106,6 @@ Gets the current position and press status of the switch
...
@@ -106,7 +106,6 @@ Gets the current position and press status of the switch
#### Returns
#### Returns
-
`pos`
The current position of the switch.
-
`pos`
The current position of the switch.
-
`press`
A boolean indicating if the switch is currently pressed.
-
`press`
A boolean indicating if the switch is currently pressed.
-
`queue`
The number of undelivered callbacks (normally 0).
#### Example
#### Example
...
...
Prev
1
2
Next
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