From a70709268b5f6e386b7552e9dde7b9a646d1d6f1 Mon Sep 17 00:00:00 2001 From: funshine Date: Wed, 18 Mar 2015 14:22:17 +0800 Subject: [PATCH] merge cjson and dev to master, make a stable release --- README.md | 52 +++++++++++++++++--------------------- app/include/user_modules.h | 2 +- app/include/user_version.h | 2 +- app/libc/c_string.h | 2 +- examples/fragment.lua | 2 +- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 7d9a8d63..90ec76e3 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ Tencent QQ group: 309957875
- Easy to access wireless router - Based on Lua 5.1.4 (without *debug, os* module.) - Event-Drive programming preferred. -- Build-in file, timer, pwm, i2c, spi, 1-wire, net, mqtt, coap, gpio, wifi, adc, uart and system api. +- Build-in json, file, timer, pwm, i2c, spi, 1-wire, net, mqtt, coap, gpio, wifi, adc, uart and system api. - GPIO pin re-mapped, use the index to access gpio, i2c, pwm. +- Both Integer(less memory usage) and Float version firmware provided. # To Do List (pull requests are very welcomed) - loadable c module @@ -35,9 +36,13 @@ Tencent QQ group: 309957875
- cross compiler (done) # Change log +2015-03-18
+update u8glib.
+merge everything to master. + 2015-03-17
add cjson module, only cjson.encode() and cjson.decode() is implemented.
-read doc [here](https://github.com/nodemcu/nodemcu-firmware/blob/json/app/cjson/manual.txt) +read doc [here](https://github.com/nodemcu/nodemcu-firmware/blob/master/app/cjson/manual.txt) 2015-03-15
bugs fixed: #239, #273.
@@ -63,32 +68,6 @@ raise internal LUA_BUFFERSIZE from 1024 to 4096.
lua require("mod") will load "mod.lc" file first if exist.
build latest pre_build bin. -2015-02-12
-fix float print.
-update spiffs, add file.rename api to file module.
-fix some file system bug. need more tests.
-add support to 8Mbyte, 16Mbyte flash.
-remove node.led() and node.key() api.
-some update to lua_modules and examples.
-build latest pre_build bin. - -2015-01-27
-support floating point LUA.
-use macro LUA_NUMBER_INTEGRAL in user_config.h control this feature.
-LUA_NUMBER_INTEGRAL to disable floating point support,
-// LUA_NUMBER_INTEGRAL to enable floating point support.
-fix tmr.time(). #132
-fix filesystem length. #113
-fix ssl reboots. #134
-build pre_build bin. - -2015-01-26
-applied sdk095_patch1 to sdk 0.9.5.
-added LUA examples and modules [by dvv](https://github.com/dvv).
-added node.readvdd33() API [by alonewolfx2](https://github.com/alonewolfx2).
-build pre_build bin. - - [more change log](https://github.com/nodemcu/nodemcu-firmware/wiki)
##GPIO NEW TABLE ( Build 20141219 and later) @@ -154,9 +133,10 @@ build pre_build bin. #define LUA_USE_MODULES_OW #define LUA_USE_MODULES_BIT #define LUA_USE_MODULES_MQTT -// #define LUA_USE_MODULES_COAP // need about 4k more ram for now +// #define LUA_USE_MODULES_COAP #define LUA_USE_MODULES_U8G #define LUA_USE_MODULES_WS2812 +#define LUA_USE_MODULES_CJSON #endif /* LUA_USE_MODULES */ ``` @@ -470,3 +450,17 @@ cc = coap.Client() cc:get(coap.CON, "coap://192.168.18.100:5683/.well-known/core") cc:post(coap.NON, "coap://192.168.18.100:5683/", "Hello") ``` + +####cjson + +```lua +-- Translate Lua value to/from JSON +-- text = cjson.encode(value) +-- value = cjson.decode(text) +json_text = '[ true, { "foo": "bar" } ]' +value = cjson.decode(json_text) +-- Returns: { true, { foo = "bar" } } +value = { true, { foo = "bar" } } +json_text = cjson.encode(value) +-- Returns: '[true,{"foo":"bar"}]' +``` diff --git a/app/include/user_modules.h b/app/include/user_modules.h index e72d6587..d8ddc654 100644 --- a/app/include/user_modules.h +++ b/app/include/user_modules.h @@ -4,7 +4,7 @@ #define LUA_USE_BUILTIN_STRING // for string.xxx() #define LUA_USE_BUILTIN_TABLE // for table.xxx() #define LUA_USE_BUILTIN_COROUTINE // for coroutine.xxx() -// #define LUA_USE_BUILTIN_MATH // for math.xxx(), partially work +#define LUA_USE_BUILTIN_MATH // for math.xxx(), partially work // #define LUA_USE_BUILTIN_IO // for io.xxx(), partially work // #define LUA_USE_BUILTIN_OS // for os.xxx(), not work diff --git a/app/include/user_version.h b/app/include/user_version.h index ed8a511b..bc64f36d 100644 --- a/app/include/user_version.h +++ b/app/include/user_version.h @@ -7,6 +7,6 @@ #define NODE_VERSION_INTERNAL 0U #define NODE_VERSION "NodeMCU 0.9.5" -#define BUILD_DATE "build 20150317" +#define BUILD_DATE "build 20150318" #endif /* __USER_VERSION_H__ */ diff --git a/app/libc/c_string.h b/app/libc/c_string.h index 3061ad06..eae05f73 100644 --- a/app/libc/c_string.h +++ b/app/libc/c_string.h @@ -25,7 +25,7 @@ #define c_strncmp os_strncmp #define c_strncpy os_strncpy // #define c_strstr os_strstr -#define c_strncasecmp strncasecmp +#define c_strncasecmp c_strncmp #define c_strstr strstr #define c_strncat strncat diff --git a/examples/fragment.lua b/examples/fragment.lua index a56e423a..67aa2c37 100644 --- a/examples/fragment.lua +++ b/examples/fragment.lua @@ -1,7 +1,7 @@ pwm.setup(0,500,50) pwm.setup(1,500,50) pwm.setup(2,500,50) pwm.start(0) pwm.start(1) pwm.start(2) function led(r,g,b) pwm.setduty(0,g) pwm.setduty(1,b) pwm.setduty(2,r) end -wifi.station.autoconnect(1) +wifi.sta.autoconnect(1) a=0 tmr.alarm( 1000,1,function() if a==0 then a=1 led(50,50,50) else a=0 led(0,0,0) end end)