From d8e7044d2a84889c844033d1acbe1cc9c5ac9df3 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 18 May 2018 09:28:25 -0700 Subject: [PATCH] Servo, edge connector and button pair simulator support (#782) * add common packages dep * inlining microservo * moving more sim * updated * bump pxt --- cmds/pxtrequire.ts | 6 - cmds/tsconfig.json | 14 - package-lock.json | 619 ++++++++++++++------------------ package.json | 4 +- sim/public/siminstructions.html | 203 ----------- sim/state/buttonpairsim.ts | 200 +++++++++++ sim/state/edgeconnectorsim.ts | 86 +++++ sim/state/microservo.ts | 83 +++++ 8 files changed, 648 insertions(+), 567 deletions(-) delete mode 100644 cmds/pxtrequire.ts delete mode 100644 cmds/tsconfig.json delete mode 100644 sim/public/siminstructions.html create mode 100644 sim/state/buttonpairsim.ts create mode 100644 sim/state/edgeconnectorsim.ts create mode 100644 sim/state/microservo.ts diff --git a/cmds/pxtrequire.ts b/cmds/pxtrequire.ts deleted file mode 100644 index 713b72c1..00000000 --- a/cmds/pxtrequire.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// - -import * as path from "path"; -export let pxtCore = require("pxt-core"); -// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir -export let pxtCoreDir = path.resolve(require.resolve("pxt-core"), "..", ".."); diff --git a/cmds/tsconfig.json b/cmds/tsconfig.json deleted file mode 100644 index 4ebfccad..00000000 --- a/cmds/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "noImplicitAny": true, - "noImplicitReturns": true, - "declaration": true, - "outDir": "../built", - "module": "commonjs", - "rootDir": ".", - "newLine": "LF", - "sourceMap": false, - "types": ["node"] - } -} diff --git a/package-lock.json b/package-lock.json index 9793eaf6..faaad7b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -388,7 +388,6 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", - "dev": true, "optional": true }, "asn1": { @@ -575,67 +574,6 @@ } } }, - "browserify": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-13.3.0.tgz", - "integrity": "sha1-tanJAgJD8McORnW+yCI7xifkFc4=", - "requires": { - "JSONStream": "1.3.2", - "assert": "1.4.1", - "browser-pack": "6.1.0", - "browser-resolve": "1.11.2", - "browserify-zlib": "0.1.4", - "buffer": "4.9.1", - "cached-path-relative": "1.0.1", - "concat-stream": "1.5.2", - "console-browserify": "1.1.0", - "constants-browserify": "1.0.0", - "crypto-browserify": "3.12.0", - "defined": "1.0.0", - "deps-sort": "2.0.0", - "domain-browser": "1.1.7", - "duplexer2": "0.1.4", - "events": "1.1.1", - "glob": "7.1.2", - "has": "1.0.1", - "htmlescape": "1.1.1", - "https-browserify": "0.0.1", - "inherits": "2.0.3", - "insert-module-globals": "7.0.6", - "labeled-stream-splicer": "2.0.1", - "module-deps": "4.1.1", - "os-browserify": "0.1.2", - "parents": "1.0.1", - "path-browserify": "0.0.0", - "process": "0.11.10", - "punycode": "1.4.1", - "querystring-es3": "0.2.1", - "read-only-stream": "2.0.0", - "readable-stream": "2.3.3", - "resolve": "1.7.1", - "shasum": "1.0.2", - "shell-quote": "1.6.1", - "stream-browserify": "2.0.1", - "stream-http": "2.8.1", - "string_decoder": "0.10.31", - "subarg": "1.0.0", - "syntax-error": "1.4.0", - "through2": "2.0.3", - "timers-browserify": "1.4.2", - "tty-browserify": "0.0.1", - "url": "0.11.0", - "util": "0.10.3", - "vm-browserify": "0.0.4", - "xtend": "4.0.1" - }, - "dependencies": { - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, "browserify-aes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", @@ -692,14 +630,6 @@ "parse-asn1": "5.1.1" } }, - "browserify-zlib": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", - "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", - "requires": { - "pako": "0.2.9" - } - }, "browserslist": { "version": "1.7.7", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-1.7.7.tgz", @@ -709,16 +639,6 @@ "electron-to-chromium": "1.3.27" } }, - "buffer": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", - "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", - "requires": { - "base64-js": "1.3.0", - "ieee754": "1.1.11", - "isarray": "1.0.0" - } - }, "buffer-from": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz", @@ -808,7 +728,7 @@ "clap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/clap/-/clap-1.2.3.tgz", - "integrity": "sha512-4CoL/A3hf90V3VIEjeuhSvlGFEHKzOz+Wfc2IVZc+FaUgU0ZQafJTP49fvnULipOPcAfqhyI2duwQyns6xqjYA==", + "integrity": "sha1-TzZ0WzIAhJJVf0ZBLWbVDLmbzlE=", "requires": { "chalk": "1.1.3" } @@ -951,36 +871,6 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "concat-stream": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", - "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.0.6", - "typedarray": "0.0.6" - }, - "dependencies": { - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, "console-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", @@ -1233,22 +1123,6 @@ "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", "optional": true }, - "detective": { - "version": "4.7.1", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", - "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", - "requires": { - "acorn": "5.5.3", - "defined": "1.0.0" - }, - "dependencies": { - "acorn": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", - "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==" - } - } - }, "diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", @@ -1259,11 +1133,6 @@ "randombytes": "2.0.6" } }, - "domain-browser": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", - "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=" - }, "duplexer2": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", @@ -1312,7 +1181,6 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz", "integrity": "sha1-uJbiOp5ei6M4cfyZar02NfyaHH0=", - "dev": true, "optional": true, "requires": { "prr": "0.0.0" @@ -1333,11 +1201,6 @@ "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=" }, - "events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" - }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -1448,11 +1311,6 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, - "fuse.js": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-2.6.1.tgz", - "integrity": "sha1-0RjgD5qFn3s1TtT3dAIUJJ4ypXo=" - }, "gauge": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", @@ -1486,7 +1344,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", "requires": { "fs.realpath": "1.0.0", "inflight": "1.0.6", @@ -1500,7 +1358,6 @@ "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true, "optional": true }, "har-schema": { @@ -1573,11 +1430,6 @@ "sntp": "2.1.0" } }, - "highlight.js": { - "version": "9.12.0", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz", - "integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=" - }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -1618,11 +1470,6 @@ "sshpk": "1.13.1" } }, - "https-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-0.0.1.tgz", - "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=" - }, "ieee754": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.11.tgz", @@ -1632,7 +1479,6 @@ "version": "0.5.5", "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz", "integrity": "sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w=", - "dev": true, "optional": true }, "indexes-of": { @@ -1640,11 +1486,6 @@ "resolved": "https://registry.npmjs.org/indexes-of/-/indexes-of-1.0.1.tgz", "integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=" }, - "indexof": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" - }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -1834,8 +1675,7 @@ "jquery": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz", - "integrity": "sha1-XE2d5lKvbNCncBVKYxu6ErAVx4c=", - "dev": true + "integrity": "sha1-XE2d5lKvbNCncBVKYxu6ErAVx4c=" }, "js-base64": { "version": "2.3.2", @@ -1871,7 +1711,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, "optional": true, "requires": { "jsonify": "0.0.0" @@ -1955,7 +1794,6 @@ "version": "2.7.3", "resolved": "https://registry.npmjs.org/less/-/less-2.7.3.tgz", "integrity": "sha512-KPdIJKWcEAb02TuJtaLrhue0krtRLoRoo7x6BNJIBelO00t/CCdJQUnHW5V34OnHMWzIktSalJxRO+FvytQlCQ==", - "dev": true, "requires": { "errno": "0.1.4", "graceful-fs": "4.1.11", @@ -1971,7 +1809,6 @@ "version": "4.11.8", "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "dev": true, "optional": true, "requires": { "co": "4.6.0", @@ -1982,21 +1819,18 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "dev": true, "optional": true }, "aws-sign2": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true, "optional": true }, "boom": { "version": "2.10.1", "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "dev": true, "requires": { "hoek": "2.16.3" } @@ -2005,7 +1839,6 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "dev": true, "optional": true, "requires": { "boom": "2.10.1" @@ -2015,7 +1848,6 @@ "version": "2.1.4", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", - "dev": true, "optional": true, "requires": { "asynckit": "0.4.0", @@ -2027,14 +1859,12 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", - "dev": true, "optional": true }, "har-validator": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", - "dev": true, "optional": true, "requires": { "ajv": "4.11.8", @@ -2045,7 +1875,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "dev": true, "optional": true, "requires": { "boom": "2.10.1", @@ -2057,14 +1886,12 @@ "hoek": { "version": "2.16.3", "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" }, "http-signature": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "dev": true, "optional": true, "requires": { "assert-plus": "0.2.0", @@ -2076,21 +1903,18 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", - "dev": true, "optional": true }, "qs": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", - "dev": true, "optional": true }, "request": { "version": "2.81.0", "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", - "dev": true, "optional": true, "requires": { "aws-sign2": "0.6.0", @@ -2121,7 +1945,6 @@ "version": "1.0.9", "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", - "dev": true, "optional": true, "requires": { "hoek": "2.16.3" @@ -2189,11 +2012,6 @@ "object-visit": "1.0.1" } }, - "marked": { - "version": "0.3.12", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.12.tgz", - "integrity": "sha512-k4NaW+vS7ytQn6MgJn3fYpQt20/mOgYM5Ft9BYMfQJDz2QT6yEeS9XJ8k2Nw8JTeWK/znPPW2n3UJGzyYEiMoA==" - }, "math-expression-evaluator": { "version": "1.2.17", "resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz", @@ -2221,7 +2039,6 @@ "version": "1.4.1", "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", - "dev": true, "optional": true }, "mime-db": { @@ -2250,7 +2067,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", "requires": { "brace-expansion": "1.1.8" } @@ -2284,28 +2101,6 @@ "minimist": "0.0.8" } }, - "module-deps": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz", - "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", - "requires": { - "JSONStream": "1.3.2", - "browser-resolve": "1.11.2", - "cached-path-relative": "1.0.1", - "concat-stream": "1.5.2", - "defined": "1.0.0", - "detective": "4.7.1", - "duplexer2": "0.1.4", - "inherits": "2.0.3", - "parents": "1.0.1", - "readable-stream": "2.3.3", - "resolve": "1.7.1", - "stream-combiner2": "1.1.1", - "subarg": "1.0.0", - "through2": "2.0.3", - "xtend": "4.0.1" - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -2375,7 +2170,7 @@ "npmlog": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=", "optional": true, "requires": { "are-we-there-yet": "1.1.4", @@ -2479,22 +2274,12 @@ "wrappy": "1.0.2" } }, - "os-browserify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.1.2.tgz", - "integrity": "sha1-ScoCk+CxlZCl9d4Qx/JlphfY/lQ=" - }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "optional": true }, - "pako": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", - "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=" - }, "parents": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", @@ -2606,65 +2391,12 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, - "pngjs": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.3.3.tgz", - "integrity": "sha512-1n3Z4p3IOxArEs1VRXnZ/RXdfEniAUS9jb68g58FIXMNkPJeZd+Qh4Uq7/e0LVxAQGos1eIUrqrt4FpjdnEd+Q==" - }, "pointer-symbol": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/pointer-symbol/-/pointer-symbol-1.0.0.tgz", "integrity": "sha1-YPkRAgTqepKbYmRKITFVQ8uz1Ec=", "optional": true }, - "postcss": { - "version": "6.0.13", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.13.tgz", - "integrity": "sha512-nHsrD1PPTMSJDfU+osVsLtPkSP9YGeoOz4FDLN4r1DW4N5vqL1J+gACzTQHsfwIiWG/0/nV4yCzjTMo1zD8U1g==", - "requires": { - "chalk": "2.3.0", - "source-map": "0.6.1", - "supports-color": "4.5.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "requires": { - "color-convert": "1.9.0" - } - }, - "chalk": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", - "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", - "requires": { - "ansi-styles": "3.2.0", - "escape-string-regexp": "1.0.5", - "supports-color": "4.5.0" - } - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" - }, - "supports-color": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", - "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", - "requires": { - "has-flag": "2.0.0" - } - } - } - }, "postcss-calc": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/postcss-calc/-/postcss-calc-5.3.1.tgz", @@ -3302,7 +3034,6 @@ "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", "integrity": "sha1-BktyYCsY+Q8pGSuLG8QY/9Hr078=", - "dev": true, "optional": true, "requires": { "asap": "2.0.6" @@ -3469,7 +3200,6 @@ "version": "0.0.0", "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz", "integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=", - "dev": true, "optional": true }, "public-encrypt": { @@ -3499,27 +3229,284 @@ "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" }, "pxt-core": { - "version": "3.10.16", - "resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.10.16.tgz", - "integrity": "sha512-QsvI6Q68Pfn99/yoQDKpOLvG0/Ldb+f1MQoTpQ3JyNGC1vuqLI1WA8sbrxT2SGbtreEGV71DHL4Lws++QEdI1Q==", + "version": "3.14.9", + "resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.14.9.tgz", + "integrity": "sha512-tjEmH8Rs5BkawzAx3DBaC0pU30iuAZ/91c7M/1vqNAjm/PZ8pu/PVKJN3b4giWJpFQFp6po8hWQ9bfHl9BDHcw==", "requires": { "bluebird": "3.5.1", - "browserify": "13.3.0", + "browserify": "16.2.0", "cssnano": "3.10.0", "faye-websocket": "0.11.1", - "fuse.js": "2.6.1", - "highlight.js": "9.12.0", "keytar": "4.2.1", + "less": "2.7.3", "lzma": "2.3.2", - "marked": "0.3.12", + "marked": "0.3.19", "node-hid": "0.5.7", - "pngjs": "3.3.3", - "postcss": "6.0.13", - "request": "2.83.0", + "pngjs": "3.3.2", + "postcss": "6.0.21", + "request": "2.85.0", "rimraf": "2.5.4", - "rtlcss": "2.2.0", + "rtlcss": "2.2.1", + "semantic-ui-less": "2.2.14", "serialport": "6.2.0", "uglify-js": "3.3.21" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "1.9.0" + } + }, + "browserify": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.2.0.tgz", + "integrity": "sha512-yotdAkp/ZbgDesHQBYU37zjc29JDH4iXT8hjzM1fdUVWogjARX0S1cKeX24Ci6zZ+jG+ADmCTRt6xvtmJnI+BQ==", + "requires": { + "JSONStream": "1.3.2", + "assert": "1.4.1", + "browser-pack": "6.1.0", + "browser-resolve": "1.11.2", + "browserify-zlib": "0.2.0", + "buffer": "5.1.0", + "cached-path-relative": "1.0.1", + "concat-stream": "1.6.2", + "console-browserify": "1.1.0", + "constants-browserify": "1.0.0", + "crypto-browserify": "3.12.0", + "defined": "1.0.0", + "deps-sort": "2.0.0", + "domain-browser": "1.2.0", + "duplexer2": "0.1.4", + "events": "2.0.0", + "glob": "7.1.2", + "has": "1.0.1", + "htmlescape": "1.1.1", + "https-browserify": "1.0.0", + "inherits": "2.0.3", + "insert-module-globals": "7.0.6", + "labeled-stream-splicer": "2.0.1", + "mkdirp": "0.5.1", + "module-deps": "6.1.0", + "os-browserify": "0.3.0", + "parents": "1.0.1", + "path-browserify": "0.0.0", + "process": "0.11.10", + "punycode": "1.4.1", + "querystring-es3": "0.2.1", + "read-only-stream": "2.0.0", + "readable-stream": "2.3.3", + "resolve": "1.7.1", + "shasum": "1.0.2", + "shell-quote": "1.6.1", + "stream-browserify": "2.0.1", + "stream-http": "2.8.1", + "string_decoder": "1.1.1", + "subarg": "1.0.0", + "syntax-error": "1.4.0", + "through2": "2.0.3", + "timers-browserify": "1.4.2", + "tty-browserify": "0.0.1", + "url": "0.11.0", + "util": "0.10.3", + "vm-browserify": "1.0.1", + "xtend": "4.0.1" + } + }, + "browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "requires": { + "pako": "1.0.6" + } + }, + "buffer": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.1.0.tgz", + "integrity": "sha512-YkIRgwsZwJWTnyQrsBTWefizHh+8GYj3kbL1BTiAQ/9pwpino0G7B2gp5tx/FUBqUlvtxV85KNR3mwfAtv15Yw==", + "requires": { + "base64-js": "1.3.0", + "ieee754": "1.1.11" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "requires": { + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.4.0" + } + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "1.0.0", + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" + } + }, + "detective": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/detective/-/detective-5.1.0.tgz", + "integrity": "sha512-TFHMqfOvxlgrfVzTEkNBSh9SvSNX/HfF4OFI2QFGCyPm02EsyILqnUeb5P6q7JZ3SFNTBL5t2sePRgrN4epUWQ==", + "requires": { + "acorn-node": "1.3.0", + "defined": "1.0.0", + "minimist": "1.2.0" + } + }, + "domain-browser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==" + }, + "events": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/events/-/events-2.0.0.tgz", + "integrity": "sha512-r/M5YkNg9zwI8QbSf7tsDWWJvO3PGwZXyG7GpFAxtMASnHL2eblFd7iHiGPtyGKKFPZ59S63NeX10Ws6WqGDcg==" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=" + }, + "marked": { + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", + "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==" + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "module-deps": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.1.0.tgz", + "integrity": "sha512-NPs5N511VD1rrVJihSso/LiBShRbJALYBKzDW91uZYy7BpjnO4bGnZL3HjZ9yKcFdZUWwaYjDz9zxbuP7vKMuQ==", + "requires": { + "JSONStream": "1.3.2", + "browser-resolve": "1.11.2", + "cached-path-relative": "1.0.1", + "concat-stream": "1.6.2", + "defined": "1.0.0", + "detective": "5.1.0", + "duplexer2": "0.1.4", + "inherits": "2.0.3", + "parents": "1.0.1", + "readable-stream": "2.3.3", + "resolve": "1.7.1", + "stream-combiner2": "1.1.1", + "subarg": "1.0.0", + "through2": "2.0.3", + "xtend": "4.0.1" + } + }, + "os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=" + }, + "pako": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", + "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" + }, + "pngjs": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.3.2.tgz", + "integrity": "sha512-bVNd3LMXRzdo6s4ehr4XW2wFMu9cb40nPgHEjSSppm8/++Xc+g0b2QQb+SeDesgfANXbjydOr1or9YQ+pcCZPQ==" + }, + "postcss": { + "version": "6.0.21", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.21.tgz", + "integrity": "sha512-y/bKfbQz2Nn/QBC08bwvYUxEFOVGfPIUOTsJ2CK5inzlXW9SdYR1x4pEsG9blRAF/PX+wRNdOah+gx/hv4q7dw==", + "requires": { + "chalk": "2.4.1", + "source-map": "0.6.1", + "supports-color": "5.4.0" + } + }, + "request": { + "version": "2.85.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", + "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==", + "requires": { + "aws-sign2": "0.7.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.3.1", + "har-validator": "5.0.3", + "hawk": "6.0.2", + "http-signature": "1.2.0", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "performance-now": "2.1.0", + "qs": "6.5.1", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + } + }, + "rtlcss": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-2.2.1.tgz", + "integrity": "sha512-JjQ5DlrmwiItAjlmhoxrJq5ihgZcE0wMFxt7S17bIrt4Lw0WwKKFk+viRhvodB/0falyG/5fiO043ZDh6/aqTw==", + "requires": { + "chalk": "2.4.1", + "findup": "0.1.5", + "mkdirp": "0.5.1", + "postcss": "6.0.21", + "strip-json-comments": "2.0.1" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "requires": { + "has-flag": "3.0.0" + } + }, + "vm-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.0.1.tgz", + "integrity": "sha512-EqzLchIMYLBjRPoqVsEkZOa/4Vr2RfOWbd58F+I/Gj79AYTrsseMunxbbSkbYfrqZaXSuPBBXNSOhtJgg0PpmA==" + } } }, "q": { @@ -3610,7 +3597,7 @@ "readable-stream": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=", "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", @@ -3700,35 +3687,6 @@ "balanced-match": "0.4.2" } }, - "request": { - "version": "2.83.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", - "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", - "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.1", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" - } - }, "resolve": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", @@ -3754,18 +3712,6 @@ "inherits": "2.0.3" } }, - "rtlcss": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/rtlcss/-/rtlcss-2.2.0.tgz", - "integrity": "sha1-E0QVJU0MJrXEA+Lq0sG4v0/AAN0=", - "requires": { - "chalk": "1.1.3", - "findup": "0.1.5", - "mkdirp": "0.5.1", - "postcss": "6.0.13", - "strip-json-comments": "2.0.1" - } - }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -3774,13 +3720,12 @@ "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + "integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk=" }, "semantic-ui-less": { "version": "2.2.14", "resolved": "https://registry.npmjs.org/semantic-ui-less/-/semantic-ui-less-2.2.14.tgz", "integrity": "sha512-JLkTqjOtct+OwM/JRv0SH76gCC0eE98xp5G4D29e9VbJ66QjWD3nB3waB7drpaMUFXo/YbKcyNOJBgMamcJI0Q==", - "dev": true, "requires": { "jquery": "3.2.1" } @@ -4141,7 +4086,7 @@ "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=", "requires": { "safe-buffer": "5.1.1" } @@ -4447,14 +4392,6 @@ "extsprintf": "1.3.0" } }, - "vm-browserify": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", - "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", - "requires": { - "indexof": "0.0.1" - } - }, "warning-symbol": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/warning-symbol/-/warning-symbol-0.1.0.tgz", @@ -4482,7 +4419,7 @@ "wide-align": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", - "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", + "integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=", "optional": true, "requires": { "string-width": "1.0.2" diff --git a/package.json b/package.json index 950f78dd..157f23e8 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,6 @@ "docs/static/*.png", "docs/static/icons/favicon.ico" ], - "main": "built/pxtrequire.js", - "typings": "built/pxtrequire.d.ts", "devDependencies": { "typescript": "2.6.1", "less": "2.7.3", @@ -43,6 +41,6 @@ "@types/node": "8.0.53" }, "dependencies": { - "pxt-core": "3.14.9" + "pxt-core": "3.15.1" } } diff --git a/sim/public/siminstructions.html b/sim/public/siminstructions.html deleted file mode 100644 index 3d88ea16..00000000 --- a/sim/public/siminstructions.html +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - Assembly Instructions - - - - - -
-
-
- - - - - - - - - - - - - - - - - - -
-

- - -
- -
-
-
-
- - \ No newline at end of file diff --git a/sim/state/buttonpairsim.ts b/sim/state/buttonpairsim.ts new file mode 100644 index 00000000..47f40284 --- /dev/null +++ b/sim/state/buttonpairsim.ts @@ -0,0 +1,200 @@ +namespace pxsim.visuals { + export function mkBtnSvg(xy: Coord): SVGAndSize { + let [innerCls, outerCls] = ["sim-button", "sim-button-outer"]; + const tabSize = PIN_DIST / 2.5; + const pegR = PIN_DIST / 5; + const btnR = PIN_DIST * .8; + const pegMargin = PIN_DIST / 8; + const plateR = PIN_DIST / 12; + + const pegOffset = pegMargin + pegR; + let [x, y] = xy; + const left = x - tabSize / 2; + const top = y - tabSize / 2; + const plateH = 3 * PIN_DIST - tabSize; + const plateW = 2 * PIN_DIST + tabSize; + const plateL = left; + const plateT = top + tabSize; + const btnCX = plateL + plateW / 2; + const btnCY = plateT + plateH / 2; + + let btng = svg.elt("g"); + //tabs + const mkTab = (x: number, y: number) => { + svg.child(btng, "rect", { class: "sim-button-tab", x: x, y: y, width: tabSize, height: tabSize}) + } + mkTab(left, top); + mkTab(left + 2 * PIN_DIST, top); + mkTab(left, top + 3 * PIN_DIST); + mkTab(left + 2 * PIN_DIST, top + 3 * PIN_DIST); + + //plate + svg.child(btng, "rect", { class: outerCls, x: plateL, y: plateT, rx: plateR, ry: plateR, width: plateW, height: plateH }); + + //pegs + const mkPeg = (x: number, y: number) => { + svg.child(btng, "circle", { class: "sim-button-nut", cx: x, cy: y, r: pegR }); + } + mkPeg(plateL + pegOffset, plateT + pegOffset) + mkPeg(plateL + plateW - pegOffset, plateT + pegOffset) + mkPeg(plateL + pegOffset, plateT + plateH - pegOffset) + mkPeg(plateL + plateW - pegOffset, plateT + plateH - pegOffset) + + //inner btn + let innerBtn = svg.child(btng, "circle", { class: innerCls, cx: btnCX, cy: btnCY, r: btnR }); + + //return + return { el: btng, y: top, x: left, w: plateW, h: plateH + 2 * tabSize }; + } + export const BUTTON_PAIR_STYLE = ` + .sim-button { + pointer-events: none; + fill: #000; + } + .sim-button-outer:active ~ .sim-button, + .sim-button-virtual:active { + fill: #FFA500; + } + .sim-button-outer { + cursor: pointer; + fill: #979797; + } + .sim-button-outer:hover { + stroke:gray; + stroke-width: ${PIN_DIST / 5}px; + } + .sim-button-nut { + fill:#000; + pointer-events:none; + } + .sim-button-nut:hover { + stroke:${PIN_DIST / 15}px solid #704A4A; + } + .sim-button-tab { + fill:#FFF; + pointer-events:none; + } + .sim-button-virtual { + cursor: pointer; + fill: rgba(255, 255, 255, 0.6); + stroke: rgba(255, 255, 255, 1); + stroke-width: ${PIN_DIST / 5}px; + } + .sim-button-virtual:hover { + stroke: rgba(128, 128, 128, 1); + } + .sim-text-virtual { + fill: #000; + pointer-events:none; + } + `; + export class ButtonPairView implements IBoardPart { + public element: SVGElement; + public defs: SVGElement[]; + public style = BUTTON_PAIR_STYLE; + private state: ButtonPairState; + private bus: EventBus; + private aBtn: SVGGElement; + private bBtn: SVGGElement; + private abBtn: SVGGElement; + + public init(bus: EventBus, state: ButtonPairState) { + this.state = state; + this.bus = bus; + this.defs = []; + this.element = this.mkBtns(); + this.updateState(); + this.attachEvents(); + } + + public moveToCoord(xy: Coord) { + let btnWidth = PIN_DIST * 3; + let [x, y] = xy; + translateEl(this.aBtn, [x, y]) + translateEl(this.bBtn, [x + btnWidth, y]) + translateEl(this.abBtn, [x + PIN_DIST * 1.5, y + PIN_DIST * 4]) + } + + public updateState() { + let stateBtns = [this.state.aBtn, this.state.bBtn, this.state.abBtn]; + let svgBtns = [this.aBtn, this.bBtn, this.abBtn]; + + if (this.state.usesButtonAB && this.abBtn.style.visibility != "visible") { + this.abBtn.style.visibility = "visible"; + } + } + + public updateTheme() {} + + private mkBtns() { + this.aBtn = mkBtnSvg([0, 0]).el; + this.bBtn = mkBtnSvg([0, 0]).el; + + const mkVirtualBtn = () => { + const numPins = 2; + const w = PIN_DIST * 2.8; + const offset = (w - (numPins * PIN_DIST)) / 2; + const corner = PIN_DIST / 2; + const cx = 0 - offset + w / 2; + const cy = cx; + const txtSize = PIN_DIST * 1.3; + const x = -offset; + const y = -offset; + const txtXOff = PIN_DIST / 7; + const txtYOff = PIN_DIST / 10; + + let btng = svg.elt("g"); + let btn = svg.child(btng, "rect", { class: "sim-button-virtual", x: x, y: y, rx: corner, ry: corner, width: w, height: w}); + let btnTxt = mkTxt(cx + txtXOff, cy + txtYOff, txtSize, 0, "A+B"); + svg.addClass(btnTxt, "sim-text") + svg.addClass(btnTxt, "sim-text-virtual"); + btng.appendChild(btnTxt); + + return btng; + } + + this.abBtn = mkVirtualBtn(); + this.abBtn.style.visibility = "hidden"; + + let el = svg.elt("g"); + svg.addClass(el, "sim-buttonpair") + el.appendChild(this.aBtn); + el.appendChild(this.bBtn); + el.appendChild(this.abBtn); + + return el; + } + + private attachEvents() { + let btnStates = [this.state.aBtn, this.state.bBtn]; + let btnSvgs = [this.aBtn, this.bBtn]; + btnSvgs.forEach((btn, index) => { + pxsim.pointerEvents.down.forEach(evid => btn.addEventListener(evid, ev => { + btnStates[index].pressed = true; + })) + btn.addEventListener(pointerEvents.leave, ev => { + btnStates[index].pressed = false; + }) + btn.addEventListener(pointerEvents.up, ev => { + btnStates[index].pressed = false; + this.bus.queue(btnStates[index].id, this.state.props.BUTTON_EVT_UP); + this.bus.queue(btnStates[index].id, this.state.props.BUTTON_EVT_CLICK); + }) + }) + let updateBtns = (s: boolean) => { + btnStates.forEach(b => b.pressed = s) + }; + pxsim.pointerEvents.down.forEach(evid => this.abBtn.addEventListener(evid, ev => { + updateBtns(true); + })); + this.abBtn.addEventListener(pointerEvents.leave, ev => { + updateBtns(false); + }) + this.abBtn.addEventListener(pointerEvents.up, ev => { + updateBtns(false); + this.bus.queue(this.state.abBtn.id, this.state.props.BUTTON_EVT_UP); + this.bus.queue(this.state.abBtn.id, this.state.props.BUTTON_EVT_CLICK); + }) + } + } +} \ No newline at end of file diff --git a/sim/state/edgeconnectorsim.ts b/sim/state/edgeconnectorsim.ts new file mode 100644 index 00000000..74949fb2 --- /dev/null +++ b/sim/state/edgeconnectorsim.ts @@ -0,0 +1,86 @@ +namespace pxsim { + export enum PinFlags { + Unused = 0, + Digital = 0x0001, + Analog = 0x0002, + Input = 0x0004, + Output = 0x0008, + Touch = 0x0010 + } + + export class Pin { + constructor(public id: number) { } + touched = false; + value = 0; + period = 0; + servoAngle = 0; + mode = PinFlags.Unused; + pitch = false; + pull = 0; // PullDown + + digitalReadPin(): number { + this.mode = PinFlags.Digital | PinFlags.Input; + return this.value > 100 ? 1 : 0; + } + + digitalWritePin(value: number) { + this.mode = PinFlags.Digital | PinFlags.Output; + this.value = value > 0 ? 200 : 0; + runtime.queueDisplayUpdate(); + } + + setPull(pull: number) { + this.pull = pull; + } + + analogReadPin(): number { + this.mode = PinFlags.Analog | PinFlags.Input; + return this.value || 0; + } + + analogWritePin(value: number) { + this.mode = PinFlags.Analog | PinFlags.Output; + this.value = Math.max(0, Math.min(1023, value)); + runtime.queueDisplayUpdate(); + } + + analogSetPeriod(micros: number) { + this.mode = PinFlags.Analog | PinFlags.Output; + this.period = micros; + runtime.queueDisplayUpdate(); + } + + servoWritePin(value: number) { + this.analogSetPeriod(20000); + this.servoAngle = Math.max(0, Math.min(180, value)); + runtime.queueDisplayUpdate(); + } + + servoSetPulse(pinId: number, micros: number) { + // TODO + } + + isTouched(): boolean { + this.mode = PinFlags.Touch | PinFlags.Analog | PinFlags.Input; + return this.touched; + } + } + + export interface EdgeConnectorProps { + pins: number[]; + servos?: { [name: string]: number; } + } + + export class EdgeConnectorState { + pins: Pin[]; + + constructor(public props: EdgeConnectorProps) { + this.pins = props.pins.map(id => id != undefined ? new Pin(id) : null); + } + + public getPin(id: number) { + return this.pins.filter(p => p && p.id == id)[0] || null + } + } + +} \ No newline at end of file diff --git a/sim/state/microservo.ts b/sim/state/microservo.ts new file mode 100644 index 00000000..30c6971d --- /dev/null +++ b/sim/state/microservo.ts @@ -0,0 +1,83 @@ +namespace pxsim.visuals { + function createMicroServoElement() { + return svg.parseString(` + + + + + + + + + + + + + + + + + `).firstElementChild as SVGGElement; + } + + export function mkMicroServoPart(xy: Coord = [0, 0]): SVGElAndSize { + return { el: createMicroServoElement(), x: xy[0], y: xy[1], w: 112.188, h: 299.674 }; + } + + export class MicroServoView implements IBoardPart { + public style: string = ""; + public overElement: SVGElement = undefined; + public element: SVGElement; + public defs: SVGElement[] = []; + public state: EdgeConnectorState; + public bus: EventBus; + private currentAngle = 0; + private targetAngle = 0; + private lastAngleTime = 0; + private pin: number; + + private crankEl: SVGGElement; + private crankTransform: string; + + public init(bus: EventBus, state: EdgeConnectorState, svgEl: SVGSVGElement, otherParams: Map) { + this.state = state; + this.pin = this.state.props.servos[ + pxsim.readPin(otherParams["name"] || otherParams["pin"]) + ]; + this.bus = bus; + this.defs = []; + this.initDom(); + this.updateState(); + } + + initDom() { + this.element = createMicroServoElement(); + this.crankEl = this.element.querySelector("#crank") as SVGGElement; + this.crankTransform = this.crankEl.getAttribute("transform"); + } + + moveToCoord(xy: visuals.Coord): void { + let [x, y] = xy; + translateEl(this.element, [x, y]) + } + updateState(): void { + this.targetAngle = 180.0 - this.state.getPin(this.pin).servoAngle; + if (this.targetAngle != this.currentAngle) { + const now = U.now(); + const cx = 56.661; + const cy = 899.475; + const speed = 300; // 0.1s/60 degree + const dt = Math.min(now - this.lastAngleTime, 50) / 1000; + const delta = this.targetAngle - this.currentAngle; + this.currentAngle += Math.min(Math.abs(delta), speed * dt) * (delta > 0 ? 1 : -1); + this.crankEl.setAttribute("transform", this.crankTransform + + ` rotate(${this.currentAngle}, ${cx}, ${cy})`) + this.lastAngleTime = now; + setTimeout(() => runtime.updateDisplay(), 20); + } + } + updateTheme(): void { + + } + } +}