Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
08f79c5a1a | |||
f817912e07 | |||
603932c2b6 | |||
a0907e7229 | |||
635d4a7624 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-ev3",
|
"name": "pxt-ev3",
|
||||||
"version": "0.0.80",
|
"version": "0.0.82",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-ev3",
|
"name": "pxt-ev3",
|
||||||
"version": "0.0.80",
|
"version": "0.0.82",
|
||||||
"description": "LEGO Mindstorms EV3 for Microsoft MakeCode",
|
"description": "LEGO Mindstorms EV3 for Microsoft MakeCode",
|
||||||
"private": true,
|
"private": true,
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@ -45,7 +45,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pxt-common-packages": "0.17.13",
|
"pxt-common-packages": "0.17.13",
|
||||||
"pxt-core": "3.1.1"
|
"pxt-core": "3.1.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||||
|
@ -15,6 +15,12 @@ namespace pxsim.visuals {
|
|||||||
-webkit-filter: grayscale(1);
|
-webkit-filter: grayscale(1);
|
||||||
filter: grayscale(1);
|
filter: grayscale(1);
|
||||||
}
|
}
|
||||||
|
.user-select-none, .sim-button {
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
.sim-button {
|
.sim-button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,18 @@ namespace pxsim.visuals {
|
|||||||
if (c % 2 == 0) cy += 5;
|
if (c % 2 == 0) cy += 5;
|
||||||
if (colorIds[c]) {
|
if (colorIds[c]) {
|
||||||
const circle = pxsim.svg.child(this.group, "circle", { 'class': 'sim-color-grid-circle', 'cx': cx, 'cy': cy, 'r': '2', 'style': `fill: ${colors[c]}` });
|
const circle = pxsim.svg.child(this.group, "circle", { 'class': 'sim-color-grid-circle', 'cx': cx, 'cy': cy, 'r': '2', 'style': `fill: ${colors[c]}` });
|
||||||
circle.addEventListener(pointerEvents.down, ev => {
|
pointerEvents.down.forEach(evid => circle.addEventListener(evid, ev => {
|
||||||
this.setColor(colorValue[c]);
|
this.setColor(colorValue[c]);
|
||||||
})
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const whiteCircleWrapper = pxsim.svg.child(this.group, "g", { 'id': 'white-cirlce-wrapper' });
|
const whiteCircleWrapper = pxsim.svg.child(this.group, "g", { 'id': 'white-cirlce-wrapper' });
|
||||||
pxsim.svg.child(whiteCircleWrapper, "circle", { 'class': 'sim-color-grid-circle', 'cx': 2.2, 'cy': '11', 'r': '2', 'style': `fill: #fff` });
|
pxsim.svg.child(whiteCircleWrapper, "circle", { 'class': 'sim-color-grid-circle', 'cx': 2.2, 'cy': '11', 'r': '2', 'style': `fill: #fff` });
|
||||||
pxsim.svg.child(whiteCircleWrapper, "circle", { 'cx': 2.2, 'cy': '11', 'r': '2', 'style': `fill: none;stroke: #94989b;stroke-width: 0.1px` });
|
pxsim.svg.child(whiteCircleWrapper, "circle", { 'cx': 2.2, 'cy': '11', 'r': '2', 'style': `fill: none;stroke: #94989b;stroke-width: 0.1px` });
|
||||||
whiteCircleWrapper.addEventListener(pointerEvents.down, ev => {
|
pointerEvents.down.forEach(evid => whiteCircleWrapper.addEventListener(evid, ev => {
|
||||||
this.setColor(6);
|
this.setColor(6);
|
||||||
})
|
}));
|
||||||
return this.group;
|
return this.group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,14 +47,17 @@ namespace pxsim.visuals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private lastLightPattern: number = -1;
|
private lastLightPattern: number = -1;
|
||||||
private lastLightAnimationId: any;
|
private lastLightAnimationId: any = undefined;
|
||||||
private updateLight() {
|
private updateLight() {
|
||||||
let state = ev3board().getBrickNode().lightState;
|
let state = ev3board().getBrickNode().lightState;
|
||||||
|
|
||||||
const lightPattern = state.lightPattern;
|
const lightPattern = state.lightPattern;
|
||||||
if (lightPattern == this.lastLightPattern) return;
|
if (lightPattern == this.lastLightPattern) return;
|
||||||
this.lastLightPattern = lightPattern;
|
this.lastLightPattern = lightPattern;
|
||||||
if (this.lastLightAnimationId) cancelAnimationFrame(this.lastLightAnimationId);
|
if (this.lastLightAnimationId) {
|
||||||
|
cancelAnimationFrame(this.lastLightAnimationId);
|
||||||
|
delete this.lastLightAnimationId;
|
||||||
|
}
|
||||||
switch (lightPattern) {
|
switch (lightPattern) {
|
||||||
case 0: // LED_BLACK
|
case 0: // LED_BLACK
|
||||||
this.setStyleFill(this.normalizeId(BrickView.EV3_LIGHT_ID), this.normalizeId(`linear-gradient-black`));
|
this.setStyleFill(this.normalizeId(BrickView.EV3_LIGHT_ID), this.normalizeId(`linear-gradient-black`));
|
||||||
@ -94,6 +97,7 @@ namespace pxsim.visuals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private flashLightAnimation(id: string) {
|
private flashLightAnimation(id: string) {
|
||||||
|
const pattern = this.lastLightPattern;
|
||||||
let fps = 3;
|
let fps = 3;
|
||||||
let now;
|
let now;
|
||||||
let then = Date.now();
|
let then = Date.now();
|
||||||
@ -101,8 +105,9 @@ namespace pxsim.visuals {
|
|||||||
let delta;
|
let delta;
|
||||||
let that = this;
|
let that = this;
|
||||||
function draw() {
|
function draw() {
|
||||||
|
if (that.lastLightPattern != pattern) return;
|
||||||
that.lastLightAnimationId = requestAnimationFrame(draw);
|
that.lastLightAnimationId = requestAnimationFrame(draw);
|
||||||
now = Date.now();
|
now = pxsim.U.now();
|
||||||
delta = now - then;
|
delta = now - then;
|
||||||
if (delta > interval) {
|
if (delta > interval) {
|
||||||
then = now - (delta % interval);
|
then = now - (delta % interval);
|
||||||
@ -124,6 +129,7 @@ namespace pxsim.visuals {
|
|||||||
|
|
||||||
|
|
||||||
private pulseLightAnimation(id: string) {
|
private pulseLightAnimation(id: string) {
|
||||||
|
const pattern = this.lastLightPattern;
|
||||||
let fps = 8;
|
let fps = 8;
|
||||||
let now;
|
let now;
|
||||||
let then = Date.now();
|
let then = Date.now();
|
||||||
@ -131,8 +137,9 @@ namespace pxsim.visuals {
|
|||||||
let delta;
|
let delta;
|
||||||
let that = this;
|
let that = this;
|
||||||
function draw() {
|
function draw() {
|
||||||
|
if (that.lastLightPattern != pattern) return;
|
||||||
that.lastLightAnimationId = requestAnimationFrame(draw);
|
that.lastLightAnimationId = requestAnimationFrame(draw);
|
||||||
now = Date.now();
|
now = pxsim.U.now();
|
||||||
delta = now - then;
|
delta = now - then;
|
||||||
if (delta > interval) {
|
if (delta > interval) {
|
||||||
// update time stuffs
|
// update time stuffs
|
||||||
@ -167,10 +174,10 @@ namespace pxsim.visuals {
|
|||||||
this.buttons.forEach((btn, index) => {
|
this.buttons.forEach((btn, index) => {
|
||||||
let button = stateButtons[index];
|
let button = stateButtons[index];
|
||||||
|
|
||||||
btn.addEventListener(pointerEvents.down, ev => {
|
pointerEvents.down.forEach(evid => btn.addEventListener(evid, ev => {
|
||||||
button.setPressed(true);
|
button.setPressed(true);
|
||||||
svg.fill(this.buttons[index], this.theme.buttonDown);
|
svg.fill(this.buttons[index], this.theme.buttonDown);
|
||||||
})
|
}));
|
||||||
btn.addEventListener(pointerEvents.leave, ev => {
|
btn.addEventListener(pointerEvents.leave, ev => {
|
||||||
button.setPressed(false);
|
button.setPressed(false);
|
||||||
svg.fill(this.buttons[index], this.theme.buttonUps[index]);
|
svg.fill(this.buttons[index], this.theme.buttonUps[index]);
|
||||||
|
@ -38,10 +38,10 @@ namespace pxsim.visuals {
|
|||||||
this.content.style.cursor = "pointer";
|
this.content.style.cursor = "pointer";
|
||||||
const btn = this.content;
|
const btn = this.content;
|
||||||
const state = ev3board().getSensor(this.port, DAL.DEVICE_TYPE_TOUCH) as TouchSensorNode;
|
const state = ev3board().getSensor(this.port, DAL.DEVICE_TYPE_TOUCH) as TouchSensorNode;
|
||||||
btn.addEventListener(pointerEvents.down, ev => {
|
pointerEvents.down.forEach(evid => btn.addEventListener(evid, ev => {
|
||||||
this.setPressed(true);
|
this.setPressed(true);
|
||||||
state.setPressed(true);
|
state.setPressed(true);
|
||||||
})
|
}))
|
||||||
btn.addEventListener(pointerEvents.leave, ev => {
|
btn.addEventListener(pointerEvents.leave, ev => {
|
||||||
this.setPressed(false);
|
this.setPressed(false);
|
||||||
state.setPressed(false);
|
state.setPressed(false);
|
||||||
|
Reference in New Issue
Block a user