Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
6bdae6547a | |||
30a67b729d | |||
3e2c61e212 | |||
7a37dec196 | |||
bac792f188 | |||
e4c3fa0e57 | |||
76f7df7579 | |||
d7e671175c | |||
f4b7230a67 | |||
afe0f9b0f7 | |||
23b6edc4bf | |||
13b3c1a194 | |||
7e58b9b699 | |||
08a860bd80 | |||
4a966a73f1 | |||
542216000c | |||
b323929f03 | |||
1e3647738d | |||
838b3f7f9a | |||
0ff2d7866d |
@ -1,6 +0,0 @@
|
||||
/// <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"), "..", "..");
|
BIN
docs/static/icons/android-chrome-192x192.png
vendored
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 477 KiB After Width: | Height: | Size: 123 KiB |
BIN
docs/static/tutorials/run-motors/run-motors.gif
vendored
Before Width: | Height: | Size: 509 KiB After Width: | Height: | Size: 220 KiB |
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 240 KiB After Width: | Height: | Size: 95 KiB |
BIN
docs/static/tutorials/touch-to-run/touch-to-run.gif
vendored
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 74 KiB |
BIN
docs/static/tutorials/what-color/color-detector.gif
vendored
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 45 KiB |
@ -33,10 +33,8 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="description">
|
||||
<span class="ui yellow circular label">1</span>
|
||||
<strong>${lf("Connect EV3 to computer with USB cable")}</strong>
|
||||
<br/>
|
||||
${lf("Use the miniUSB port on top of EV3 brick")}
|
||||
<span class="ui blue circular label">1</span>
|
||||
<strong>${lf("Connect the EV3 brick to your computer with a USB cable.")}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -57,9 +55,9 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
</div>
|
||||
<div class="ui one column grid">
|
||||
<div class="column">
|
||||
<a href="/troubleshoot" target="_blank" class="ui segment container yellow">
|
||||
<a href="/troubleshoot" target="_blank" class="ui segment container" style="background:#ffdb90">
|
||||
<i class="icon exclamation circle large" aria-hidden="true"></i>
|
||||
${lf("Something wrong? Click here to troubleshoot..")}
|
||||
${lf("Did you prepare your EV3 brick for MakeCode?")}
|
||||
</a>
|
||||
</div>
|
||||
</div>`;
|
||||
|
@ -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|detected %mode|%condition"
|
||||
//% block="on **color sensor** %this|%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|detected %mode|%condition"
|
||||
//% block="pause until **color sensor** %this|%mode|%condition"
|
||||
//% blockId=colorPauseUntilLightDetected
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
|
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.1.35",
|
||||
"version": "0.1.41",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.1.35",
|
||||
"version": "0.1.41",
|
||||
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
|
||||
"private": true,
|
||||
"keywords": [
|
||||
@ -30,8 +30,6 @@
|
||||
"docs/*/*.md",
|
||||
"docs/*/*/*.md"
|
||||
],
|
||||
"main": "built/pxtrequire.js",
|
||||
"typings": "built/pxtrequire.d.ts",
|
||||
"devDependencies": {
|
||||
"typescript": "2.6.1",
|
||||
"semantic-ui-less": "2.2.14",
|
||||
@ -42,7 +40,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-common-packages": "0.22.1",
|
||||
"pxt-core": "3.12.12"
|
||||
"pxt-core": "3.12.17"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||
|
@ -110,8 +110,8 @@
|
||||
"path": "http://service.lego.com"
|
||||
},
|
||||
{
|
||||
"name": "Upgrade Firmware",
|
||||
"path": "https://ev3manager.education.lego.com/"
|
||||
"name": "Troubleshoot",
|
||||
"path": "/troubleshoot"
|
||||
},
|
||||
{
|
||||
"name": "Blocks",
|
||||
|
@ -17,7 +17,8 @@ namespace pxsim {
|
||||
private speedCmdTime: number;
|
||||
private _synchedMotor: MotorNode; // non-null if synchronized
|
||||
|
||||
private manualSpeed: number = undefined;
|
||||
private manualReferenceAngle: number = undefined;
|
||||
private manualAngle: number = undefined;
|
||||
|
||||
constructor(port: number, large: boolean) {
|
||||
super(port);
|
||||
@ -103,14 +104,18 @@ namespace pxsim {
|
||||
}
|
||||
|
||||
manualMotorDown() {
|
||||
this.manualReferenceAngle = this.angle;
|
||||
this.manualAngle = 0;
|
||||
}
|
||||
|
||||
manualMotorMove(speed: number) {
|
||||
this.manualSpeed = speed;
|
||||
// position: 0, 360
|
||||
manualMotorAngle(angle: number) {
|
||||
this.manualAngle = angle;
|
||||
}
|
||||
|
||||
manualMotorUp() {
|
||||
this.manualSpeed = undefined;
|
||||
delete this.manualReferenceAngle;
|
||||
delete this.manualAngle;
|
||||
}
|
||||
|
||||
updateState(elapsed: number) {
|
||||
@ -126,7 +131,7 @@ namespace pxsim {
|
||||
}
|
||||
|
||||
private updateStateStep(elapsed: number) {
|
||||
if (!this.manualSpeed) {
|
||||
if (this.manualAngle === undefined) {
|
||||
// compute new speed
|
||||
switch (this.speedCmd) {
|
||||
case DAL.opOutputSpeed:
|
||||
@ -202,7 +207,11 @@ namespace pxsim {
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.speed = this.manualSpeed;
|
||||
// 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 = Math.round(this.speed); // integer only
|
||||
|
||||
@ -217,7 +226,8 @@ namespace pxsim {
|
||||
|
||||
// if the motor was stopped or there are no speed commands,
|
||||
// let it coast to speed 0
|
||||
if (this.speed && !(this.started || this.speedCmd)) {
|
||||
if ((this.manualReferenceAngle === undefined)
|
||||
&& 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));
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ namespace pxsim.visuals {
|
||||
private static colorIds = ['red', 'yellow', 'blue', 'green', 'black', 'grey', 'white'];
|
||||
private static colorValue = [5, 4, 2, 3, 1, 7, 6];
|
||||
|
||||
private colorDivs: Element[] = [];
|
||||
|
||||
getInnerView() {
|
||||
this.group = svg.elt("g") as SVGGElement;
|
||||
this.group.setAttribute("transform", `translate(2, 2.5) scale(0.6)`)
|
||||
@ -23,6 +25,7 @@ namespace pxsim.visuals {
|
||||
const circle = pxsim.svg.child(this.group, "circle", {
|
||||
'class': `sim-color-grid-circle sim-color-grid-${colorIds[c]}`,
|
||||
'cx': cx, 'cy': cy, 'r': '2', 'style': `fill: ${colors[c]}` });
|
||||
this.colorDivs.push(circle);
|
||||
pointerEvents.down.forEach(evid => circle.addEventListener(evid, ev => {
|
||||
this.setColor(ColorGridControl.colorValue[c]);
|
||||
}));
|
||||
@ -30,7 +33,8 @@ namespace pxsim.visuals {
|
||||
}
|
||||
|
||||
const whiteCircleWrapper = pxsim.svg.child(this.group, "g", { 'id': 'white-cirlce-wrapper' });
|
||||
pxsim.svg.child(whiteCircleWrapper, "circle", { 'class': 'sim-color-grid-circle sim-color-grid-white', 'cx': 2.2, 'cy': '16', 'r': '2', 'style': `fill: #fff` });
|
||||
const circle = pxsim.svg.child(whiteCircleWrapper, "circle", { 'class': 'sim-color-grid-circle sim-color-grid-white', 'cx': 2.2, 'cy': '16', 'r': '2', 'style': `fill: #fff` });
|
||||
this.colorDivs.push(circle);
|
||||
pxsim.svg.child(whiteCircleWrapper, "circle", { 'cx': 2.2, 'cy': '16', 'r': '2', 'style': `fill: none;stroke: #94989b;stroke-width: 0.1px` });
|
||||
pointerEvents.down.forEach(evid => whiteCircleWrapper.addEventListener(evid, ev => {
|
||||
this.setColor(6);
|
||||
@ -56,7 +60,7 @@ namespace pxsim.visuals {
|
||||
for (let c = 0; c < ColorGridControl.colorValue.length; c++) {
|
||||
const colorId = ColorGridControl.colorIds[c];
|
||||
const colorValue = ColorGridControl.colorValue[c];
|
||||
const colorDiv = this.group.getElementsByClassName(`sim-color-grid-${colorId}`)[0] as HTMLElement;
|
||||
const colorDiv = this.colorDivs[c] as HTMLElement;
|
||||
|
||||
if (colorValue == color) {
|
||||
pxsim.U.addClass(colorDiv, 'sim-color-selected');
|
||||
|
@ -13,7 +13,7 @@ namespace pxsim.visuals {
|
||||
|
||||
private static SLIDER_RADIUS = 100;
|
||||
|
||||
private internalSpeed: number = 0;
|
||||
private internalAngle: 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) / 360 * this.getMax()));
|
||||
const value = Math.abs(Math.ceil((deg % 360)));
|
||||
|
||||
this.internalSpeed = value;
|
||||
this.internalAngle = 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.manualMotorMove(this.internalSpeed);
|
||||
state.manualMotorAngle(this.internalAngle);
|
||||
}
|
||||
|
||||
private handleSliderUp() {
|
||||
@ -127,19 +127,18 @@ namespace pxsim.visuals {
|
||||
const state = this.state;
|
||||
state.manualMotorUp();
|
||||
|
||||
this.internalSpeed = 0;
|
||||
this.internalAngle = 0;
|
||||
this.updateDial();
|
||||
}
|
||||
|
||||
private updateDial() {
|
||||
let speed = this.internalSpeed;
|
||||
let angle = this.internalAngle;
|
||||
|
||||
// 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(deg * Math.PI / 180)) + radius;
|
||||
const y = Math.ceil((radius - dialRadius) * -Math.cos(deg * Math.PI / 180)) + radius;
|
||||
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;
|
||||
this.dial.setAttribute('transform', `translate(${x}, ${y})`);
|
||||
}
|
||||
|
||||
@ -148,18 +147,10 @@ namespace pxsim.visuals {
|
||||
return;
|
||||
}
|
||||
const node = this.state;
|
||||
const speed = node.getSpeed();
|
||||
const angle = node.getAngle() % 360;
|
||||
|
||||
// Update reporter
|
||||
this.reporter.textContent = `${speed}`;
|
||||
}
|
||||
|
||||
private getMin() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private getMax() {
|
||||
return 100;
|
||||
this.reporter.textContent = `${angle}°`;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ 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;
|
||||
|
||||
@ -372,7 +373,7 @@ namespace pxsim.visuals {
|
||||
|
||||
// Translate and resize view
|
||||
view.resize(inputWidth - inputPadding * 2, inputHeight);
|
||||
const viewHeight = view.getActualHeight();
|
||||
const viewHeight = Math.max(view.getActualHeight(), MIN_MODULE_HEIGHT);
|
||||
view.translate(inputPadding, 0, true);
|
||||
|
||||
// Resize control
|
||||
|
@ -36,7 +36,10 @@ namespace pxsim.visuals {
|
||||
|
||||
private updateSensorLightVisual(color: string) {
|
||||
const sensorHole = this.content.getElementById(this.normalizeId(ColorSensorView.sensor_hole_id)) as SVGCircleElement;
|
||||
sensorHole.style.fill = color;
|
||||
sensorHole.style.stroke = color;
|
||||
if (color != '#ffffff') {
|
||||
sensorHole.style.strokeWidth = '2px';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,6 @@
|
||||
"Maker": "maker"
|
||||
},
|
||||
"electronManifest": {
|
||||
"latest": "v0.1.30"
|
||||
"latest": "v0.1.36"
|
||||
}
|
||||
}
|
||||
|