Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
Diff: mbed/jsonrpc/RpcAnalogIn.cpp
- Revision:
- 77:8651d3c19a55
- Child:
- 78:8cdb8fc7eda8
diff -r b375b3d750d8 -r 8651d3c19a55 mbed/jsonrpc/RpcAnalogIn.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/jsonrpc/RpcAnalogIn.cpp Fri Jun 20 15:38:30 2014 +0000
@@ -0,0 +1,57 @@
+#include "RpcHandlerBase.h"
+namespace MiMic
+{
+ class AnalogInHandler :RpcHandlerBase
+ {
+ public:
+ static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+ {
+ //u
+ ModJsonRpc* mod=(ModJsonRpc*)i_param;
+ PinName pin;
+ if(getParamsAsPin(mod,i_rpc,&pin,1)){
+ addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<AnalogIn>(new AnalogIn(pin)));
+ }
+ return NyLPC_TBool_TRUE;
+ }
+ static NyLPC_TBool read_u16(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+ {
+ //d return d
+ ModJsonRpc* mod=(ModJsonRpc*)i_param;
+ AnalogIn* inst=(AnalogIn*)getObjectBatch(mod,i_rpc);
+ if(inst!=NULL){
+ mod->putResult(i_rpc->method.id,"%d",(int)(inst->read_u16()));
+ }
+ return NyLPC_TBool_TRUE;
+ }
+ /** 10000倍したread()の値を返す*/
+ static NyLPC_TBool read_fx(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
+ {
+ //d return d
+ ModJsonRpc* mod=(ModJsonRpc*)i_param;
+ AnalogIn* inst=(AnalogIn*)getObjectBatch(mod,i_rpc);
+ if(inst!=NULL){
+ mod->putResult(i_rpc->method.id,"%d",(int)(inst->read()*10000));
+ }
+ return NyLPC_TBool_TRUE;
+ }
+ };
+
+
+
+const static struct NyLPC_TJsonRpcMethodDef func_table[]=
+{
+ { "_new1" ,"u" ,AnalogInHandler::new1},
+ { "read_u16" ,"d" ,AnalogInHandler::read_u16},
+ { "read_fx" ,"d" ,AnalogInHandler::read_fx},
+ { NULL ,NULL ,NULL}
+};
+
+const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_ANALOG_IN={
+ "mbedJS","AnalogIn",func_table
+};
+
+
+
+}
+
