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 TinyJS by
Diff: Mbed_Functions.cpp
- Revision:
- 9:f80cf055f03d
- Parent:
- 8:819934a27c2d
diff -r 819934a27c2d -r f80cf055f03d Mbed_Functions.cpp --- a/Mbed_Functions.cpp Mon Jan 20 00:07:35 2014 +0000 +++ b/Mbed_Functions.cpp Wed Sep 10 08:41:53 2014 +0000 @@ -9,6 +9,7 @@ #include "mbed.h" #include "TinyJS.h" #include "Mbed_Functions.h" +#include "PinNameTable.h" //--------------------------------------------- @@ -62,9 +63,10 @@ string pinNameString = c->getParameter("pinName")->getString(); PinName pinName = _mbedPinNameExchange(pinNameString); float val = c->getParameter("val")->getDouble(); - +#if DEVICE_ANALOGOUT AnalogOut aout = AnalogOut((PinName)pinName); aout.write(val); +#endif } //--------------------------------------------- @@ -169,6 +171,7 @@ //--------------------------------------------- PinName _mbedPinNameExchange(string pinNameString) { +#if 0 if (pinNameString == "p5") return p5; if (pinNameString == "p6") return p6; if (pinNameString == "p7") return p7; @@ -207,6 +210,22 @@ if (pinNameString == "USBRX") return USBRX; return NC; +#else + int imin = 0; + int imax = sizeof(pinname_table) / sizeof(pinNameStr) - 1; + while(imax >= imin) { + int i = (imin + imax) / 2; + int c = strcmp(pinNameString.c_str(), pinname_table[i].name); + if (c == 0) { + return pinname_table[i].pin; + } else if (c > 0) { + imin = i + 1; + } else { + imax = i - 1; + } + } + return NC; +#endif } //---------------------------------------------