From 3dd1ac37390371272210c3d9a48b4ba995aa94b7 Mon Sep 17 00:00:00 2001 From: HuangRui Date: Fri, 27 Mar 2015 00:52:55 +0800 Subject: [PATCH] Move node.readvdd33 to adc.readvdd33, fix #162. --- app/modules/adc.c | 22 ++++++++++++++++++++++ app/modules/node.c | 17 ++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/modules/adc.c b/app/modules/adc.c index b64697ba..eee15fe4 100644 --- a/app/modules/adc.c +++ b/app/modules/adc.c @@ -8,6 +8,7 @@ #include "lrotable.h" #include "c_types.h" +#include "user_interface.h" // Lua: read(id) , return system adc static int adc_sample( lua_State* L ) @@ -19,12 +20,33 @@ static int adc_sample( lua_State* L ) return 1; } +// Lua: readvdd33() +static int adc_readvdd33( lua_State* L ) +{ + uint32_t vdd33 = 0; + if(STATION_MODE == wifi_get_opmode()) + { + // Bug fix + wifi_set_opmode( STATIONAP_MODE ); + vdd33 = readvdd33(); + wifi_set_opmode( STATION_MODE ); + } + else + { + vdd33 = readvdd33(); + } + + lua_pushinteger(L, vdd33); + return 1; +} + // Module function map #define MIN_OPT_LEVEL 2 #include "lrodefs.h" const LUA_REG_TYPE adc_map[] = { { LSTRKEY( "read" ), LFUNCVAL( adc_sample ) }, + { LSTRKEY( "readvdd33" ), LFUNCVAL( adc_readvdd33) }, #if LUA_OPTIMIZE_MEMORY > 0 #endif diff --git a/app/modules/node.c b/app/modules/node.c index 53d59ae0..5f6ae9bd 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -100,13 +100,15 @@ static int node_chipid( lua_State* L ) lua_pushinteger(L, id); return 1; } + +// deprecated, moved to adc module // Lua: readvdd33() -static int node_readvdd33( lua_State* L ) -{ - uint32_t vdd33 = readvdd33(); - lua_pushinteger(L, vdd33); - return 1; -} +// static int node_readvdd33( lua_State* L ) +// { +// uint32_t vdd33 = readvdd33(); +// lua_pushinteger(L, vdd33); +// return 1; +// } // Lua: flashid() static int node_flashid( lua_State* L ) @@ -430,7 +432,8 @@ const LUA_REG_TYPE node_map[] = #endif { LSTRKEY( "input" ), LFUNCVAL( node_input ) }, { LSTRKEY( "output" ), LFUNCVAL( node_output ) }, - { LSTRKEY( "readvdd33" ), LFUNCVAL( node_readvdd33) }, +// Moved to adc module, use adc.readvdd33() +// { LSTRKEY( "readvdd33" ), LFUNCVAL( node_readvdd33) }, { LSTRKEY( "compile" ), LFUNCVAL( node_compile) }, { LSTRKEY( "CPU80MHZ" ), LNUMVAL( CPU80MHZ ) }, { LSTRKEY( "CPU160MHZ" ), LNUMVAL( CPU160MHZ ) },