Ergänzt das jQueryMobile Beispiel um die Fehlenden Aktoren wie LED 3 und Servo 2.

Fork of RPCHTTPServerVariable by smd.iotkit2.ch

Committer:
stefan1691
Date:
Wed Apr 08 12:31:28 2015 +0000
Revision:
14:3835863bc412
Korrektur AnalogIn laut . https://developer.mbed.org/questions/3897/AnalogIn-not-working-in-rpc/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stefan1691 14:3835863bc412 1 /* mbed Microcontroller Library
stefan1691 14:3835863bc412 2 * Copyright (c) 2006-2013 ARM Limited
stefan1691 14:3835863bc412 3 *
stefan1691 14:3835863bc412 4 * Licensed under the Apache License, Version 2.0 (the "License");
stefan1691 14:3835863bc412 5 * you may not use this file except in compliance with the License.
stefan1691 14:3835863bc412 6 * You may obtain a copy of the License at
stefan1691 14:3835863bc412 7 *
stefan1691 14:3835863bc412 8 * http://www.apache.org/licenses/LICENSE-2.0
stefan1691 14:3835863bc412 9 *
stefan1691 14:3835863bc412 10 * Unless required by applicable law or agreed to in writing, software
stefan1691 14:3835863bc412 11 * distributed under the License is distributed on an "AS IS" BASIS,
stefan1691 14:3835863bc412 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
stefan1691 14:3835863bc412 13 * See the License for the specific language governing permissions and
stefan1691 14:3835863bc412 14 * limitations under the License.
stefan1691 14:3835863bc412 15 */
stefan1691 14:3835863bc412 16 #ifndef MBED_CLASSES_H
stefan1691 14:3835863bc412 17 #define MBED_CLASSES_H
stefan1691 14:3835863bc412 18
stefan1691 14:3835863bc412 19 #include "rpc.h"
stefan1691 14:3835863bc412 20
stefan1691 14:3835863bc412 21 namespace mbed {
stefan1691 14:3835863bc412 22
stefan1691 14:3835863bc412 23 class RpcDigitalOut : public RPC {
stefan1691 14:3835863bc412 24 public:
stefan1691 14:3835863bc412 25 RpcDigitalOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 14:3835863bc412 26
stefan1691 14:3835863bc412 27 void write(int a0) {o.write(a0);}
stefan1691 14:3835863bc412 28 int read(void) {return o.read();}
stefan1691 14:3835863bc412 29
stefan1691 14:3835863bc412 30 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 31 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 32 {"write", rpc_method_caller<RpcDigitalOut, int, &RpcDigitalOut::write>},
stefan1691 14:3835863bc412 33 {"read", rpc_method_caller<int, RpcDigitalOut, &RpcDigitalOut::read>},
stefan1691 14:3835863bc412 34 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 35 };
stefan1691 14:3835863bc412 36 return rpc_methods;
stefan1691 14:3835863bc412 37 }
stefan1691 14:3835863bc412 38 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 39 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 40 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalOut, PinName, const char*> >},
stefan1691 14:3835863bc412 41 RPC_METHOD_END
stefan1691 14:3835863bc412 42 };
stefan1691 14:3835863bc412 43 static rpc_class c = {"DigitalOut", funcs, NULL};
stefan1691 14:3835863bc412 44 return &c;
stefan1691 14:3835863bc412 45 }
stefan1691 14:3835863bc412 46 private:
stefan1691 14:3835863bc412 47 DigitalOut o;
stefan1691 14:3835863bc412 48 };
stefan1691 14:3835863bc412 49
stefan1691 14:3835863bc412 50 class RpcDigitalIn : public RPC {
stefan1691 14:3835863bc412 51 public:
stefan1691 14:3835863bc412 52 RpcDigitalIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 14:3835863bc412 53
stefan1691 14:3835863bc412 54 int read(void) {return o.read();}
stefan1691 14:3835863bc412 55
stefan1691 14:3835863bc412 56 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 57 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 58 {"read", rpc_method_caller<int, RpcDigitalIn, &RpcDigitalIn::read>},
stefan1691 14:3835863bc412 59 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 60 };
stefan1691 14:3835863bc412 61 return rpc_methods;
stefan1691 14:3835863bc412 62 }
stefan1691 14:3835863bc412 63 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 64 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 65 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalIn, PinName, const char*> >},
stefan1691 14:3835863bc412 66 RPC_METHOD_END
stefan1691 14:3835863bc412 67 };
stefan1691 14:3835863bc412 68 static rpc_class c = {"DigitalIn", funcs, NULL};
stefan1691 14:3835863bc412 69 return &c;
stefan1691 14:3835863bc412 70 }
stefan1691 14:3835863bc412 71 private:
stefan1691 14:3835863bc412 72 DigitalIn o;
stefan1691 14:3835863bc412 73 };
stefan1691 14:3835863bc412 74
stefan1691 14:3835863bc412 75 class RpcDigitalInOut : public RPC {
stefan1691 14:3835863bc412 76 public:
stefan1691 14:3835863bc412 77 RpcDigitalInOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 14:3835863bc412 78
stefan1691 14:3835863bc412 79 int read(void) {return o.read();}
stefan1691 14:3835863bc412 80 void write(int a0) {o.write(a0);}
stefan1691 14:3835863bc412 81 void input(void) {o.input();}
stefan1691 14:3835863bc412 82 void output(void) {o.output();}
stefan1691 14:3835863bc412 83
stefan1691 14:3835863bc412 84 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 85 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 86 {"read", rpc_method_caller<int, RpcDigitalInOut, &RpcDigitalInOut::read>},
stefan1691 14:3835863bc412 87 {"write", rpc_method_caller<RpcDigitalInOut, int, &RpcDigitalInOut::write>},
stefan1691 14:3835863bc412 88 {"input", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::input>},
stefan1691 14:3835863bc412 89 {"output", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::output>},
stefan1691 14:3835863bc412 90 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 91 };
stefan1691 14:3835863bc412 92 return rpc_methods;
stefan1691 14:3835863bc412 93 }
stefan1691 14:3835863bc412 94 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 95 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 96 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalInOut, PinName, const char*> >},
stefan1691 14:3835863bc412 97 RPC_METHOD_END
stefan1691 14:3835863bc412 98 };
stefan1691 14:3835863bc412 99 static rpc_class c = {"DigitalInOut", funcs, NULL};
stefan1691 14:3835863bc412 100 return &c;
stefan1691 14:3835863bc412 101 }
stefan1691 14:3835863bc412 102 private:
stefan1691 14:3835863bc412 103 DigitalInOut o;
stefan1691 14:3835863bc412 104 };
stefan1691 14:3835863bc412 105
stefan1691 14:3835863bc412 106 #if DEVICE_ANALOGIN
stefan1691 14:3835863bc412 107 class RpcAnalogIn : public RPC {
stefan1691 14:3835863bc412 108 public:
stefan1691 14:3835863bc412 109 RpcAnalogIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 14:3835863bc412 110
stefan1691 14:3835863bc412 111 float read(void) {return o.read();}
stefan1691 14:3835863bc412 112 unsigned short read_u16(void) {return o.read_u16();}
stefan1691 14:3835863bc412 113
stefan1691 14:3835863bc412 114 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 115 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 116 {"read", rpc_method_caller<float, RpcAnalogIn, &RpcAnalogIn::read>},
stefan1691 14:3835863bc412 117 {"read_u16", rpc_method_caller<unsigned short, RpcAnalogIn, &RpcAnalogIn::read_u16>},
stefan1691 14:3835863bc412 118 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 119 };
stefan1691 14:3835863bc412 120 return rpc_methods;
stefan1691 14:3835863bc412 121 }
stefan1691 14:3835863bc412 122 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 123 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 124 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogIn, PinName, const char*> >},
stefan1691 14:3835863bc412 125 RPC_METHOD_END
stefan1691 14:3835863bc412 126 };
stefan1691 14:3835863bc412 127 static rpc_class c = {"AnalogIn", funcs, NULL};
stefan1691 14:3835863bc412 128 return &c;
stefan1691 14:3835863bc412 129 }
stefan1691 14:3835863bc412 130 private:
stefan1691 14:3835863bc412 131 AnalogIn o;
stefan1691 14:3835863bc412 132 };
stefan1691 14:3835863bc412 133 #endif
stefan1691 14:3835863bc412 134
stefan1691 14:3835863bc412 135 #if DEVICE_ANALOGOUT
stefan1691 14:3835863bc412 136 class RpcAnalogOut : public RPC {
stefan1691 14:3835863bc412 137 public:
stefan1691 14:3835863bc412 138 RpcAnalogOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 14:3835863bc412 139
stefan1691 14:3835863bc412 140 float read(void) {return o.read();}
stefan1691 14:3835863bc412 141 void write(float a0) {o.write(a0);}
stefan1691 14:3835863bc412 142 void write_u16(unsigned short a0) {o.write_u16(a0);}
stefan1691 14:3835863bc412 143
stefan1691 14:3835863bc412 144 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 145 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 146 {"read", rpc_method_caller<float, RpcAnalogOut, &RpcAnalogOut::read>},
stefan1691 14:3835863bc412 147 {"write", rpc_method_caller<RpcAnalogOut, float, &RpcAnalogOut::write>},
stefan1691 14:3835863bc412 148 {"write_u16", rpc_method_caller<RpcAnalogOut, unsigned short, &RpcAnalogOut::write_u16>},
stefan1691 14:3835863bc412 149 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 150 };
stefan1691 14:3835863bc412 151 return rpc_methods;
stefan1691 14:3835863bc412 152 }
stefan1691 14:3835863bc412 153 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 154 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 155 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogOut, PinName, const char*> >},
stefan1691 14:3835863bc412 156 RPC_METHOD_END
stefan1691 14:3835863bc412 157 };
stefan1691 14:3835863bc412 158 static rpc_class c = {"AnalogOut", funcs, NULL};
stefan1691 14:3835863bc412 159 return &c;
stefan1691 14:3835863bc412 160 }
stefan1691 14:3835863bc412 161 private:
stefan1691 14:3835863bc412 162 AnalogOut o;
stefan1691 14:3835863bc412 163 };
stefan1691 14:3835863bc412 164 #endif
stefan1691 14:3835863bc412 165
stefan1691 14:3835863bc412 166 #if DEVICE_PWMOUT
stefan1691 14:3835863bc412 167 class RpcPwmOut : public RPC {
stefan1691 14:3835863bc412 168 public:
stefan1691 14:3835863bc412 169 RpcPwmOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
stefan1691 14:3835863bc412 170
stefan1691 14:3835863bc412 171 float read(void) {return o.read();}
stefan1691 14:3835863bc412 172 void write(float a0) {o.write(a0);}
stefan1691 14:3835863bc412 173 void period(float a0) {o.period(a0);}
stefan1691 14:3835863bc412 174 void period_ms(int a0) {o.period_ms(a0);}
stefan1691 14:3835863bc412 175 void pulsewidth(float a0) {o.pulsewidth(a0);}
stefan1691 14:3835863bc412 176 void pulsewidth_ms(int a0) {o.pulsewidth_ms(a0);}
stefan1691 14:3835863bc412 177
stefan1691 14:3835863bc412 178 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 179 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 180 {"read", rpc_method_caller<float, RpcPwmOut, &RpcPwmOut::read>},
stefan1691 14:3835863bc412 181 {"write", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::write>},
stefan1691 14:3835863bc412 182 {"period", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::period>},
stefan1691 14:3835863bc412 183 {"period_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::period_ms>},
stefan1691 14:3835863bc412 184 {"pulsewidth", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::pulsewidth>},
stefan1691 14:3835863bc412 185 {"pulsewidth_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::pulsewidth_ms>},
stefan1691 14:3835863bc412 186 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 187 };
stefan1691 14:3835863bc412 188 return rpc_methods;
stefan1691 14:3835863bc412 189 }
stefan1691 14:3835863bc412 190 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 191 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 192 {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcPwmOut, PinName, const char*> >},
stefan1691 14:3835863bc412 193 RPC_METHOD_END
stefan1691 14:3835863bc412 194 };
stefan1691 14:3835863bc412 195 static rpc_class c = {"PwmOut", funcs, NULL};
stefan1691 14:3835863bc412 196 return &c;
stefan1691 14:3835863bc412 197 }
stefan1691 14:3835863bc412 198 private:
stefan1691 14:3835863bc412 199 PwmOut o;
stefan1691 14:3835863bc412 200 };
stefan1691 14:3835863bc412 201 #endif
stefan1691 14:3835863bc412 202
stefan1691 14:3835863bc412 203 #if DEVICE_SPI
stefan1691 14:3835863bc412 204 class RpcSPI : public RPC {
stefan1691 14:3835863bc412 205 public:
stefan1691 14:3835863bc412 206 RpcSPI(PinName a0, PinName a1, PinName a2, const char *name=NULL) : RPC(name), o(a0, a1, a2) {}
stefan1691 14:3835863bc412 207
stefan1691 14:3835863bc412 208 void format(int a0, int a1) {o.format(a0, a1);}
stefan1691 14:3835863bc412 209 void frequency(int a0) {o.frequency(a0);}
stefan1691 14:3835863bc412 210 int write(int a0) {return o.write(a0);}
stefan1691 14:3835863bc412 211
stefan1691 14:3835863bc412 212 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 213 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 214 {"format", rpc_method_caller<RpcSPI, int, int, &RpcSPI::format>},
stefan1691 14:3835863bc412 215 {"frequency", rpc_method_caller<RpcSPI, int, &RpcSPI::frequency>},
stefan1691 14:3835863bc412 216 {"write", rpc_method_caller<int, RpcSPI, int, &RpcSPI::write>},
stefan1691 14:3835863bc412 217 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 218 };
stefan1691 14:3835863bc412 219 return rpc_methods;
stefan1691 14:3835863bc412 220 }
stefan1691 14:3835863bc412 221 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 222 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 223 {"new", rpc_function_caller<const char*, PinName, PinName, PinName, const char*, &RPC::construct<RpcSPI, PinName, PinName, PinName, const char*> >},
stefan1691 14:3835863bc412 224 RPC_METHOD_END
stefan1691 14:3835863bc412 225 };
stefan1691 14:3835863bc412 226 static rpc_class c = {"SPI", funcs, NULL};
stefan1691 14:3835863bc412 227 return &c;
stefan1691 14:3835863bc412 228 }
stefan1691 14:3835863bc412 229 private:
stefan1691 14:3835863bc412 230 SPI o;
stefan1691 14:3835863bc412 231 };
stefan1691 14:3835863bc412 232 #endif
stefan1691 14:3835863bc412 233
stefan1691 14:3835863bc412 234 #if DEVICE_SERIAL
stefan1691 14:3835863bc412 235 class RpcSerial : public RPC {
stefan1691 14:3835863bc412 236 public:
stefan1691 14:3835863bc412 237 RpcSerial(PinName a0, PinName a1, const char *name=NULL) : RPC(name), o(a0, a1) {}
stefan1691 14:3835863bc412 238
stefan1691 14:3835863bc412 239 void baud(int a0) {o.baud(a0);}
stefan1691 14:3835863bc412 240 int readable(void) {return o.readable();}
stefan1691 14:3835863bc412 241 int writeable(void) {return o.writeable();}
stefan1691 14:3835863bc412 242 int putc(int a0) {return o.putc(a0);}
stefan1691 14:3835863bc412 243 int getc(void) {return o.getc();}
stefan1691 14:3835863bc412 244 int puts(const char * a0) {return o.puts(a0);}
stefan1691 14:3835863bc412 245
stefan1691 14:3835863bc412 246 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 247 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 248 {"baud", rpc_method_caller<RpcSerial, int, &RpcSerial::baud>},
stefan1691 14:3835863bc412 249 {"readable", rpc_method_caller<int, RpcSerial, &RpcSerial::readable>},
stefan1691 14:3835863bc412 250 {"writeable", rpc_method_caller<int, RpcSerial, &RpcSerial::writeable>},
stefan1691 14:3835863bc412 251 {"putc", rpc_method_caller<int, RpcSerial, int, &RpcSerial::putc>},
stefan1691 14:3835863bc412 252 {"getc", rpc_method_caller<int, RpcSerial, &RpcSerial::getc>},
stefan1691 14:3835863bc412 253 {"puts", rpc_method_caller<int, RpcSerial, const char *, &RpcSerial::puts>},
stefan1691 14:3835863bc412 254 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 255 };
stefan1691 14:3835863bc412 256 return rpc_methods;
stefan1691 14:3835863bc412 257 }
stefan1691 14:3835863bc412 258 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 259 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 260 {"new", rpc_function_caller<const char*, PinName, PinName, const char*, &RPC::construct<RpcSerial, PinName, PinName, const char*> >},
stefan1691 14:3835863bc412 261 RPC_METHOD_END
stefan1691 14:3835863bc412 262 };
stefan1691 14:3835863bc412 263 static rpc_class c = {"Serial", funcs, NULL};
stefan1691 14:3835863bc412 264 return &c;
stefan1691 14:3835863bc412 265 }
stefan1691 14:3835863bc412 266 private:
stefan1691 14:3835863bc412 267 Serial o;
stefan1691 14:3835863bc412 268 };
stefan1691 14:3835863bc412 269 #endif
stefan1691 14:3835863bc412 270
stefan1691 14:3835863bc412 271 class RpcTimer : public RPC {
stefan1691 14:3835863bc412 272 public:
stefan1691 14:3835863bc412 273 RpcTimer(const char *name=NULL) : RPC(name), o() {}
stefan1691 14:3835863bc412 274
stefan1691 14:3835863bc412 275 void start(void) {o.start();}
stefan1691 14:3835863bc412 276 void stop(void) {o.stop();}
stefan1691 14:3835863bc412 277 void reset(void) {o.reset();}
stefan1691 14:3835863bc412 278 float read(void) {return o.read();}
stefan1691 14:3835863bc412 279 int read_ms(void) {return o.read_ms();}
stefan1691 14:3835863bc412 280 int read_us(void) {return o.read_us();}
stefan1691 14:3835863bc412 281
stefan1691 14:3835863bc412 282 virtual const struct rpc_method *get_rpc_methods() {
stefan1691 14:3835863bc412 283 static const rpc_method rpc_methods[] = {
stefan1691 14:3835863bc412 284 {"start", rpc_method_caller<RpcTimer, &RpcTimer::start>},
stefan1691 14:3835863bc412 285 {"stop", rpc_method_caller<RpcTimer, &RpcTimer::stop>},
stefan1691 14:3835863bc412 286 {"reset", rpc_method_caller<RpcTimer, &RpcTimer::reset>},
stefan1691 14:3835863bc412 287 {"read", rpc_method_caller<float, RpcTimer, &RpcTimer::read>},
stefan1691 14:3835863bc412 288 {"read_ms", rpc_method_caller<int, RpcTimer, &RpcTimer::read_ms>},
stefan1691 14:3835863bc412 289 {"read_us", rpc_method_caller<int, RpcTimer, &RpcTimer::read_us>},
stefan1691 14:3835863bc412 290 RPC_METHOD_SUPER(RPC)
stefan1691 14:3835863bc412 291 };
stefan1691 14:3835863bc412 292 return rpc_methods;
stefan1691 14:3835863bc412 293 }
stefan1691 14:3835863bc412 294 static struct rpc_class *get_rpc_class() {
stefan1691 14:3835863bc412 295 static const rpc_function funcs[] = {
stefan1691 14:3835863bc412 296 {"new", rpc_function_caller<const char*, const char*, &RPC::construct<RpcTimer, const char*> >},
stefan1691 14:3835863bc412 297 RPC_METHOD_END
stefan1691 14:3835863bc412 298 };
stefan1691 14:3835863bc412 299 static rpc_class c = {"Timer", funcs, NULL};
stefan1691 14:3835863bc412 300 return &c;
stefan1691 14:3835863bc412 301 }
stefan1691 14:3835863bc412 302 private:
stefan1691 14:3835863bc412 303 Timer o;
stefan1691 14:3835863bc412 304 };
stefan1691 14:3835863bc412 305
stefan1691 14:3835863bc412 306 }
stefan1691 14:3835863bc412 307
stefan1691 14:3835863bc412 308 #endif