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.
Diff: Script.cpp
- Revision:
- 3:f56c36ea8266
- Parent:
- 2:f0b75885747c
--- a/Script.cpp Sat Jan 11 22:10:19 2014 +0000
+++ b/Script.cpp Sat Jan 18 15:23:00 2014 +0000
@@ -38,6 +38,10 @@
*/
#include "TinyJS.h"
#include "TinyJS_Functions.h"
+#ifdef MBED
+#include "Mbed_Functions.h"
+#endif
+
#include <assert.h>
#include <stdio.h>
@@ -97,12 +101,6 @@
extern int readOneLine(char *buffer, const int bufferSize);
-// mbed function(s)
-extern void mbedDigitalOut(CScriptVar *c, void *);
-extern char *mbedLedsVarString(int ledNo);
-extern void mbedMemfree(CScriptVar *c, void *);
-
-
int tinyjs_main(int argc, char **argv)
{
CTinyJS *js = new CTinyJS();
@@ -115,12 +113,8 @@
js->execute("print(\"Interactive mode... Type quit(); to exit, or print(...); to print something, or dump() to dump the symbol table!\");");
// add mbed functions
- js->addNative("function mbed.memfree()", &mbedMemfree, 0);
- js->addNative("function mbed.DigitalOut(pinName, val)", &mbedDigitalOut, 0);
- js->execute(mbedLedsVarString(1));
- js->execute(mbedLedsVarString(2));
- js->execute(mbedLedsVarString(3));
- js->execute(mbedLedsVarString(4));
+ registerMbedFunctions(js);
+
while (js->evaluate("lets_quit") == "0") {
char buffer[2048];