Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
239827c259 | |||
cd0097749a | |||
94db31beb7 | |||
408631d426 | |||
2407e7e179 | |||
f63b447fee | |||
bbd1a9d215 | |||
cfc4688fbe | |||
24d48c0171 | |||
523c507c35 | |||
d6cbbcc3d9 | |||
2b5cedb404 | |||
224e9c54f0 | |||
f3f33828f3 | |||
2905814898 | |||
96f1086c8f | |||
7bd2192a0a | |||
6f539de2d2 | |||
1d83d6c40e | |||
53bff7b133 | |||
2f6ad3110a | |||
22ce840181 | |||
d8589ea98c |
2
.gitignore
vendored
@ -17,8 +17,6 @@ clients/**/bin/**
|
||||
clients/**/obj/**
|
||||
clients/electron/projects
|
||||
libs/**/_locales/**
|
||||
libs/**/shims.d.ts
|
||||
libs/**/enums.d.ts
|
||||
|
||||
videos/**
|
||||
|
||||
|
10
README.md
@ -2,7 +2,7 @@
|
||||
|
||||
[](https://ci2.dot.net/job/Private/job/pxt_project_rainbow/job/master/job/pxt-ev3_Push/)
|
||||
|
||||
This repo contains the editor target hosted at https://d541eec2-1e96-4b7b-a223-da9d01d0337a.pxt.io/
|
||||
This repo contains the editor target hosted at https://makecode.legoeducation.com
|
||||
|
||||
LEGO Auth: https://src.education.lego.com/groups/ev3-makecode (use Google Authenticator)
|
||||
LEGO Chat: https://chat.internal.education.lego.com/make-code/channels/town-square
|
||||
@ -11,7 +11,7 @@ LEGO Chat: https://chat.internal.education.lego.com/make-code/channels/town-squa
|
||||
|
||||
These instructions assume familiarity with dev tools and languages.
|
||||
|
||||
* install Node.js 6+
|
||||
* install Node.js 8.9.4+
|
||||
* install Docker; make sure `docker` command is in your `PATH`
|
||||
* (optional) install [Visual Studio Code](https://code.visualstudio.com/)
|
||||
|
||||
@ -58,12 +58,6 @@ cd libs/core
|
||||
pxt deploy
|
||||
```
|
||||
|
||||
### Hosted editor
|
||||
|
||||
Currently hosted at:
|
||||
|
||||
https://d541eec2-1e96-4b7b-a223-da9d01d0337a.pxt.io/
|
||||
|
||||
### Jenkins build
|
||||
https://ci2.dot.net/job/Private/job/pxt_project_rainbow/job/master/
|
||||
|
||||
|
@ -2,14 +2,30 @@
|
||||
|
||||
## Projects #projects
|
||||
|
||||
* [Getting Started](/getting-started)
|
||||
* [Try](/getting-started/try)
|
||||
* [Use](/getting-started/use)
|
||||
|
||||
* [Coding](/coding)
|
||||
* [Autonomous Parking](/coding/autonomous-parking)
|
||||
* [Object Detection](/coding/object-detection)
|
||||
* [Line Following](/coding/line-following)
|
||||
|
||||
* [Design Engineering](/design-engineering)
|
||||
* [Make It Move Without Wheels](/design-engineering/make-it-move)
|
||||
* [Make It Smarter and Faster](/design-engineering/make-it-faster)
|
||||
* [Make a System that Communicates](/design-engineering/make-it-communicate)
|
||||
|
||||
* [Maker](/maker)
|
||||
* [Sound Machine](/maker/sound-machine)
|
||||
* [Make a Sound Machine](/maker/sound-machine)
|
||||
|
||||
* [Examples](/examples)
|
||||
* [Make it move](/lessons/make-it-move)
|
||||
* [Line detection](/lessons/line-detection)
|
||||
* [Sound of Color](/maker/sound-of-color)
|
||||
* [Security Gadget](/maker/security-gadget)
|
||||
* [Intruder detector](/maker/intruder-detector)
|
||||
* [Puppet](/maker/puppet)
|
||||
|
||||
* [Coding](/coding)
|
||||
* [Three Point Turn 1](/coding/three-point-turn-1)
|
||||
* [Three Point Turn 2](/coding/three-point-turn-2)
|
||||
* [Three Point Turn 3](/coding/three-point-turn-3)
|
||||
@ -34,10 +50,6 @@
|
||||
* [Roaming 1](/coding/roaming-1)
|
||||
* [Roaming 2](/coding/roaming-2)
|
||||
|
||||
* [Lessons](/lessons)
|
||||
* [Make it move](/lessons/make-it-move)
|
||||
* [Line detection](/lessons/line-detection)
|
||||
|
||||
## Reference #reference
|
||||
|
||||
* [Reference](/reference)
|
||||
@ -67,8 +79,18 @@
|
||||
* [angle](/reference/motors/motor/angle)
|
||||
* [speed](/reference/motors/motor/speed)
|
||||
* [clear counts](/reference/motors/motor/clear-counts)
|
||||
* [stop all motors](/reference/motors/stop-all-motors)
|
||||
* [stop all motors](/reference/motors/stop-all)
|
||||
* [Sensors](/reference/sensors)
|
||||
* [angle](/reference/sensors/gyro/angle)
|
||||
* [rate](/reference/sensors/gyro/rate)
|
||||
* [reset](/reference/sensors/gyro/reset)
|
||||
* [Touch](/reference/sensors/touch-sensor)
|
||||
* [on event](/reference/sensors/touch-sensor/on-event)
|
||||
* [pause until](/reference/sensors/touch-sensor/pause-until)
|
||||
* [is pressed](/reference/sensors/touch-sensor/is-pressed)
|
||||
* [was pressed](/reference/sensors/touch-sensor/was-pressed)
|
||||
* [Gyro](/reference/sensors/gyro)
|
||||
* [angle](/reference/sensors/gyro/angle)
|
||||
* [rate](/reference/sensors/gyro/rate)
|
||||
* [reset](/reference/sensors/gyro/reset)
|
||||
* [Ultrasonic](/reference/sensors/ultrasonic)
|
||||
* [on event](/reference/sensors/ultrasonic/on-event),
|
||||
* [distance](reference/sensors/ultrasonic/distance),
|
||||
* [pause until](reference/sensors/ultrasonic/pause-until)
|
173
docs/coding.md
@ -1,171 +1,24 @@
|
||||
# Coding Activites
|
||||
|
||||
12 computer science activities, with cross-curricular opportunities in design and technology, science, and math.
|
||||
|
||||
* [Download Curriculum Materials](https://education.lego.com/en-us/downloads/mindstorms-ev3)
|
||||
|
||||
## Three Point Turn
|
||||
## Projects
|
||||
|
||||
```codecard
|
||||
[
|
||||
{
|
||||
"name": "Three Point Turn 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/three-point-turn-1",
|
||||
"cardType": "example"
|
||||
"name": "Autonomous Parking",
|
||||
"description": "TBD",
|
||||
"url":"/coding/autonomous-parking",
|
||||
"cardType": "side"
|
||||
}, {
|
||||
"name": "Three Point Turn 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/three-point-turn-2",
|
||||
"cardType": "example"
|
||||
"name": "Object Detection",
|
||||
"description": "TBD",
|
||||
"url":"/coding/object-detection",
|
||||
"cardType": "side"
|
||||
}, {
|
||||
"name": "Three Point Turn 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/three-point-turn-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Reversing the robot
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Reversing the robot 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/reversing-the-robot-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Reversing the robot 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/reversing-the-robot-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Reversing the robot 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/reversing-the-robot-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Light the way
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Light the way 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/light-the-way-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Light the way 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/light-the-way-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Light the way 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/light-the-way-3",
|
||||
"cardType": "example"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Traffic Lights
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Traffic Lights 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/traffic-lights-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Traffic Lights 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/traffic-lights-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Traffic Lights 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/traffic-lights-3",
|
||||
"cardType": "example"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Reverse Bepper
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Reverse Beeper 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/reverse-beeper-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Reverse Beeper 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/reverse-beeper-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Reverse Beeper 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/reverse-beeper-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Ignition
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Ignition 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/ingition-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Ignition 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/ignition-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Ignition 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/ignition-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Cruise Control
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Cruise Control 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/cruise-control-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Cruise Control 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/cruise-control-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Cruise Control 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/cruise-control-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Roaming
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Roaming 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/roaming-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Roaming 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/roaming-2",
|
||||
"cardType": "example"
|
||||
"name": "Line Following",
|
||||
"description": "TBD",
|
||||
"url":"/coding/line-following",
|
||||
"cardType": "side"
|
||||
}]
|
||||
```
|
||||
|
29
docs/design-engineering.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Design Engineering Projects
|
||||
|
||||
## Projects
|
||||
|
||||
```codecard
|
||||
[
|
||||
{
|
||||
"name": "Make It Move Without Wheels",
|
||||
"description": "TBD",
|
||||
"imageUrl": "/static/lessons/make-it-move.png",
|
||||
"url": "/design-engineering/make-it-move",
|
||||
"cardType": "side"
|
||||
},
|
||||
{
|
||||
"name": "Make It Smarter and Faster",
|
||||
"description": "TBD",
|
||||
"imageUrl": "/static/lessons/make-it-smarter.png",
|
||||
"url": "/design-engineering/make-it-move",
|
||||
"cardType": "side"
|
||||
},
|
||||
{
|
||||
"name": "Make a System that Communicates",
|
||||
"description": "TBD",
|
||||
"imageUrl": "/static/lessons/make-a-system.png",
|
||||
"url": "/design-engineering/make-it-move",
|
||||
"cardType": "side"
|
||||
}
|
||||
]
|
||||
```
|
90
docs/design-engineering/make-it-move.md
Normal file
@ -0,0 +1,90 @@
|
||||
# Make It Move Without Wheels
|
||||
|
||||
## ~ avatar
|
||||
|
||||
Design, build and program a robot that can move itself using no wheels for locomotion.
|
||||
|
||||
## ~
|
||||
|
||||
## Connect
|
||||
|
||||
### Design Brief
|
||||
|
||||
Design, build and program a robot that can move itself a distance of at least 30cm, using at least one motor, using NO wheels for locomotion.
|
||||
|
||||
### Brainstorm
|
||||
|
||||
Discuss different solutions to the design brief.
|
||||
|
||||
Think about:
|
||||
|
||||
How can robots move without wheels? For example, how will you:
|
||||
* Connect the motor(s) to something to make the robot walk, crawl, or wiggle?
|
||||
How will you program the robot to move? For example, which programming blocks will you use to:
|
||||
* Turn on and turn off the motor or motors?
|
||||
* Display the distance moved?
|
||||
|
||||
### Select the Best Solution
|
||||
|
||||
Describe the solution that you have agreed to build and program.
|
||||
|
||||
Think about examples from your brainstorming discussion. Then explain why you chose this solution for the design brief.
|
||||
|
||||

|
||||
|
||||
https://www.youtube.com/watch?v=ErC_s3hLGMk
|
||||
|
||||
## Construct
|
||||
|
||||
### Build and Program
|
||||
|
||||
Now you are ready to start building and programming your solution!
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations);
|
||||
motors.stopAll();
|
||||
```
|
||||
|
||||
As you work on your solution:
|
||||
|
||||
* Describe one part of your design that worked especially well.
|
||||
* Describe one design change that you had to make.
|
||||
|
||||
What will you try next?
|
||||
|
||||
As you test your design solution, use the table for recording your findings.
|
||||
|
||||
[**VIEW BUILDING INSTRUCTIONS**](TODO) for a sample solution. (7.8 MB, PDF)
|
||||
|
||||
# Contemplate
|
||||
|
||||
## Test and Analyze
|
||||
|
||||
How well does your solution satisfy the design brief? Record your data. Name the columns and rows, such as Trial Number, Distance Moved, and Observations.
|
||||
|
||||
## Review and Revise
|
||||
|
||||
Take a moment to reflect on your robot solution.
|
||||
|
||||
Think about:
|
||||
* Is the robot using something other than wheels to move? Trace the movement from the motor axle to the mechanism(s) that drives the robot forward, backward or sideways. Wheels can be used to stabilize the robot but not to drive it.
|
||||
* Does the robot display the distance moved?
|
||||
* Is it accurate? How do you know?
|
||||
Describe two ways you could improve your robot.
|
||||
|
||||
# Continue
|
||||
|
||||
## Communicate
|
||||
|
||||
Here are some ideas:
|
||||
* Create a video of your project, especially your final presentation and your robot’s performance.
|
||||
* Explain some important features of your software program.
|
||||
* Produce a building guide for your model by taking a series of photographs as you deconstruct it.
|
||||
* Include an image of your program with comments.
|
||||
* Add a team photograph!
|
||||
|
||||
## ~ avatar
|
||||
|
||||
Congratulations! What will you design next?
|
||||
|
||||
## ~
|
201
docs/examples.md
@ -2,6 +2,207 @@
|
||||
|
||||
Here are some fun programs for your @boardname@!
|
||||
|
||||
## Maker
|
||||
|
||||
```codecard
|
||||
[
|
||||
{
|
||||
"name": "Sound Of Color",
|
||||
"description": "Play different sounds based on the color",
|
||||
"url":"/maker/sound-of-color",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/sound-of-color.png"
|
||||
},
|
||||
{
|
||||
"name": "Security Gadget",
|
||||
"description": "Raise the alarm when your brick is lifted!",
|
||||
"url":"/maker/security-gadget",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/security-gadget.png"
|
||||
},
|
||||
{
|
||||
"name": "Intruder Detector",
|
||||
"description": "Raise the alarm when an intruder sneaks in",
|
||||
"url":"/maker/intruder-detector",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/intruder-detector.png"
|
||||
},
|
||||
{
|
||||
"name": "Puppet",
|
||||
"description": "Build an automated puppet",
|
||||
"url":"/maker/puppet",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/puppet.png"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Three Point Turn
|
||||
|
||||
```codecard
|
||||
[
|
||||
{
|
||||
"name": "Three Point Turn 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/three-point-turn-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Three Point Turn 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/three-point-turn-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Three Point Turn 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/three-point-turn-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Reversing the robot
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Reversing the robot 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/reversing-the-robot-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Reversing the robot 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/reversing-the-robot-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Reversing the robot 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/reversing-the-robot-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Light the way
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Light the way 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/light-the-way-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Light the way 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/light-the-way-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Light the way 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/light-the-way-3",
|
||||
"cardType": "example"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Traffic Lights
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Traffic Lights 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/traffic-lights-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Traffic Lights 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/traffic-lights-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Traffic Lights 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/traffic-lights-3",
|
||||
"cardType": "example"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Reverse Bepper
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Reverse Beeper 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/reverse-beeper-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Reverse Beeper 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/reverse-beeper-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Reverse Beeper 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/reverse-beeper-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Ignition
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Ignition 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/ingition-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Ignition 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/ignition-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Ignition 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/ignition-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Cruise Control
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Cruise Control 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/cruise-control-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Cruise Control 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/cruise-control-2",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Cruise Control 3",
|
||||
"description": "Activity 3",
|
||||
"url":"/coding/cruise-control-3",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Roaming
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Roaming 1",
|
||||
"description": "Activity 1",
|
||||
"url":"/coding/roaming-1",
|
||||
"cardType": "example"
|
||||
}, {
|
||||
"name": "Roaming 2",
|
||||
"description": "Activity 2",
|
||||
"url":"/coding/roaming-2",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
||||
|
||||
## Fun stuff
|
||||
|
||||
```codecard
|
||||
|
@ -108,7 +108,7 @@ function checkFallen() {
|
||||
// stop all motors and wait for touch button to be
|
||||
// pressed
|
||||
function stop() {
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
state = 0
|
||||
moods.knockedOut.show();
|
||||
sensors.touch3.pauseUntil(ButtonEvent.Pressed)
|
||||
|
@ -144,7 +144,7 @@ loops.forever(function () {
|
||||
let p = 5 - (t2 - t1);
|
||||
loops.pause(Math.max(1, p))
|
||||
}
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
st = 0;
|
||||
brick.setStatusLight(StatusLight.RedPulse);
|
||||
brick.showImage(images.eyesKnockedOut)
|
||||
|
@ -144,7 +144,7 @@ loops.forever(function () {
|
||||
let p = 5 - (t2 - t1);
|
||||
loops.pause(Math.max(1, p))
|
||||
}
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
st = 0;
|
||||
brick.setStatusLight(StatusLight.RedPulse);
|
||||
brick.showImage(images.eyesKnockedOut)
|
||||
|
22
docs/getting-started.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Getting Started
|
||||
|
||||
## Projects
|
||||
|
||||
```codecard
|
||||
[
|
||||
{
|
||||
"name": "Try",
|
||||
"imageUrl": "/static/lessons/try.png",
|
||||
"description": "TBD",
|
||||
"url": "/getting-started/try",
|
||||
"cardType": "side"
|
||||
},
|
||||
{
|
||||
"name": "use",
|
||||
"imageUrl": "/static/lessons/use.png",
|
||||
"description": "TBD",
|
||||
"url": "/getting-started/use",
|
||||
"cardType": "side"
|
||||
}
|
||||
]
|
||||
```
|
@ -81,7 +81,7 @@ Study the program...what do you think the program will do?
|
||||
motors.largeBC.steer(0, 20)
|
||||
while (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
}
|
||||
```
|
||||
|
||||
@ -148,7 +148,7 @@ while (true) {
|
||||
motors.largeBC.steer(0, 20)
|
||||
while (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -162,7 +162,7 @@ while (true) {
|
||||
motors.largeBC.steer(0, 20)
|
||||
while (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
}
|
||||
while (true) {
|
||||
|
||||
@ -183,7 +183,7 @@ while (true) {
|
||||
motors.largeBC.steer(0, 20)
|
||||
while (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
}
|
||||
while (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
|
@ -51,7 +51,7 @@ The ``||motors:tank large B+C||`` block will run for `9` rotations when the **ce
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
## Program 3 @fullscreen
|
||||
@ -63,7 +63,7 @@ The ``||motors:tank large B+C||`` will run for `9` rotations when the **center**
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
brick.showString("30 cm", 1)
|
||||
```
|
||||
|
||||
|
@ -9,39 +9,12 @@ These six activities require the LEGO® MINDSTORMS® Education EV3 Core Set (455
|
||||
```codecard
|
||||
[
|
||||
{
|
||||
"name": "Sound Machine",
|
||||
"name": "Make A Sound Machine",
|
||||
"description": "Create instruments with your EV3 Brick!",
|
||||
"url":"/maker/sound-machine",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/sound-machine.png"
|
||||
},
|
||||
{
|
||||
"name": "Sound Of Color",
|
||||
"description": "Play different sounds based on the color",
|
||||
"url":"/maker/sound-of-color",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/sound-of-color.png"
|
||||
},
|
||||
{
|
||||
"name": "Security Gadget",
|
||||
"description": "Raise the alarm when your brick is lifted!",
|
||||
"url":"/maker/security-gadget",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/security-gadget.png"
|
||||
},
|
||||
{
|
||||
"name": "Intruder Detector",
|
||||
"description": "Raise the alarm when an intruder sneaks in",
|
||||
"url":"/maker/intruder-detector",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/intruder-detector.png"
|
||||
},
|
||||
{
|
||||
"name": "Puppet",
|
||||
"description": "Build an automated puppet",
|
||||
"url":"/maker/puppet",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/puppet.png"
|
||||
"imageUrl": "/static/maker/sound-machine.png",
|
||||
"cardType": "side"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
@ -3,7 +3,7 @@
|
||||
```namespaces
|
||||
brick.showMood(moods.sleeping);
|
||||
sensors.color(null);
|
||||
motors.stopAllMotors();
|
||||
motors.stopAll();
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
@ -12,7 +12,7 @@ motors.largeA.setInverted(true)
|
||||
motors.largeA.setRegulated(false)
|
||||
motors.largeA.stop()
|
||||
motors.largeA.reset()
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
```
|
||||
## Counters
|
||||
|
||||
|
@ -6,11 +6,11 @@ Get the current angle of the motor's rotation in degrees.
|
||||
motors.largeA.angle()
|
||||
```
|
||||
|
||||
When a motor is started for the first time, or after a reset, it's angle of rotation starts at `0` degrees. A complete rotation (a turn in a full circle) is `360` degrees. At `360` degrees, the motor angle gets set back to `0`. So, one and a half turns adds up to `540` degrees of total rotation but the motor only cares about the current angle from `0` degrees which is `180` degrees.
|
||||
When a motor is started for the first time, or after a reset, it's angle of rotation starts at `0` degrees. A complete rotation (a turn in a full circle) is `360` degrees. At `360` degrees, the motor angle doesn't go back to `0` but keeps counting in degrees. So, one and a half turns adds up to `540` degrees of total rotation.
|
||||
|
||||
## Returns
|
||||
|
||||
* a [number](/types/number) which is the current angle of rotation for the motor. The value returned is the number of degrees from `0` to `359`.
|
||||
* a [number](/types/number) which is the current angle of rotation for the motor.
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Stops all motors currently running on the brick.
|
||||
|
||||
```sig
|
||||
motors.stopAllMotors();
|
||||
motors.stopAll();
|
||||
```
|
||||
|
||||
The motors stops but any motion caused from previously running the motors continues until it runs down. If you are driving your brick and then stop the motors, it will coast for awhile before stopping.
|
||||
@ -15,7 +15,7 @@ Tank the @boardname@ forward at half speed for 5 seconds and then stop.
|
||||
```blocks
|
||||
motors.largeAB.tank(50, 50);
|
||||
loops.pause(5000);
|
||||
motors.stopAllMotors();
|
||||
motors.stopAll();
|
||||
```
|
||||
|
||||
## See also
|
@ -76,7 +76,7 @@ for (let i = 0; i < 4; i++) {
|
||||
motors.largeBC.steer(-30, 30)
|
||||
loops.pause(5000)
|
||||
}
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
## See also
|
||||
|
@ -46,7 +46,7 @@ motors.largeAB.tank(75, 75)
|
||||
loops.pause(10000)
|
||||
motors.largeAB.tank(-55, -55)
|
||||
loops.pause(10000)
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
### Slip steer
|
||||
@ -73,7 +73,7 @@ Run both motors in opposite directions to spin the brick around to the left.
|
||||
```blocks
|
||||
motors.largeAB.tank(-30, 30)
|
||||
loops.pause(5000)
|
||||
motors.stopAllMotors()
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
## See also
|
||||
|
@ -1,9 +1,26 @@
|
||||
# Sensors
|
||||
|
||||
## Touch
|
||||
|
||||
```cards
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {})
|
||||
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
|
||||
sensors.touch1.wasPressed()
|
||||
sensors.touch1.isPressed()
|
||||
```
|
||||
|
||||
## Gyro
|
||||
|
||||
```cards
|
||||
sensors.gyro1.angle();
|
||||
sensors.gyro1.rate();
|
||||
sensors.gyro1.reset();
|
||||
```
|
||||
```
|
||||
|
||||
## Ultrasonic
|
||||
|
||||
```cards
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectDetected, function () {});
|
||||
sensors.ultrasonic1.distance();
|
||||
sensors.ultrasonic1.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
|
||||
```
|
||||
|
BIN
docs/static/backgrounds/simulator.png
vendored
Before Width: | Height: | Size: 705 B After Width: | Height: | Size: 681 B |
34
docs/static/backgrounds/simulator.svg
vendored
@ -9,14 +9,14 @@
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="101.07757"
|
||||
height="100.57249"
|
||||
viewBox="0 0 101.07757 100.57249"
|
||||
width="76.47757"
|
||||
height="75.972496"
|
||||
viewBox="0 0 76.477571 75.972499"
|
||||
id="svg4138"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
|
||||
sodipodi:docname="simulator.svg"
|
||||
inkscape:export-filename="/Users/sam/pxt-ev3/docs/static/backgrounds/simulator.png"
|
||||
inkscape:export-filename="C:\Users\samelh\pxt-ev3\docs\static\backgrounds\simulator.png"
|
||||
inkscape:export-xdpi="50.11311"
|
||||
inkscape:export-ydpi="50.11311">
|
||||
<defs
|
||||
@ -29,20 +29,20 @@
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="4"
|
||||
inkscape:cx="134.33221"
|
||||
inkscape:cy="8.1953909"
|
||||
inkscape:cx="60.782211"
|
||||
inkscape:cy="-4.104587"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
fit-margin-top="28.3"
|
||||
fit-margin-left="28.3"
|
||||
fit-margin-right="28.3"
|
||||
fit-margin-bottom="28.3"
|
||||
fit-margin-top="16"
|
||||
fit-margin-left="16"
|
||||
fit-margin-right="16"
|
||||
fit-margin-bottom="16"
|
||||
units="px"
|
||||
inkscape:window-width="2556"
|
||||
inkscape:window-height="1395"
|
||||
inkscape:window-x="4"
|
||||
inkscape:window-y="1"
|
||||
inkscape:window-width="3000"
|
||||
inkscape:window-height="1875"
|
||||
inkscape:window-x="-13"
|
||||
inkscape:window-y="-13"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata4143">
|
||||
@ -60,9 +60,9 @@
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-68.659229,-124.25339)">
|
||||
transform="translate(-80.959229,-136.55339)">
|
||||
<ellipse
|
||||
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:2.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.31372549"
|
||||
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:2.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.47058824"
|
||||
id="path4699"
|
||||
cx="119.19801"
|
||||
cy="174.53964"
|
||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
BIN
docs/static/lessons/make-a-sound-machine.png
vendored
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
docs/static/lessons/make-a-system.png
vendored
Normal file
After Width: | Height: | Size: 592 KiB |
BIN
docs/static/lessons/make-it-move.jpg
vendored
Before Width: | Height: | Size: 16 KiB |
BIN
docs/static/lessons/make-it-move.png
vendored
Normal file
After Width: | Height: | Size: 357 KiB |
BIN
docs/static/lessons/make-it-move/hero.png
vendored
Normal file
After Width: | Height: | Size: 357 KiB |
BIN
docs/static/lessons/make-it-smarter.png
vendored
Normal file
After Width: | Height: | Size: 413 KiB |
BIN
docs/static/lessons/try.png
vendored
Normal file
After Width: | Height: | Size: 132 KiB |
BIN
docs/static/lessons/use.png
vendored
Normal file
After Width: | Height: | Size: 236 KiB |
@ -73,7 +73,7 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
<span class="ui blue circular label">2</span>
|
||||
<strong>${lf("Make sure you have the latest EV3 firmware")}</strong>
|
||||
<br/>
|
||||
<a href="" target="_blank">${lf("Click here to update to latest firmware")}</a>
|
||||
<a href="https://ev3manager.education.lego.com/" target="_blank">${lf("Click here to update to latest firmware")}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
34
libs/base/enums.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Auto-generated. Do not edit.
|
||||
|
||||
|
||||
declare const enum NumberFormat {
|
||||
Int8LE = 1,
|
||||
UInt8LE = 2,
|
||||
Int16LE = 3,
|
||||
UInt16LE = 4,
|
||||
Int32LE = 5,
|
||||
Int8BE = 6,
|
||||
UInt8BE = 7,
|
||||
Int16BE = 8,
|
||||
UInt16BE = 9,
|
||||
Int32BE = 10,
|
||||
|
||||
UInt32LE = 11,
|
||||
UInt32BE = 12,
|
||||
Float32LE = 13,
|
||||
Float64LE = 14,
|
||||
Float32BE = 15,
|
||||
Float64BE = 16,
|
||||
}
|
||||
|
||||
|
||||
declare const enum ValType {
|
||||
Undefined = 0,
|
||||
Boolean = 1,
|
||||
Number = 2,
|
||||
String = 3,
|
||||
Object = 4,
|
||||
Function = 5,
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
159
libs/base/shims.d.ts
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Auto-generated. Do not edit.
|
||||
|
||||
|
||||
|
||||
//% indexerGet=BufferMethods::getByte indexerSet=BufferMethods::setByte
|
||||
declare interface Buffer {
|
||||
/**
|
||||
* Write a number in specified format in the buffer.
|
||||
*/
|
||||
//% shim=BufferMethods::setNumber
|
||||
setNumber(format: NumberFormat, offset: int32, value: number): void;
|
||||
|
||||
/**
|
||||
* Read a number in specified format from the buffer.
|
||||
*/
|
||||
//% shim=BufferMethods::getNumber
|
||||
getNumber(format: NumberFormat, offset: int32): number;
|
||||
|
||||
/** Returns the length of a Buffer object. */
|
||||
//% property shim=BufferMethods::length
|
||||
length: int32;
|
||||
|
||||
/**
|
||||
* Fill (a fragment) of the buffer with given value.
|
||||
*/
|
||||
//% offset.defl=0 length.defl=-1 shim=BufferMethods::fill
|
||||
fill(value: int32, offset?: int32, length?: int32): void;
|
||||
|
||||
/**
|
||||
* Return a copy of a fragment of a buffer.
|
||||
*/
|
||||
//% offset.defl=0 length.defl=-1 shim=BufferMethods::slice
|
||||
slice(offset?: int32, length?: int32): Buffer;
|
||||
|
||||
/**
|
||||
* Shift buffer left in place, with zero padding.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus
|
||||
* start. eg: -1
|
||||
*/
|
||||
//% start.defl=0 length.defl=-1 shim=BufferMethods::shift
|
||||
shift(offset: int32, start?: int32, length?: int32): void;
|
||||
|
||||
/**
|
||||
* Convert a buffer to its hexadecimal representation.
|
||||
*/
|
||||
//% shim=BufferMethods::toHex
|
||||
toHex(): string;
|
||||
|
||||
/**
|
||||
* Rotate buffer left in place.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus
|
||||
* start. eg: -1
|
||||
*/
|
||||
//% start.defl=0 length.defl=-1 shim=BufferMethods::rotate
|
||||
rotate(offset: int32, start?: int32, length?: int32): void;
|
||||
|
||||
/**
|
||||
* Write contents of `src` at `dstOffset` in current buffer.
|
||||
*/
|
||||
//% shim=BufferMethods::write
|
||||
write(dstOffset: int32, src: Buffer): void;
|
||||
}
|
||||
declare namespace loops {
|
||||
|
||||
/**
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body code to execute
|
||||
*/
|
||||
//% help=loops/forever weight=100 afterOnStart=true
|
||||
//% blockId=forever block="forever" blockAllowMultiple=1 shim=loops::forever
|
||||
function forever(a: () => void): void;
|
||||
|
||||
/**
|
||||
* Pause for the specified time in milliseconds
|
||||
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
|
||||
*/
|
||||
//% help=loops/pause weight=99
|
||||
//% async block="pause %pause=timePicker|ms"
|
||||
//% blockId=device_pause shim=loops::pause
|
||||
function pause(ms: int32): void;
|
||||
}
|
||||
declare namespace control {
|
||||
|
||||
/**
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=control/millis weight=50
|
||||
//% blockId=control_running_time block="millis (ms)" shim=control::millis
|
||||
function millis(): int32;
|
||||
|
||||
/**
|
||||
* Run code when a registered event happens.
|
||||
* @param id the event compoent id
|
||||
* @param value the event value to match
|
||||
*/
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src|with value %value"
|
||||
//% blockExternalInputs=1
|
||||
//% help="control/on-event" flags.defl=16 shim=control::onEvent
|
||||
function onEvent(src: int32, value: int32, handler: () => void, flags?: int32): void;
|
||||
|
||||
/**
|
||||
* Reset the device.
|
||||
*/
|
||||
//% weight=30 async help=control/reset blockGap=8
|
||||
//% blockId="control_reset" block="reset" shim=control::reset
|
||||
function reset(): void;
|
||||
|
||||
/**
|
||||
* Block the current fiber for the given microseconds
|
||||
* @param micros number of micro-seconds to wait. eg: 4
|
||||
*/
|
||||
//% help=control/wait-micros weight=29 async
|
||||
//% blockId="control_wait_us" block="wait (µs)%micros" shim=control::waitMicros
|
||||
function waitMicros(micros: int32): void;
|
||||
|
||||
/**
|
||||
* Run other code in the parallel.
|
||||
*/
|
||||
//% help=control/run-in-parallel handlerStatement=1
|
||||
//% blockId="control_run_in_parallel" block="run in parallel" blockGap=8 shim=control::runInParallel
|
||||
function runInParallel(a: () => void): void;
|
||||
|
||||
/**
|
||||
* Blocks the calling thread until the specified event is raised.
|
||||
*/
|
||||
//% help=control/wait-for-event async
|
||||
//% blockId=control_wait_for_event block="wait for event|from %src|with value %value" shim=control::waitForEvent
|
||||
function waitForEvent(src: int32, value: int32): void;
|
||||
|
||||
/**
|
||||
* Derive a unique, consistent serial number of this device from internal data.
|
||||
*/
|
||||
//% blockId="control_device_serial_number" block="device serial number" weight=9
|
||||
//% help=control/device-serial-number shim=control::deviceSerialNumber
|
||||
function deviceSerialNumber(): int32;
|
||||
}
|
||||
declare namespace serial {
|
||||
|
||||
/**
|
||||
* Write some text to the serial port.
|
||||
*/
|
||||
//% help=serial/write-string
|
||||
//% weight=87 blockHidden=true
|
||||
//% blockId=serial_writestring block="serial|write string %text" shim=serial::writeString
|
||||
function writeString(text: string): void;
|
||||
|
||||
/**
|
||||
* Send a buffer across the serial connection.
|
||||
*/
|
||||
//% help=serial/write-buffer weight=6 blockHidden=true
|
||||
//% blockId=serial_writebuffer block="serial|write buffer %buffer" shim=serial::writeBuffer
|
||||
function writeBuffer(buffer: Buffer): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
@ -19,22 +19,22 @@ enum LightIntensityMode {
|
||||
}
|
||||
|
||||
const enum ColorSensorColor {
|
||||
//% block="none" blockIdentity=sensors.color
|
||||
//% block="none" jres=colors.none
|
||||
None,
|
||||
//% block="black" blockIdentity=sensors.color
|
||||
//% block="black" jres=colors.black
|
||||
Black,
|
||||
//% block="blue" blockIdentity=sensors.color
|
||||
//% block="blue" jres=colors.blue
|
||||
Blue,
|
||||
//% block="green" blockIdentity=sensors.color
|
||||
//% block="green" jres=colors.green
|
||||
Green,
|
||||
//% block="yellow" blockIdentity=sensors.color
|
||||
//% block="yellow" jres=colors.yellow
|
||||
Yellow,
|
||||
//% block="red" blockIdentity=sensors.color
|
||||
//% block="red" jres=colors.red
|
||||
Red,
|
||||
//% block="white" blockIdentity=sensors.color
|
||||
//% block="white" jres=colors.white
|
||||
White,
|
||||
//% block="brown" blockIdentity=sensors.color
|
||||
Brown,
|
||||
//% block="brown" jres=colors.brown
|
||||
Brown
|
||||
}
|
||||
|
||||
enum LightCondition {
|
||||
@ -117,6 +117,11 @@ namespace sensors {
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% weight=100 blockGap=12
|
||||
//% group="Color Sensor"
|
||||
//% color.fieldEditor="gridpicker"
|
||||
//% color.fieldOptions.columns=4
|
||||
//% color.fieldOptions.tooltips=true
|
||||
//% color.fieldOptions.hideRect=true
|
||||
//% color.fieldOptions.width=268
|
||||
onColorDetected(color: ColorSensorColor, handler: () => void) {
|
||||
this.setMode(ColorSensorMode.Color)
|
||||
const v = this._colorEventValue(<number>color);
|
||||
@ -137,6 +142,11 @@ namespace sensors {
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% weight=99 blockGap=8
|
||||
//% group="Color Sensor"
|
||||
//% color.fieldEditor="gridpicker"
|
||||
//% color.fieldOptions.columns=4
|
||||
//% color.fieldOptions.tooltips=true
|
||||
//% color.fieldOptions.hideRect=true
|
||||
//% color.fieldOptions.width=268
|
||||
pauseForColor(color: ColorSensorColor) {
|
||||
this.setMode(ColorSensorMode.Color);
|
||||
if (this.color() != color) {
|
||||
|
30
libs/color-sensor/colors.jres
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"*": {
|
||||
"namespace": "colors",
|
||||
"dataEncoding": "base64"
|
||||
},
|
||||
"black": {
|
||||
"icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMAUExURQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAszD0iAAAAQB0Uk5T////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AFP3ByUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAALklEQVRYR+3MQQ0AIAADMfybHjkN/EgroGePBIIIBBEIIhBEIIhAEIEggg+C7QKnC/DiLFihnAAAAABJRU5ErkJggg=="
|
||||
},
|
||||
"red": {
|
||||
"icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMAUExURf8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH8gKTMAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAAG0lEQVRYR+3BgQAAAADDoPlT3+AEVQAAAABXDRBAAAFce08FAAAAAElFTkSuQmCC"
|
||||
}
|
||||
}
|
BIN
libs/color-sensor/jres/colors/black-icon.png
Normal file
After Width: | Height: | Size: 951 B |
BIN
libs/color-sensor/jres/colors/blue-icon.png
Normal file
After Width: | Height: | Size: 951 B |
BIN
libs/color-sensor/jres/colors/brown-icon.png
Normal file
After Width: | Height: | Size: 951 B |
BIN
libs/color-sensor/jres/colors/green-icon.png
Normal file
After Width: | Height: | Size: 951 B |
BIN
libs/color-sensor/jres/colors/none-icon.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
libs/color-sensor/jres/colors/red-icon.png
Normal file
After Width: | Height: | Size: 951 B |
BIN
libs/color-sensor/jres/colors/white-icon.png
Normal file
After Width: | Height: | Size: 951 B |
BIN
libs/color-sensor/jres/colors/yellow-icon.png
Normal file
After Width: | Height: | Size: 951 B |
@ -3,6 +3,7 @@
|
||||
"description": "Color Sensor support",
|
||||
"files": [
|
||||
"README.md",
|
||||
"colors.jres",
|
||||
"color.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
|
@ -161,7 +161,7 @@ namespace brick {
|
||||
// this needs to be done in query(), which is run without the main JS execution mutex
|
||||
// otherwise, while(true){} will lock the device
|
||||
if (ret & DAL.BUTTON_ID_ESCAPE) {
|
||||
motors.stopAllMotors(); // ensuring that all motors are off
|
||||
motors.stopAll(); // ensuring that all motors are off
|
||||
control.reset()
|
||||
}
|
||||
return ret
|
||||
|
29
libs/core/enums.d.ts
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Auto-generated. Do not edit.
|
||||
|
||||
|
||||
/**
|
||||
* Mode for lseek()
|
||||
*/
|
||||
|
||||
declare const enum SeekWhence {
|
||||
Set = 0,
|
||||
Current = 1,
|
||||
End = 2,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Drawing modes
|
||||
*/
|
||||
|
||||
declare const enum Draw {
|
||||
Normal = 0x00,
|
||||
Clear = 0x01,
|
||||
Xor = 0x02,
|
||||
Fill = 0x04,
|
||||
Transparent = 0x08,
|
||||
Double = 0x10,
|
||||
Quad = 0x20,
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
@ -113,8 +113,8 @@ namespace motors {
|
||||
//% blockId=motorStopAll block="stop all motors"
|
||||
//% weight=1
|
||||
//% group="Move"
|
||||
//% help=motors/stop-all-motors
|
||||
export function stopAllMotors() {
|
||||
//% help=motors/stop-all
|
||||
export function stopAll() {
|
||||
const b = mkCmd(Output.ALL, DAL.opOutputStop, 0)
|
||||
writePWM(b)
|
||||
}
|
||||
@ -223,9 +223,10 @@ namespace motors {
|
||||
* @param value (optional) measured distance or rotation
|
||||
* @param unit (optional) unit of the value
|
||||
*/
|
||||
//% blockId=motorSetSpeed block="set %motor|speed to %speed=motorSpeedPicker|%"
|
||||
//% blockId=motorSetSpeed block="set %motor speed to %speed=motorSpeedPicker|\\%||for %value %unit"
|
||||
//% weight=100 blockGap=8
|
||||
//% group="Move"
|
||||
//% expandableArgumentMode=toggle
|
||||
//% help=motors/motor/set-speed
|
||||
setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
||||
this.init();
|
||||
@ -495,10 +496,11 @@ namespace motors {
|
||||
* @param value (optional) move duration or rotation
|
||||
* @param unit (optional) unit of the value
|
||||
*/
|
||||
//% blockId=motorPairTank block="tank %motors|%speedLeft=motorSpeedPicker|%|%speedRight=motorSpeedPicker|%"
|
||||
//% blockId=motorPairTank block="tank %motors %speedLeft=motorSpeedPicker|\\% %speedRight=motorSpeedPicker|\\%||for %value %unit"
|
||||
//% weight=96 blockGap=8
|
||||
//% inlineInputMode=inline
|
||||
//% group="Move"
|
||||
//% expandableArgumentMode=toggle
|
||||
//% help=motors/synced/tank
|
||||
tank(speedLeft: number, speedRight: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
||||
this.init();
|
||||
@ -521,11 +523,12 @@ namespace motors {
|
||||
* @param value (optional) move duration or rotation
|
||||
* @param unit (optional) unit of the value
|
||||
*/
|
||||
//% blockId=motorPairSteer block="steer %chassis|turn ratio %turnRatio=motorTurnRatioPicker|speed %speed=motorSpeedPicker|%"
|
||||
//% blockId=motorPairSteer block="steer %chassis turn ratio %turnRatio=motorTurnRatioPicker speed %speed=motorSpeedPicker|\\%||for %value %unit"
|
||||
//% weight=95
|
||||
//% turnRatio.min=-200 turnRatio=200
|
||||
//% inlineInputMode=inline
|
||||
//% group="Move"
|
||||
//% expandableArgumentMode=toggle
|
||||
//% help=motors/synced/steer
|
||||
steer(turnRatio: number, speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
||||
this.init();
|
||||
|
144
libs/core/shims.d.ts
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare namespace control {
|
||||
|
||||
/** Create new file mapping in memory */
|
||||
//% shim=control::mmap
|
||||
function mmap(filename: string, size: int32, offset: int32): MMap;
|
||||
}
|
||||
|
||||
|
||||
declare interface MMap {
|
||||
/**
|
||||
* Write a number in specified format in the buffer.
|
||||
*/
|
||||
//% shim=MMapMethods::setNumber
|
||||
setNumber(format: NumberFormat, offset: int32, value: number): void;
|
||||
|
||||
/**
|
||||
* Read a number in specified format from the buffer.
|
||||
*/
|
||||
//% shim=MMapMethods::getNumber
|
||||
getNumber(format: NumberFormat, offset: int32): number;
|
||||
|
||||
/**
|
||||
* Read a range of bytes into a buffer.
|
||||
*/
|
||||
//% offset.defl=0 length.defl=-1 shim=MMapMethods::slice
|
||||
slice(offset?: int32, length?: int32): Buffer;
|
||||
|
||||
/** Returns the length of a Buffer object. */
|
||||
//% property shim=MMapMethods::length
|
||||
length: int32;
|
||||
|
||||
/** Perform ioctl(2) on the underlaying file */
|
||||
//% shim=MMapMethods::ioctl
|
||||
ioctl(id: uint32, data: Buffer): int32;
|
||||
|
||||
/** Perform write(2) on the underlaying file */
|
||||
//% shim=MMapMethods::write
|
||||
write(data: Buffer): int32;
|
||||
|
||||
/** Perform read(2) on the underlaying file */
|
||||
//% shim=MMapMethods::read
|
||||
read(data: Buffer): int32;
|
||||
|
||||
/** Set pointer on the underlaying file. */
|
||||
//% shim=MMapMethods::lseek
|
||||
lseek(offset: int32, whence: SeekWhence): int32;
|
||||
}
|
||||
declare namespace control {
|
||||
|
||||
/**
|
||||
* Announce that an event happened to registered handlers.
|
||||
* @param src ID of the Component that generated the event
|
||||
* @param value Component specific code indicating the cause of the event.
|
||||
* @param mode optional definition of how the event should be processed after construction.
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event"
|
||||
//% block="raise event|from %src|with value %value" blockExternalInputs=1 shim=control::raiseEvent
|
||||
function raiseEvent(src: int32, value: int32): void;
|
||||
|
||||
/**
|
||||
* Allocates the next user notification event
|
||||
*/
|
||||
//% help=control/allocate-notify-event shim=control::allocateNotifyEvent
|
||||
function allocateNotifyEvent(): int32;
|
||||
|
||||
/** Write data to DMESG debugging buffer. */
|
||||
//% shim=control::dmesg
|
||||
function dmesg(s: string): void;
|
||||
}
|
||||
declare namespace serial {
|
||||
|
||||
/** Send DMESG debug buffer over serial. */
|
||||
//% shim=serial::writeDmesg
|
||||
function writeDmesg(): void;
|
||||
}
|
||||
declare namespace screen {
|
||||
|
||||
/** Decompresses a 1-bit gray scale PNG image to image format. */
|
||||
//% shim=screen::unpackPNG
|
||||
function unpackPNG(png: Buffer): Image;
|
||||
}
|
||||
declare namespace screen {
|
||||
|
||||
/** Clear screen and reset font to normal. */
|
||||
//% shim=screen::clear
|
||||
function clear(): void;
|
||||
|
||||
/** Makes an image bound to a buffer. */
|
||||
//% shim=screen::imageOf
|
||||
function imageOf(buf: Buffer): Image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% fixedInstances
|
||||
declare interface Image {
|
||||
/** Returns the underlaying Buffer object. */
|
||||
//% property shim=ImageMethods::buffer
|
||||
buffer: Buffer;
|
||||
|
||||
/** Returns the width of an image. */
|
||||
//% property shim=ImageMethods::width
|
||||
width: int32;
|
||||
|
||||
/** Returns the height of an image. */
|
||||
//% property shim=ImageMethods::height
|
||||
height: int32;
|
||||
|
||||
/** Double size of an image. */
|
||||
//% shim=ImageMethods::doubled
|
||||
doubled(): Image;
|
||||
|
||||
/** Draw an image on the screen. */
|
||||
//% shim=ImageMethods::draw
|
||||
draw(x: int32, y: int32, mode: Draw): void;
|
||||
}
|
||||
declare namespace output {
|
||||
|
||||
/**
|
||||
* Create a new zero-initialized buffer.
|
||||
* @param size number of bytes in the buffer
|
||||
*/
|
||||
//% shim=output::createBuffer
|
||||
function createBuffer(size: int32): Buffer;
|
||||
}
|
||||
declare namespace motors {
|
||||
|
||||
/**
|
||||
* Mark a motor as used
|
||||
*/
|
||||
//% shim=motors::__motorUsed
|
||||
function __motorUsed(port: int32, large: boolean): void;
|
||||
}
|
||||
declare namespace sensors {
|
||||
|
||||
/**
|
||||
* Mark a sensor as used
|
||||
*/
|
||||
//% shim=sensors::__sensorUsed
|
||||
function __sensorUsed(port: int32, type: int32): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
13
libs/gyro-sensor/docs/reference/sensors/gyro.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Gyro sensor
|
||||
|
||||
```cards
|
||||
sensors.gyro1.angle();
|
||||
sensors.gyro1.rate();
|
||||
sensors.gyro1.reset();
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
[angle](/reference/sensors/gyro/angle),
|
||||
[rate](/reference/sensors/gyro/rate),
|
||||
[reset](/reference/sensors/gyro/reset)
|
@ -3,11 +3,35 @@
|
||||
Get the current rotation angle of the gyro.
|
||||
|
||||
```sig
|
||||
sensors.gyro2.rate()
|
||||
sensors.gyro2.angle()
|
||||
```
|
||||
|
||||
When the brick changes its position, it's moved in the direction of one of the axes used to measure three-dimensional space. Depending on where the gyro sensor is attached, it can measure the difference in angle from where it was before it moved. This angle is measured in degrees. The angle is the number of degrees rotated from where the gyro was last [reset](/reference/sensors/gyro/reset).
|
||||
|
||||
## ~hint
|
||||
|
||||
## Accuracy and calibration
|
||||
|
||||
Gyro sensors aren't perfectly accurate. Sometimes, because of temperature and changes in the way elecricity behaves in the sensor, the gyro returns a small error in it's measurement. This causes the gyro sensor to return an incorrect value for the amount of angle it detected. This might make your robot drive off course and not go to where you want it to.
|
||||
|
||||
### Drift
|
||||
|
||||
If you want to turn the tank or robot you built to the left by 45 degrees, you might run the motor on the right side until the gyro reported that you turned by 45 degrees. What if the gyro was getting an error of 4 degrees every time it measured an angle? You may have actually turned 49 degrees when you expected to turn 45 degrees. Well, that might not be too bad if you use the gyro's angle value only once. It's fine if you just wanted to turn and stop or drive a short distance in only that direction.
|
||||
|
||||
The problem is that when you need to read the angle measurement frequently, the amount of error in the angle measurement may continue to increase. If the sensor thought it moved by 45 degrees the first time instead of really 49 degrees, your second turn will put you at 98 degrees when the sensor said 90 degrees. If you want a robot to turn right 90 degrees and drive for 5 meters, it might actually turn 98 degrees and drive 0.7 meters off course before it stops. This error in the sensor's measurement is called _drift_.
|
||||
|
||||
### Time to reset
|
||||
|
||||
If errors in the angle values returned by the gyro sensor are making your project not work right, then it's time to **[reset](/reference/sensors/gyro/reset)**. A reset will return the gyro sensor's current angle value back to `0` and _calibrate_ for drift. Calibration is the process of finding out how much error there is in a sensor's measurement and then removing the error from the value returned to your program.
|
||||
|
||||
Are you using a gyro sensor in your project and need accuracy for your angle values? You should reset the gyro sensor at a regular intervals to improve precision in the values reported to your program.
|
||||
|
||||
### Handling imprecision
|
||||
|
||||
Unfortunately, the angle values returned from the [gyro sensor](https://education.lego.com/en-us/products/ev3-gyro-sensor-/45505) are going to have some inaccuracy even when calibrated. The error could be as muchs as 3 degrees in either direction of rotation (`3` or `-3` degrees). So, you need to decide how precise your angle measurments need to be and have your code handle the possiblity that angle values aren't always exact.
|
||||
|
||||
## ~
|
||||
|
||||
## Returns
|
||||
|
||||
* a [number](/types/number) that is the current angle of rotation in degrees.
|
||||
|
56
libs/music/shims.d.ts
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare namespace music {
|
||||
|
||||
/**
|
||||
* Set the output volume of the sound synthesizer.
|
||||
* @param volume the volume 0...100, eg: 50
|
||||
*/
|
||||
//% weight=96
|
||||
//% blockId=synth_set_volume block="set volume %volume"
|
||||
//% parts="speaker" blockGap=8
|
||||
//% volume.min=0 volume.max=100
|
||||
//% help=music/set-volume
|
||||
//% weight=1 shim=music::setVolume
|
||||
function setVolume(volume: int32): void;
|
||||
|
||||
/**
|
||||
* Play a tone through the speaker for some amount of time.
|
||||
* @param frequency pitch of the tone to play in Hertz (Hz)
|
||||
* @param ms tone duration in milliseconds (ms)
|
||||
*/
|
||||
//% help=music/play-tone
|
||||
//% blockId=music_play_note block="play tone|at %note=device_note|for %duration=device_beat"
|
||||
//% parts="headphone" async
|
||||
//% blockNamespace=music
|
||||
//% weight=76 blockGap=8 shim=music::playTone
|
||||
function playTone(frequency: int32, ms: int32): void;
|
||||
|
||||
/**
|
||||
* Play a tone through the speaker for some amount of time.
|
||||
*/
|
||||
//% help=music/stop-all-sounds
|
||||
//% blockId=music_stop_all_sounds block="stop all sounds"
|
||||
//% parts="headphone"
|
||||
//% blockNamespace=music
|
||||
//% weight=97 shim=music::stopAllSounds
|
||||
function stopAllSounds(): void;
|
||||
|
||||
/** Makes a sound bound to a buffer in WAV format. */
|
||||
//% shim=music::fromWAV
|
||||
function fromWAV(buf: Buffer): Sound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% fixedInstances
|
||||
declare interface Sound {
|
||||
/** Returns the underlaying Buffer object. */
|
||||
//% property shim=SoundMethods::buffer
|
||||
buffer: Buffer;
|
||||
|
||||
/** Play sound. */
|
||||
//% promise shim=SoundMethods::play
|
||||
play(): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
17
libs/storage/shims.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare namespace storage {
|
||||
|
||||
/** Will be moved. */
|
||||
//% shim=storage::__stringToBuffer
|
||||
function __stringToBuffer(s: string): Buffer;
|
||||
|
||||
/** Will be moved. */
|
||||
//% shim=storage::__bufferToString
|
||||
function __bufferToString(s: Buffer): string;
|
||||
|
||||
/** Create named directory. */
|
||||
//% shim=storage::__mkdir
|
||||
function __mkdir(filename: string): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
@ -3,10 +3,10 @@ tests.onEvent(TestEvent.RunSetUp, function() {
|
||||
console.sendToScreen();
|
||||
})
|
||||
tests.onEvent(TestEvent.TestSetUp, function() {
|
||||
motors.stopAllMotors();
|
||||
motors.stopAll();
|
||||
motors.resetAllMotors();
|
||||
})
|
||||
tests.onEvent(TestEvent.TestTearDown, function() {
|
||||
motors.stopAllMotors();
|
||||
motors.stopAll();
|
||||
motors.resetAllMotors();
|
||||
})
|
||||
|
@ -1,5 +1,18 @@
|
||||
# is Pressed
|
||||
|
||||
Check to see if a touch sensor is currently pressed or not.
|
||||
|
||||
```sig
|
||||
sensors.touch1.isPressed()
|
||||
```
|
||||
## Returns
|
||||
|
||||
* a [boolean](/types/boolean) value that is `true` if the sensor is currently pressed. It's `false` if the sensor is not pressed.
|
||||
|
||||
## Example
|
||||
|
||||
If the touch sensor ``touch 1`` is pressed, show a `green` status light. Otherwise, set the status light to `orange`.
|
||||
|
||||
```blocks
|
||||
loops.forever(function () {
|
||||
if (sensors.touch1.isPressed()) {
|
||||
@ -8,4 +21,8 @@ loops.forever(function () {
|
||||
brick.setStatusLight(StatusLight.Orange)
|
||||
}
|
||||
})
|
||||
```
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[was pressed](/reference/sensors/touch-sensor/was-pressed), [on event](/reference/sensors/touch-sensor/on-event)
|
@ -1,16 +1,33 @@
|
||||
# On Event
|
||||
# on Event
|
||||
|
||||
Run some code when a touch sensor is pressed, bumped, or released.
|
||||
|
||||
```sig
|
||||
sensors.touch1.onEvent(ButtonEvent.Released, function () { })
|
||||
sensors.touch1.onEvent(ButtonEvent.Bumped, function () {
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
# Parameters
|
||||
## Parameters
|
||||
|
||||
## Examples
|
||||
* **ev**: the touch sensor action to run some code for. The the touch actions (events) are:
|
||||
> * ``pressed``: the sensor was pressed, or pressed and released
|
||||
> * ``bumped``: the sensor was just bumped
|
||||
> * ``released``: the sensor was just released
|
||||
* **body**: the code you want to run when something happens to the touch sensor.
|
||||
|
||||
## Example
|
||||
|
||||
Check for an event on touch sensor ``touch 1``. Put an expression on the screen when the senosr is released.
|
||||
|
||||
```blocks
|
||||
sensors.touch1.onEvent(ButtonEvent.Released, function () {
|
||||
brick.showImage(images.expressionsSick)
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[is pressed](/reference/sensors/touch-sensor/is-pressed),
|
||||
[was pressed](/reference/sensors/touch-sensor/was-pressed),
|
||||
[pause until](/reference/sensors/touch-sensor/pause-until)
|
||||
|
@ -0,0 +1,37 @@
|
||||
# pause Until
|
||||
|
||||
Make your program wait until an event at a touch sensor happens.
|
||||
|
||||
```sig
|
||||
sensors.touch1.pauseUntil(ButtonEvent.Bumped);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
* **ev**: the touch sensor action to wait for. The the touch actions (events) are:
|
||||
> * ``pressed``: the sensor was pressed, or pressed and released
|
||||
> * ``bumped``: the sensor was just bumped
|
||||
> * ``released``: the sensor was just released
|
||||
|
||||
## Example
|
||||
|
||||
Wait for a bump to touch sensor `touch 1` before continuing with displaying a message on the screen.
|
||||
|
||||
```blocks
|
||||
let waitTime = 0;
|
||||
brick.showString("We're going to wait", 1);
|
||||
brick.showString("for you to bump the", 2);
|
||||
brick.showString("touch sensor on port 1", 3);
|
||||
waitTime = control.millis();
|
||||
sensors.touch1.pauseUntil(ButtonEvent.Bumped);
|
||||
brick.clearScreen();
|
||||
if (control.millis() - waitTime > 5000) {
|
||||
brick.showString("Ok, that took awhile!", 1)
|
||||
} else {
|
||||
brick.showString("Ah, you let go!", 1)
|
||||
}
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[on event](/reference/sensors/touch-sensor/on-event)
|
@ -1,5 +1,21 @@
|
||||
# was Pressed
|
||||
|
||||
See if a touch sensor was pressed since the last time it was checked.
|
||||
|
||||
```sig
|
||||
sensors.touch1.wasPressed()
|
||||
```
|
||||
|
||||
If a touch sensor was pressed, then that event is remembered. Once you check if a touch sensor **was pressed**, that status is set back to `false`. If you check again before the sensor is touched another time, the **was pressed** status is `false`. Only when the sensor is touched will the **was pressed** status go to `true`.
|
||||
|
||||
## Returns
|
||||
|
||||
* a [boolean](/types/boolean) value that is `true` if the sensor is was pressed before. It's `false` if the sensor was not pressed.
|
||||
|
||||
## Example
|
||||
|
||||
If the touch sensor ``touch 1`` was pressed, show a `green` status light. Otherwise, set the status light to `orange`.
|
||||
|
||||
```blocks
|
||||
loops.forever(function () {
|
||||
if (sensors.touch1.wasPressed()) {
|
||||
@ -7,5 +23,10 @@ loops.forever(function () {
|
||||
} else {
|
||||
brick.setStatusLight(StatusLight.Orange)
|
||||
}
|
||||
loops.pause(500)
|
||||
})
|
||||
```
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[is pressed](/reference/sensors/touch-sensor/is-pressed), [on event](/reference/sensors/touch-sensor/on-event)
|
@ -29,7 +29,7 @@ namespace sensors {
|
||||
* @param event the kind of button gesture that needs to be detected
|
||||
* @param body code to run when the event is raised
|
||||
*/
|
||||
//% help=input/touch-sensor/on-event
|
||||
//% help=sensors/touch-sensor/on-event
|
||||
//% blockId=touchEvent block="on %sensor|%event"
|
||||
//% parts="touch"
|
||||
//% blockNamespace=sensors
|
||||
@ -45,7 +45,7 @@ namespace sensors {
|
||||
* @param sensor the touch sensor that needs to be clicked or used
|
||||
* @param event the kind of button gesture that needs to be detected
|
||||
*/
|
||||
//% help=input/touch-sensor/pause-until
|
||||
//% help=sensors/touch-sensor/pause-until
|
||||
//% blockId=touchWaitUntil block="pause until %sensor|%event"
|
||||
//% parts="touch"
|
||||
//% blockNamespace=sensors
|
||||
@ -60,7 +60,7 @@ namespace sensors {
|
||||
* Check if touch sensor is touched.
|
||||
* @param sensor the port to query the request
|
||||
*/
|
||||
//% help=input/touch-sensor/is-pressed
|
||||
//% help=sensors/touch-sensor/is-pressed
|
||||
//% block="%sensor|is pressed"
|
||||
//% blockId=touchIsPressed
|
||||
//% parts="touch"
|
||||
@ -76,7 +76,7 @@ namespace sensors {
|
||||
* Check if touch sensor is touched since it was last checked.
|
||||
* @param sensor the port to query the request
|
||||
*/
|
||||
//% help=input/touch-sensor/was-pressed
|
||||
//% help=sensors/touch-sensor/was-pressed
|
||||
//% block="%sensor|was pressed"
|
||||
//% blockId=touchWasPressed
|
||||
//% parts="touch"
|
||||
|
13
libs/ultrasonic-sensor/docs/reference/sensors/ultrasonic.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Ultrasonic sensor
|
||||
|
||||
```cards
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectDetected, function () {});
|
||||
sensors.ultrasonic1.distance();
|
||||
sensors.ultrasonic1.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
[on event](/reference/sensors/ultrasonic/on-event),
|
||||
[distance](reference/sensors/ultrasonic/distance),
|
||||
[pause until](reference/sensors/ultrasonic/pause-until)
|
@ -0,0 +1,30 @@
|
||||
# distance
|
||||
|
||||
The distance of an object detected by the ultrasonic sensor.
|
||||
|
||||
```sig
|
||||
sensors.ultrasonic1.distance()
|
||||
```
|
||||
|
||||
The distance value returned is the number of centimeters to the object that the sensor is currently detecting.
|
||||
|
||||
## Returns
|
||||
|
||||
* a [number](/types/number) that is the distance of the object detected by the ultrasonic sensor in centimeters.
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
When the ultrasonic sensor on port 4 detects a far object, display its distance on the screen.
|
||||
|
||||
```blocks
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectFar, function () {
|
||||
brick.showString("Object detected at:", 1)
|
||||
brick.showNumber(sensors.ultrasonic4.distance(), 2)
|
||||
brick.showString("centimeters", 3)
|
||||
})
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[on event](/reference/sensors/ultrasonic/on-event), [pause until](/reference/sensors/ultrasonic/pause-until)
|
@ -0,0 +1,39 @@
|
||||
# on Event
|
||||
|
||||
Run some code when an object is detected by the ultrasonic sensor.
|
||||
|
||||
```sig
|
||||
sensors.ultrasonic1.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
|
||||
```
|
||||
|
||||
How an object is detected depends on the distance and movement _thresholds_ set for the sensor. A threshold is a number that is some distance in centimeters or the strength of ultrasonic sound. You can set a distance to detect something that is far, near, or is sending out ultrasound (like the sensor of another robot in the area). The three thresholds you can set are:
|
||||
|
||||
* **near**: a distance to set to detect objects coming close
|
||||
* **far**: a distance to set to detect objects farther away but not as close as the **near** threshold
|
||||
* **detected**: the strength of ultrasound to needed to detect presence of another ultrasonic sensor
|
||||
|
||||
Both **near** and **far** have distance thresholds set in centimeters. The **detect** threshold is a value of strength the ultrasonic sound in decibels.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **event**: the object detection action to wait for. The detection types (events) are:
|
||||
> * ``object detected``: some other object is sending out an ultrasonic sound
|
||||
> * ``object near``: the sensor detected something within the distance of the near threshold
|
||||
> * ``object far``: the sensor detected somethin within the distance of the far threshold
|
||||
* **body**: the code you want to run when something happens to the touch sensor.
|
||||
|
||||
## Example
|
||||
|
||||
When the ultrasonic sensor on port 4 detects a far object, display its distance on the screen.
|
||||
|
||||
```blocks
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectFar, function () {
|
||||
brick.showString("Object detected at:", 1)
|
||||
brick.showNumber(sensors.ultrasonic4.distance(), 2)
|
||||
brick.showString("centimeters", 3)
|
||||
})
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[pause until](/reference/sensors/ultrasonic/pause-until)
|
@ -0,0 +1,38 @@
|
||||
# pause Until
|
||||
|
||||
Make your program wait until an some object is detected in proximity of the sensor.
|
||||
|
||||
```sig
|
||||
sensors.ultrasonic1.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
|
||||
```
|
||||
|
||||
How an object is detected depends on the distance and movement _thresholds_ set for the sensor. A threshold is a number that is some distance in centimeters or the strength of ultrasonic sound. You can set a distance to detect something that is far, near, or is sending out ultrasound (like the sensor of another robot in the area). The three thresholds you can set are:
|
||||
|
||||
* **near**: a distance to set to detect objects coming close
|
||||
* **far**: a distance to set to detect objects farther away but not as close as the **near** threshold
|
||||
* **detected**: the strength of ultrasound to needed to detect presence of another ultrasonic sensor
|
||||
|
||||
Both **near** and **far** have distance thresholds set in centimeters. The **detect** threshold is a value of strength the ultrasonic sound in decibels.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **event**: the object detection action to wait for. The detection types (events) are:
|
||||
> * ``object detected``: some other object is sending out an ultrasonic sound
|
||||
> * ``object near``: the sensor detected something within the distance of the near threshold
|
||||
> * ``object far``: the sensor detected somethin within the distance of the far threshold
|
||||
|
||||
## Example
|
||||
|
||||
Wait for another object sending out ultrasonic sound. Show a message on the screen when it's dectected.
|
||||
|
||||
```blocks
|
||||
brick.showString("Waiting for another", 1);
|
||||
brick.showString("robot to appear...", 2);
|
||||
sensors.ultrasonic1.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
|
||||
brick.showString("Hey, I just heard", 1)
|
||||
brick.showString("Something!", 2);
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[on event](/reference/sensors/ultrasonic/on-event)
|
@ -41,7 +41,7 @@ namespace sensors {
|
||||
* Registers code to run when the given color is close
|
||||
* @param handler the code to run when detected
|
||||
*/
|
||||
//% help=input/ultrasonic/on
|
||||
//% help=sensors/ultrasonic/on-event
|
||||
//% blockId=ultrasonicOn
|
||||
//% block="on %sensor|%event"
|
||||
//% parts="ultrasonicsensor"
|
||||
@ -56,7 +56,7 @@ namespace sensors {
|
||||
/**
|
||||
* Waits for the event to occur
|
||||
*/
|
||||
//% help=input/ultrasonic/wait
|
||||
//% help=sensors/ultrasonic/pause-until
|
||||
//% block="pause until %sensor| %event"
|
||||
//% blockId=ultrasonicWait
|
||||
//% parts="ultrasonicsensor"
|
||||
@ -72,7 +72,7 @@ namespace sensors {
|
||||
* Gets the distance from the sonar in centimeters
|
||||
* @param sensor the ultrasonic sensor port
|
||||
*/
|
||||
//% help=input/ultrasonic/distance
|
||||
//% help=sensors/ultrasonic/distance
|
||||
//% block="%sensor|distance"
|
||||
//% blockId=sonarGetDistance
|
||||
//% parts="ultrasonicsensor"
|
||||
|
2173
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.0.96",
|
||||
"version": "0.0.101",
|
||||
"description": "LEGO Mindstorms EV3 for Microsoft MakeCode",
|
||||
"private": true,
|
||||
"keywords": [
|
||||
@ -21,6 +21,7 @@
|
||||
"files": [
|
||||
"README.md",
|
||||
"pxtarget.json",
|
||||
"targetconfig.json",
|
||||
"built/*.js",
|
||||
"built/*.json",
|
||||
"built/*.d.ts",
|
||||
@ -44,8 +45,8 @@
|
||||
"webfonts-generator": "^0.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-common-packages": "0.18.1",
|
||||
"pxt-core": "3.3.1"
|
||||
"pxt-common-packages": "0.19.4",
|
||||
"pxt-core": "3.4.3"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||
|
@ -38,7 +38,7 @@
|
||||
"packages": true,
|
||||
"sharing": true,
|
||||
"publishing": true,
|
||||
"importing": false,
|
||||
"importing": true,
|
||||
"preferredPackages": [],
|
||||
"githubPackages": true
|
||||
},
|
||||
@ -127,7 +127,8 @@
|
||||
"invertedMenu": false,
|
||||
"invertedMonaco": false,
|
||||
"monacoToolbox": true,
|
||||
"invertedToolbox": true,
|
||||
"invertedToolbox": false,
|
||||
"coloredToolbox": true,
|
||||
"hasAudio": true,
|
||||
"usbHelp": [],
|
||||
"extendEditor": true,
|
||||
@ -162,5 +163,5 @@
|
||||
"editor.background": "#ecf6ff"
|
||||
}
|
||||
},
|
||||
"ignoreDocsErrors": false
|
||||
"ignoreDocsErrors": true
|
||||
}
|
||||
|
@ -86,9 +86,11 @@ namespace pxsim.visuals {
|
||||
private prevVal: number;
|
||||
private updateSliderValue(pt: SVGPoint, parent: SVGSVGElement, ev: MouseEvent) {
|
||||
let cur = svg.cursorPoint(pt, parent, ev);
|
||||
let bBox = this.content.getBoundingClientRect();
|
||||
|
||||
const coords = {
|
||||
x: cur.x / this.scaleFactor - this.left / this.scaleFactor,
|
||||
y: cur.y / this.scaleFactor - this.top / this.scaleFactor
|
||||
x: cur.x / this.scaleFactor - bBox.left / this.scaleFactor,
|
||||
y: cur.y / this.scaleFactor - bBox.top / this.scaleFactor
|
||||
};
|
||||
const radius = MotorSliderControl.SLIDER_RADIUS / 2;
|
||||
const dx = coords.x - radius;
|
||||
|
@ -76,7 +76,7 @@ namespace pxsim.visuals {
|
||||
let t = Math.max(0, Math.min(1, (width + bBox.left / this.scaleFactor - cur.x / this.scaleFactor) / width))
|
||||
|
||||
const state = this.state;
|
||||
state.setAngle((1 - t) * (100));
|
||||
state.setRate((1 - t) * (100));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,9 @@
|
||||
]
|
||||
},
|
||||
"galleries": {
|
||||
"Maker Activities": "maker",
|
||||
"Coding Activites": "coding",
|
||||
"Lessons": "lessons"
|
||||
"Getting Started": "getting-started",
|
||||
"Design Engineering": "design-engineering",
|
||||
"Coding": "coding",
|
||||
"Maker": "maker"
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ span.blocklyTreeIcon {
|
||||
/*box-shadow: inset 0px 0px 0px 2px #D3A805;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-bottom-right-radius: 3px;*/
|
||||
box-shadow: 3px 0 1px -2px @legoGreyLight;
|
||||
}
|
||||
|
||||
div.blocklyTreeRow {
|
||||
@ -39,10 +40,14 @@ div.blocklyTreeRow {
|
||||
/*-webkit-box-shadow: inset 0px 0px 0px 3px rgba(0,0,0,0.2);
|
||||
-moz-box-shadow: inset 0px 0px 0px 3px rgba(0,0,0,0.2);
|
||||
box-shadow: inset 0px 0px 0px 3px rgba(0,0,0,0.2);*/
|
||||
|
||||
border: none !important;
|
||||
border-bottom: 1px solid #EBEBEB !important;
|
||||
}
|
||||
|
||||
div.blocklyTreeSeparator {
|
||||
border-bottom: solid #CEA403 2px;
|
||||
border: none;
|
||||
/*border-bottom: solid #CEA403 2px;*/
|
||||
}
|
||||
|
||||
/* Remove shadow around blockly blocks */
|
||||
@ -66,9 +71,9 @@ span.blocklyTreeLabel {
|
||||
}
|
||||
.blocklySearchInputField {
|
||||
border-radius: 1rem !important;
|
||||
border: 1px solid #ebebeb !important;
|
||||
}
|
||||
|
||||
|
||||
/* Square shaped corners */
|
||||
.blocklyDropDownDiv {
|
||||
border-radius: 0px !important;
|
||||
|
@ -8,6 +8,6 @@
|
||||
}
|
||||
|
||||
#mainmenu {
|
||||
background: #f4f7f9;
|
||||
background: @legoGreyLight;
|
||||
border-bottom: 5px solid #00a5c8;
|
||||
}
|
@ -27,9 +27,11 @@
|
||||
@orange: #fa7f2a;
|
||||
@green: @brightYellowishGreen;
|
||||
|
||||
@legoGreyLight: #eaeeef;
|
||||
@legoGreyLight: #F4F1F4;
|
||||
@legoGreyDark: #f4f7f9;
|
||||
|
||||
@grey: @legoGreyLight;
|
||||
|
||||
/* Lego official colors */
|
||||
|
||||
/* Solid */
|
||||
@ -126,7 +128,7 @@
|
||||
--------------------*/
|
||||
|
||||
@simulatorBackground: #D6EDFF; /* #FFF */ /* #fcfbfa; */
|
||||
@editorToolsBackground: #fff; /* #fcfbfa; */
|
||||
@editorToolsBackground: @legoGreyLight; /* #fff;*/ /* #fcfbfa; */
|
||||
@blocklySvgColor: #f9f9f9; /*#f2f6f8;*/ /*ecf6fe;*/
|
||||
|
||||
@homeScreenBackground: #EAEEEF;
|
||||
@ -149,8 +151,8 @@
|
||||
Editor
|
||||
--------------------*/
|
||||
|
||||
@blocklyToolboxColor: #FAC80A;
|
||||
@trashIconColor: white;
|
||||
@blocklyToolboxColor: #FFF; /*#FAC80A;*/
|
||||
@trashIconColor: #FAC80A; /*white*/
|
||||
|
||||
|
||||
/*-------------------
|
||||
|
@ -29,11 +29,23 @@
|
||||
&:extend(.ui.primary.button all);
|
||||
}
|
||||
|
||||
.ui.button.editortools-btn {
|
||||
&:extend(.ui.blue.button all);
|
||||
@buttonBackgroundColor: white;
|
||||
@buttonForegroundColor: #5E5E5E;
|
||||
|
||||
.ui.button.editortools-btn, .simtoolbar .ui.button,
|
||||
.ui.button.collapse-button, .ui.button.collapsed-button {
|
||||
background-color: @buttonBackgroundColor;
|
||||
color: @buttonForegroundColor;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
.ui.button.editortools-btn:hover,
|
||||
.ui.button.editortools-btn:focus {
|
||||
color: darken(@buttonForegroundColor, 0.2) !important;
|
||||
}
|
||||
|
||||
.projectname-input {
|
||||
.ui.input.projectname-input input {
|
||||
box-shadow: none; border: none !important;
|
||||
}
|
||||
|
||||
.ui.button.getting-started-btn {
|
||||
@ -93,7 +105,7 @@
|
||||
}
|
||||
|
||||
#downloadArea {
|
||||
background: white;
|
||||
background: @legoGreyLight;
|
||||
}
|
||||
|
||||
/* Mobile */
|
||||
@ -109,15 +121,18 @@
|
||||
|
||||
/* Small Monitor */
|
||||
@media only screen and (min-width: @computerBreakpoint) and (max-width: @largestSmallMonitor) {
|
||||
#editortools, #downloadArea {
|
||||
background: #828A95;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Large Monitor */
|
||||
@media only screen and (min-width: @largeMonitorBreakpoint) {
|
||||
#editortools, #downloadArea {
|
||||
background: #828A95;
|
||||
|
||||
}
|
||||
|
||||
/* >= Small Monitor (Small Monitor + Large Monitor + Wide Monitor) */
|
||||
@media only screen and (min-width: @computerBreakpoint) {
|
||||
.fullscreensim #boardview {
|
||||
background: @simulatorBackground data-uri("../docs/static/backgrounds/simulator.png") 0 0 repeat !important;
|
||||
}
|
||||
}
|
||||
/* Mobile, Tablet AND thin screen */
|
||||
|