Compare commits

..

2 Commits

Author SHA1 Message Date
41a1ced9ae 0.1.37 2018-05-02 16:24:07 -07:00
0ce5ffb1d6 Fix color grid on IE. 2018-05-02 16:23:22 -07:00
26 changed files with 106 additions and 114 deletions

6
cmds/pxtrequire.ts Normal file
View File

@ -0,0 +1,6 @@
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
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"), "..", "..");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

After

Width:  |  Height:  |  Size: 509 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 KiB

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -185,7 +185,7 @@ namespace sensors {
* @param handler the code to run when detected
*/
//% help=sensors/color-sensor/on-light-detected
//% block="on **color sensor** %this|%mode|%condition"
//% block="on **color sensor** %this|detected %mode|%condition"
//% blockId=colorOnLightDetected
//% parts="colorsensor"
//% blockNamespace=sensors
@ -202,7 +202,7 @@ namespace sensors {
* @param color the color to detect
*/
//% help=sensors/color-sensor/pause-until-light-detected
//% block="pause until **color sensor** %this|%mode|%condition"
//% block="pause until **color sensor** %this|detected %mode|%condition"
//% blockId=colorPauseUntilLightDetected
//% parts="colorsensor"
//% blockNamespace=sensors

70
package-lock.json generated
View File

@ -1,25 +1,25 @@
{
"name": "pxt-ev3",
"version": "0.1.43",
"version": "0.1.37",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/bluebird": {
"version": "2.0.33",
"resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-2.0.33.tgz",
"integrity": "sha1-J3wmM9z1qAgDvXGHEMK4VyWWYoU=",
"integrity": "sha512-iq7ss0qO31YCYeLEPrBoVMDLw1dBotOS7394a+Dj2CSvQNjQfJvryVo9es5ghvQZmIqO7Q0tlCe9YpwTZKOoXg==",
"dev": true
},
"@types/marked": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@types/marked/-/marked-0.3.0.tgz",
"integrity": "sha1-WDwiPdMzhaHdoBqvd7DNBBHEtSQ=",
"integrity": "sha512-CSf9YWJdX1DkTNu9zcNtdCcn6hkRtB5ILjbhRId4ZOQqx30fXmdecuaXhugQL6eyrhuXtaHJ7PHI+Vm7k9ZJjg==",
"dev": true
},
"@types/node": {
"version": "8.0.53",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.53.tgz",
"integrity": "sha1-OWs1r4JvpmqtRyyMt7jV4nf05tg=",
"integrity": "sha512-54Dm6NwYeiSQmRB1BLXKr5GELi0wFapR1npi8bnZhEcu84d/yQKqnwwXQ56hZ0RUbTG6L5nqDZaN3dgByQXQRQ==",
"dev": true
},
"JSONStream": {
@ -34,7 +34,7 @@
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha1-+PLIh60Qv2f2NPAFtph/7TF5qsg=",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
},
"acorn": {
@ -361,7 +361,7 @@
"aproba": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
"integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo="
"integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw=="
},
"are-we-there-yet": {
"version": "1.1.4",
@ -499,7 +499,7 @@
"base64-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz",
"integrity": "sha1-qRlH2h9KUW6jjltOwOw3c2deCIY="
"integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw=="
},
"bcrypt-pbkdf": {
"version": "1.0.1",
@ -763,7 +763,7 @@
"bufferstreams": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.3.tgz",
"integrity": "sha1-qFFawCT6kOj6fVjBGxPeofKKvnI=",
"integrity": "sha512-HaJnVuslRF4g2kSDeyl++AaVizoitCpL9PglzCYwy0uHHyvWerfvEb8jWmYbF1z4kiVFolGomnxSGl+GUQp2jg==",
"dev": true,
"requires": {
"readable-stream": "2.3.3"
@ -864,7 +864,7 @@
"cipher-base": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
"integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=",
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
"requires": {
"inherits": "2.0.3",
"safe-buffer": "5.1.1"
@ -873,7 +873,7 @@
"clap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/clap/-/clap-1.2.3.tgz",
"integrity": "sha1-TzZ0WzIAhJJVf0ZBLWbVDLmbzlE=",
"integrity": "sha512-4CoL/A3hf90V3VIEjeuhSvlGFEHKzOz+Wfc2IVZc+FaUgU0ZQafJTP49fvnULipOPcAfqhyI2duwQyns6xqjYA==",
"requires": {
"chalk": "1.1.3"
}
@ -1544,7 +1544,7 @@
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
@ -1654,7 +1654,7 @@
"hash.js": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz",
"integrity": "sha1-NA3tvmKQGHFRweodd3o0SJNd+EY=",
"integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==",
"requires": {
"inherits": "2.0.3",
"minimalistic-assert": "1.0.0"
@ -2277,11 +2277,6 @@
"object-visit": "1.0.1"
}
},
"marked": {
"version": "0.3.19",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz",
"integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg=="
},
"math-expression-evaluator": {
"version": "1.2.17",
"resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz",
@ -2354,7 +2349,7 @@
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "1.1.8"
}
@ -2546,7 +2541,7 @@
"npmlog": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
"integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=",
"integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
"requires": {
"are-we-there-yet": "1.1.4",
"console-control-strings": "1.1.0",
@ -3284,17 +3279,19 @@
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
},
"pxt-common-packages": {
"version": "0.22.2",
"resolved": "https://registry.npmjs.org/pxt-common-packages/-/pxt-common-packages-0.22.2.tgz",
"integrity": "sha512-bndrU1Aqig0O504QuaQYICrSQfQF7QFBoOArl0hdY7NWfq2yNJu8CHoW2oKJm+r+LTz150D4XuHjCIGLEv2MBQ==",
"version": "0.22.1",
"resolved": "https://registry.npmjs.org/pxt-common-packages/-/pxt-common-packages-0.22.1.tgz",
"integrity": "sha512-GdqA/7tk1OQbkeMeCiPG4oRocV7lMb9HCya6gp5RuCPLKNpbLaCDHyLsXQGR8sXJOoFqrLjUWaQILbMKhCGNMQ==",
"requires": {
"pxt-core": "3.12.18"
"autoprefixer": "6.7.7",
"pxt-core": "3.12.12",
"rtlcss": "2.2.1"
}
},
"pxt-core": {
"version": "3.12.18",
"resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.12.18.tgz",
"integrity": "sha512-Dd1XHjMjSR6gqf8B2LB7mtppD+VI49wckd/jCK8dHZcjb7RbngqTnfjOuHcDbXfSrvDrGFNzBhYvYaLf70AV7g==",
"version": "3.12.12",
"resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.12.12.tgz",
"integrity": "sha512-o/u+Qxt2Xuid8f6f2KHDYnJ7qcxOvcbiUqxoOMFZrQkgnME7Pekly+mQPn2w1kjpO9M84BX70Mi9ld8dY/nLRg==",
"requires": {
"bluebird": "3.5.1",
"browserify": "16.2.0",
@ -3303,7 +3300,6 @@
"keytar": "4.2.1",
"less": "2.7.3",
"lzma": "2.3.2",
"marked": "0.3.19",
"node-hid": "0.5.7",
"pngjs": "3.3.2",
"postcss": "6.0.21",
@ -3472,7 +3468,7 @@
"readable-stream": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
"integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=",
"integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
"requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
@ -3486,7 +3482,7 @@
"string_decoder": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
"integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=",
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"requires": {
"safe-buffer": "5.1.1"
}
@ -3731,12 +3727,12 @@
"safe-buffer": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM="
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk="
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"semantic-ui-less": {
"version": "2.2.14",
@ -4048,7 +4044,7 @@
"stream-http": {
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz",
"integrity": "sha1-QKBQ7I3DtTsz2ZCUFcAsC/Gr+60=",
"integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==",
"requires": {
"builtin-status-codes": "3.0.0",
"inherits": "2.0.3",
@ -4199,7 +4195,7 @@
"commander": {
"version": "2.12.2",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz",
"integrity": "sha1-D1lGxCftnsDZGka7ne9T5UZQ5VU=",
"integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==",
"dev": true
}
}
@ -4359,7 +4355,7 @@
"pako": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
"integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg=",
"integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==",
"dev": true
}
}
@ -4514,7 +4510,7 @@
"uuid": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz",
"integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ="
"integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g=="
},
"varstream": {
"version": "0.3.2",
@ -4610,7 +4606,7 @@
"which": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
"integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=",
"integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==",
"dev": true,
"requires": {
"isexe": "2.0.0"
@ -4619,7 +4615,7 @@
"wide-align": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
"integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=",
"integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
"requires": {
"string-width": "1.0.2"
}

View File

@ -1,6 +1,6 @@
{
"name": "pxt-ev3",
"version": "0.1.43",
"version": "0.1.37",
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
"private": true,
"keywords": [
@ -30,6 +30,8 @@
"docs/*/*.md",
"docs/*/*/*.md"
],
"main": "built/pxtrequire.js",
"typings": "built/pxtrequire.d.ts",
"devDependencies": {
"typescript": "2.6.1",
"semantic-ui-less": "2.2.14",
@ -39,8 +41,8 @@
"webfonts-generator": "^0.4.0"
},
"dependencies": {
"pxt-common-packages": "0.22.7",
"pxt-core": "3.12.19"
"pxt-common-packages": "0.22.1",
"pxt-core": "3.12.16"
},
"scripts": {
"test": "node node_modules/pxt-core/built/pxt.js travis"

View File

@ -81,6 +81,7 @@
"accentColor": "#0089BF",
"logoUrl": "https://education.lego.com/",
"logo": "./static/lego_education_logo.png",
"highContrastLogo": "./static/lego_education_logo_white.png",
"docsLogo": "./static/lego-logo.svg",
"portraitLogo": "./static/lego-logo.svg",
"footerLogo": "./static/lego-logo.svg",
@ -109,8 +110,8 @@
"path": "http://service.lego.com"
},
{
"name": "Troubleshoot",
"path": "/troubleshoot"
"name": "Upgrade Firmware",
"path": "https://ev3manager.education.lego.com/"
},
{
"name": "Blocks",

View File

@ -17,8 +17,7 @@ namespace pxsim {
private speedCmdTime: number;
private _synchedMotor: MotorNode; // non-null if synchronized
private manualReferenceAngle: number = undefined;
private manualAngle: number = undefined;
private manualSpeed: number = undefined;
constructor(port: number, large: boolean) {
super(port);
@ -104,18 +103,14 @@ namespace pxsim {
}
manualMotorDown() {
this.manualReferenceAngle = this.angle;
this.manualAngle = 0;
}
// position: 0, 360
manualMotorAngle(angle: number) {
this.manualAngle = angle;
manualMotorMove(speed: number) {
this.manualSpeed = speed;
}
manualMotorUp() {
delete this.manualReferenceAngle;
delete this.manualAngle;
this.manualSpeed = undefined;
}
updateState(elapsed: number) {
@ -131,7 +126,7 @@ namespace pxsim {
}
private updateStateStep(elapsed: number) {
if (this.manualAngle === undefined) {
if (!this.manualSpeed) {
// compute new speed
switch (this.speedCmd) {
case DAL.opOutputSpeed:
@ -207,11 +202,7 @@ namespace pxsim {
}
}
else {
// the user is holding the handle - so position is the angle
this.speed = 0;
// rotate by the desired angle change
this.angle = this.manualReferenceAngle + this.manualAngle;
this.setChangedState();
this.speed = this.manualSpeed;
}
this.speed = Math.round(this.speed); // integer only
@ -226,8 +217,7 @@ namespace pxsim {
// if the motor was stopped or there are no speed commands,
// let it coast to speed 0
if ((this.manualReferenceAngle === undefined)
&& this.speed && !(this.started || this.speedCmd)) {
if (this.speed && !(this.started || this.speedCmd)) {
// decay speed 5% per tick
this.speed = Math.round(Math.max(0, Math.abs(this.speed) - 10) * sign(this.speed));
}

View File

@ -101,13 +101,10 @@ namespace pxsim.visuals {
export const SCREEN_HEIGHT = 128;
export interface IBoardTheme {
accent?: string;
highContrast?: boolean;
display?: string;
buttonOuter?: string;
buttonUps: string[];
buttonDown?: string;
wireColor?: string;
backgroundViewColor?: string;
}
export var themes: IBoardTheme[] = ["#3ADCFE"].map(accent => {
@ -115,21 +112,12 @@ namespace pxsim.visuals {
accent: accent,
buttonOuter: "#979797",
buttonUps: ["#a8aaa8", "#393939", "#a8aaa8", "#a8aaa8", "#a8aaa8", '#a8aaa8'],
buttonDown: "#000",
wireColor: '#5A5A5A',
backgroundViewColor: '#d6edff'
buttonDown: "#000"
}
});
export function randomTheme(highContrast?: boolean, light?: boolean): IBoardTheme {
let theme = themes[Math.floor(Math.random() * themes.length)];
if (highContrast) {
theme = JSON.parse(JSON.stringify(theme)) as IBoardTheme;
theme.highContrast = true;
theme.wireColor = '#ffffff';
theme.backgroundViewColor = '#ffffff';
}
return theme;
return themes[Math.floor(Math.random() * themes.length)];
}
export interface IBoardProps {
@ -346,7 +334,7 @@ namespace pxsim.visuals {
this.style.textContent = EV3_STYLE;
this.layoutView = new LayoutView();
this.layoutView.inject(this.element, this.props.theme);
this.layoutView.inject(this.element);
const brick = new BrickViewPortrait(-1);
this.layoutView.setBrick(brick);

View File

@ -13,7 +13,7 @@ namespace pxsim.visuals {
'x': 0, 'y': 0,
'width': '100%',
'height': '100%',
'style': `fill: ${this.theme.backgroundViewColor};stroke: #A8A9A8; stroke-width: 3px; stroke-opacity: 0.2`
'style': `fill: #d6edff; stroke: #A8A9A8; stroke-width: 3px; stroke-opacity: 0.2`
}) as SVGRectElement;
return this.backgroundGroup;
}

View File

@ -13,7 +13,7 @@ namespace pxsim.visuals {
private static SLIDER_RADIUS = 100;
private internalAngle: number = 0;
private internalSpeed: number = 0;
getInnerView(parent: SVGSVGElement, globalDefs: SVGDefsElement) {
this.group = svg.elt("g") as SVGGElement;
@ -102,9 +102,9 @@ namespace pxsim.visuals {
} else if (dx >= 0 && dy <= 0) {
deg = 90 - deg;
}
const value = Math.abs(Math.ceil((deg % 360)));
const value = Math.abs(Math.ceil((deg % 360) / 360 * this.getMax()));
this.internalAngle = value;
this.internalSpeed = value;
this.updateDial();
this.prevVal = deg;
@ -119,7 +119,7 @@ namespace pxsim.visuals {
private handleSliderMove() {
this.dial.setAttribute('cursor', '-webkit-grabbing');
const state = this.state;
state.manualMotorAngle(this.internalAngle);
state.manualMotorMove(this.internalSpeed);
}
private handleSliderUp() {
@ -127,18 +127,19 @@ namespace pxsim.visuals {
const state = this.state;
state.manualMotorUp();
this.internalAngle = 0;
this.internalSpeed = 0;
this.updateDial();
}
private updateDial() {
let angle = this.internalAngle;
let speed = this.internalSpeed;
// Update dial position
const deg = speed / this.getMax() * 360; // degrees
const radius = MotorSliderControl.SLIDER_RADIUS;
const dialRadius = 5;
const x = Math.ceil((radius - dialRadius) * Math.sin(angle * Math.PI / 180)) + radius;
const y = Math.ceil((radius - dialRadius) * -Math.cos(angle * Math.PI / 180)) + radius;
const x = Math.ceil((radius - dialRadius) * Math.sin(deg * Math.PI / 180)) + radius;
const y = Math.ceil((radius - dialRadius) * -Math.cos(deg * Math.PI / 180)) + radius;
this.dial.setAttribute('transform', `translate(${x}, ${y})`);
}
@ -147,10 +148,18 @@ namespace pxsim.visuals {
return;
}
const node = this.state;
const angle = node.getAngle() % 360;
const speed = node.getSpeed();
// Update reporter
this.reporter.textContent = `${angle}°`;
this.reporter.textContent = `${speed}`;
}
private getMin() {
return 0;
}
private getMax() {
return 100;
}
}

View File

@ -12,7 +12,6 @@ namespace pxsim.visuals {
export const MODULE_INNER_PADDING_RATIO = 1 / 35;
export const MAX_MODULE_WIDTH = 100;
export const MIN_MODULE_HEIGHT = 40;
export const CLOSE_ICON_GAP_MULTIPLIER = 0.3;
@ -79,8 +78,8 @@ namespace pxsim.visuals {
public setBrick(brick: BrickView) {
this.brick = brick;
this.brick.inject(this.scrollGroup, this.theme);
this.brickLandscape.inject(this.scrollGroup, this.theme);
this.brick.inject(this.scrollGroup);
this.brickLandscape.inject(this.scrollGroup);
this.brick.setSelected(false);
this.brickLandscape.setSelected(true);
this.brickLandscape.setVisible(false);
@ -212,16 +211,16 @@ namespace pxsim.visuals {
// Inject all wires
for (let port = 0; port < DAL.NUM_OUTPUTS; port++) {
this.outputWires[port].inject(this.scrollGroup, this.theme);
this.outputWires[port].inject(this.scrollGroup);
}
for (let port = 0; port < DAL.NUM_INPUTS; port++) {
this.inputWires[port].inject(this.scrollGroup, this.theme);
this.inputWires[port].inject(this.scrollGroup);
}
// Inject all view containers
for (let i = 0; i < 4; i++) {
this.inputContainers[i].inject(this.scrollGroup, this.theme);
this.outputContainers[i].inject(this.scrollGroup, this.theme);
this.inputContainers[i].inject(this.scrollGroup);
this.outputContainers[i].inject(this.scrollGroup);
}
// Inject all ports
@ -253,12 +252,6 @@ namespace pxsim.visuals {
}
public updateTheme(theme: IBoardTheme) {
this.inputWires.forEach(n => {
n.updateTheme(theme);
})
this.outputWires.forEach(n => {
n.updateTheme(theme);
})
this.inputs.forEach(n => {
n.updateTheme(theme);
})
@ -379,7 +372,7 @@ namespace pxsim.visuals {
// Translate and resize view
view.resize(inputWidth - inputPadding * 2, inputHeight);
const viewHeight = Math.max(view.getActualHeight(), MIN_MODULE_HEIGHT);
const viewHeight = view.getActualHeight();
view.translate(inputPadding, 0, true);
// Resize control

View File

@ -36,10 +36,7 @@ namespace pxsim.visuals {
private updateSensorLightVisual(color: string) {
const sensorHole = this.content.getElementById(this.normalizeId(ColorSensorView.sensor_hole_id)) as SVGCircleElement;
sensorHole.style.stroke = color;
if (color != '#ffffff') {
sensorHole.style.strokeWidth = '2px';
}
sensorHole.style.fill = color;
}
}
}

View File

@ -19,9 +19,8 @@ namespace pxsim.visuals {
public abstract getInnerWidth(): number;
public abstract getInnerHeight(): number;
public inject(parent: SVGElement, theme: IBoardTheme, width?: number, visible = true) {
public inject(parent: SVGElement, width?: number, visible = true) {
this.width = width;
this.theme = theme;
parent.appendChild(this.getView());
if (visible) {
@ -277,7 +276,7 @@ namespace pxsim.visuals {
}
public addView(view: View) {
view.inject(this.element, this.theme);
view.inject(this.element);
}
public clear() {

View File

@ -41,11 +41,6 @@ namespace pxsim.visuals {
return this.wire;
}
public updateThemeCore() {
let theme = this.theme;
this.path.setAttribute('stroke', theme.wireColor);
}
updatePath() {
if (!this.hasDimensions) return;
const height = this.endY - this.startY;

View File

@ -15,6 +15,6 @@
"Maker": "maker"
},
"electronManifest": {
"latest": "v0.1.40"
"latest": "v0.1.30"
}
}

View File

@ -155,6 +155,22 @@
}
}
/** high contrast **/
.hc {
.ui.menu, #downloadArea,
.menubar .ui.menu.fixed .ui.item.editor-menuitem .item.active {
background-color: black !important;
color: white !important;
}
.ui.red.corner.label {
border-color: #d4000d!important;
}
.menubar .ui.menu.fixed .item.editor-menuitem .ui.grid {
border-color: white !important;
}
}
/*******************************
Custom icons
*******************************/