Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
fc877b889c | |||
49dc3b0a75 | |||
994e57c395 | |||
a6298078ba | |||
acc55506cb | |||
0c7d31770d | |||
8c2ede17a0 | |||
be55a342ff | |||
d356c87c83 | |||
2abf59010e | |||
9360f938b7 | |||
3006af3e63 | |||
d5b55585cd | |||
ab3c4c5267 | |||
6d07d5bd23 | |||
eb45a76928 | |||
fcba14aae1 | |||
44c68a7c0e | |||
d4b3ebc2e4 | |||
fa5ba504c5 | |||
2d639b9a90 | |||
f8b8fbb1b4 | |||
594ead703c | |||
5f05934dda | |||
3e0ca1acb9 | |||
c2d26a8418 | |||
5bd9705966 | |||
1160d73b16 | |||
a2218d9ba5 | |||
54576ae77a | |||
f16549d7cd | |||
a021c0b292 | |||
cda7013e96 | |||
2f0fefbeaf | |||
b5303a660b | |||
a60958f72a | |||
33dcb6deee | |||
130a47d684 | |||
2d355bb2ca | |||
8ee63df325 | |||
7d16cf10ac | |||
60ec3f1c99 | |||
6524b0a841 | |||
d778232155 |
@ -13,7 +13,7 @@
|
||||
|
||||
* [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 It Smarter and Faster](/design-engineering/make-it-smarter)
|
||||
* [Make a System that Communicates](/design-engineering/make-it-communicate)
|
||||
|
||||
* [Maker](/maker)
|
||||
@ -41,12 +41,8 @@
|
||||
* [Reverse Beeper 1](/coding/reverse-beeper-1)
|
||||
* [Reverse Beeper 2](/coding/reverse-beeper-2)
|
||||
* [Reverse Beeper 3](/coding/reverse-beeper-3)
|
||||
* [Ignition 1](/coding/ignition-1)
|
||||
* [Ignition 2](/coding/ignition-2)
|
||||
* [Ignition 3](/coding/ignition-3)
|
||||
* [Cruise Control 1](/coding/cruise-control-1)
|
||||
* [Cruise Control 2](/coding/cruise-control-2)
|
||||
* [Cruise Control 3](/coding/cruise-control-3)
|
||||
* [Ignition](/coding/ignition)
|
||||
* [Cruise Control](/coding/cruise-control)
|
||||
* [Roaming 1](/coding/roaming-1)
|
||||
* [Roaming 2](/coding/roaming-2)
|
||||
|
||||
@ -111,3 +107,25 @@
|
||||
* [pause for light](/reference/sensors/color-sensor/pause-for-light)
|
||||
* [color](/reference/sensors/color-sensor/color)
|
||||
* [light](/reference/sensors/color-sensor/ambient-light)
|
||||
* [Music](/reference/music)
|
||||
* [play sound effect](/reference/music/play-sound-effect)
|
||||
* [play sound effect until done](/reference/music/play-sound-effect-until-done)
|
||||
* [play tone](/reference/music/play-tone)
|
||||
* [ring tone](/reference/music/ring-tone)
|
||||
* [stop all sounds](/reference/music/stop-all-sounds)
|
||||
* [rest](/reference/music/rest)
|
||||
* [change tempo by](/reference/music/change-tempo-by)
|
||||
* [set tempo](/reference/music/set-tempo)
|
||||
* [note frequency](/reference/music/note-frequency)
|
||||
* [beat](/reference/music/beat)
|
||||
* [set volume](/reference/music/set-volume)
|
||||
* [Control](/reference/control)
|
||||
* [Timer](/reference/control/timer)
|
||||
* [seconds](/reference/control/timer/seconds)
|
||||
* [millis](/reference/control/timer/millis)
|
||||
* [reset](/reference/control/timer/reset)
|
||||
* [pause until](/reference/control/timer/pause-until)
|
||||
* [Console](/reference/console)
|
||||
* [log](/reference/console/log)
|
||||
* [log value](/reference/console/log-value)
|
||||
* [send to screen](/reference/console/send-to-screen)
|
||||
|
@ -7,18 +7,21 @@
|
||||
[
|
||||
{
|
||||
"name": "Autonomous Parking",
|
||||
"description": "TBD",
|
||||
"description": "Design cars that can park by themselves",
|
||||
"url":"/coding/autonomous-parking",
|
||||
"imageUrl": "/static/lessons/autonomous-parking.png",
|
||||
"cardType": "side"
|
||||
}, {
|
||||
"name": "Object Detection",
|
||||
"description": "TBD",
|
||||
"url":"/coding/object-detection",
|
||||
"imageUrl": "/static/lessons/object-detection.jpg",
|
||||
"cardType": "side"
|
||||
}, {
|
||||
"name": "Line Following",
|
||||
"description": "TBD",
|
||||
"url":"/coding/line-following",
|
||||
"url":"/coding/line-detection",
|
||||
"imageUrl": "/static/lessons/line-detection.jpg",
|
||||
"cardType": "side"
|
||||
}]
|
||||
```
|
||||
|
172
docs/coding/autonomous-parking.md
Normal file
@ -0,0 +1,172 @@
|
||||
# Autonomous Parking
|
||||
|
||||
Design cars that can park themselves safely without driver intervention.
|
||||
|
||||

|
||||
|
||||
## Connect
|
||||
|
||||
**Think about:**
|
||||
|
||||
* How do autonomous cars work?
|
||||
* What would it take to ensure that autonomous cars are safe?
|
||||
* What types of movements do autonomous cars need to perform?
|
||||
|
||||
## Construct
|
||||
|
||||
### Build
|
||||
|
||||
Build a LEGO MINDSTORMS vehicle that can park itself safely without driver intervention.
|
||||
Start by constructing this [model](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf).
|
||||
|
||||

|
||||
|
||||
### Checks
|
||||
|
||||
Before you program, check:
|
||||
|
||||
* Are all the wires correctly connected from the motors to ports B and C?
|
||||
* Are the wheels correctly installed?
|
||||
* Are the wheels rotating freely?
|
||||
|
||||
### Program
|
||||
|
||||
Write a program that will make the robot turn three times in various ways.
|
||||
|
||||
**Think about:**
|
||||
|
||||
* How will you make the robot turn in different ways?
|
||||
* How can the robot make a three point turn?
|
||||
|
||||
### ~hint
|
||||
|
||||
Consider using these blocks in your solution:
|
||||
|
||||
```block
|
||||
motors.largeBC.tank(50, 50)
|
||||
pause(500)
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
### Sample Solution - Three Point Turn
|
||||
|
||||
1. When the brick button is pressed, turn the driving base right and stop after 1.5 seconds.
|
||||
2. Turn the driving base left and stop after 1 second.
|
||||
3. Move the driving base forward for 3 seconds.
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeBC.tank(75, 30)
|
||||
loops.pause(1500)
|
||||
motors.largeBC.tank(-30, -75)
|
||||
loops.pause(1000)
|
||||
motors.largeBC.tank(50, 50)
|
||||
loops.pause(3000)
|
||||
})
|
||||
```
|
||||
### Download and test
|
||||
|
||||
Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
## Contemplate
|
||||
|
||||
Choose one of the following autonomous driving scenarios and create a program for it:
|
||||
|
||||
* Parallel parking
|
||||
* Angle parking
|
||||
* Perpendicular parking
|
||||
|
||||
### ~hint
|
||||
|
||||
Document pseudocode for your program before choosing programming blocks.
|
||||
|
||||
### ~
|
||||
|
||||
### Sample Solution - Parallel Parking
|
||||
|
||||
1. When the brick button is pressed, drive forward in a straight line for 3 rotations.
|
||||
2. Wait for 1 second.
|
||||
3. Reverse motor rotation while turning for 1.5 rotations.
|
||||
4. Reverse motor rotation while turning the other way for 1.5 rotations.
|
||||
5. Drive backward in a straight line for 0.5 rotations.
|
||||
6. Drive forward in a straight line for 0.5 rotations.
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeBC.steer(0, 50, 3, MoveUnit.Rotations)
|
||||
pause(1000)
|
||||
motors.largeBC.steer(-50, -50, 1.5, MoveUnit.Rotations)
|
||||
motors.largeBC.steer(50, -50, 1.5, MoveUnit.Rotations)
|
||||
motors.largeBC.steer(0, -50, 0.5, MoveUnit.Rotations)
|
||||
motors.largeBC.steer(0, 50, 0.5, MoveUnit.Rotations)
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
### Differentiation
|
||||
|
||||
Create a program that simulates displaying appropriate warning lights while parking.
|
||||
|
||||
### ~hint
|
||||
|
||||
Consider using this block in your solution:
|
||||
|
||||
```block
|
||||
brick.setStatusLight(StatusLight.OrangeFlash)
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
### Sample Solution - Simulating Reverse Gear and Reverse Warning Lights
|
||||
|
||||
1. When the brick button is pressed, drive forward in a straight line for 3 rotations.
|
||||
2. Wait for 1 second.
|
||||
3. Set brick status light to orange flash.
|
||||
4. Reverse motor rotation while turning for 1.5 rotations.
|
||||
5. Reverse motor rotation while turning the other way for 1.5 rotations.
|
||||
6. Drive backward in a straight line for 0.5 rotations.
|
||||
7. Set brick status light to off.
|
||||
8. Drive forward in a straight line for 0.5 rotations.
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeBC.steer(0, 50, 3, MoveUnit.Rotations)
|
||||
pause(1000)
|
||||
brick.setStatusLight(StatusLight.OrangeFlash)
|
||||
motors.largeBC.steer(-50, -50, 1.5, MoveUnit.Rotations)
|
||||
motors.largeBC.steer(50, -50, 1.5, MoveUnit.Rotations)
|
||||
motors.largeBC.steer(0, -50, 0.5, MoveUnit.Rotations)
|
||||
brick.setStatusLight(StatusLight.Off)
|
||||
motors.largeBC.steer(0, 50, 0.5, MoveUnit.Rotations)
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
### Share
|
||||
|
||||
**Think about:**
|
||||
|
||||
* What challenged you?
|
||||
* Were there any surprises?
|
||||
* How can you improve your program?
|
||||
* Can your program be more streamlined? Have you used too many blocks?
|
||||
* Is there a more efficient way to build your program?
|
||||
* How can your program be used in real-world scenarios?
|
||||
|
||||
|
||||
## Continue
|
||||
|
||||
* Click on the JavaScript tab and experiment with changing the values in the code.
|
||||
* Add a custom image or sounds from the Brick or Music menus.
|
||||
* Create a video of your project, especially your final presentation and your robot’s performance. Explain some important features of your software program.
|
||||
* Include an image of your program with comments.
|
||||
* Add a team photograph!
|
||||
|
||||
Congratulations! What will you design next?
|
@ -1,10 +0,0 @@
|
||||
# Cruise Control Activity 1
|
||||
|
||||
```blocks
|
||||
let speed = 0;
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
if (speed < 100)
|
||||
speed = speed + 10;
|
||||
motors.largeBC.run(speed);
|
||||
})
|
||||
```
|
@ -1,15 +0,0 @@
|
||||
# Cruise Control Activity 2
|
||||
|
||||
```blocks
|
||||
let speed = 0;
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
if (speed < 100)
|
||||
speed = speed + 10;
|
||||
motors.largeBC.run(speed);
|
||||
})
|
||||
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
|
||||
if (speed > -100)
|
||||
speed = speed - 10;
|
||||
motors.largeBC.run(speed);
|
||||
})
|
||||
```
|
@ -1,28 +0,0 @@
|
||||
# Cruise Control Activity 3
|
||||
|
||||
```blocks
|
||||
let speed = 0
|
||||
function decelerate() {
|
||||
if (speed > -100) {
|
||||
speed = speed - 10
|
||||
}
|
||||
}
|
||||
function accelerate() {
|
||||
if (speed < 100) {
|
||||
speed = speed + 10
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
brick.clearScreen()
|
||||
brick.showString("speed: " + speed, 1)
|
||||
motors.largeBC.run(speed)
|
||||
}
|
||||
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
|
||||
accelerate()
|
||||
update()
|
||||
})
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
decelerate()
|
||||
update()
|
||||
})
|
||||
```
|
65
docs/coding/cruise-control.md
Normal file
@ -0,0 +1,65 @@
|
||||
# Cruise Control
|
||||
|
||||
Learn how to set and adjust motor speeds.
|
||||
|
||||
## Activity 1
|
||||
|
||||
Increase motor speed when touch sensor `1` is pressed.
|
||||
|
||||
```blocks
|
||||
let speed = 0;
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
if (speed < 100)
|
||||
speed = speed + 10;
|
||||
motors.largeBC.run(speed);
|
||||
})
|
||||
```
|
||||
|
||||
## Activity 2
|
||||
|
||||
Add a "reduce" motor speed action when touch sensor `2` is pressed.
|
||||
|
||||
```blocks
|
||||
let speed = 0;
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
if (speed < 100)
|
||||
speed = speed + 10;
|
||||
motors.largeBC.run(speed);
|
||||
})
|
||||
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
|
||||
if (speed > -100)
|
||||
speed = speed - 10;
|
||||
motors.largeBC.run(speed);
|
||||
})
|
||||
```
|
||||
|
||||
## Activity 3
|
||||
|
||||
Refactor your code by moving the speed increase and speed decrease code into ``||functions:accelerate||`` and ``||functions:decelerate||`` functions. Run the motors at the new speed in an ``||functions:update||`` function.
|
||||
|
||||
```blocks
|
||||
let speed = 0
|
||||
function decelerate() {
|
||||
if (speed > -100) {
|
||||
speed = speed - 10
|
||||
}
|
||||
}
|
||||
function accelerate() {
|
||||
if (speed < 100) {
|
||||
speed = speed + 10
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
brick.clearScreen()
|
||||
brick.showString("speed: " + speed, 1)
|
||||
motors.largeBC.run(speed)
|
||||
}
|
||||
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
|
||||
accelerate()
|
||||
update()
|
||||
})
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
decelerate()
|
||||
update()
|
||||
})
|
||||
```
|
@ -1,11 +0,0 @@
|
||||
# Ignition Activity 1
|
||||
|
||||
```blocks
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
brick.showImage(images.eyesDizzy)
|
||||
})
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectDetected, function () {
|
||||
brick.showImage(images.eyesTiredMiddle)
|
||||
})
|
||||
brick.showImage(images.eyesSleeping)
|
||||
```
|
@ -1,12 +0,0 @@
|
||||
# Ignition Activity 2
|
||||
|
||||
```blocks
|
||||
while (true) {
|
||||
if (sensors.touch1.wasPressed() &&
|
||||
sensors.ultrasonic4.distance() < 10) {
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
|
||||
}
|
||||
pause(1);
|
||||
}
|
||||
```
|
@ -1,13 +0,0 @@
|
||||
# Ignition Activity 3
|
||||
|
||||
```blocks
|
||||
while (true) {
|
||||
if (sensors.ultrasonic4.distance() < 10 &&
|
||||
sensors.touch1.wasPressed() &&
|
||||
brick.buttonEnter.wasPressed()) {
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
|
||||
}
|
||||
pause(1);
|
||||
}
|
||||
```
|
48
docs/coding/ignition.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Ignition
|
||||
|
||||
Explore sensor events and sensor status.
|
||||
|
||||
## Activity 1
|
||||
|
||||
Wait for a touch sensor press or ultrasonic object detection. Show an expression on the screen when they happen.
|
||||
|
||||
```blocks
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
brick.showImage(images.eyesDizzy)
|
||||
})
|
||||
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectDetected, function () {
|
||||
brick.showImage(images.eyesTiredMiddle)
|
||||
})
|
||||
brick.showImage(images.eyesSleeping)
|
||||
```
|
||||
|
||||
## Activity 2
|
||||
|
||||
Play some motor sounds if touch sensor `1` is pressed at the same moment when and object comes close.
|
||||
|
||||
```blocks
|
||||
while (true) {
|
||||
if (sensors.touch1.wasPressed() &&
|
||||
sensors.ultrasonic4.distance() < 10) {
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
|
||||
}
|
||||
pause(1);
|
||||
}
|
||||
```
|
||||
|
||||
## Activity 3
|
||||
|
||||
Play some motor sounds if touch sensor `1` is pressed when both the `enter` button is pressed on the brick and an object comes close.
|
||||
|
||||
```blocks
|
||||
while (true) {
|
||||
if (sensors.ultrasonic4.distance() < 10 &&
|
||||
sensors.touch1.wasPressed() &&
|
||||
brick.buttonEnter.wasPressed()) {
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
|
||||
}
|
||||
pause(1);
|
||||
}
|
||||
```
|
238
docs/coding/line-detection.md
Normal file
@ -0,0 +1,238 @@
|
||||
# Line Detection
|
||||
|
||||
Design ways to improve driving safety by helping to prevent drivers from falling asleep and causing an accident.
|
||||
|
||||

|
||||
|
||||
## Connect
|
||||
|
||||
Think about:
|
||||
|
||||
* How can autonomous cars react to different traffic light signals?
|
||||
* What can happen if a driver falls asleep while driving?
|
||||
* How can we detect when a driver is falling asleep?
|
||||
|
||||
## Construct
|
||||
|
||||
### Build
|
||||
|
||||
Build a LEGO MINDSTORMS vehicle that can help prevent drivers from falling asleep and causing an accident.
|
||||
|
||||
Start by constructing this [model](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-color-sensor-down-driving-base-d30ed30610c3d6647d56e17bc64cf6e2.pdf):
|
||||
|
||||

|
||||
|
||||
Build red and green “lights” for your robot to detect. You can use LEGO bricks, colored tape, or marker on white paper. Read the building [instructions](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/color%20squares-0a88dfd98bb2e64b5b8151fc422bae36.pdf).
|
||||
|
||||

|
||||
|
||||
Before you program, check:
|
||||
|
||||
* Are all the wires correctly connected from the motors to ports B and C?
|
||||
* Are the wheels correctly installed?
|
||||
* Are the wheels rotating freely?
|
||||
* Are the wires connected from the Color Sensor to port 3?
|
||||
|
||||

|
||||
|
||||
### Program
|
||||
|
||||
Autonomous cars need to recognize and respond to traffic lights automatically. Create a program that will make your robot stop at red lights. Make sure your robot is only responding to the color red. Once you have succeeded, program your robot to drive forward again when the light changes from red to green.
|
||||
|
||||
Before you program, think about:
|
||||
|
||||
* How will you program the robot to detect a color?
|
||||
* How will you program the robot to stop at a color?
|
||||
* Which programming blocks will you use?
|
||||
|
||||
### ~ hint
|
||||
|
||||
Consider using these blocks in your solution:
|
||||
|
||||
```block
|
||||
loops.forever(function () {
|
||||
|
||||
})
|
||||
motors.largeBC.steer(0, 50)
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
### Sample Solution - Red light detection
|
||||
|
||||
1. Loop forever.
|
||||
2. Start motors ``B`` and ``C`` (drive forward).
|
||||
3. Wait for the color sensor to detect the color red.
|
||||
4. Stop all motors.
|
||||
|
||||
```blocks
|
||||
loops.forever(function () {
|
||||
motors.largeBC.steer(0, 50)
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
motors.stopAll()
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick.
|
||||
|
||||
Congratulations! Your robot can stop at a red light.
|
||||
|
||||
Now add to your program and have your robot to drive forward again when the light changes from red to green.
|
||||
|
||||
### Sample Solution - Red and green light detection in a loop
|
||||
|
||||
1. Start motors ``B`` and ``C`` (drive forward).
|
||||
2. Wait for the color sensor to detect the color red.
|
||||
3. Stop all motors.
|
||||
4. Wait for the color sensor to detect the color green.
|
||||
5. Loop forever.
|
||||
|
||||
```blocks
|
||||
loops.forever(function () {
|
||||
motors.largeBC.steer(0, 50)
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
motors.stopAll()
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Green)
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick.
|
||||
|
||||
## Contemplate
|
||||
|
||||
To simulate what could happen if a driver falls asleep while driving, your robot could sound an alarm signal when it crosses the line. This feature is often available in new cars.
|
||||
|
||||
Program your robot to perform this function.
|
||||
|
||||
Draw a dark line with tape or marker for your robot to cross.
|
||||
|
||||
### ~hint
|
||||
|
||||
Consider using these blocks in your solution:
|
||||
|
||||
```block
|
||||
motors.largeBC.steer(0, 50)
|
||||
music.playSoundEffect(sounds.systemGeneralAlert)
|
||||
```
|
||||
### ~
|
||||
|
||||
### Sample Solution - Line detection in a loop
|
||||
|
||||
1. Start motors ``B`` and ``C`` (drive forward with a curve toward the line).
|
||||
2. Wait for the color sensor to detect the color black.
|
||||
3. Play sound effect “System General Alert.”
|
||||
4. Start motors ``B`` and ``C`` (drive forward with a curve away from the line).
|
||||
5. Wait for the color sensor to detect the color white.
|
||||
6. Loop forever.
|
||||
|
||||
```blocks
|
||||
loops.forever(function () {
|
||||
motors.largeBC.steer(-30, 20)
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Black)
|
||||
music.playSoundEffect(sounds.systemGeneralAlert)
|
||||
motors.largeBC.steer(30, 20)
|
||||
sensors.color3.pauseForColor(ColorSensorColor.White)
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick.
|
||||
|
||||
### Differentiation
|
||||
|
||||
Program your robot to drive on “autopilot” along a given route. You will need to create a program that recognizes and responds to a dark line (or white line). You will create a line-following program and your robot will need to travel along the line without losing contact with it.
|
||||
|
||||
You will need to constantly debug your program in order to make your robot travel as smoothly as possible along the line.
|
||||
|
||||
### ~hint
|
||||
|
||||
Consider using these blocks in your solution:
|
||||
|
||||
```block
|
||||
while (true) {
|
||||
|
||||
}
|
||||
motors.largeBC.steer(0, 50)
|
||||
```
|
||||
|
||||
> **- OR -**
|
||||
|
||||
```block
|
||||
if (true) {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
### Sample Solutions
|
||||
|
||||
#### Line Following in Loop
|
||||
|
||||
1. While the Color Sensor detects the color black, start motors ``B`` and ``C`` (drive forward with a curve toward the line).
|
||||
2. While the Color Sensor detects the color white, start motors ``B`` and ``C`` (drive forward with a curve away from the line).
|
||||
3. Loop forever.
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
while (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Black)
|
||||
motors.largeBC.steer(-30, 50)
|
||||
}
|
||||
while (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.White)
|
||||
motors.largeBC.steer(30, 50)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### Line Following in Loop
|
||||
|
||||
1. If the Color Sensor detects the color black, start motors ``B`` and ``C`` (drive forward with a curve toward the line).
|
||||
Else the Color Sensor detects the color white, start motors ``B`` and ``C`` (drive forward with a curve away from the line).
|
||||
2. Loop forever.
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
if (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Black)
|
||||
motors.largeBC.steer(-30, 50)
|
||||
} else {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.White)
|
||||
motors.largeBC.steer(30, 50)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick.
|
||||
|
||||
### Share
|
||||
|
||||
Think about:
|
||||
|
||||
* What challenged you?
|
||||
* Were there any surprises?
|
||||
* How can you improve your program?
|
||||
* Can your program be more streamlined? Have you used too many blocks?
|
||||
* Is there a more efficient way to build your program?
|
||||
* How can your program be used in real-world scenarios?
|
||||
|
||||
Personalize:
|
||||
|
||||
* Click on the **JavaScript** tab and experiment with changing the values in the code.
|
||||
* Add a custom image or sounds from the ``||brick:Brick||`` or ``||music:Music||`` menus.
|
||||
* Create a video of your project, especially your final presentation and your robot’s performance. Explain some important features of your software program.
|
||||
* Include an image of your program with comments.
|
||||
* Add a team photograph!
|
||||
|
||||
Congratulations! What will you design next?
|
||||
|
137
docs/coding/object-detection.md
Normal file
@ -0,0 +1,137 @@
|
||||
# Object Detection
|
||||
|
||||
Design ways to avoid accidents between vehicles and objects in the road.
|
||||
|
||||

|
||||
|
||||
## Connect
|
||||
|
||||
Think about:
|
||||
|
||||
* In what driving situations can a car hit an obstacle?
|
||||
* What do you need to be aware of to avoid collisions with obstacles?
|
||||
* What causes traffic jams in high density areas?
|
||||
|
||||
## Construct
|
||||
|
||||
### Build
|
||||
|
||||
Build a LEGO MINDSTORMS vehicle that can avoid accidents between vehicles and objects in the road.
|
||||
|
||||
Start by constructing this [model](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-ultrasonic-sensor-driving-base-61ffdfa461aee2470b8ddbeab16e2070.pdf).
|
||||
|
||||

|
||||
|
||||
Build an obstacle for your robot to detect. You can build the [cuboid model](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-cuboid-dc93b2e60bed2981e76b3bac9ea04558.pdf) out of LEGO bricks or an obstacle of your choice.
|
||||
|
||||

|
||||
|
||||
Before you program, check:
|
||||
|
||||
* Are all the wires correctly connected from the motors to ports B and C?
|
||||
* Are the wheels correctly installed?
|
||||
* Are the wheels rotating freely?
|
||||
* Are the wires connected from the Ultrasonic Sensor to port 4?
|
||||
|
||||
### Program
|
||||
|
||||
* Program your robot to detect any obstacles that might appear while the robot is moving forward (or backward).
|
||||
* Make the robot stop when it detects an object that is less than 20 cm away.
|
||||
|
||||
Before you program, think about:
|
||||
* How will you program the robot to detect obstacles?
|
||||
* How will you program the robot to stop at obstacles?
|
||||
* Which programming blocks will you use?
|
||||
|
||||
### ~hint
|
||||
|
||||
Consider using these blocks in your solution:
|
||||
|
||||
```block
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
|
||||
})
|
||||
motors.largeBC.steer(0, 50)
|
||||
pauseUntil(() => true)
|
||||
let near = sensors.ultrasonic4.distance() < 20
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
### Sample Solution
|
||||
|
||||
1. Start the program when EV3 ``enter`` button is pressed.
|
||||
2. Turn motors ``B`` and ``C`` on at speed ``50``.
|
||||
3. Wait until Ultrasonic Sensor detects an obstacle at a distance of less than ``20`` cm.
|
||||
4. Stops all motors.
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeBC.steer(0, 50)
|
||||
pauseUntil(() => sensors.ultrasonic4.distance() < 20)
|
||||
motors.stopAll()
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
|
||||
|
||||
## Contemplate
|
||||
|
||||
On the road, when a driver sees and object, they slow their car down before coming to a full stop.
|
||||
|
||||
Program your EV3 Driving Base to do the same.
|
||||
|
||||
If the Ultrasonic Sensor:
|
||||
|
||||
* Detects an object less than `10` cm away, make the robot stop.
|
||||
* Detects an object between `10` and `20` cm away, make the robot slow down.
|
||||
* Does not detect any object, continue to move at full speed.
|
||||
|
||||
### ~hint
|
||||
|
||||
Consider using this block in your solution:
|
||||
|
||||
```block
|
||||
if (true) {
|
||||
}
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
### Sample Solution
|
||||
|
||||
```blocks
|
||||
loops.forever(function () {
|
||||
motors.largeBC.steer(0, 50)
|
||||
if (sensors.ultrasonic4.distance() < 10) {
|
||||
motors.stopAll()
|
||||
} else if (sensors.ultrasonic4.distance() < 20) {
|
||||
motors.largeBC.steer(0, 10)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
|
||||
|
||||
## Continue
|
||||
|
||||
* Get together with other building teams and make a traffic jam by placing all of your robots in a line with varying amounts of space between them.
|
||||
* Have everyone start their robots at the same time and see what happens.
|
||||
* Refine your programs so that all of the robots continue driving at the same speed with equal distances between them.
|
||||
* Click on the JavaScript tab and experiment with changing the values in the code.
|
||||
* Add a custom image or sounds from the Brick or Music menus.
|
||||
|
||||
### Share
|
||||
|
||||
* Share what you think “efficiency in programming” means.
|
||||
* Explore the different solutions other programmers came up with.
|
||||
* Create a video of your project, especially your final presentation and your robot’s performance. Explain some important features of your software program.
|
||||
* Include an image of your program with comments.
|
||||
* Add a team photograph!
|
||||
|
||||
Congratulations! What will you design next
|
@ -7,21 +7,21 @@
|
||||
{
|
||||
"name": "Make It Move Without Wheels",
|
||||
"description": "TBD",
|
||||
"imageUrl": "/static/lessons/make-it-move.png",
|
||||
"imageUrl": "/static/lessons/make-it-move-without-wheels.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",
|
||||
"imageUrl": "/static/lessons/make-it-smarter-and-faster.png",
|
||||
"url": "/design-engineering/make-it-smarter",
|
||||
"cardType": "side"
|
||||
},
|
||||
{
|
||||
"name": "Make a System that Communicates",
|
||||
"description": "A robot that tells you what it is doing.",
|
||||
"imageUrl": "/static/lessons/make-it-communicate.png",
|
||||
"imageUrl": "/static/lessons/make-a-system-that-communicates.png",
|
||||
"url": "/design-engineering/make-it-communicate",
|
||||
"cardType": "side"
|
||||
}
|
||||
|
192
docs/design-engineering/make-it-smarter.md
Normal file
@ -0,0 +1,192 @@
|
||||
# Make It Smarter and Faster
|
||||
|
||||
|
||||
## Connect
|
||||
|
||||
### Design Brief
|
||||
|
||||
Design, build and program a robotic creature that can sense its environment and respond by moving.
|
||||
|
||||
https://www.youtube.com/watch?v=y9-A_C_08KY
|
||||
|
||||
* What do the robots in the video need to be able to sense, plan, and act?
|
||||
* What senses do humans have and why are they important to us?
|
||||
* How many human-like senses do you see the robots demonstrating?
|
||||
|
||||
### Brainstorm
|
||||
|
||||
Discuss different solutions to the design brief.
|
||||
|
||||
Think about:
|
||||
|
||||
* What kind of creature can it be?
|
||||
* How can it move?
|
||||
* What does it need to be aware so that it stays safe, well fed and warm (or cool)?
|
||||
* Is it looking for food, a safe place to hide or a warm place to soak up the sun?
|
||||
* Will the creature need to move fast or slow?
|
||||
* Will it need to turn?
|
||||
* Will it need to go backward?
|
||||
|
||||

|
||||
|
||||
## Construct
|
||||
|
||||
### Build
|
||||
|
||||
Think about a creature’s movement for inspiration. Your mechanism can be attached or unattached to the EV3 brick. You can start by tinkering with the LEGO elements in the picture add then build on.
|
||||
More building ideas:
|
||||
|
||||
* [EV3 Frames](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/ev3%20frames-5054ee378e624fb4cb31158d2fc8e5cf.pdf)
|
||||
* [Color Sensor 1](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/color%20sensor_v1-16a7231bdc187cd88a8da120c68f58d5.pdf)
|
||||
* [Gyro Sensor](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/gyro%20sensor-6f0fdbd82ae45fe0effa0ebf3f460f3d.pdf)
|
||||
* [Ultrasonic Sensor](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/ultrasonic%20sensor-a56156c72e8946ed4c58c5e69f3520d3.pdf)
|
||||
* [Touch Sensor](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/touch%20sensor-868fda1b9d6070a0a034fb22456a7fc9.pdf)
|
||||
* [Jaw](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/jaw-ee93e8f3243e4d30cd34b0c337c33653.pdf)
|
||||
* [Leg 1](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/leg%201-c14624046ea3a95148820ed404f5ac65.pdf)
|
||||
* [Leg 2](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/leg%202-8855c35b990205f6b9d7130687a3d4db.pdf)
|
||||
* [Leg 3](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/leg%203-575d52ef15fb79f1e4d3350d36607160.pdf)
|
||||
|
||||
|
||||
### Program
|
||||
|
||||
Before you program, think about:
|
||||
|
||||
* How will you program the robot to sense?
|
||||
* How will you program the robot to respond?
|
||||
* Which programming blocks will you use?
|
||||
|
||||
### ~ hint
|
||||
|
||||
**Hint:** Explore the different Sensor blocks in the Sensors Menu
|
||||
|
||||
### ~
|
||||
|
||||
## SCREEN 5
|
||||
|
||||
Sample Solution
|
||||
|
||||
[Video: EV3 Insect]
|
||||
|
||||
This Insect uses its Ultrasonic Sensor to sense danger and move away from threat.
|
||||
|
||||
The Insect solution combines these building ideas:
|
||||
|
||||
* EV3 Frames
|
||||
* Leg 2
|
||||
* Leg 3
|
||||
* Ultrasonic Sensor
|
||||
|
||||
Four copies of Leg 3 were built: one for the front left, one for the back right, and two mirror copies for the front right and back left.
|
||||
|
||||
* [Building Instructions](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/insect-94b8a46f0dc5082c9d78ddb734626dc9.pdf)
|
||||
|
||||
### Sample Solution
|
||||
|
||||
This program checks if the Ultrasonic Sensor senses something near.
|
||||
|
||||
This program:
|
||||
|
||||
* Turns on the green EV3 brick Status Light
|
||||
|
||||
```block
|
||||
brick.setStatusLight(StatusLight.Green)
|
||||
```
|
||||
|
||||
* Waits for Ultrasonic Sensor to detect an object
|
||||
|
||||
```block
|
||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected)
|
||||
```
|
||||
|
||||
* Turns on Motors A and D in opposite directions
|
||||
|
||||
```block
|
||||
motors.largeAD.tank(50, -50)
|
||||
```
|
||||
|
||||
* Waits for one half of a second (1500 milli seconds)
|
||||
|
||||
```block
|
||||
pause(1500)
|
||||
```
|
||||
|
||||
* Reverses the direction of Motors A and D
|
||||
|
||||
```block
|
||||
motors.largeAD.tank(-50, 50)
|
||||
```
|
||||
|
||||
* Waits for one half of a second
|
||||
* Stops all motors
|
||||
|
||||
```block
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
* Makes an insect chirping sound
|
||||
|
||||
```block
|
||||
music.playSoundEffectUntilDone(sounds.animalsInsectChirp)
|
||||
```
|
||||
|
||||
* Loops so the insect wanders around when the Ultrasonic Sensor is triggered
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
brick.setStatusLight(StatusLight.Green)
|
||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected)
|
||||
motors.largeAD.tank(50, -50)
|
||||
pause(1500)
|
||||
motors.largeAD.tank(-50, 50)
|
||||
pause(1500)
|
||||
motors.stopAll()
|
||||
music.playSoundEffectUntilDone(sounds.animalsInsectChirp)
|
||||
})
|
||||
```
|
||||
|
||||
### Download and test
|
||||
|
||||
Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
## Contemplate
|
||||
|
||||
### Test and Analyze
|
||||
|
||||
As you work on your solution:
|
||||
1. Describe one part of your design that worked especially well.
|
||||
2. Describe one design change that you had to make.
|
||||
3. What will you try next?
|
||||
|
||||
|
||||
### Review and Revise
|
||||
|
||||
Take a moment to reflect on your robot solution.
|
||||
|
||||
Think about:
|
||||
|
||||
* Does your robot move when the sensor is activated?
|
||||
* If not, what will you change to make the robot’s ability to sense and respond more obvious?
|
||||
* What other behaviors can you add to the robot to make it more realistic?
|
||||
|
||||
Describe two ways you could improve your robot.
|
||||
|
||||
|
||||
## Continue
|
||||
|
||||
Personalize your project
|
||||
|
||||
* Add/remove LEGO elements to improve the way your robot moves.
|
||||
* Click on the JavaScript tab and experiment with changing the values in the code.
|
||||
* Add a custom image or sounds by adding blocks from the Brick or Music menus.
|
||||
* Does your robot resemble a creature? Add arts and crafts materials to you project.
|
||||
|
||||
## 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!
|
||||
|
||||
Congratulations! What will you design next?
|
@ -7,14 +7,14 @@
|
||||
{
|
||||
"name": "Try",
|
||||
"imageUrl": "/static/lessons/try.png",
|
||||
"description": "TBD",
|
||||
"description": "Get a quick introduction to programming with EV3.",
|
||||
"url": "/getting-started/try",
|
||||
"cardType": "side"
|
||||
},
|
||||
{
|
||||
"name": "use",
|
||||
"name": "Use",
|
||||
"imageUrl": "/static/lessons/use.png",
|
||||
"description": "TBD",
|
||||
"description": "Build a robot and drive into the world of robotics!",
|
||||
"url": "/getting-started/use",
|
||||
"cardType": "side"
|
||||
}
|
||||
|
178
docs/getting-started/try.md
Normal file
@ -0,0 +1,178 @@
|
||||
# Try
|
||||
|
||||
[IMG: Neutral Image Display on EV3 Brick with Music Notes]
|
||||
|
||||
Get a quick introduction to programming with EV3.
|
||||
|
||||
We are excited to help you get started with LEGO MINDSTORMS Education EV3. In this project we will guide you through connecting your EV3 brick, creating your first program, controlling a Large Motor, a Touch Sensor and a Color Sensor. These steps can take up to 45 minutes.
|
||||
|
||||
## Turn on your EV3 Brick
|
||||
|
||||
[IMG: Hand pressing power button, Neutral Image Display, EV3 Brick]
|
||||
|
||||
Power on your EV3 Brick by pressing the Center Button.
|
||||
|
||||
## Connect Your EV3 Brick to Your Device
|
||||
|
||||
[IMG: Hand on cable & computer, Neutral Image Display, EV3 Brick]
|
||||
|
||||
Use the USB cable to connect your EV3 Brick to your device.
|
||||
|
||||
## Create and Run your First Program
|
||||
|
||||
[IMG: Try Program Blocks (see JavaScript below)]
|
||||
|
||||
1 - Create the program shown here:
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
brick.showMood(moods.neutral)
|
||||
music.playSoundEffect(sounds.communicationHello)
|
||||
})
|
||||
```
|
||||
|
||||
* Drag a Brick Screen show mood block inside the on button block
|
||||
* Change mood to
|
||||
|
||||
```block
|
||||
brick.showMood(moods.neutral)
|
||||
```
|
||||
|
||||
* Drag a Music play sound effect block below the show mood block
|
||||
* Change sound effect to
|
||||
|
||||
```block
|
||||
music.playSoundEffect(sounds.communicationHello)
|
||||
```
|
||||
|
||||
2 – Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
## ~ hint
|
||||
|
||||
Note: Click here for help and more information about the programming blocks.
|
||||
|
||||
## ~
|
||||
|
||||
## Did It Work?
|
||||
|
||||
[IMG: Neutral Image Display, EV3 Brick]
|
||||
|
||||
Verify that the program you just created shows eyes on the Brick Display, and that the EV3 Brick played the sound “Hello!”
|
||||
|
||||
**Well done!**
|
||||
|
||||
## Connect a Large Motor
|
||||
|
||||
[IMG: EV3 Brick with hands connecting Large Motor to Port D]
|
||||
|
||||
Now you will learn to control the Large Motor.
|
||||
|
||||
Connect a Large Motor to Port D of your EV3 Brick using any of the connector cables.
|
||||
|
||||
## Create and Run This Program
|
||||
|
||||
[IMG: Program Blocks (see JavaScript below)]
|
||||
|
||||
1) Create the program shown here:
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeD.run(50, 1, MoveUnit.Rotations)
|
||||
})
|
||||
```
|
||||
|
||||
* Start a new program
|
||||
* Drag a run large A motor block inside the on button block
|
||||
* Change large A to large D motors.largeD.run(50)
|
||||
* Click on the + sign
|
||||
* Change to 1 rotation
|
||||
|
||||
2) Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
## Did It Rotate?
|
||||
|
||||
[IMG: Large Motor D w/Rotating “WHRRR,” Hand, EV3 Brick]
|
||||
|
||||
Confirm that your motor has turned one rotation at power level 50 before stopping.
|
||||
|
||||
Download and run the program as many times as you want in order to verify this, or tinker with different power levels and different rotations.
|
||||
|
||||
## Connect a Touch Sensor
|
||||
|
||||
[IMG: Hands connecting Touch Sensor to Port 1 on EV3 Brick]
|
||||
|
||||
We will now control the Large Motor using a Touch Sensor.
|
||||
|
||||
Keeping the Large Motor connected to **Port D**, connect a Touch Sensor to **Port 1** of your EV3 Brick.
|
||||
|
||||
## Modify Your Program
|
||||
|
||||
[IMG: Program Blocks (see JavaScript below)]
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
|
||||
motors.largeD.run(50, 1, MoveUnit.Rotations)
|
||||
})
|
||||
```
|
||||
|
||||
1) Add a pause until touch 1 pressed Sensor block on top of the run large D Motor block
|
||||
|
||||
```block
|
||||
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
|
||||
```
|
||||
|
||||
2) Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
## Press the Touch Sensor
|
||||
|
||||
[IMG: Hand Touch Sensor Pressed & EV3 Brick & Large Motor]
|
||||
|
||||
Confirm that the Large Motor has turned one rotation AFTER you press the Touch Sensor.
|
||||
|
||||
Download and run the program as many times as you want in order to verify this, or tinker with different Touch Sensor and Large Motor values.
|
||||
|
||||
## Connect a Color Sensor
|
||||
|
||||
[IMG: Hand connecting Color Sensor to Port 4, Large Motor D, EV3 Brick]
|
||||
|
||||
Now we will try to control the Large Motor using another sensor.
|
||||
|
||||
Keeping the Large Motor connected to **Port D**, connect the Color Sensor to **Port 4**.
|
||||
Modify Your Program
|
||||
|
||||
[IMG: Program Blocks (see JavaScript below)]
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Green)
|
||||
motors.largeD.run(50, 1, MoveUnit.Rotations)
|
||||
})
|
||||
```
|
||||
|
||||
1) Using the same program, replace the pause until touch 1 block with a pause color 3 for color block
|
||||
|
||||
```block
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Green)
|
||||
```
|
||||
|
||||
2) Select the color you want to detect (e.g., green).
|
||||
|
||||
3) Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
## Place a Colored Brick in Front of the Color Sensor
|
||||
|
||||
[IMG: Colored bricks in front of Color Sensor, hands, EV3 Brick]
|
||||
|
||||
Confirm that the Large Motor has turned one rotation AFTER the Color Sensor has detected the colored brick.
|
||||
|
||||
Download and run the program as many times as you want in order to verify this, or tinker with different Color Sensor and Large Motor values.
|
||||
|
||||
Click on the JavaScript tab and change the color the Color Sensor detects to Black, Blue, Green, Yellow, Red, White, or Brown. Use Title Case for the color names.
|
||||
|
||||
## Well Done!
|
||||
|
||||
[IMG: EV3 Driving Base]
|
||||
|
||||
You have now learned how to control some of the inputs and outputs of the EV3.
|
||||
|
114
docs/getting-started/use.md
Normal file
@ -0,0 +1,114 @@
|
||||
# Use
|
||||
|
||||
[IMG: EV3 Driving Base full w/cuboid]
|
||||
|
||||
Build a robot and drive into the world of robotics!
|
||||
In this project we will guide you through building a Driving Base Robot and programming it to move straight and turn. You will also build and Object Detector Module, and program it to detect an object. It’s a good idea to have done the [Try](/getting-started/try) sequence first.
|
||||
|
||||
## Connect
|
||||
|
||||
[IMG: Apple Picker]
|
||||
|
||||
What if your school had a multipurpose robot? How would you use it?
|
||||
|
||||
Would you use it to clean the school or plant trees?
|
||||
|
||||
## Build Your Driving Base Robot
|
||||
|
||||
[IMG: EV3 Driving Base Building Instructions Cover Image]
|
||||
|
||||
* [Building instructions](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf)
|
||||
|
||||
## Make It Move
|
||||
|
||||
[IMG: Program Blocks (see JavaScript below)]
|
||||
|
||||
1) Create a program that makes the Driving Base move forward and stop at the finish line, which is 1 meter away.
|
||||
|
||||
Start by building this program:
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations)
|
||||
})
|
||||
```
|
||||
|
||||
* Drag a steer large B+C motor block inside the on button block
|
||||
* Click on the + sign
|
||||
* Change to 1 rotation
|
||||
|
||||
### ~ hint
|
||||
|
||||
Hint: You will have to modify the number of rotations until you find the number that matches the robot moving forward 1 meter and stopping.
|
||||
|
||||
### ~
|
||||
|
||||
2) Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
## Make It Turn
|
||||
|
||||
[IMG: Program Blocks (see JavaScript below)]
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeBC.steer(-50, 50, 1, MoveUnit.Rotations)
|
||||
})
|
||||
```
|
||||
|
||||
1) Create a new program that turns the Driving Base 180 degrees.
|
||||
|
||||
### ~ hint
|
||||
|
||||
Hint: You will have to modify the turn ratio and the number of rotations until the robot reaches 180 degrees.
|
||||
|
||||
### ~
|
||||
|
||||
|
||||
2) Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
## Add an Ultrasonic Sensor to Your Driving Base
|
||||
|
||||
[IMG: EV3 Ultrasonic Sensor Driving Base Building Instructions Main Image]
|
||||
|
||||
* [building instructions](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-ultrasonic-sensor-driving-base-61ffdfa461aee2470b8ddbeab16e2070.pdf)
|
||||
|
||||
## Detect an Object
|
||||
|
||||
[IMG: Program Blocks (see JavaScript below)]
|
||||
|
||||
1 - Create a program that moves the Driving Base and makes it stop ``6`` cm from the Cuboid.
|
||||
|
||||
Create a new program
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
motors.largeBC.tank(50, 50)
|
||||
sensors.ultrasonic4.setThreshold(UltrasonicSensorEvent.ObjectDetected, 6)
|
||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
|
||||
motors.stopAll()
|
||||
})
|
||||
```
|
||||
|
||||
* Drag a tank large B+C motor block inside the on button block
|
||||
* Drag a threshold Ultrasonic Sensor block and place below the motor block
|
||||
* Drag a stop all motors block and place it below the sensor block
|
||||
|
||||
### ~ hint
|
||||
|
||||
Hint: You will have to modify the values of the Ultrasonic Sensor block until the robot reaches the desired position.
|
||||
|
||||
### ~
|
||||
|
||||
2) Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
|
||||
|
||||
Click on the JavaScript tab and change and test the number value of the Ultrasonic Sensor
|
||||
|
||||
```typescript
|
||||
sensors.ultrasonic4.setThreshold(UltrasonicSensorEvent.ObjectDetected, 10)
|
||||
```
|
||||
|
||||
[IMG: EV3 Ultrasonic Sensor Driving Base Building Instructions Main Image]
|
||||
|
||||
**Congratulations!**
|
||||
|
||||
You are ready to move on to the next steps.
|
||||
Try a LEGO MINDSTORMS Design Engineering, Coding, or Maker activity.
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"appref": "v0.0.104"
|
||||
"appref": "v0"
|
||||
}
|
||||
|
135
docs/lessons/make-a-security-gadget.md
Normal file
@ -0,0 +1,135 @@
|
||||
|
||||
# Make a Security Gadget
|
||||
|
||||

|
||||
|
||||
Invent a Security Gadget that will protect your belongings by warning you!
|
||||
|
||||
## Connect
|
||||
|
||||
Over time, people have come up with many different ways to help protect their personal belongings from theft. These inventions include simple alarm systems and even traps!
|
||||
|
||||

|
||||
|
||||
Look at the photos and think about:
|
||||
|
||||
* What do you see?
|
||||
* Can you see any new design opportunities?
|
||||
* What problems can you see?
|
||||
* How could you make use of the LEGO bricks, the EV3 Programmable Brick, motors, and sensors?
|
||||
|
||||
### Things You’ll Need
|
||||
|
||||
* [LEGO MINDSTORMS Education EV3 Core Set](https://education.lego.com/enus/products/legomindstormseducationev3coreset/5003400)
|
||||
|
||||
Additional materials to add to your Security Gadget:
|
||||
|
||||
* String
|
||||
* Arts and crafts materials such as:
|
||||
>* Cardboard
|
||||
>* Construction paper
|
||||
>* Pipe cleaners
|
||||
>* Plastic or paper cups
|
||||
>* Recycled materials
|
||||
>* Rubber bands
|
||||
>* Wire
|
||||
|
||||
### Prior Knowledge
|
||||
|
||||
This activity uses sensor inputs. You may want to try the Use or Object Detection activity before this one. Or, you can start out with this activity and tinker with coding sensor inputs on your own.
|
||||
|
||||
### Defining the Problem
|
||||
|
||||

|
||||
|
||||
1. What problems did you imagine?
|
||||
2. Pick one problem and explain it to a partner.
|
||||
|
||||
### Brainstorm
|
||||
|
||||
Now that you have defined a problem, start to generate ideas for solving it.
|
||||
|
||||
### ~hint
|
||||
|
||||
Some things to do while brainstorming:
|
||||
|
||||
* Use the bricks from the LEGO set to help you brainstorm or sketch your ideas on paper.
|
||||
* The goal of brainstorming is to explore as many solutions as possible. You can use the tinkering examples in the Sample Solutions section below as inspiration for getting started.
|
||||
* Share your ideas and get some feedback. It may lead to more ideas!
|
||||
|
||||
### ~
|
||||
|
||||
### Define the Design Criteria
|
||||
|
||||
1. You should have generated a number of ideas. Now select the best one to make.
|
||||
2. Write out two or three specific design criteria your design must meet.
|
||||
|
||||
## Go Make
|
||||
|
||||
It is time to start making!
|
||||
|
||||
* Use the components from the LEGO® MINDSTORMS EV3 Core Set and additional materials to make your chosen solution.
|
||||
* Test and analyze your design as you go and record any improvements that you make.
|
||||
|
||||
### Review and Revise Your Solution
|
||||
|
||||
* Have you managed to solve the problem that you defined?
|
||||
* Look back at your design criteria. How well does your solution work?
|
||||
* How can you improve your design?
|
||||
|
||||
### Communicate Your Solution
|
||||
|
||||
Now that you have finished you can:
|
||||
|
||||
* Make a sketch or take a photo or video of your model.
|
||||
* Label the three most important parts and explain how they work.
|
||||
* Share your work with others.
|
||||
|
||||
### Sample Solutions
|
||||
|
||||
#### Phone Protector
|
||||
|
||||

|
||||
|
||||
This example program combined with the small model will sound an alarm if someone picks it up. The program activates an alarm when an object is lifted from the Touch Sensor.
|
||||
|
||||
1. Drag a ``||sensors:pause until touch||`` block and place it inside the ``||loops:forever||`` loop.
|
||||
2. Drag a ``||music:play sound effect||`` block and place it below the ``||sensors:pause until||`` block.
|
||||
3. Change the sound effect to ``mechanical horn1``.
|
||||
|
||||

|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
|
||||
music.playSoundEffect(sounds.mechanicalHorn1)
|
||||
})
|
||||
```
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
|
||||
|
||||
#### Object Detection
|
||||
|
||||

|
||||
|
||||
This example program combined with the small model will sound an alarm if someone (or something) crosses its path! The program activates an alarm when an object moves in front of the Ultrasonic Sensor.
|
||||
|
||||

|
||||
|
||||
1. Drag a ``||sensors:pause until ultrasonic||`` block and place it inside the ``||loops:forever||`` loop.
|
||||
2. Drag a ``||music:play sound effect||`` block and place it below the ``||sensors:pause until||`` block.
|
||||
3. Change the sound effect to ``mechanical horn1``.
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected)
|
||||
music.playSoundEffect(sounds.mechanicalHorn1)
|
||||
})
|
||||
```
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
|
||||
|
||||
### Well done!
|
||||
|
||||
Click [here](#) to try out some more projects!
|
||||
|
157
docs/lessons/make-a-sound-machine.md
Normal file
@ -0,0 +1,157 @@
|
||||
# Make a Sound Machine
|
||||
|
||||

|
||||
|
||||
Make a Sound Machine that can play a rhythm, music or just noise!
|
||||
|
||||
## Connect
|
||||
|
||||
Music is made up of a combination of sounds, notes and rhythm. A rhythm is a regular movement or repeated pattern of movements that can be used in many different ways. In mechanical machines, a rhythm can help keep a machine running smoothly. It can also be used to generate different sounds in music.
|
||||
|
||||

|
||||
|
||||
Look at the photos and think about:
|
||||
|
||||
* What do you see?
|
||||
* Can you see any new design opportunities?
|
||||
* What problems can you see?
|
||||
* How could you make use of the LEGO bricks, the EV3 Programmable Brick, motors, and sensors?
|
||||
|
||||
### Things You’ll Need
|
||||
|
||||
* [LEGO MINDSTORMS Education EV3 Core Set](https://education.lego.com/enus/products/legomindstormseducationev3coreset/5003400)
|
||||
|
||||
Additional materials to add to your Sound Machine:
|
||||
|
||||
* Small musical instruments, such as chimes, bells, and small drums
|
||||
* Arts and crafts materials such as:
|
||||
>* Cardboard
|
||||
>* Construction paper
|
||||
>* Pipe cleaners
|
||||
>* Plastic or paper cups
|
||||
>* Recycled materials
|
||||
>* Rubber bands
|
||||
>* Wire
|
||||
|
||||
### Prior Knowledge
|
||||
|
||||
This activity uses motor rotations and sensor inputs. You may want to try the Use or Object Detection activity before this one. Or, you can start out with this activity and tinker with coding motor and sensor inputs on your own.
|
||||
|
||||
### Defining the Problem
|
||||
|
||||

|
||||
|
||||
1. What problems did you imagine?
|
||||
2. Pick one problem and explain it to a partner.
|
||||
|
||||
### Brainstorm
|
||||
|
||||
Now that you have defined a problem, start to generate ideas for solving it.
|
||||
|
||||
### ~hint
|
||||
|
||||
Some things to do while brainstorming:
|
||||
|
||||
* Use the bricks from the LEGO set to help you brainstorm or sketch your ideas on paper.
|
||||
* The goal of brainstorming is to explore as many solutions as possible. You can use the tinkering examples in the Sample Solutions section below as inspiration for getting started.
|
||||
* Share your ideas and get some feedback. It may lead to more ideas!
|
||||
|
||||
### ~
|
||||
|
||||
### Define the Design Criteria
|
||||
|
||||
* You should have generated a number of ideas. Now select the best one to make.
|
||||
* Write out two or three specific design criteria your design must meet.
|
||||
|
||||
## Go Make
|
||||
|
||||
It is time to start making!
|
||||
* Use the components from the LEGO® MINDSTORMS EV3 Core Set and additional materials to make your chosen solution.
|
||||
* Test and analyze your design as you go and record any improvements that you make.
|
||||
|
||||
Review and Revise Your Solution
|
||||
* Have you managed to solve the problem that you defined?
|
||||
* Look back at your design criteria. How well does your solution work?
|
||||
* How can you improve your design?
|
||||
|
||||
Communicate Your Solution
|
||||
Now that you have finished you can:
|
||||
* Make a sketch or take a photo or video of your model.
|
||||
* Label the three most important parts and explain how they work.
|
||||
* Share your work with others.
|
||||
|
||||
## Sample Solutions
|
||||
|
||||
### Rhythm Maker
|
||||
|
||||

|
||||
|
||||
This example program combined with the small model will make a beat and rhythm on any surface when the program is run.
|
||||
|
||||

|
||||
|
||||
1. Drag a run ``||motors:large motor A||`` block inside the ``||loops:forever||`` loop.
|
||||
2. Press the **(+)**.
|
||||
3. Change the rotations to `2`.
|
||||
4. Drag a ``||loops:pause||`` block and place it under the motor block.
|
||||
5. Change the duration to ``200`` ms.
|
||||
6. Drag a ``||run large motor A||`` block inside the ``||loops:forever||`` loop.
|
||||
7. Press the **(+)**.
|
||||
8. Change the power to `100`.
|
||||
9. Change the rotations to `1`.
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
motors.largeA.run(50, 2, MoveUnit.Rotations)
|
||||
pause(200)
|
||||
motors.largeA.run(100, 1, MoveUnit.Rotations)
|
||||
})
|
||||
```
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
|
||||
|
||||
### Color Sensor Sounds
|
||||
|
||||

|
||||
|
||||
You can also tinker with the use of sensors.
|
||||
|
||||

|
||||
|
||||
1. Drag an ``||logic:if else||`` Logic block and place it inside the ``||loops:forever||`` loop.
|
||||
2. Drag a ``||sensors:pause color sensor||`` block and place it inside the ``||logic:if true then||`` block.
|
||||
3. Change the color to ``blue``.
|
||||
4. Drag a ``||music:play tone||`` block and place under the sensor block.
|
||||
5. Change the tone to ``Middle G`` (392 Hz).
|
||||
6. Drag a ``||sensors:pause color sensor||`` block and place it inside the ``||logic:else||`` block.
|
||||
7. Change the color to ``red``.
|
||||
8. Drag a ``||music:play tone||`` block and place under the new sensor block.
|
||||
9. Change the tone to ``High C`` (523 Hz).
|
||||
10. Press the **(+)**.
|
||||
11. Drag a ``||sensors:pause color sensor||`` block and place it inside the ``||logic:else if||`` block.
|
||||
12. Change the color to ``green``.
|
||||
13. Drag a ``||music:play tone||`` block and place under the new sensor block.
|
||||
14. Change the tone to ``High D`` (587 Hz).
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
if (true) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Blue)
|
||||
music.playTone(392, music.beat(BeatFraction.Whole))
|
||||
} else if (false) {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Red)
|
||||
music.playTone(523, music.beat(BeatFraction.Half))
|
||||
} else {
|
||||
sensors.color3.pauseForColor(ColorSensorColor.Green)
|
||||
music.playTone(587, music.beat(BeatFraction.Half))
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
|
||||
|
||||
### Well done!
|
||||
|
||||
Click [here](#) to try out some more projects!
|
||||
|
||||
|
@ -13,7 +13,15 @@ These six activities require the LEGO® MINDSTORMS® Education EV3 Core Set (455
|
||||
"description": "Create instruments with your EV3 Brick!",
|
||||
"url":"/maker/sound-machine",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/maker/sound-machine.png",
|
||||
"imageUrl": "/static/lessons/make-a-sound-machine.png",
|
||||
"cardType": "side"
|
||||
},
|
||||
{
|
||||
"name": "Make A Security Gadget",
|
||||
"description": "TBD",
|
||||
"url":"/maker/security-gadget",
|
||||
"cardType": "example",
|
||||
"imageUrl": "/static/lessons/make-a-security-device.png",
|
||||
"cardType": "side"
|
||||
}
|
||||
]
|
||||
|
@ -1,9 +1,17 @@
|
||||
# Reference
|
||||
|
||||
```namespaces
|
||||
brick.showMood(moods.sleeping);
|
||||
music.playSoundEffect(sounds.animalsCatPurr);
|
||||
sensors.color(null);
|
||||
motors.stopAll();
|
||||
brick.showMood(moods.sleeping);
|
||||
```
|
||||
|
||||
## Advanced
|
||||
|
||||
```namespaces
|
||||
console.log("");
|
||||
control.runInParallel(function(){});
|
||||
```
|
||||
|
||||
## See Also
|
||||
@ -11,5 +19,6 @@ motors.stopAll();
|
||||
[brick](/reference/brick),
|
||||
[sensors](/reference/sensors),
|
||||
[motors](/reference/motors),
|
||||
[touch sensor](/reference/sensors/touch-sensor),
|
||||
[color sensor](/reference/sensors/color-sensor)
|
||||
[music](/reference/music),
|
||||
[control](/reference/control),
|
||||
[console](/reference/console)
|
||||
|
15
docs/reference/console.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Console
|
||||
|
||||
Output text and data values to the console.
|
||||
|
||||
```cards
|
||||
console.log("");
|
||||
console.logValue("x", 0);
|
||||
console.sendToScreen();
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[log](/reference/console/log),
|
||||
[log value](/reference/console/log-value),
|
||||
[send to screen](/reference/console/send-to-screen)
|
26
docs/reference/console/send-to-screen.md
Normal file
@ -0,0 +1,26 @@
|
||||
# send To Screen
|
||||
|
||||
Direct the console output to go to the @boardname@ screen.
|
||||
|
||||
```sig
|
||||
console.sendToScreen();
|
||||
```
|
||||
|
||||
A "console" is a place for a user to see special messages from a device. It could be something connected to a serial port, a display that shows text, or even a text file. A console is typically used as a place to send information that is added to a message _log_ (a record of messages that are sent from a device). Your program can send log messages using the [console](/reference/console) functions. The MakeCode editor has a console view that lets you see the console output when your program runs in the simulator.
|
||||
|
||||
On the @boardname@, the screen can serve as a console too and you can make your console output go there. Before using the console log functions, set the screen as the console output location.
|
||||
|
||||
## Example
|
||||
|
||||
Direct the console output to go to the screen. Show 20 values on the screen. Use the up and down buttons to scroll through the values.
|
||||
|
||||
```blocks
|
||||
console.sendToScreen()
|
||||
for (let index = 0; index <= 20; index++) {
|
||||
console.logValue("index", index)
|
||||
}
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[log](reference/console/log), [log value](/reference/console/log-value)
|
33
docs/reference/control.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Control
|
||||
|
||||
Program controls and events.
|
||||
|
||||
```cards
|
||||
control.millis();
|
||||
control.runInParallel(() => {
|
||||
|
||||
});
|
||||
control.reset();
|
||||
control.waitMicros(4);
|
||||
control.deviceSerialNumber();
|
||||
```
|
||||
|
||||
## Timer
|
||||
|
||||
```cards
|
||||
control.timer1.reset()
|
||||
control.timer1.pauseUntil(5)
|
||||
control.timer1.millis()
|
||||
control.timer1.seconds()
|
||||
```
|
||||
|
||||
## Advanced #advanced
|
||||
|
||||
```cards
|
||||
control.raiseEvent(0, 0);
|
||||
control.onEvent(0, 0, () => {
|
||||
|
||||
});
|
||||
control.assert(false, 0);
|
||||
control.panic(0);
|
||||
```
|
12
docs/reference/control/assert.md
Normal file
@ -0,0 +1,12 @@
|
||||
# @extends
|
||||
|
||||
## Example #example
|
||||
|
||||
Stop the program if the gyro dectects an angle greater than 45 degrees.
|
||||
|
||||
```blocks
|
||||
forever(function () {
|
||||
control.assert(sensors.gyro2.angle() > 45, 15)
|
||||
pause(300)
|
||||
})
|
||||
```
|
9
docs/reference/control/device-serial-number.md
Normal file
@ -0,0 +1,9 @@
|
||||
# @extends
|
||||
|
||||
## Example #example
|
||||
|
||||
Log the device serial number to the console.
|
||||
|
||||
```blocks
|
||||
console.logValue("serialnumber", control.deviceSerialNumber());
|
||||
```
|
25
docs/reference/control/on-event.md
Normal file
@ -0,0 +1,25 @@
|
||||
# @extends
|
||||
|
||||
# Example #example
|
||||
|
||||
Register two events coming from source `22`. Make the brick status light up when
|
||||
the events of `0` and `1` are _raised_.
|
||||
|
||||
```blocks
|
||||
const statusLighter = 22;
|
||||
|
||||
control.runInParallel(() => {
|
||||
for (let i = 0; i < 2; i++) {
|
||||
pause(1000);
|
||||
control.raiseEvent(statusLighter, i);
|
||||
}
|
||||
})
|
||||
|
||||
control.onEvent(statusLighter, 0, () => {
|
||||
brick.setStatusLight(StatusLight.OrangePulse)
|
||||
})
|
||||
|
||||
control.onEvent(statusLighter, 1, () => {
|
||||
brick.setStatusLight(StatusLight.GreenPulse)
|
||||
})
|
||||
```
|
13
docs/reference/control/panic.md
Normal file
@ -0,0 +1,13 @@
|
||||
# @extends
|
||||
|
||||
## Example #example
|
||||
|
||||
Send a 'code red' error that you created to the error display if the brick crashes into a wall.
|
||||
|
||||
```blocks
|
||||
let codeRed = 1
|
||||
let codeBlue = 2
|
||||
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
|
||||
control.panic(codeRed)
|
||||
})
|
||||
```
|
25
docs/reference/control/raise-event.md
Normal file
@ -0,0 +1,25 @@
|
||||
# @extends
|
||||
|
||||
# Example #example
|
||||
|
||||
Register two events coming from source `22`. Make the brick status light up when
|
||||
the events of `0` and `1` are _raised_.
|
||||
|
||||
```blocks
|
||||
const statusLighter = 22;
|
||||
|
||||
control.runInParallel(() => {
|
||||
for (let i = 0; i < 2; i++) {
|
||||
pause(1000);
|
||||
control.raiseEvent(statusLighter, i);
|
||||
}
|
||||
})
|
||||
|
||||
control.onEvent(statusLighter, 0, () => {
|
||||
brick.setStatusLight(StatusLight.OrangePulse)
|
||||
})
|
||||
|
||||
control.onEvent(statusLighter, 1, () => {
|
||||
brick.setStatusLight(StatusLight.GreenPulse)
|
||||
})
|
||||
```
|
61
docs/reference/control/run-in-parallel.md
Normal file
@ -0,0 +1,61 @@
|
||||
# @extends
|
||||
|
||||
## Separate tasks #tasks
|
||||
|
||||
As an example, you could have a small task that checks the battery level and gives a warning when it drops below 15 percent. This is placed inside a ``||control:run in parallel||`` block:
|
||||
|
||||
```block
|
||||
let powerCheck = false;
|
||||
|
||||
control.runInParallel(() => {
|
||||
while (!powerCheck) {
|
||||
if (brick.batteryLevel() <= 15) {
|
||||
brick.setStatusLight(StatusLight.RedFlash)
|
||||
powerCheck = true;
|
||||
} else {
|
||||
pause(5000);
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The code the main program just drives the brick in a constant pattern until the battery check in the parallel task says that the battery level is too low.
|
||||
|
||||
```block
|
||||
let powerCheck = false;
|
||||
while (!powerCheck) {
|
||||
motors.largeBC.tank(50, 50, 5, MoveUnit.Seconds)
|
||||
motors.largeBC.steer(5, 50, 6, MoveUnit.Rotations)
|
||||
}
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
## #example
|
||||
|
||||
Tank the brick in a pattern until the battery warning variable is set. Have a separate task check the battery level and set a warning variable when the level is below `5` percent.
|
||||
|
||||
```blocks
|
||||
let powerCheck = false;
|
||||
|
||||
control.runInParallel(() => {
|
||||
while (!powerCheck) {
|
||||
if (brick.batteryLevel() < 5) {
|
||||
powerCheck = true;
|
||||
} else {
|
||||
pause(5000);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
while (!powerCheck) {
|
||||
motors.largeBC.tank(20, 20, 5, MoveUnit.Seconds)
|
||||
motors.largeBC.steer(15, 20, 6, MoveUnit.Rotations)
|
||||
motors.largeBC.tank(40, 40, 5, MoveUnit.Seconds)
|
||||
motors.largeBC.steer(-10, 20, 3, MoveUnit.Rotations)
|
||||
}
|
||||
motors.stopAll()
|
||||
```
|
||||
|
||||
## See also #seealso
|
||||
|
||||
[forever](/reference/loops/forever)
|
8
docs/reference/control/timer.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Timer
|
||||
|
||||
```cards
|
||||
control.timer1.reset()
|
||||
control.timer1.pauseUntil(5)
|
||||
control.timer1.millis()
|
||||
control.timer1.seconds()
|
||||
```
|
25
docs/reference/control/timer/millis.md
Normal file
@ -0,0 +1,25 @@
|
||||
# millis
|
||||
|
||||
Get the amount of time counted by the timer in milliseconds.
|
||||
|
||||
The timer count begins from `0` when you program starts or is [reset](/reference/control/timer/reset).
|
||||
|
||||
## Returns
|
||||
|
||||
* a [number](/types/number) that is the amount of time elapsed, in milliseconds, since the timer was started or reset.
|
||||
|
||||
## Example
|
||||
|
||||
Find out how many milliseconds go by between presses of the `down` button on the brick.
|
||||
|
||||
```blocks
|
||||
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
|
||||
brick.showValue("DownButtonTime", control.timer1.millis(), 1)
|
||||
control.timer1.reset()
|
||||
})
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[seconds](/reference/control/timer/seconds), [reset](/reference/control/timer/reset)
|
||||
|
32
docs/reference/control/timer/pause-until.md
Normal file
@ -0,0 +1,32 @@
|
||||
# pauseUntil
|
||||
|
||||
Pause until the timer counts up to a number of milliseconds.
|
||||
|
||||
```sig
|
||||
control.timer1.pauseUntil(0)
|
||||
```
|
||||
|
||||
When code in a block comes to a **pauseUntil**, it will wait until the timer count reaches the number of milliseconds you say. Code in blocks like **forever** and **runInParallel** will keep running while the current code is paused.
|
||||
|
||||
The time number you give is the number of milliseconds past the running timer count. If the timer is currently at `25000` milliseconds and you want to pause for `10` seconds, then use a pause time of `35000`. If you want your pause time number to match the actual wait time, then [reset](/reference/control/timer/reset) the timer first.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **ms**: the [number](/types/number) of milliseconds that you want the timer to count up to. For seconds, convert to milliseconds: 100 milliseconds = 1/10 second and 1000 milliseconds = 1 second.
|
||||
|
||||
## Example
|
||||
|
||||
Pause between messages on the screen by `5` seconds.
|
||||
|
||||
```blocks
|
||||
brick.clearScreen()
|
||||
brick.showString("Testing my pause...", 1)
|
||||
let startTime = control.timer1.millis()
|
||||
brick.showValue("StartTime", startTime, 3)
|
||||
control.timer1.pauseUntil(startTime + 5000)
|
||||
brick.showValue("EndTime", control.timer1.millis() - startTime, 4)
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[millis](/reference/control/timer/millis), [reset](/reference/control/timer/reset)
|
49
docs/reference/control/timer/reset.md
Normal file
@ -0,0 +1,49 @@
|
||||
# reset
|
||||
|
||||
Reset the elapsed time of the timer back to `0`.
|
||||
|
||||
```sig
|
||||
control.timer1.reset()
|
||||
```
|
||||
|
||||
A timer starts counting from `0` when your program starts. It's time value always gets larger as your program runs. Maybe you want to meausure how long some task takes to finish or you want to do some action only for a little while. A timer can keep track of the time it takes to do it.
|
||||
|
||||
Resetting the timer sets the time value to `0` so the next time you check the time it's exactly the amount of time that has _elapsed_. Otherwise, you need to remember a start time value and then subtract it from the current time.
|
||||
|
||||
## Examples
|
||||
|
||||
### Press time
|
||||
|
||||
Find out how much time goes by between presses of the `enter` button on the brick.
|
||||
|
||||
```blocks
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
|
||||
brick.showValue("PressTime", control.timer1.seconds(), 1)
|
||||
control.timer1.reset()
|
||||
})
|
||||
```
|
||||
|
||||
### Difference timer
|
||||
|
||||
Use a difference timer and compare it to a timer that resets. Use the ``left`` button to start timing and the ``right`` button to stop.
|
||||
|
||||
```blocks
|
||||
let startTime = 0
|
||||
let timing = false
|
||||
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
|
||||
brick.clearScreen()
|
||||
brick.showString("Starting timers...", 1)
|
||||
startTime = control.timer1.seconds()
|
||||
control.timer2.reset()
|
||||
timing = true
|
||||
})
|
||||
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
|
||||
if (timing) {
|
||||
brick.clearScreen()
|
||||
brick.showString("Timer results...", 1)
|
||||
brick.showValue("timer 1", control.timer1.seconds() - startTime, 3)
|
||||
brick.showValue("timer 2", control.timer2.seconds(), 4)
|
||||
timing = false;
|
||||
}
|
||||
})
|
||||
```
|
25
docs/reference/control/timer/seconds.md
Normal file
@ -0,0 +1,25 @@
|
||||
# seconds
|
||||
|
||||
Get the amount of time counted by the timer in seconds.
|
||||
|
||||
The timer count begins from `0` when you program starts or is [reset](/reference/control/timer/reset). The number of seconds returned also includes milliseconds if there is a fractional part of a second too.
|
||||
|
||||
## Returns
|
||||
|
||||
* a [number](/types/number) that is the amount of time elapsed, in seconds, since the timer was started or reset.
|
||||
|
||||
## Example
|
||||
|
||||
Find out how many seconds go by between presses of the `down` button on the brick.
|
||||
|
||||
```blocks
|
||||
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
|
||||
brick.showValue("DownButtonTime", control.timer1.seconds(), 1)
|
||||
control.timer1.reset()
|
||||
})
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[millis](/reference/control/timer/millis), [reset](/reference/control/timer/reset)
|
||||
|
17
docs/reference/control/wait-micros.md
Normal file
@ -0,0 +1,17 @@
|
||||
# @extends
|
||||
|
||||
## Example #example
|
||||
|
||||
Use the a wait and the timer to generate a crazy number.
|
||||
|
||||
```blocks
|
||||
let crazy = 0
|
||||
for (let i = 0; i < 100; i++) {
|
||||
control.waitMicros(100)
|
||||
crazy = control.millis()
|
||||
crazy += control.deviceSerialNumber()
|
||||
if (crazy != 0) {
|
||||
crazy = crazy / 1000000
|
||||
}
|
||||
}
|
||||
```
|
11
docs/reference/music/ring-tone.md
Normal file
@ -0,0 +1,11 @@
|
||||
# @extends
|
||||
|
||||
## Example #example
|
||||
|
||||
This program checks the speed from the large `A` motor and uses the speed to adjust a tone it rings.
|
||||
|
||||
```blocks
|
||||
loops.forever(function () {
|
||||
music.ringTone(motors.largeA.speed() * 100)
|
||||
})
|
||||
```
|
10
docs/reference/music/set-volume.md
Normal file
@ -0,0 +1,10 @@
|
||||
# @extends
|
||||
|
||||
## Example #example
|
||||
|
||||
Play a tyrannosaurus roar at half volume.
|
||||
|
||||
```blocks
|
||||
music.setVolume(50)
|
||||
music.playSoundEffect(sounds.animalsTRexRoar)
|
||||
```
|
10
docs/reference/music/stop-all-sounds.md
Normal file
@ -0,0 +1,10 @@
|
||||
# @extends
|
||||
|
||||
## Example #example
|
||||
|
||||
Play a sound effect but stop it right away.
|
||||
|
||||
```blocks
|
||||
music.playSoundEffect(sounds.expressionsCrying)
|
||||
music.stopAllSounds()
|
||||
```
|
@ -40,9 +40,9 @@ sensors.ultrasonic1.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
|
||||
## Infrared
|
||||
|
||||
```cards
|
||||
sensors.infraredSensor1.onEvent(null, function () {});
|
||||
sensors.infraredSensor1.pauseUntil(null);
|
||||
sensors.infraredSensor1.proximity();
|
||||
sensors.infrared1.onEvent(null, function () {});
|
||||
sensors.infrared1.pauseUntil(null);
|
||||
sensors.infrared1.proximity();
|
||||
|
||||
```
|
||||
|
||||
@ -53,5 +53,5 @@ sensors.remoteButtonCenter.onEvent(ButtonEvent.Pressed, function () {})
|
||||
sensors.remoteButtonCenter.pauseUntil(ButtonEvent.Pressed);
|
||||
sensors.remoteButtonCenter.isPressed()
|
||||
sensors.remoteButtonCenter.wasPressed()
|
||||
sensors.infraredSensor1.setRemoteChannel(null)
|
||||
sensors.infrared1.setRemoteChannel(null)
|
||||
```
|
||||
|
142
docs/static/avatar.svg
vendored
@ -5,105 +5,53 @@
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32"
|
||||
style="enable-background:new 0 0 32 32;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#303030;}
|
||||
.st0{fill:#DE0612;}
|
||||
.st1{fill:#FFFFFF;stroke:#FFFFFF;stroke-width:0.4;stroke-miterlimit:10;}
|
||||
</style>
|
||||
<sodipodi:namedview bordercolor="#666666" borderopacity="1" gridtolerance="10" guidetolerance="10" id="namedview15" inkscape:current-layer="svg2" inkscape:cx="16" inkscape:cy="16" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-height="661" inkscape:window-maximized="0" inkscape:window-width="997" inkscape:window-x="0" inkscape:window-y="0" inkscape:zoom="5.2149125" objecttolerance="10" pagecolor="#ffffff" showgrid="false">
|
||||
</sodipodi:namedview>
|
||||
<g id="avatar_mf" transform="translate(-5304.979 8145.745)">
|
||||
<path id="Path_180" class="st0" d="M5317.1-8125.6c0.2,0,0.3-0.1,0.5-0.1l2.9-0.6c1.3-0.3,2.5-0.5,3.8-0.8c0.5-0.1,1-0.2,1.5-0.3
|
||||
c0.1,0,0.1,0,0.1-0.1c0-0.5,0-1-0.1-1.5c-0.1-0.6-0.2-1.1-0.3-1.7c-0.1-0.4-0.1-0.8-0.2-1.2c-0.1-0.7-0.2-1.4-0.3-2
|
||||
c-0.1-0.6-0.2-1.1-0.3-1.7c0-0.2-0.2-0.4-0.4-0.4c0,0,0,0-0.1,0c-0.2,0-0.5,0.1-0.7,0.1c-0.5,0.1-1,0.1-1.5,0.2
|
||||
c-0.5,0.1-1,0.1-1.6,0.2c-0.5,0.1-1,0.1-1.4,0.2c-0.2,0-0.3,0-0.5,0.1c-0.2,0-0.4,0.2-0.5,0.4c0,0.2-0.1,0.4-0.1,0.5
|
||||
c0,0.4-0.1,0.8-0.1,1.2c-0.1,0.5-0.1,1-0.2,1.5c0,0.4-0.1,0.9-0.1,1.3l-0.1,1.3l-0.1,1.3c-0.1,0.5-0.1,1-0.2,1.5
|
||||
C5317.1-8126,5317.1-8125.8,5317.1-8125.6z"/>
|
||||
<path id="Path_181" class="st0" d="M5316.1-8140c0,0.6,0.1,1.2,0.1,1.8c0,0.4,0.2,0.8,0.6,1c0.3,0.2,0.7,0.3,1.1,0.3
|
||||
c0.7,0.1,1.4,0.1,2.1,0c0.6,0,1.2-0.1,1.8-0.2c0.4,0,0.9-0.2,1.2-0.5c0.3-0.3,0.5-0.7,0.5-1.1c0-1.2,0-2.3-0.1-3.5
|
||||
c0-0.3-0.1-0.6-0.3-0.8c-0.3-0.4-0.8-0.6-1.4-0.6c0,0,0,0-0.1,0c-0.2,0.1-0.4,0.1-0.6,0.1c-0.9,0-1.8,0.1-2.7,0.1
|
||||
c-0.1,0-0.3,0-0.4,0c-0.4-0.1-0.8,0-1.2,0.2c-0.4,0.2-0.6,0.6-0.7,1c0,0.1,0,0.2,0,0.3C5316-8141.2,5316.1-8140.6,5316.1-8140
|
||||
L5316.1-8140z"/>
|
||||
<path id="Path_182" class="st0" d="M5312-8129.2c0,0.6,0,1.2,0,1.8c0,0.1,0,0.1,0.1,0.1c0.3,0,0.6,0.1,0.9,0.1c0.3,0,0.7,0,1,0
|
||||
c0.1,0,0.2,0,0.3,0c0.1,0,0.1,0,0.1-0.1c0.1-0.4,0.2-0.8,0.2-1.2c0.1-0.5,0.2-1,0.3-1.4c0-0.1,0.1-0.1,0.1-0.1
|
||||
c0.4-0.2,0.8-0.5,1.2-0.8c0.4-0.4,0.7-0.9,0.8-1.5c0.1-0.6,0-1.2-0.4-1.7c-0.2-0.3-0.6-0.4-0.9-0.3c-0.3,0.1-0.6,0.3-0.9,0.5
|
||||
c-0.7,0.6-1.5,1.2-2.2,1.8c-0.3,0.2-0.5,0.5-0.6,0.8c0,0.2-0.1,0.4-0.1,0.6C5311.9-8130.2,5311.9-8129.7,5312-8129.2
|
||||
C5311.9-8129.2,5312-8129.2,5312-8129.2z"/>
|
||||
<path id="Path_183" class="st0" d="M5315.5-8124.7c0,0.2-0.1,0.5-0.1,0.7c-0.1,0.5-0.4,0.9-0.8,1.1c0,0,0,0,0,0
|
||||
c-0.1,0-0.2,0.2-0.2,0.3c-0.4,1.4-0.9,2.7-1.3,4.1c0,0,0,0.1,0,0.1c0.8,1.1,1.6,2.2,2.4,3.3c0,0,0,0,0.1,0.1
|
||||
c0.1-0.2,0.1-0.3,0.2-0.5c0.1-0.3,0.2-0.5,0.3-0.8c0,0,0-0.1,0-0.1c-0.2-0.3-0.5-0.7-0.7-1c0,0,0-0.1,0-0.2
|
||||
c0.3-0.9,0.6-1.7,0.9-2.6c0,0,0-0.1,0.1-0.1c0.5-0.2,0.9-0.6,1.1-1.1c0.1-0.3,0.1-0.7,0.1-1.1c0-0.4-0.1-0.8-0.3-1.2
|
||||
c-0.2-0.4-0.5-0.8-1-1C5315.9-8124.7,5315.7-8124.7,5315.5-8124.7z"/>
|
||||
<path id="Path_184" class="st0" d="M5314.7-8134.2c0.1-0.1,0.2-0.1,0.3-0.2c0.3-0.2,0.7-0.3,1-0.3c0.4,0,0.7,0.2,0.8,0.6
|
||||
c0.6,1.1,0.5,2.4-0.4,3.3c-0.4,0.4-0.8,0.7-1.3,1c0,0-0.1,0.1-0.1,0.1c-0.2,0.8-0.3,1.6-0.5,2.5c0,0,0,0.1,0,0.1
|
||||
c0,0.2,0,0.2-0.2,0.2c-0.1,0-0.1,0-0.2,0c0,0.1,0,0.2,0,0.3c0,0,0,0,0.1,0.1l1.9,0.7c0.2,0.1,0.4,0.2,0.7,0.2c0-0.1,0-0.2,0-0.2
|
||||
c0-0.3,0-0.6,0-0.8l0.2-1.5l0.2-1.5c0.1-0.5,0.1-1,0.2-1.5c0.1-0.5,0.1-1.1,0.2-1.6c0.1-0.5,0.1-1,0.2-1.5c0-0.2,0-0.4,0-0.6
|
||||
c0-0.2-0.1-0.4-0.3-0.4c0,0,0,0,0,0c-0.1,0-0.1,0-0.2,0c-0.6-0.1-1.2-0.2-1.9-0.3c-0.1,0-0.2,0-0.3,0c-0.1,0-0.2,0.1-0.3,0.3
|
||||
C5314.8-8135,5314.7-8134.6,5314.7-8134.2z"/>
|
||||
<path id="Path_185" class="st0" d="M5324.5-8117.2c-0.2-0.7-0.5-1.3-0.7-2l-0.7,0.3c0,0-0.1,0-0.1,0c-0.1,0.1-0.2,0-0.2-0.1
|
||||
c-0.1-0.3-0.2-0.5-0.3-0.8c-0.2-0.7-0.5-1.4-0.7-2.1c0,0,0-0.1,0-0.1c0,0,0,0.1-0.1,0.1c-0.1,0.2-0.3,0.3-0.5,0.5c0,0-0.1,0-0.1,0
|
||||
c-0.3,0.1-0.6,0.1-0.8,0.2c0,0-0.1,0-0.1,0c0,0.2-0.1,0.3-0.1,0.5c0.6,1.5,1.1,3.1,1.7,4.6c0,0,0,0,0,0.1
|
||||
C5322.7-8116.3,5323.6-8116.7,5324.5-8117.2z"/>
|
||||
<path id="Path_186" class="st0" d="M5325.4-8123.1c-0.7,0.2-1.3,0.3-2,0.5c-0.5,0.1-0.9,0.2-1.4,0.3c-0.1,0-0.2,0.1-0.1,0.2
|
||||
c0,0,0,0,0,0.1c0.2,0.5,0.3,0.9,0.5,1.4c0.2,0.5,0.4,1.1,0.6,1.6c0,0,0,0,0,0c0.1-0.1,0.2-0.1,0.3-0.2c0.2-0.1,0.3-0.2,0.5-0.2
|
||||
c0.2-0.1,0.4-0.1,0.6-0.2c0.7-0.2,1.5-0.4,2.2-0.6c0,0,0,0,0.1,0C5326.3-8121.1,5325.9-8122.1,5325.4-8123.1z"/>
|
||||
<path id="Path_187" class="st0" d="M5320.7-8124.4c-0.4,0.1-0.8,0.2-1.2,0.3c-0.6,0.1-1.3,0.3-1.9,0.4c0,0-0.1,0-0.1,0
|
||||
c-0.1,0-0.2-0.1-0.3-0.1c0,0,0,0.1,0,0.1c0.3,0.7,0.4,1.5,0.3,2.2c-0.1,0.4-0.3,0.8-0.5,1.1c0,0,0,0-0.1,0.1
|
||||
c0.2-0.1,0.4-0.1,0.6-0.1l2.5-0.6c0.5-0.1,0.9-0.6,1-1.1c0.1-0.5,0-1-0.1-1.5C5320.8-8124,5320.8-8124.2,5320.7-8124.4z"/>
|
||||
<path id="Path_188" class="st0" d="M5325.5-8127c-2.7,0.5-5.3,1.1-7.9,1.6c0,0.5,0,0.9,0.1,1.4c0.1,0,0.2,0,0.3-0.1
|
||||
c1.2-0.3,2.3-0.5,3.5-0.8c1.2-0.3,2.4-0.5,3.6-0.8c0.1,0,0.3-0.1,0.4-0.1c0,0,0.1,0,0.1-0.1
|
||||
C5325.6-8126.2,5325.5-8126.6,5325.5-8127z"/>
|
||||
<path id="Path_189" class="st0" d="M5328.6-8118.4c-0.2-0.4-0.3-0.7-0.5-1.1c-0.1-0.2-0.2-0.5-0.3-0.7c0-0.1,0-0.1-0.1,0
|
||||
c-1.2,0.3-2.4,0.6-3.6,1c0,0,0,0-0.1,0c0.2,0.7,0.5,1.3,0.7,2C5326-8117.6,5327.3-8118,5328.6-8118.4z"/>
|
||||
<path id="Path_190" class="st0" d="M5319.9-8120.9l-0.6,0.1c-1,0.2-2,0.5-3,0.7c-0.1,0-0.1,0.1-0.1,0.1c-0.3,0.7-0.5,1.5-0.8,2.2
|
||||
c0,0,0,0,0,0.1c0.2,0,0.4-0.1,0.5-0.1c1-0.3,2-0.5,3.1-0.8c0.1,0,0.2-0.1,0.3-0.2C5319.5-8119.5,5319.7-8120.2,5319.9-8120.9z"/>
|
||||
<path id="Path_191" class="st0" d="M5325.1-8125.4c-1.1,0.2-2.2,0.5-3.3,0.7c0.3,0.7,0.4,1.4,0.3,2.2c0.2,0,0.4-0.1,0.5-0.1
|
||||
c0.9-0.2,1.8-0.4,2.7-0.6c0.1,0,0.1,0,0.1-0.1c0.1-0.4,0-0.9-0.1-1.3C5325.3-8124.9,5325.2-8125.1,5325.1-8125.4
|
||||
C5325.1-8125.3,5325.1-8125.4,5325.1-8125.4z"/>
|
||||
<path id="Path_192" class="st0" d="M5325.6-8132c0.2,0,0.4,0,0.5,0c0.2,0,0.4,0,0.6,0c0.3,0,0.6-0.2,0.8-0.4c0.3-0.4,0.7-0.8,1-1.2
|
||||
c-0.1-0.1-0.1-0.1-0.1-0.2c0,0,0,0-0.1,0c-0.7-0.1-1.3-0.5-1.4-1.2c-0.1-0.2-0.1-0.4-0.1-0.6c-0.2,0.1-0.3,0.3-0.5,0.4
|
||||
c-0.1,0.1-0.2,0.1-0.3,0.2c0,0-0.1,0.1-0.2,0c-0.2,0-0.5-0.1-0.7-0.1c0,0,0,0-0.1,0C5325.3-8134.1,5325.4-8133.1,5325.6-8132z"/>
|
||||
<path id="Path_193" class="st0" d="M5328.4-8134.2c0.2-0.3,0.5-0.5,0.8-0.7c0.4-0.4,0.6-0.8,0.7-1.4c0-0.1,0-0.2-0.1-0.3
|
||||
c-0.3-0.5-0.7-1.1-1-1.6c0-0.1-0.1-0.1-0.1,0c-0.4,0.2-0.8,0.5-1.1,0.8c-0.2,0.2-0.4,0.4-0.6,0.6c-0.1,0.1-0.1,0.3,0,0.4
|
||||
c0.5,0.7,1,1.5,1.4,2.2C5328.4-8134.2,5328.4-8134.2,5328.4-8134.2z"/>
|
||||
<path id="Path_194" class="st0" d="M5314.3-8126.1c-0.1-0.1-0.1-0.1-0.2-0.2c-0.1,0-0.1-0.1-0.1-0.2c0-0.1,0-0.3,0-0.4h-0.1
|
||||
c-0.6,0-1.2-0.1-1.7-0.2c0,0-0.1,0-0.1,0c-0.4,0.2-0.7,0.4-1,0.8c-0.4,0.6-0.4,1.4,0.1,1.9c0.2,0.2,0.4,0.4,0.6,0.6
|
||||
c0.1,0.1,0.2,0.2,0.3,0.2c-0.2-0.6,0-1.3,0.5-1.8C5313-8125.9,5313.6-8126.2,5314.3-8126.1z"/>
|
||||
<path id="Path_195" class="st0" d="M5315.7-8114.9c0.5-0.1,0.9-0.3,1.4-0.4c0.8-0.2,1.6-0.4,2.4-0.7c0.1,0,0.1,0,0.1-0.1
|
||||
c0.1-0.4,0.2-0.7,0.4-1.1c0,0,0,0,0-0.1c-0.1,0-0.2,0-0.3,0.1c-1.2,0.3-2.3,0.6-3.5,1c-0.1,0-0.1,0.1-0.1,0.1
|
||||
c-0.1,0.4-0.3,0.7-0.4,1.1C5315.7-8115,5315.7-8115,5315.7-8114.9z"/>
|
||||
<path id="Path_196" class="st0" d="M5315.4-8117.4c0.2,0.3,0.4,0.6,0.6,0.9c0,0,0.1,0,0.1,0c1-0.3,1.9-0.5,2.9-0.8
|
||||
c0.3-0.1,0.6-0.2,0.9-0.2c-0.1-0.1-0.1-0.2-0.2-0.2c-0.2-0.2-0.3-0.4-0.5-0.6c0,0-0.1-0.1-0.1,0c-0.9,0.3-1.9,0.5-2.8,0.8
|
||||
C5316-8117.5,5315.7-8117.5,5315.4-8117.4z"/>
|
||||
<path id="Path_197" class="st0" d="M5321.3-8143.6c0-0.3,0-0.7,0-1c0,0-0.1,0-0.1,0c-0.7,0-1.5,0-2.2,0.1c-0.4,0-0.7,0-1.1,0.1
|
||||
c-0.1,0-0.1,0-0.1,0.1c0,0.3,0,0.6,0,0.8c0,0,0,0.1,0.1,0.1c0.4,0,0.8,0,1.1,0c0.5,0,1.1,0,1.6-0.1
|
||||
C5320.9-8143.5,5321.1-8143.6,5321.3-8143.6z"/>
|
||||
<path id="Path_198" class="st0" d="M5329.2-8134.3c0.1,0,0.2,0,0.2-0.1c0.4-0.2,0.8-0.4,1.1-0.7c0.3-0.2,0.4-0.5,0.6-0.8
|
||||
c0.1-0.3,0.1-0.6-0.1-0.9c-0.4-0.5-0.7-1-1.1-1.6c0,0,0,0-0.1-0.1c-0.2,0.2-0.4,0.4-0.6,0.6c0,0,0,0,0,0c0,0,0,0.1,0,0.1
|
||||
c0.2,0.4,0.5,0.7,0.7,1c0.1,0.2,0.2,0.4,0.1,0.6c0,0.5-0.1,0.9-0.4,1.3c-0.1,0.1-0.2,0.2-0.3,0.3
|
||||
C5329.4-8134.5,5329.3-8134.4,5329.2-8134.3C5329.2-8134.3,5329.2-8134.3,5329.2-8134.3z"/>
|
||||
<path id="Path_199" class="st0" d="M5317.5-8136.7c0,0.2,0,0.3,0,0.5c0,0,0,0.1,0.1,0.1c0.2,0,0.3,0.1,0.5,0.1c0.7,0.1,1.4,0.1,2,0
|
||||
c0.4,0,0.8-0.1,1.2-0.1c0.2,0,0.5-0.1,0.7-0.1c0.1,0,0.1,0,0.1-0.1c0-0.2,0-0.3,0-0.5C5320.5-8136.6,5319-8136.5,5317.5-8136.7z"/>
|
||||
<path id="Path_200" class="st0" d="M5312.5-8123.2c0.1-0.4,0.1-0.8,0.2-1.2c0.1-0.6,0.6-1,1.2-1c0.3,0,0.5,0.1,0.7,0.3
|
||||
c0.2,0.2,0.2,0.4,0.2,0.7c-0.1,0.3-0.2,0.6-0.2,0.9c0,0.1-0.1,0.2-0.1,0.4c0,0,0,0,0,0c0.1-0.1,0.2-0.2,0.3-0.3
|
||||
c0.3-0.4,0.4-0.9,0.4-1.4c0-0.6-0.4-1-0.9-1.1c-0.1,0-0.1,0-0.2,0c-0.5,0-1,0.3-1.4,0.7c-0.3,0.3-0.4,0.6-0.5,1
|
||||
c-0.1,0.3,0,0.7,0.2,1C5312.5-8123.2,5312.5-8123.2,5312.5-8123.2z"/>
|
||||
<path id="Path_201" class="st0" d="M5314.3-8123.2c0.1-0.5,0.3-0.9,0.4-1.4c0.1-0.2,0-0.4-0.2-0.5c-0.4-0.2-0.9-0.1-1.2,0.2
|
||||
c0,0,0,0,0,0.1c0,0.2,0,0.4,0.1,0.6c0,0.1,0.1,0.2,0.2,0.3C5313.7-8123.6,5314-8123.4,5314.3-8123.2
|
||||
C5314.2-8123.2,5314.3-8123.2,5314.3-8123.2z"/>
|
||||
<path id="Path_202" class="st0" d="M5317.4-8124.1c0-0.4,0-0.9-0.1-1.3c-0.1,0-0.1,0-0.2,0c-0.1,0-0.2,0-0.3,0
|
||||
c-0.7-0.3-1.4-0.5-2.1-0.8c0,0,0,0,0,0c0.1,0.1,0.1,0.1,0.2,0.2c0.3,0.2,0.5,0.6,0.6,0.9c0,0,0,0,0,0c0.1,0,0.3,0,0.4,0.1
|
||||
c0.3,0.1,0.6,0.3,0.9,0.5c0,0,0.1,0.1,0.1,0.1C5317.1-8124.2,5317.2-8124.1,5317.4-8124.1z"/>
|
||||
<path id="Path_203" class="st0" d="M5321.6-8124.6c-0.2,0-0.4,0.1-0.6,0.1c0.1,0.2,0.1,0.4,0.2,0.6c0.1,0.4,0.2,0.8,0.1,1.2
|
||||
c0,0.5-0.1,0.9-0.4,1.3c0,0,0,0,0,0c0.3,0,0.6-0.2,0.7-0.5c0.2-0.3,0.3-0.6,0.3-0.9C5321.9-8123.4,5321.8-8124,5321.6-8124.6z"/>
|
||||
<path id="Path_204" class="st0" d="M5315.7-8135.8c0.2,0,0.3,0.1,0.5,0.1c0.5,0.1,1,0.2,1.5,0.2c0.2,0,0.5,0,0.7,0
|
||||
c0.7-0.1,1.4-0.2,2.1-0.2c0.6-0.1,1.2-0.2,1.8-0.2c0.5-0.1,1.1-0.1,1.6-0.2l-1.5-0.2c0,0,0,0,0,0c0,0.2-0.1,0.3-0.2,0.3
|
||||
c0,0,0,0,0,0c-0.3,0.1-0.5,0.1-0.8,0.2c-0.8,0.1-1.6,0.1-2.3,0.1c-0.4,0-0.9,0-1.3-0.1c-0.1,0-0.2-0.1-0.3-0.2c0,0-0.1,0-0.1,0
|
||||
c-0.3,0-0.6,0.1-0.9,0.1L5315.7-8135.8L5315.7-8135.8z"/>
|
||||
<path id="Path_205" class="st0" d="M5327.3-8117.7c-0.3,0.1-0.5,0.2-0.8,0.2c-0.6,0.2-1.1,0.3-1.7,0.5c0,0-0.1,0-0.1,0.1
|
||||
c-0.5,0.2-1,0.5-1.5,0.7c0,0,0,0,0,0c0.3-0.1,0.5-0.1,0.8-0.2c0.5-0.2,1.1-0.3,1.6-0.5c0.1,0,0.2-0.1,0.2-0.1
|
||||
C5326.2-8117.2,5326.8-8117.5,5327.3-8117.7C5327.3-8117.7,5327.3-8117.7,5327.3-8117.7C5327.3-8117.7,5327.3-8117.7,5327.3-8117.7
|
||||
z"/>
|
||||
<path id="Path_206" class="st0" d="M5327-8135.8c0,0.1,0,0.2,0,0.4c0.1,0.5,0.3,0.9,0.7,1.1c0.1,0.1,0.3,0.1,0.4,0.2l0,0
|
||||
C5327.8-8134.7,5327.4-8135.2,5327-8135.8L5327-8135.8z"/>
|
||||
<path id="Path_207" class="st0" d="M5329-8134.4c-0.1,0.1-0.2,0.2-0.3,0.4c0,0,0,0,0,0.1c0,0.1,0,0.1,0.1,0.1c0.1,0,0.2,0,0.3-0.1
|
||||
c0.1,0,0.2-0.1,0.3-0.1c-0.1,0-0.1-0.1-0.2-0.1C5329-8134.2,5329-8134.3,5329-8134.4z"/>
|
||||
<g>
|
||||
<polygon class="st0" points="2,9.9 5.8,8.2 5.8,8 6.2,7.4 6.9,6.9 8,6.6 9.1,6.5 9.5,6.6 13.1,5 13.1,4.8 13.4,4.3 14,3.9
|
||||
14.9,3.6 16,3.5 17.1,3.6 18,3.9 18.6,4.3 18.9,4.8 18.9,5 22.4,6.6 23,6.6 24,6.7 25,7 25.8,7.5 26.2,8 26.2,8.3 29.9,10
|
||||
28.8,19.3 15.9,28.5 3.1,19.2 "/>
|
||||
<g>
|
||||
<path class="st1" d="M15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6L15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6
|
||||
C15.9,28.6,15.9,28.6,15.9,28.6L15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6L15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6L15.9,28.6
|
||||
C15.9,28.6,15.9,28.6,15.9,28.6L15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6
|
||||
C15.9,28.6,15.9,28.6,15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6L3.1,19.3c0,0,0,0,0,0L2,9.9c0,0,0,0,0,0c0,0,0,0,0,0l0,0
|
||||
c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0l0,0c0,0,0,0,0,0v0c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0h0c0,0,0,0,0,0c0,0,0,0,0,0
|
||||
c0,0,0,0,0,0l3.8-1.7l0-0.1l0-0.1c0,0,0,0,0,0l0.4-0.6c0,0,0,0,0,0l0.7-0.5c0,0,0,0,0,0l1-0.3c0,0,0,0,0,0l1.2-0.1c0,0,0,0,0,0
|
||||
l0.4,0l3.6-1.6l0-0.1c0,0,0,0,0,0c0,0,0,0,0,0l0,0l0.2-0.5c0,0,0,0,0,0L14,3.8c0,0,0,0,0,0l0.9-0.3c0,0,0,0,0,0L16,3.4
|
||||
c0,0,0,0,0,0l1.1,0.1c0,0,0,0,0,0L18,3.8c0,0,0,0,0,0l0.6,0.4c0,0,0,0,0,0l0.3,0.5c0,0,0,0,0,0v0c0,0,0,0,0,0l0,0.2l3.6,1.6l0.4,0
|
||||
c0,0,0,0,0,0L24,6.6c0,0,0,0,0,0l1,0.3c0,0,0,0,0,0l0.8,0.5c0,0,0,0,0,0L26.2,8c0,0,0,0,0,0c0,0,0,0,0,0l0,0.2L30,9.9c0,0,0,0,0,0
|
||||
l0,0c0,0,0,0,0,0l0,0c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0l0,0c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0
|
||||
c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0l-1.2,9.3c0,0,0,0,0,0L15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6
|
||||
C15.9,28.6,15.9,28.6,15.9,28.6L15.9,28.6C15.9,28.6,15.9,28.6,15.9,28.6z M16,18.5L16,28.4l12.8-9.1l1.2-9.2L16,18.5z M3.2,19.2
|
||||
l12.7,9.2l0.1-9.9L2.1,10L3.2,19.2z M2.1,9.9L16,18.4L29.9,10l-3.6-1.6L26.1,10L26,10.6c0,0,0,0,0,0l-0.6,0.5c0,0,0,0,0,0
|
||||
l-0.9,0.4c0,0,0,0,0,0l-1.2,0.1c0,0,0,0,0,0L22,11.5c0,0,0,0,0,0l-1.1-0.4c0,0,0,0,0,0l-0.7-0.5c0,0,0,0,0,0L19.9,10c0,0,0,0,0,0
|
||||
L20,8c0,0,0,0,0,0v0c0,0,0,0,0,0s0,0,0,0v0c0,0,0,0,0,0l0.2-0.6c0,0,0,0,0,0l0.6-0.5c0,0,0,0,0,0l0.9-0.3c0,0,0,0,0,0l0.5-0.1
|
||||
l-3.3-1.5l0,1.5c0,0,0,0,0,0l-0.2,0.5c0,0,0,0,0,0l-0.6,0.4c0,0,0,0,0,0l-0.9,0.3c0,0,0,0,0,0L16,8c0,0,0,0,0,0l-1.1-0.1
|
||||
c0,0,0,0,0,0l-0.9-0.3c0,0,0,0,0,0l-0.6-0.5c0,0,0,0,0,0l-0.2-0.5c0,0,0,0,0,0l0-1.5L9.7,6.5l0.5,0.1c0,0,0,0,0,0l0.9,0.3
|
||||
c0,0,0,0,0,0l0,0c0,0,0,0,0,0l0.6,0.5c0,0,0,0,0,0L12,8c0,0,0,0,0,0l0.1,1.9c0,0,0,0,0,0l-0.3,0.5l0,0.1c0,0,0,0,0,0L11,11.1
|
||||
c0,0,0,0,0,0L10,11.5c0,0,0,0,0,0l-1.2,0.1c0,0,0,0,0,0l-1.2-0.1c0,0,0,0,0,0l-0.9-0.4c0,0,0,0,0,0L6,10.5c0,0,0,0,0,0L5.9,9.9
|
||||
L5.8,8.3L2.1,9.9z M22,11.4l1.2,0.1l1.2-0.1l0.9-0.3l0.5-0.5L26,9.9l0.1-1.2L26,8.8l-0.1,0.1l-0.3,0.3c0,0,0,0,0,0l-1,0.3
|
||||
c0,0,0,0,0,0l-1.2,0.1c0,0,0,0,0,0l-1.2-0.1c0,0,0,0,0,0L21,9.2c0,0,0,0,0,0l-0.7-0.5c0,0,0,0,0,0l-0.2-0.4L20,9.9l0.3,0.6L21,11
|
||||
L22,11.4z M7.6,11.3l1.2,0.1l1.2-0.1l1-0.3l0.7-0.5l0,0L12,9.9l-0.1-1.7l-0.2,0.4c0,0,0,0,0,0L11,9.2c0,0,0,0,0,0L9.9,9.5
|
||||
c0,0,0,0,0,0L8.7,9.6c0,0,0,0,0,0L7.4,9.5c0,0,0,0,0,0l-1-0.4c0,0,0,0,0,0L5.9,8.7L6,9.9l0.1,0.6L6.7,11L7.6,11.3z M22.1,9.4
|
||||
l1.2,0.1l1.2-0.1l1-0.3l0.3-0.3l0.1-0.1L26,8.6l0.1-0.5l0,0l-0.3-0.5L25,7l-1-0.3l-1.2-0.1l-0.4,0l-0.7,0.1L20.8,7l-0.6,0.5
|
||||
L20.1,8l0.3,0.5l0.7,0.5L22.1,9.4z M7.4,9.4l1.2,0.1l1.2-0.1l1.1-0.3l0.7-0.5L11.9,8l-0.2-0.5L11.1,7l-0.9-0.3L9.5,6.6
|
||||
c0,0,0,0,0,0l-0.4,0l0,0L8,6.7L6.9,7L6.2,7.4L5.9,8l0,0c0,0,0,0,0,0L6,8.5L6.5,9L7.4,9.4z M14.9,7.8L16,7.9l1.1-0.1l0.1,0L18,7.5
|
||||
l0.6-0.4l0.2-0.5l0-1.4l-0.1,0.2c0,0,0,0,0,0l-0.6,0.4c0,0,0,0,0,0l-0.9,0.3c0,0,0,0,0,0L16,6.2c0,0,0,0,0,0l-1.1-0.1c0,0,0,0,0,0
|
||||
l-0.9-0.3c0,0,0,0,0,0l-0.6-0.4c0,0,0,0,0,0l-0.1-0.2l0,1.5l0.2,0.5L14,7.5L14.9,7.8z M14.9,5.9L16,6.1L17.1,6L18,5.7l0.6-0.4
|
||||
l0.2-0.5l-0.2-0.5L18,3.9L17,3.6L16,3.6l-1.1,0.1L14,3.9l-0.6,0.4l-0.2,0.5l0.2,0.5L14,5.7L14.9,5.9z M16,15.8
|
||||
C16,15.8,16,15.8,16,15.8l-1.3-0.2c0,0,0,0,0,0l-1.1-0.4c0,0,0,0,0,0l-0.7-0.6c0,0,0,0,0,0l-0.2-0.7c0,0,0,0,0,0l0-2l0,0
|
||||
c0,0,0,0,0,0l0.3-0.7c0,0,0,0,0,0l0.7-0.6c0,0,0,0,0,0l1.1-0.4c0,0,0,0,0,0L16,10c0,0,0,0,0,0l1.3,0.1c0,0,0,0,0,0l1.1,0.4
|
||||
c0,0,0,0,0,0l0.7,0.6c0,0,0,0,0,0l0.3,0.7c0,0,0,0,0,0l0,0l-0.1,2c0,0,0,0,0,0l-0.2,0.7c0,0,0,0,0,0l-0.7,0.6c0,0,0,0,0,0
|
||||
l-1.1,0.4c0,0,0,0,0,0L16,15.8C16,15.8,16,15.8,16,15.8z M14.7,15.5l1.3,0.1l1.3-0.1l1.1-0.4l0.7-0.6l0.2-0.7v0l0-1.5l-0.1,0.2
|
||||
c0,0,0,0,0,0l-0.7,0.6c0,0,0,0,0,0l-1.1,0.4c0,0,0,0,0,0L16,13.7c0,0,0,0,0,0l-1.3-0.1c0,0,0,0,0,0l-1.1-0.4c0,0,0,0,0,0l-0.7-0.6
|
||||
c0,0,0,0,0,0l-0.1-0.3l0,1.5l0.2,0.7l0.7,0.6L14.7,15.5z M14.7,13.5l1.3,0.1l1.3-0.1l1.1-0.4l0.7-0.6l0.1-0.3l0,0c0,0,0,0,0,0
|
||||
l0-0.1l0,0c0,0,0,0,0,0l0,0l0-0.1L19,11.2l-0.7-0.5l-1.1-0.4L16,10.2l-1.2,0.1l-1.1,0.4L13,11.2l-0.3,0.6l0,0c0,0,0,0,0,0l0.2,0.7
|
||||
l0.7,0.6L14.7,13.5z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.9 KiB |
BIN
docs/static/coding/autonomous-parking/auto-parking-connect.jpg
vendored
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
docs/static/coding/autonomous-parking/ev3-robot-driving-base.jpg
vendored
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
docs/static/coding/line-detection/car-road-line.jpg
vendored
Normal file
After Width: | Height: | Size: 77 KiB |
BIN
docs/static/coding/line-detection/ev3-color-squares.jpg
vendored
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
docs/static/coding/line-detection/ev3-robot-color-sensor-down.jpg
vendored
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
docs/static/coding/line-detection/ev3-robot-driving-base.jpg
vendored
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
docs/static/coding/object-detection/ev3-cuboid.jpg
vendored
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
docs/static/coding/object-detection/ev3-robot-driving-base.jpg
vendored
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
docs/static/coding/object-detection/road-deer.jpg
vendored
Normal file
After Width: | Height: | Size: 42 KiB |
9
docs/static/fonts/icons/iconfont.css
vendored
@ -1,8 +1,8 @@
|
||||
@font-face {
|
||||
font-family: "iconfont";
|
||||
src: url("iconfont.eot?8b7e57577c2d1f1ae9e810b9e010bc84?#iefix") format("embedded-opentype"),
|
||||
url("iconfont.woff2?8b7e57577c2d1f1ae9e810b9e010bc84") format("woff2"),
|
||||
url("iconfont.woff?8b7e57577c2d1f1ae9e810b9e010bc84") format("woff");
|
||||
src: url("iconfont.eot?92b07c6c5392088e45983d845234d068?#iefix") format("embedded-opentype"),
|
||||
url("iconfont.woff2?92b07c6c5392088e45983d845234d068") format("woff2"),
|
||||
url("iconfont.woff?92b07c6c5392088e45983d845234d068") format("woff");
|
||||
}
|
||||
|
||||
.icon {
|
||||
@ -91,3 +91,6 @@ url("iconfont.woff?8b7e57577c2d1f1ae9e810b9e010bc84") format("woff");
|
||||
.icon-blocks:before {
|
||||
content: "\f119";
|
||||
}
|
||||
.icon-search:before {
|
||||
content: "\f11a";
|
||||
}
|
||||
|
BIN
docs/static/fonts/icons/iconfont.eot
vendored
3
docs/static/fonts/icons/iconfont.svg
vendored
@ -82,6 +82,9 @@
|
||||
<glyph glyph-name="blocks"
|
||||
unicode=""
|
||||
horiz-adv-x="40" d=" M10.9 23H39V16.9H10.9V23z M39.2 27.1L39.2 33L0.9 33L0.9 31.1L0.9 27.1L0.9 12.9L0.9 7L39.2 7L39.2 12.9L6.9 12.9L6.9 27.1z" />
|
||||
<glyph glyph-name="search"
|
||||
unicode=""
|
||||
horiz-adv-x="40" d=" M38.6 4.9L29.6 13.9C31.5 16.5 32.7 19.7 32.7 23.1C32.7 31.8 25.7 38.8 17 38.8C8.3 38.8 1.4 31.8 1.4 23.1C1.4 14.4 8.3 7.5 17 7.5C20.3 7.5 23.3 8.5 25.9 10.3L35 1.2L38.6 4.9zM17 12.7C11.3 12.7 6.6 17.4 6.6 23.1S11.3 33.6 17 33.6S27.5 28.9 27.5 23.1S22.8 12.7 17 12.7z" />
|
||||
</font>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
BIN
docs/static/fonts/icons/iconfont.ttf
vendored
BIN
docs/static/fonts/icons/iconfont.woff
vendored
BIN
docs/static/fonts/icons/iconfont.woff2
vendored
BIN
docs/static/lessons/autonomous-parking.png
vendored
Normal file
After Width: | Height: | Size: 101 KiB |
BIN
docs/static/lessons/line-detection.jpg
vendored
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 36 KiB |
BIN
docs/static/lessons/make-a-security-device.png
vendored
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
docs/static/lessons/make-a-security-gadget/lego-maker-security.jpg
vendored
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
docs/static/lessons/make-a-security-gadget/lego-security-gadget.jpg
vendored
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
docs/static/lessons/make-a-sound-machine/lego-maker-sound-machine-1.jpg
vendored
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
docs/static/lessons/make-a-sound-machine/lego-maker-sound-machine.jpg
vendored
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
docs/static/lessons/make-a-sound-machine/three-stock.jpg
vendored
Normal file
After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
BIN
docs/static/lessons/make-a-system.png
vendored
Before Width: | Height: | Size: 592 KiB |
BIN
docs/static/lessons/make-it-move-without-wheels.png
vendored
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
docs/static/lessons/make-it-move.png
vendored
Before Width: | Height: | Size: 357 KiB |
BIN
docs/static/lessons/make-it-smarter-and-faster.png
vendored
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
docs/static/lessons/make-it-smarter.png
vendored
Before Width: | Height: | Size: 413 KiB |
BIN
docs/static/lessons/make-it-smarter/bricks.png
vendored
Normal file
After Width: | Height: | Size: 118 KiB |
BIN
docs/static/lessons/object-detection.jpg
vendored
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
docs/static/lessons/try.png
vendored
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 34 KiB |
BIN
docs/static/lessons/use.png
vendored
Before Width: | Height: | Size: 236 KiB After Width: | Height: | Size: 48 KiB |
@ -7,6 +7,7 @@ import { FieldImages } from "./field_images";
|
||||
import { FieldSpeed } from "./field_speed";
|
||||
import { FieldBrickButtons } from "./field_brickbuttons";
|
||||
import { FieldTurnRatio } from "./field_turnratio";
|
||||
import { FieldColorEnum } from "./field_color";
|
||||
|
||||
pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
||||
pxt.debug('loading pxt-ev3 target extensions...')
|
||||
@ -27,6 +28,9 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
}, {
|
||||
selector: "turnratio",
|
||||
editor: FieldTurnRatio
|
||||
}, {
|
||||
selector: "colorenum",
|
||||
editor: FieldColorEnum
|
||||
}],
|
||||
deployCoreAsync,
|
||||
showUploadInstructionsAsync: (fn: string, url: string, confirmAsync: (options: any) => Promise<number>) => {
|
||||
|
71
editor/field_color.ts
Normal file
@ -0,0 +1,71 @@
|
||||
/// <reference path="../node_modules/pxt-core/localtypings/blockly.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
|
||||
|
||||
export interface FieldColorEnumOptions extends pxtblockly.FieldColourNumberOptions {
|
||||
}
|
||||
|
||||
export class FieldColorEnum extends pxtblockly.FieldColorNumber implements Blockly.FieldCustom {
|
||||
public isFieldCustom_ = true;
|
||||
|
||||
constructor(text: string, params: FieldColorEnumOptions, opt_validator?: Function) {
|
||||
super(text, params, opt_validator);
|
||||
}
|
||||
|
||||
mapColour(enumString: string) {
|
||||
switch(enumString) {
|
||||
case '#000000': return 'ColorSensorColor.Black';
|
||||
case '#006db3': return 'ColorSensorColor.Blue';
|
||||
case '#00934b': return 'ColorSensorColor.Green';
|
||||
case '#ffd01b': return 'ColorSensorColor.Yellow';
|
||||
case '#f12a21': return 'ColorSensorColor.Red';
|
||||
case '#ffffff': return 'ColorSensorColor.White';
|
||||
case '#6c2d00': return 'ColorSensorColor.Brown';
|
||||
default: return 'ColorSensorColor.None';
|
||||
}
|
||||
}
|
||||
|
||||
mapEnum(colorString: string) {
|
||||
console.log(colorString);
|
||||
switch(colorString) {
|
||||
case 'ColorSensorColor.Black': return '#000000';
|
||||
case 'ColorSensorColor.Blue': return '#006db3';
|
||||
case 'ColorSensorColor.Green': return '#00934b';
|
||||
case 'ColorSensorColor.Yellow': return '#ffd01b';
|
||||
case 'ColorSensorColor.Red': return '#f12a21';
|
||||
case 'ColorSensorColor.White': return '#ffffff';
|
||||
case 'ColorSensorColor.Brown': return '#6c2d00';
|
||||
case 'ColorSensorColor.None': return '#dfe6e9'; // Grey
|
||||
default: return colorString;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current colour.
|
||||
* @param {boolean} opt_asHex optional field if the returned value should be a hex
|
||||
* @return {string} Current colour in '#rrggbb' format.
|
||||
*/
|
||||
getValue(opt_asHex?: boolean) {
|
||||
var colour = this.mapColour(this.colour_);
|
||||
if (!opt_asHex && colour.indexOf('#') > -1) {
|
||||
return `0x${colour.replace(/^#/, '')}`;
|
||||
}
|
||||
return colour;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the colour.
|
||||
* @param {string} colour The new colour in '#rrggbb' format.
|
||||
*/
|
||||
setValue(colorStr: string) {
|
||||
var colour = this.mapEnum(colorStr);
|
||||
if (this.sourceBlock_ && Blockly.Events.isEnabled() &&
|
||||
this.colour_ != colour) {
|
||||
Blockly.Events.fire(new (Blockly as any).Events.BlockChange(
|
||||
this.sourceBlock_, 'field', this.name, this.colour_, colour));
|
||||
}
|
||||
this.colour_ = colour;
|
||||
if (this.sourceBlock_) {
|
||||
this.sourceBlock_.setColour(colour, colour, colour);
|
||||
}
|
||||
}
|
||||
}
|
9
libs/base/shims.d.ts
vendored
@ -64,6 +64,15 @@ declare interface Buffer {
|
||||
//% shim=BufferMethods::write
|
||||
write(dstOffset: int32, src: Buffer): void;
|
||||
}
|
||||
declare namespace control {
|
||||
|
||||
/**
|
||||
* Create a new zero-initialized buffer.
|
||||
* @param size number of bytes in the buffer
|
||||
*/
|
||||
//% shim=control::createBuffer
|
||||
function createBuffer(size: int32): Buffer;
|
||||
}
|
||||
declare namespace loops {
|
||||
|
||||
/**
|
||||
|
@ -19,21 +19,21 @@ enum LightIntensityMode {
|
||||
}
|
||||
|
||||
const enum ColorSensorColor {
|
||||
//% block="none" jres=colors.none blockIdentity=sensors.color
|
||||
//% block="none" blockIdentity=sensors.__colorEnumPicker
|
||||
None,
|
||||
//% block="black" jres=colors.black blockIdentity=sensors.color
|
||||
//% block="black" blockIdentity=sensors.__colorEnumPicker
|
||||
Black,
|
||||
//% block="blue" jres=colors.blue blockIdentity=sensors.color
|
||||
//% block="blue" blockIdentity=sensors.__colorEnumPicker
|
||||
Blue,
|
||||
//% block="green" jres=colors.green blockIdentity=sensors.color
|
||||
//% block="green" blockIdentity=sensors.__colorEnumPicker
|
||||
Green,
|
||||
//% block="yellow" jres=colors.yellow blockIdentity=sensors.color
|
||||
//% block="yellow" blockIdentity=sensors.__colorEnumPicker
|
||||
Yellow,
|
||||
//% block="red" jres=colors.red blockIdentity=sensors.color
|
||||
//% block="red" blockIdentity=sensors.__colorEnumPicker
|
||||
Red,
|
||||
//% block="white" jres=colors.white blockIdentity=sensors.color
|
||||
//% block="white" blockIdentity=sensors.__colorEnumPicker
|
||||
White,
|
||||
//% block="brown" jres=colors.brown blockIdentity=sensors.color
|
||||
//% block="brown" blockIdentity=sensors.__colorEnumPicker
|
||||
Brown
|
||||
}
|
||||
|
||||
@ -110,19 +110,14 @@ namespace sensors {
|
||||
* @param handler the code to run when detected
|
||||
*/
|
||||
//% help=sensors/color-sensor/on-color-detected
|
||||
//% block="on %sensor|detected color %color"
|
||||
//% block="on **color sensor** %this|detected %color=colorEnumPicker"
|
||||
//% blockId=colorOnColorDetected
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.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) {
|
||||
onColorDetected(color: number, handler: () => void) {
|
||||
this.setMode(ColorSensorMode.Color)
|
||||
const v = this._colorEventValue(<number>color);
|
||||
control.onEvent(this._id, v, handler);
|
||||
@ -135,19 +130,14 @@ namespace sensors {
|
||||
* @param color the color to detect
|
||||
*/
|
||||
//% help=sensors/color-sensor/pause-for-color
|
||||
//% block="pause %sensor|for color %color"
|
||||
//% block="pause **color sensor** %this|for %color=colorEnumPicker"
|
||||
//% blockId=colorPauseForColorDetected
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.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) {
|
||||
pauseForColor(color: number) {
|
||||
this.setMode(ColorSensorMode.Color);
|
||||
if (this.color() != color) {
|
||||
const v = this._colorEventValue(<number>color);
|
||||
@ -160,11 +150,11 @@ namespace sensors {
|
||||
* @param sensor the color sensor to query the request
|
||||
*/
|
||||
//% help=sensors/color-sensor/color
|
||||
//% block="%sensor| color"
|
||||
//% block="**color sensor** %this| color"
|
||||
//% blockId=colorGetColor
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.fieldEditor="ports"
|
||||
//% weight=98
|
||||
//% group="Color Sensor"
|
||||
//% blockGap=8
|
||||
@ -179,11 +169,11 @@ namespace sensors {
|
||||
* @param handler the code to run when detected
|
||||
*/
|
||||
//% help=sensors/color-sensor/on-light-changed
|
||||
//% block="on %sensor|%mode|%condition"
|
||||
//% block="on **color sensor** %this|%mode|%condition"
|
||||
//% blockId=colorOnLightChanged
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.fieldEditor="ports"
|
||||
//% weight=89 blockGap=12
|
||||
//% group="Color Sensor"
|
||||
onLightChanged(mode: LightIntensityMode, condition: LightCondition, handler: () => void) {
|
||||
@ -196,11 +186,11 @@ namespace sensors {
|
||||
* @param color the color to detect
|
||||
*/
|
||||
//% help=sensors/color-sensor/pause-for-light
|
||||
//% block="pause %sensor|for %mode|%condition"
|
||||
//% block="pause **color sensor** %this|for %mode|%condition"
|
||||
//% blockId=colorPauseForLight
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.fieldEditor="ports"
|
||||
//% weight=88 blockGap=8
|
||||
//% group="Color Sensor"
|
||||
pauseForLight(mode: LightIntensityMode, condition: LightCondition) {
|
||||
@ -214,11 +204,11 @@ namespace sensors {
|
||||
* @param sensor the color sensor port
|
||||
*/
|
||||
//% help=sensors/color-sensor/light
|
||||
//% block="%sensor|%mode"
|
||||
//% block="**color sensor** %this|%mode"
|
||||
//% blockId=colorLight
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.fieldEditor="ports"
|
||||
//% weight=87
|
||||
//% group="Color Sensor"
|
||||
light(mode: LightIntensityMode) {
|
||||
@ -241,10 +231,10 @@ namespace sensors {
|
||||
* @param condition the dark or bright light condition
|
||||
* @param value the value threshold
|
||||
*/
|
||||
//% blockId=colorSetThreshold block="set %sensor|%condition|to %value"
|
||||
//% blockId=colorSetThreshold block="set **color sensor** %this|%condition|to %value"
|
||||
//% group="Threshold" blockGap=8 weight=90
|
||||
//% value.min=0 value.max=100
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.fieldEditor="ports"
|
||||
//% help=sensors/color-sensor/set-threshold
|
||||
setThreshold(condition: LightCondition, value: number) {
|
||||
if (condition == LightCondition.Dark)
|
||||
@ -257,9 +247,9 @@ namespace sensors {
|
||||
* Get a threshold value
|
||||
* @param condition the light condition
|
||||
*/
|
||||
//% blockId=colorGetThreshold block="%sensor|%condition"
|
||||
//% blockId=colorGetThreshold block="**color sensor** %this|%condition"
|
||||
//% group="Threshold" blockGap=8 weight=89
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.fieldEditor="ports"
|
||||
//% help=sensors/color-sensor/threshold
|
||||
threshold(condition: LightCondition): number {
|
||||
return this.thresholdDetector.threshold(<ThresholdState><number>LightCondition.Dark);
|
||||
@ -268,9 +258,9 @@ namespace sensors {
|
||||
/**
|
||||
* Collects measurement of the light condition and adjusts the threshold to 10% / 90%.
|
||||
*/
|
||||
//% blockId=colorCalibrateLight block="calibrate|%sensor|for %mode"
|
||||
//% blockId=colorCalibrateLight block="calibrate **color sensor** %this|for %mode"
|
||||
//% group="Threshold" weight=91 blockGap=8
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.fieldEditor="ports"
|
||||
//% help=sensors/color-sensor/calibrate-light
|
||||
calibrateLight(mode: LightIntensityMode, deviation: number = 8) {
|
||||
this.calibrating = true; // prevent events
|
||||
@ -319,28 +309,23 @@ namespace sensors {
|
||||
* @param color the color sensed by the sensor, eg: ColorSensorColor.Red
|
||||
*/
|
||||
//% shim=TD_ID
|
||||
//% blockId=colorSensorColor block="color %color"
|
||||
//% blockId=colorSensorColor block="color %color=colorEnumPicker"
|
||||
//% group="Color Sensor"
|
||||
//% weight=97
|
||||
//% help=sensors/color
|
||||
//% color.fieldEditor="gridpicker"
|
||||
//% color.fieldOptions.columns=4
|
||||
//% color.fieldOptions.tooltips=true
|
||||
//% color.fieldOptions.hideRect=true
|
||||
//% color.fieldOptions.width=268
|
||||
export function color(color: ColorSensorColor): ColorSensorColor {
|
||||
export function color(color: number): ColorSensorColor {
|
||||
return color;
|
||||
}
|
||||
|
||||
//% whenUsed block="color 3" weight=95 fixedInstance jres=icons.port3
|
||||
//% whenUsed block="3" weight=95 fixedInstance jres=icons.port3
|
||||
export const color3: ColorSensor = new ColorSensor(3)
|
||||
|
||||
//% whenUsed block="color 1" weight=90 fixedInstance jres=icons.port1
|
||||
//% whenUsed block="1" weight=90 fixedInstance jres=icons.port1
|
||||
export const color1: ColorSensor = new ColorSensor(1)
|
||||
|
||||
//% whenUsed block="color 2" weight=90 fixedInstance jres=icons.port2
|
||||
//% whenUsed block="2" weight=90 fixedInstance jres=icons.port2
|
||||
export const color2: ColorSensor = new ColorSensor(2)
|
||||
|
||||
//% whenUsed block="color 4" weight=90 fixedInstance jres=icons.port4
|
||||
//% whenUsed block="4" weight=90 fixedInstance jres=icons.port4
|
||||
export const color4: ColorSensor = new ColorSensor(4)
|
||||
}
|
||||
|
17
libs/color-sensor/ns.ts
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
namespace sensors {
|
||||
|
||||
/**
|
||||
* A color enum picker
|
||||
* @param color to use, eg: ColorSensorColor.Blue
|
||||
*/
|
||||
//% blockId=colorEnumPicker block="%color" shim=TD_ID
|
||||
//% weight=0 blockHidden=1 turnRatio.fieldOptions.decompileLiterals=1
|
||||
//% color.fieldEditor="colorenum"
|
||||
//% color.fieldOptions.colours='["#f12a21", "#ffd01b", "#006db3", "#00934b", "#ffffff", "#6c2d00", "#000000"]'
|
||||
//% color.fieldOptions.columns=2 color.fieldOptions.className='legoColorPicker'
|
||||
export function __colorEnumPicker(color: ColorSensorColor): number {
|
||||
return color;
|
||||
}
|
||||
}
|
@ -4,7 +4,8 @@
|
||||
"files": [
|
||||
"README.md",
|
||||
"colors.jres",
|
||||
"color.ts"
|
||||
"color.ts",
|
||||
"ns.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
|
@ -51,12 +51,13 @@ namespace console {
|
||||
*/
|
||||
//% blockId=logsendtostreen block="send console to screen"
|
||||
//% weight=1
|
||||
//% help=console/send-to-screen
|
||||
export function sendToScreen(): void {
|
||||
console.screen.attach();
|
||||
console._screen.attach();
|
||||
}
|
||||
}
|
||||
|
||||
namespace console.screen {
|
||||
namespace console._screen {
|
||||
const maxLines = 100;
|
||||
const screenLines = 10;
|
||||
let lines: string[];
|
||||
@ -77,7 +78,7 @@ namespace console.screen {
|
||||
for (let i = 0; i < screenLines; ++i) {
|
||||
const line = lines[i + scrollPosition];
|
||||
if (line)
|
||||
brick.print(line, 0, 4 + i * brick.LINE_HEIGHT)
|
||||
screen.print(line, 0, 4 + i * brick.LINE_HEIGHT)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ namespace control {
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event"
|
||||
//% block="raise event|from %src|with value %value" blockExternalInputs=1
|
||||
//% help=control/raise-event
|
||||
void raiseEvent(int src, int value) {
|
||||
pxt::raiseEvent(src, value);
|
||||
}
|
||||
|
15
libs/core/enums.d.ts
vendored
@ -11,19 +11,4 @@
|
||||
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.
|
||||
|
@ -19,20 +19,13 @@ struct PNGHeader {
|
||||
uint8_t IDAT[4];
|
||||
} __attribute__((packed));
|
||||
|
||||
namespace screen {
|
||||
namespace image {
|
||||
|
||||
static uint32_t swap(uint32_t num) {
|
||||
return ((num >> 24) & 0xff) | ((num << 8) & 0xff0000) | ((num >> 8) & 0xff00) |
|
||||
((num << 24) & 0xff000000);
|
||||
}
|
||||
|
||||
static uint8_t revbits(uint8_t v) {
|
||||
v = (v & 0xf0) >> 4 | (v & 0x0f) << 4;
|
||||
v = (v & 0xcc) >> 2 | (v & 0x33) << 2;
|
||||
v = (v & 0xaa) >> 1 | (v & 0x55) << 1;
|
||||
return v;
|
||||
}
|
||||
|
||||
/** Decompresses a 1-bit gray scale PNG image to image format. */
|
||||
//%
|
||||
Image unpackPNG(Buffer png) {
|
||||
@ -101,12 +94,11 @@ Image unpackPNG(Buffer png) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Buffer res = mkBuffer(NULL, 2 + byteW * hd.height);
|
||||
res->data[0] = 0xf0;
|
||||
res->data[1] = hd.width;
|
||||
uint8_t *dst = res->data + 2;
|
||||
auto res = mkImage(hd.width, hd.height, 1);
|
||||
|
||||
uint8_t *dst = res->pix();
|
||||
uint8_t *src = tmp;
|
||||
uint8_t lastMask = (1 << (hd.width & 7)) - 1;
|
||||
uint8_t lastMask = 0xff << (8 - (hd.width & 7));
|
||||
if (lastMask == 0)
|
||||
lastMask = 0xff;
|
||||
for (uint32_t i = 0; i < hd.height; ++i) {
|
||||
@ -117,7 +109,7 @@ Image unpackPNG(Buffer png) {
|
||||
return NULL;
|
||||
}
|
||||
for (uint32_t j = 0; j < byteW; ++j) {
|
||||
*dst = ~revbits(*src++);
|
||||
*dst = ~*src++;
|
||||
if (j == byteW - 1) {
|
||||
*dst &= lastMask;
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ class MMap : public RefObject {
|
||||
extern volatile bool paniced;
|
||||
|
||||
// Buffer, Sound, and Image share representation.
|
||||
typedef Buffer Image;
|
||||
typedef Buffer Sound;
|
||||
|
||||
}
|
||||
@ -41,4 +40,6 @@ typedef Buffer Sound;
|
||||
#define DEVICE_ID_NOTIFY 10000
|
||||
#define DEVICE_ID_NOTIFY_ONE 10001
|
||||
|
||||
#define IMAGE_BITS 1
|
||||
|
||||
#endif
|
||||
|
@ -16,7 +16,6 @@
|
||||
"buttons.ts",
|
||||
"png.cpp",
|
||||
"screen.cpp",
|
||||
"screen.ts",
|
||||
"battery.ts",
|
||||
"output.cpp",
|
||||
"output.ts",
|
||||
@ -26,8 +25,6 @@
|
||||
"shims.d.ts",
|
||||
"enums.d.ts",
|
||||
"dal.d.ts",
|
||||
"images.ts",
|
||||
"images.jres",
|
||||
"icons.jres",
|
||||
"ns.ts"
|
||||
],
|
||||
|
@ -9,39 +9,12 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/**
|
||||
* Drawing modes
|
||||
*/
|
||||
enum class Draw {
|
||||
Normal = 0x00, // set pixels to black, no fill
|
||||
Clear = 0x01,
|
||||
Xor = 0x02,
|
||||
Fill = 0x04,
|
||||
Transparent = 0x08,
|
||||
Double = 0x10,
|
||||
Quad = 0x20,
|
||||
};
|
||||
namespace pxt {
|
||||
|
||||
inline bool operator&(Draw a, Draw b) {
|
||||
return ((int)a & (int)b) != 0;
|
||||
}
|
||||
|
||||
inline Draw operator|(Draw a, Draw b) {
|
||||
return (Draw)((int)a | (int)b);
|
||||
}
|
||||
|
||||
#define XX(v) ((uint32_t)(v)&0xffff)
|
||||
#define YY(v) ((uint32_t)(v) >> 16)
|
||||
|
||||
// We only support up to 4 arguments for C++ functions - need to pack them on the TS side
|
||||
namespace screen {
|
||||
|
||||
#define ROW_SIZE 32
|
||||
#define ROW_SIZE 23
|
||||
#define FB_SIZE (60 * LCD_HEIGHT)
|
||||
|
||||
static const uint8_t pixmap[] = {0x00, 0xE0, 0x1C, 0xFC, 0x03, 0xE3, 0x1F, 0xFF};
|
||||
static uint8_t bitBuffer[ROW_SIZE * LCD_HEIGHT];
|
||||
static bool dirty;
|
||||
static const uint8_t pixmap[] = {0x00, 0x03, 0x1C, 0x1F, 0xE0, 0xE3, 0xFC, 0xFF};
|
||||
|
||||
static void bitBufferToFrameBuffer(uint8_t *bitBuffer, uint8_t *fb) {
|
||||
uint32_t pixels;
|
||||
@ -49,129 +22,53 @@ static void bitBufferToFrameBuffer(uint8_t *bitBuffer, uint8_t *fb) {
|
||||
for (int line = 0; line < LCD_HEIGHT; line++) {
|
||||
int n = 7;
|
||||
while (n--) {
|
||||
pixels = *bitBuffer++ << 0;
|
||||
pixels = *bitBuffer++ << 16;
|
||||
pixels |= *bitBuffer++ << 8;
|
||||
pixels |= *bitBuffer++ << 16;
|
||||
pixels |= *bitBuffer++ << 0;
|
||||
|
||||
int m = 8;
|
||||
while (m--) {
|
||||
*fb++ = pixmap[pixels & 0x07];
|
||||
pixels >>= 3;
|
||||
*fb++ = pixmap[(pixels >> 21) & 0x07];
|
||||
pixels <<= 3;
|
||||
}
|
||||
}
|
||||
|
||||
pixels = *bitBuffer++ << 0;
|
||||
pixels |= *bitBuffer++ << 8;
|
||||
|
||||
bitBuffer += ROW_SIZE - 23;
|
||||
pixels = *bitBuffer++ << 8;
|
||||
pixels |= *bitBuffer++ << 0;
|
||||
|
||||
int m = 4;
|
||||
while (m--) {
|
||||
*fb++ = pixmap[pixels & 0x07];
|
||||
pixels >>= 3;
|
||||
*fb++ = pixmap[(pixels >> 13) & 0x07];
|
||||
pixels <<= 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define OFF(x, y) (((y) << 5) + ((x) >> 3))
|
||||
#define MASK(x, y) (1 << ((x)&7))
|
||||
#define PIX2BYTES(x) (((x) + 7) >> 3)
|
||||
|
||||
static inline void applyMask(int off, int mask, Draw mode) {
|
||||
if (mode & Draw::Clear)
|
||||
bitBuffer[off] &= ~mask;
|
||||
else if (mode & Draw::Xor)
|
||||
bitBuffer[off] ^= mask;
|
||||
else
|
||||
bitBuffer[off] |= mask;
|
||||
}
|
||||
|
||||
//%
|
||||
void _setPixel(int x, int y, Draw mode) {
|
||||
applyMask(OFF(x, y), MASK(x, y), mode);
|
||||
}
|
||||
|
||||
void blitLineCore(int x, int y, int w, uint8_t *data, Draw mode) {
|
||||
if (y < 0 || y >= LCD_HEIGHT)
|
||||
return;
|
||||
if (x + w <= 0)
|
||||
return;
|
||||
if (x >= LCD_WIDTH)
|
||||
return;
|
||||
|
||||
int shift = x & 7;
|
||||
int off = OFF(x, y);
|
||||
int off0 = OFF(0, y);
|
||||
int off1 = OFF(LCD_WIDTH - 1, y);
|
||||
int x1 = x + w + shift;
|
||||
int prev = 0;
|
||||
|
||||
while (x < x1 - 8) {
|
||||
int curr = *data++ << shift;
|
||||
if (off0 <= off && off <= off1)
|
||||
applyMask(off, curr | prev, mode);
|
||||
off++;
|
||||
prev = curr >> 8;
|
||||
x += 8;
|
||||
}
|
||||
|
||||
int left = x1 - x;
|
||||
if (left > 0) {
|
||||
int curr = *data << shift;
|
||||
if (off0 <= off && off <= off1)
|
||||
applyMask(off, (curr | prev) & ((1 << left) - 1), mode);
|
||||
}
|
||||
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
//%
|
||||
void _blitLine(int xw, int y, Buffer buf, Draw mode) {
|
||||
blitLineCore(XX(xw), y, YY(xw), buf->data, mode);
|
||||
}
|
||||
|
||||
/** Clear screen and reset font to normal. */
|
||||
//%
|
||||
void clear() {
|
||||
memset(bitBuffer, 0, sizeof(bitBuffer));
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
//%
|
||||
void dump() {
|
||||
char buf[LCD_WIDTH + 1];
|
||||
FILE *f = fopen("/tmp/screen.txt", "w");
|
||||
for (int i = 0; i < LCD_HEIGHT; ++i) {
|
||||
for (int j = 0; j < LCD_WIDTH; ++j) {
|
||||
if (bitBuffer[OFF(j, i)] & MASK(j, i))
|
||||
buf[j] = '#';
|
||||
else
|
||||
buf[j] = '.';
|
||||
}
|
||||
buf[LCD_WIDTH] = 0;
|
||||
fprintf(f, "%s\n", buf);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static uint8_t *mappedFrameBuffer;
|
||||
static Image lastImg;
|
||||
|
||||
//%
|
||||
void updateLCD() {
|
||||
if (dirty && mappedFrameBuffer != MAP_FAILED) {
|
||||
dirty = false;
|
||||
bitBufferToFrameBuffer(bitBuffer, mappedFrameBuffer);
|
||||
void updateScreen(Image img) {
|
||||
if (img && img != lastImg) {
|
||||
decrRC(lastImg);
|
||||
incrRC(img);
|
||||
lastImg = img;
|
||||
}
|
||||
|
||||
if (lastImg && lastImg->isDirty() && mappedFrameBuffer != MAP_FAILED) {
|
||||
if (lastImg->bpp() != 1 || lastImg->width() != LCD_WIDTH || lastImg->height() != LCD_HEIGHT)
|
||||
target_panic(906);
|
||||
lastImg->clearDirty();
|
||||
bitBufferToFrameBuffer(lastImg->pix(), mappedFrameBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void *screenRefresh(void *dummy) {
|
||||
while (true) {
|
||||
sleep_core_us(30000);
|
||||
updateLCD();
|
||||
}
|
||||
//%
|
||||
void updateStats(String str) {
|
||||
|
||||
}
|
||||
|
||||
void init() {
|
||||
void screen_init() {
|
||||
DMESG("init screen");
|
||||
if (mappedFrameBuffer)
|
||||
return;
|
||||
@ -182,25 +79,19 @@ void init() {
|
||||
if (mappedFrameBuffer == MAP_FAILED) {
|
||||
target_panic(903);
|
||||
}
|
||||
clear();
|
||||
|
||||
pthread_t pid;
|
||||
pthread_create(&pid, NULL, screenRefresh, NULL);
|
||||
pthread_detach(pid);
|
||||
}
|
||||
|
||||
static const uint8_t numbers[] = {
|
||||
0x06, 0x09, 0x09, 0x09, 0x06, 0x04, 0x06, 0x04, 0x04, 0x0e, 0x07, 0x08, 0x06, 0x01, 0x0f, 0x0f,
|
||||
0x08, 0x04, 0x09, 0x06, 0x0c, 0x0a, 0x09, 0x1f, 0x08, 0x1f, 0x01, 0x0f, 0x10, 0x0f, 0x08, 0x04,
|
||||
0x0e, 0x11, 0x0e, 0x1f, 0x08, 0x04, 0x02, 0x01, 0x0e, 0x11, 0x0e, 0x11, 0x0e, 0x0e, 0x11, 0x0e,
|
||||
0x04, 0x02,
|
||||
// face
|
||||
0b11011, 0b11011, 0b00000, 0b11111, 0b11011,
|
||||
0x06, 0x09, 0x09, 0x09, 0x06, 0x04, 0x06, 0x04, 0x04, 0x0e, 0x07, 0x08, 0x06,
|
||||
0x01, 0x0f, 0x0f, 0x08, 0x04, 0x09, 0x06, 0x0c, 0x0a, 0x09, 0x1f, 0x08, 0x1f,
|
||||
0x01, 0x0f, 0x10, 0x0f, 0x08, 0x04, 0x0e, 0x11, 0x0e, 0x1f, 0x08, 0x04, 0x02,
|
||||
0x01, 0x0e, 0x11, 0x0e, 0x11, 0x0e, 0x0e, 0x11, 0x0e, 0x04, 0x02,
|
||||
|
||||
0x1b, 0x1b, 0x00, 0x1f, 0x1b,
|
||||
};
|
||||
|
||||
static void drawNumber(int off, int idx) {
|
||||
static void drawNumber(uint8_t *dst, int idx) {
|
||||
const uint8_t *src = &numbers[idx * 5];
|
||||
uint8_t *dst = &bitBuffer[off];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
uint8_t ch = *src++;
|
||||
for (int jj = 0; jj < 8; ++jj) {
|
||||
@ -215,13 +106,19 @@ static void drawNumber(int off, int idx) {
|
||||
}
|
||||
|
||||
extern "C" void drawPanic(int code) {
|
||||
clear();
|
||||
int fd = open("/dev/lms_ui", O_RDWR);
|
||||
uint8_t cmd[] = {48 + 5, 0};
|
||||
write(fd, cmd, 2);
|
||||
close(fd);
|
||||
|
||||
int ptr = ROW_SIZE * 16 + 3 + 6;
|
||||
uint8_t bitBuffer[ROW_SIZE * LCD_HEIGHT];
|
||||
|
||||
memset(bitBuffer, 0, sizeof(bitBuffer));
|
||||
|
||||
auto ptr = &bitBuffer[ROW_SIZE * 16 + 3 + 6];
|
||||
drawNumber(ptr, 10);
|
||||
ptr += 6;
|
||||
|
||||
ptr = ROW_SIZE * 70 + 3;
|
||||
ptr = &bitBuffer[ROW_SIZE * 70 + 3];
|
||||
|
||||
drawNumber(ptr, (code / 100) % 10);
|
||||
ptr += 6;
|
||||
@ -230,132 +127,9 @@ extern "C" void drawPanic(int code) {
|
||||
drawNumber(ptr, (code / 1) % 10);
|
||||
ptr += 6;
|
||||
|
||||
updateLCD();
|
||||
|
||||
int fd = open("/dev/lms_ui", O_RDWR);
|
||||
uint8_t cmd[] = {48 + 5, 0};
|
||||
write(fd, cmd, 2);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
bool isValidImage(Buffer buf) {
|
||||
return buf != NULL && buf->length >= 3 && buf->data[0] == 0xf0;
|
||||
}
|
||||
|
||||
/** Makes an image bound to a buffer. */
|
||||
//%
|
||||
Image imageOf(Buffer buf) {
|
||||
if (!isValidImage(buf))
|
||||
return NULL;
|
||||
incrRC(buf);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxt {
|
||||
void screen_init() {
|
||||
screen::init();
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstances
|
||||
namespace ImageMethods {
|
||||
|
||||
using namespace screen;
|
||||
|
||||
static const uint8_t bitdouble[] = {
|
||||
0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f, 0xc0, 0xc3, 0xcc, 0xcf, 0xf0, 0xf3, 0xfc, 0xff,
|
||||
};
|
||||
|
||||
static uint8_t ones[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
};
|
||||
|
||||
/** Returns the underlaying Buffer object. */
|
||||
//% property
|
||||
Buffer buffer(Image ic) {
|
||||
incrRC(ic);
|
||||
return ic;
|
||||
}
|
||||
|
||||
/** Returns the width of an image. */
|
||||
//% property
|
||||
int width(Image ic) {
|
||||
if (!isValidImage(ic))
|
||||
return 0;
|
||||
return ic->data[1];
|
||||
}
|
||||
|
||||
/** Returns the height of an image. */
|
||||
//% property
|
||||
int height(Image ic) {
|
||||
if (!isValidImage(ic))
|
||||
return 0;
|
||||
int bw = PIX2BYTES(ic->data[1]);
|
||||
return (ic->length - 2) / bw;
|
||||
}
|
||||
|
||||
/** Double size of an image. */
|
||||
//%
|
||||
Image doubled(Image buf) {
|
||||
if (!isValidImage(buf))
|
||||
return NULL;
|
||||
int w = buf->data[1];
|
||||
if (w > 126)
|
||||
return NULL;
|
||||
int bw = PIX2BYTES(w);
|
||||
int h = (buf->length - 2) / bw;
|
||||
int bw2 = PIX2BYTES(w * 2);
|
||||
Buffer out = mkBuffer(NULL, 2 + bw2 * h * 2);
|
||||
out->data[0] = 0xf0;
|
||||
out->data[1] = w * 2;
|
||||
uint8_t *src = buf->data + 2;
|
||||
uint8_t *dst = out->data + 2;
|
||||
for (int i = 0; i < h; ++i) {
|
||||
for (int jj = 0; jj < 2; ++jj) {
|
||||
auto p = src;
|
||||
for (int j = 0; j < bw; ++j) {
|
||||
*dst++ = bitdouble[*p & 0xf];
|
||||
*dst++ = bitdouble[*p >> 4];
|
||||
p++;
|
||||
}
|
||||
}
|
||||
src += bw;
|
||||
if (mappedFrameBuffer != MAP_FAILED) {
|
||||
bitBufferToFrameBuffer(bitBuffer, mappedFrameBuffer);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Draw an image on the screen. */
|
||||
//%
|
||||
void draw(Image buf, int x, int y, Draw mode) {
|
||||
if (!isValidImage(buf))
|
||||
return;
|
||||
if (mode & (Draw::Double | Draw::Quad)) {
|
||||
buf = doubled(buf);
|
||||
if (mode & Draw::Quad) {
|
||||
auto pbuf = buf;
|
||||
buf = doubled(buf);
|
||||
decrRC(pbuf);
|
||||
}
|
||||
}
|
||||
|
||||
int pixwidth = buf->data[1];
|
||||
int ptr = 2;
|
||||
int bytewidth = PIX2BYTES(pixwidth);
|
||||
pixwidth = min(pixwidth, LCD_WIDTH);
|
||||
while (ptr + bytewidth <= buf->length) {
|
||||
if (mode & (Draw::Clear | Draw::Xor | Draw::Transparent)) {
|
||||
// no erase of background
|
||||
} else {
|
||||
blitLineCore(x, y, pixwidth, ones, Draw::Clear);
|
||||
}
|
||||
blitLineCore(x, y, pixwidth, &buf->data[ptr], mode);
|
||||
y++;
|
||||
ptr += bytewidth;
|
||||
}
|
||||
|
||||
if (mode & (Draw::Double | Draw::Quad))
|
||||
decrRC(buf);
|
||||
}
|
||||
}
|
||||
} // namespace pxt
|
||||
|
@ -1,214 +0,0 @@
|
||||
namespace brick {
|
||||
export const LINE_HEIGHT = 12;
|
||||
|
||||
//% shim=screen::_setPixel
|
||||
function _setPixel(p0: uint32, p1: uint32, mode: Draw): void { }
|
||||
|
||||
//% shim=screen::_blitLine
|
||||
function _blitLine(xw: uint32, y: uint32, buf: Buffer, mode: Draw): void { }
|
||||
|
||||
function pack(x: number, y: number) {
|
||||
return Math.clamp(0, 512, x) | (Math.clamp(0, 512, y) << 16)
|
||||
}
|
||||
|
||||
const ones = hex`ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`
|
||||
|
||||
function setLineCore(x: number, x1: number, y: number, mode: Draw) {
|
||||
_blitLine(pack(x, x1 - x), y, ones, mode)
|
||||
}
|
||||
|
||||
export interface Font {
|
||||
charWidth: number;
|
||||
charHeight: number;
|
||||
firstChar: number;
|
||||
data: Buffer;
|
||||
}
|
||||
let currFont: Font
|
||||
|
||||
export function setFont(f: Font) {
|
||||
currFont = f
|
||||
}
|
||||
|
||||
export const heart = screen.imageOf(hex`f007 367f7f3e1c08`)
|
||||
|
||||
export function defaultFont(): Font {
|
||||
return {
|
||||
charWidth: 8,
|
||||
charHeight: 8,
|
||||
firstChar: 32,
|
||||
// source https://github.com/dhepper/font8x8
|
||||
data: hex`
|
||||
0000000000000000 183C3C1818001800 3636000000000000 36367F367F363600 0C3E031E301F0C00 006333180C666300
|
||||
1C361C6E3B336E00 0606030000000000 180C0606060C1800 060C1818180C0600 00663CFF3C660000 000C0C3F0C0C0000
|
||||
00000000000C0C06 0000003F00000000 00000000000C0C00 6030180C06030100 3E63737B6F673E00 0C0E0C0C0C0C3F00
|
||||
1E33301C06333F00 1E33301C30331E00 383C36337F307800 3F031F3030331E00 1C06031F33331E00 3F3330180C0C0C00
|
||||
1E33331E33331E00 1E33333E30180E00 000C0C00000C0C00 000C0C00000C0C06 180C0603060C1800 00003F00003F0000
|
||||
060C1830180C0600 1E3330180C000C00 3E637B7B7B031E00 0C1E33333F333300 3F66663E66663F00 3C66030303663C00
|
||||
1F36666666361F00 7F46161E16467F00 7F46161E16060F00 3C66030373667C00 3333333F33333300 1E0C0C0C0C0C1E00
|
||||
7830303033331E00 6766361E36666700 0F06060646667F00 63777F7F6B636300 63676F7B73636300 1C36636363361C00
|
||||
3F66663E06060F00 1E3333333B1E3800 3F66663E36666700 1E33070E38331E00 3F2D0C0C0C0C1E00 3333333333333F00
|
||||
33333333331E0C00 6363636B7F776300 6363361C1C366300 3333331E0C0C1E00 7F6331184C667F00 1E06060606061E00
|
||||
03060C1830604000 1E18181818181E00 081C366300000000 00000000000000FF 0C0C180000000000 00001E303E336E00
|
||||
0706063E66663B00 00001E3303331E00 3830303e33336E00 00001E333f031E00 1C36060f06060F00 00006E33333E301F
|
||||
0706366E66666700 0C000E0C0C0C1E00 300030303033331E 070666361E366700 0E0C0C0C0C0C1E00 0000337F7F6B6300
|
||||
00001F3333333300 00001E3333331E00 00003B66663E060F 00006E33333E3078 00003B6E66060F00 00003E031E301F00
|
||||
080C3E0C0C2C1800 0000333333336E00 00003333331E0C00 0000636B7F7F3600 000063361C366300 00003333333E301F
|
||||
00003F190C263F00 380C0C070C0C3800 1818180018181800 070C0C380C0C0700 6E3B000000000000 0000000000000000
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
function setPixel(on: boolean, x: number, y: number) {
|
||||
x |= 0
|
||||
y |= 0
|
||||
if (0 <= x && x < DAL.LCD_WIDTH && 0 <= y && y < DAL.LCD_HEIGHT)
|
||||
_setPixel(x, y, on ? Draw.Normal : Draw.Clear)
|
||||
}
|
||||
|
||||
/**
|
||||
* Show text on the screen at a specific line.
|
||||
* @param text the text to print on the screen, eg: "Hello world"
|
||||
* @param line the line number to print the text at, eg: 1
|
||||
*/
|
||||
//% blockId=screen_print block="show string %text|at line %line"
|
||||
//% weight=98 group="Screen" inlineInputMode="inline" blockGap=8
|
||||
//% help=brick/show-string
|
||||
//% line.min=1 line.max=10
|
||||
export function showString(text: string, line: number) {
|
||||
const NUM_LINES = 9;
|
||||
const offset = 5;
|
||||
const y = offset + (Math.clamp(0, NUM_LINES, line - 1) / (NUM_LINES + 2)) * DAL.LCD_HEIGHT;
|
||||
brick.print(text, offset, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a number on the screen
|
||||
* @param value the numeric value
|
||||
* @param line the line number to print the text at, eg: 1
|
||||
*/
|
||||
//% blockId=screenShowNumber block="show number %name|at line %line"
|
||||
//% weight=96 group="Screen" inlineInputMode="inline" blockGap=8
|
||||
//% help=brick/show-number
|
||||
//% line.min=1 line.max=10
|
||||
export function showNumber(value: number, line: number) {
|
||||
showString("" + value, line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a name, value pair on the screen
|
||||
* @param value the numeric value
|
||||
* @param line the line number to print the text at, eg: 1
|
||||
*/
|
||||
//% blockId=screenShowValue block="show value %name|= %text|at line %line"
|
||||
//% weight=96 group="Screen" inlineInputMode="inline" blockGap=8
|
||||
//% help=brick/show-value
|
||||
//% line.min=1 line.max=10
|
||||
export function showValue(name: string, value: number, line: number) {
|
||||
value = Math.round(value * 1000) / 1000;
|
||||
showString((name ? name + ": " : "") + value, line);
|
||||
}
|
||||
|
||||
export function print(text: string, x: number, y: number, mode = Draw.Normal) {
|
||||
x |= 0
|
||||
y |= 0
|
||||
if (!currFont) currFont = defaultFont()
|
||||
let x0 = x
|
||||
let cp = 0
|
||||
let byteWidth = (currFont.charWidth + 7) >> 3
|
||||
let charSize = byteWidth * currFont.charHeight
|
||||
let imgBuf = output.createBuffer(2 + charSize)
|
||||
let double = (mode & Draw.Quad) ? 4 : (mode & Draw.Double) ? 2 : 1
|
||||
imgBuf[0] = 0xf0
|
||||
imgBuf[1] = currFont.charWidth
|
||||
let img = screen.imageOf(imgBuf)
|
||||
while (cp < text.length) {
|
||||
let ch = text.charCodeAt(cp++)
|
||||
if (ch == 10) {
|
||||
y += double * currFont.charHeight + 2
|
||||
x = x0
|
||||
}
|
||||
if (ch < 32) continue
|
||||
let idx = (ch - currFont.firstChar) * charSize
|
||||
if (idx < 0 || idx + imgBuf.length - 1 > currFont.data.length)
|
||||
imgBuf.fill(0, 2)
|
||||
else
|
||||
imgBuf.write(2, currFont.data.slice(idx, charSize))
|
||||
img.draw(x, y, mode)
|
||||
x += double * currFont.charWidth
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an image on the screen
|
||||
* @param image image to draw
|
||||
*/
|
||||
//% blockId=screen_show_image block="show image %image=screen_image_picker"
|
||||
//% weight=100 group="Screen" blockGap=8
|
||||
//% help=brick/show-image
|
||||
export function showImage(image: Image) {
|
||||
if (!image) return;
|
||||
image.draw(0, 0, Draw.Normal);
|
||||
}
|
||||
|
||||
/**
|
||||
* An image
|
||||
* @param image the image
|
||||
*/
|
||||
//% blockId=screen_image_picker block="%image" shim=TD_ID
|
||||
//% image.fieldEditor="images"
|
||||
//% image.fieldOptions.columns=6
|
||||
//% image.fieldOptions.width=600
|
||||
//% group="Screen" weight=0 blockHidden=1
|
||||
export function __imagePicker(image: Image): Image {
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the screen
|
||||
*/
|
||||
//% blockId=screen_clear_screen block="clear screen"
|
||||
//% weight=90 group="Screen"
|
||||
//% help=brick/clear-screen
|
||||
export function clearScreen() {
|
||||
screen.clear();
|
||||
}
|
||||
|
||||
function drawRect(x: number, y: number, w: number, h: number, mode = Draw.Normal) {
|
||||
x |= 0;
|
||||
y |= 0;
|
||||
w |= 0;
|
||||
h |= 0;
|
||||
if (x < 0) {
|
||||
w += x;
|
||||
x = 0;
|
||||
}
|
||||
if (y < 0) {
|
||||
h += y;
|
||||
y = 0;
|
||||
}
|
||||
if (w <= 0)
|
||||
return;
|
||||
if (h <= 0)
|
||||
return;
|
||||
let x1 = Math.min(DAL.LCD_WIDTH, x + w);
|
||||
let y1 = Math.min(DAL.LCD_HEIGHT, y + h);
|
||||
if (w == 1) {
|
||||
while (y < y1)
|
||||
_setPixel(x, y++, mode);
|
||||
return;
|
||||
}
|
||||
|
||||
setLineCore(x, x1, y++, mode);
|
||||
while (y < y1 - 1) {
|
||||
if (mode & Draw.Fill) {
|
||||
setLineCore(x, x1, y, mode);
|
||||
} else {
|
||||
_setPixel(x, y, mode);
|
||||
_setPixel(x1 - 1, y, mode);
|
||||
}
|
||||
y++;
|
||||
}
|
||||
if (y < y1)
|
||||
setLineCore(x, x1, y, mode);
|
||||
}
|
||||
}
|
42
libs/core/shims.d.ts
vendored
@ -55,7 +55,8 @@ declare namespace control {
|
||||
* @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
|
||||
//% block="raise event|from %src|with value %value" blockExternalInputs=1
|
||||
//% help=control/raise-event shim=control::raiseEvent
|
||||
function raiseEvent(src: int32, value: int32): void;
|
||||
|
||||
/**
|
||||
@ -74,47 +75,12 @@ declare namespace serial {
|
||||
//% shim=serial::writeDmesg
|
||||
function writeDmesg(): void;
|
||||
}
|
||||
declare namespace screen {
|
||||
declare namespace image {
|
||||
|
||||
/** Decompresses a 1-bit gray scale PNG image to image format. */
|
||||
//% shim=screen::unpackPNG
|
||||
//% shim=image::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 {
|
||||
|
||||
/**
|
||||
|
@ -11,36 +11,40 @@ namespace control {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the elapsed time in millis since the last reset
|
||||
* Get the elapsed time in millis since the last reset
|
||||
*/
|
||||
//% blockId=timerMillis block="%timer|millis"
|
||||
//% help=control/timer/millis
|
||||
millis(): number {
|
||||
return control.millis() - this.start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the elapsed time in seconds since the last reset
|
||||
* Get the elapsed time in seconds since the last reset
|
||||
*/
|
||||
//% blockId=timerSeconds block="%timer|seconds"
|
||||
//% help=control/timer/seconds
|
||||
seconds(): number {
|
||||
return this.millis() / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the timer
|
||||
* Reset the timer
|
||||
*/
|
||||
//% blockId=timerRest block="%timer|reset"
|
||||
//% help=control/timer/reset
|
||||
reset() {
|
||||
this.start = control.millis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pauses until the timer reaches the given amount of milliseconds
|
||||
* Pause until the timer reaches the given amount of milliseconds
|
||||
* @param ms how long to pause for, eg: 5, 100, 200, 500, 1000, 2000
|
||||
*/
|
||||
//% blockId=timerPauseUntil block="%timer|pause until (ms) %ms"
|
||||
//% help=control/timer/pause-until
|
||||
pauseUntil(ms: number) {
|
||||
const remaining = this.millis() - ms;
|
||||
const remaining = ms - this.millis();
|
||||
pause(Math.max(0, remaining));
|
||||
}
|
||||
}
|
||||
|
@ -1,229 +1,229 @@
|
||||
namespace images {
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsBigSmile = screen.unpackPNG(hex``);
|
||||
export const expressionsBigSmile = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsHeartLarge = screen.unpackPNG(hex``);
|
||||
export const expressionsHeartLarge = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsHeartSmall = screen.unpackPNG(hex``);
|
||||
export const expressionsHeartSmall = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsMouth1open = screen.unpackPNG(hex``);
|
||||
export const expressionsMouth1open = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsMouth1shut = screen.unpackPNG(hex``);
|
||||
export const expressionsMouth1shut = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsMouth2open = screen.unpackPNG(hex``);
|
||||
export const expressionsMouth2open = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsMouth2shut = screen.unpackPNG(hex``);
|
||||
export const expressionsMouth2shut = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsSad = screen.unpackPNG(hex``);
|
||||
export const expressionsSad = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsSick = screen.unpackPNG(hex``);
|
||||
export const expressionsSick = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsSmile = screen.unpackPNG(hex``);
|
||||
export const expressionsSmile = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsSwearing = screen.unpackPNG(hex``);
|
||||
export const expressionsSwearing = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsTalking = screen.unpackPNG(hex``);
|
||||
export const expressionsTalking = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsWink = screen.unpackPNG(hex``);
|
||||
export const expressionsWink = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const expressionsZzz = screen.unpackPNG(hex``);
|
||||
export const expressionsZzz = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesAngry = screen.unpackPNG(hex``);
|
||||
export const eyesAngry = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesAwake = screen.unpackPNG(hex``);
|
||||
export const eyesAwake = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesBlackEye = screen.unpackPNG(hex``);
|
||||
export const eyesBlackEye = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesBottomLeft = screen.unpackPNG(hex``);
|
||||
export const eyesBottomLeft = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesBottomRight = screen.unpackPNG(hex``);
|
||||
export const eyesBottomRight = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesCrazy1 = screen.unpackPNG(hex``);
|
||||
export const eyesCrazy1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesCrazy2 = screen.unpackPNG(hex``);
|
||||
export const eyesCrazy2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesDisappointed = screen.unpackPNG(hex``);
|
||||
export const eyesDisappointed = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesDizzy = screen.unpackPNG(hex``);
|
||||
export const eyesDizzy = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesDown = screen.unpackPNG(hex``);
|
||||
export const eyesDown = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesEvil = screen.unpackPNG(hex``);
|
||||
export const eyesEvil = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesHurt = screen.unpackPNG(hex``);
|
||||
export const eyesHurt = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesKnockedOut = screen.unpackPNG(hex``);
|
||||
export const eyesKnockedOut = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesLove = screen.unpackPNG(hex``);
|
||||
export const eyesLove = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesMiddleLeft = screen.unpackPNG(hex``);
|
||||
export const eyesMiddleLeft = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesMiddleRight = screen.unpackPNG(hex``);
|
||||
export const eyesMiddleRight = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesNeutral = screen.unpackPNG(hex``);
|
||||
export const eyesNeutral = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesNuclear = screen.unpackPNG(hex``);
|
||||
export const eyesNuclear = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesPinchLeft = screen.unpackPNG(hex``);
|
||||
export const eyesPinchLeft = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesPinchMiddle = screen.unpackPNG(hex``);
|
||||
export const eyesPinchMiddle = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesPinchRight = screen.unpackPNG(hex``);
|
||||
export const eyesPinchRight = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesSleeping = screen.unpackPNG(hex``);
|
||||
export const eyesSleeping = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesTear = screen.unpackPNG(hex``);
|
||||
export const eyesTear = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesTiredLeft = screen.unpackPNG(hex``);
|
||||
export const eyesTiredLeft = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesTiredMiddle = screen.unpackPNG(hex``);
|
||||
export const eyesTiredMiddle = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesTiredRight = screen.unpackPNG(hex``);
|
||||
export const eyesTiredRight = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesToxic = screen.unpackPNG(hex``);
|
||||
export const eyesToxic = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesUp = screen.unpackPNG(hex``);
|
||||
export const eyesUp = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const eyesWinking = screen.unpackPNG(hex``);
|
||||
export const eyesWinking = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationAccept = screen.unpackPNG(hex``);
|
||||
export const informationAccept = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationBackward = screen.unpackPNG(hex``);
|
||||
export const informationBackward = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationDecline = screen.unpackPNG(hex``);
|
||||
export const informationDecline = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationForward = screen.unpackPNG(hex``);
|
||||
export const informationForward = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationLeft = screen.unpackPNG(hex``);
|
||||
export const informationLeft = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationNoGo = screen.unpackPNG(hex``);
|
||||
export const informationNoGo = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationQuestionMark = screen.unpackPNG(hex``);
|
||||
export const informationQuestionMark = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationRight = screen.unpackPNG(hex``);
|
||||
export const informationRight = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationStop1 = screen.unpackPNG(hex``);
|
||||
export const informationStop1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationStop2 = screen.unpackPNG(hex``);
|
||||
export const informationStop2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationThumbsDown = screen.unpackPNG(hex``);
|
||||
export const informationThumbsDown = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationThumbsUp = screen.unpackPNG(hex``);
|
||||
export const informationThumbsUp = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const informationWarning = screen.unpackPNG(hex``);
|
||||
export const informationWarning = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoColorSensor = screen.unpackPNG(hex``);
|
||||
export const legoColorSensor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoEv3icon = screen.unpackPNG(hex``);
|
||||
export const legoEv3icon = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoEv3 = screen.unpackPNG(hex``);
|
||||
export const legoEv3 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoGyroSensor = screen.unpackPNG(hex``);
|
||||
export const legoGyroSensor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoIrBeacon = screen.unpackPNG(hex``);
|
||||
export const legoIrBeacon = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoIrSensor = screen.unpackPNG(hex``);
|
||||
export const legoIrSensor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoLego = screen.unpackPNG(hex``);
|
||||
export const legoLego = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoLargeMotor = screen.unpackPNG(hex``);
|
||||
export const legoLargeMotor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoMindstorms = screen.unpackPNG(hex``);
|
||||
export const legoMindstorms = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoMediumMotor = screen.unpackPNG(hex``);
|
||||
export const legoMediumMotor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoSoundSensor = screen.unpackPNG(hex``);
|
||||
export const legoSoundSensor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoTempSensor = screen.unpackPNG(hex``);
|
||||
export const legoTempSensor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoTouchSensor = screen.unpackPNG(hex``);
|
||||
export const legoTouchSensor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const legoUsSensor = screen.unpackPNG(hex``);
|
||||
export const legoUsSensor = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsBomb = screen.unpackPNG(hex``);
|
||||
export const objectsBomb = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsBoom = screen.unpackPNG(hex``);
|
||||
export const objectsBoom = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsFire = screen.unpackPNG(hex``);
|
||||
export const objectsFire = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsFlowers = screen.unpackPNG(hex``);
|
||||
export const objectsFlowers = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsForest = screen.unpackPNG(hex``);
|
||||
export const objectsForest = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsLightOff = screen.unpackPNG(hex``);
|
||||
export const objectsLightOff = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsLightOn = screen.unpackPNG(hex``);
|
||||
export const objectsLightOn = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsLightning = screen.unpackPNG(hex``);
|
||||
export const objectsLightning = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsNight = screen.unpackPNG(hex``);
|
||||
export const objectsNight = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsPirate = screen.unpackPNG(hex``);
|
||||
export const objectsPirate = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsSnow = screen.unpackPNG(hex``);
|
||||
export const objectsSnow = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const objectsTarget = screen.unpackPNG(hex``);
|
||||
export const objectsTarget = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressBar0 = screen.unpackPNG(hex``);
|
||||
export const progressBar0 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressBar1 = screen.unpackPNG(hex``);
|
||||
export const progressBar1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressBar2 = screen.unpackPNG(hex``);
|
||||
export const progressBar2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressBar3 = screen.unpackPNG(hex``);
|
||||
export const progressBar3 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressBar4 = screen.unpackPNG(hex``);
|
||||
export const progressBar4 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDial0 = screen.unpackPNG(hex``);
|
||||
export const progressDial0 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDial1 = screen.unpackPNG(hex``);
|
||||
export const progressDial1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDial2 = screen.unpackPNG(hex``);
|
||||
export const progressDial2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDial3 = screen.unpackPNG(hex``);
|
||||
export const progressDial3 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDial4 = screen.unpackPNG(hex``);
|
||||
export const progressDial4 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDots0 = screen.unpackPNG(hex``);
|
||||
export const progressDots0 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDots1 = screen.unpackPNG(hex``);
|
||||
export const progressDots1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDots2 = screen.unpackPNG(hex``);
|
||||
export const progressDots2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressDots3 = screen.unpackPNG(hex``);
|
||||
export const progressDots3 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressHourglass0 = screen.unpackPNG(hex``);
|
||||
export const progressHourglass0 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressHourglass1 = screen.unpackPNG(hex``);
|
||||
export const progressHourglass1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressHourglass2 = screen.unpackPNG(hex``);
|
||||
export const progressHourglass2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressTimer0 = screen.unpackPNG(hex``);
|
||||
export const progressTimer0 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressTimer1 = screen.unpackPNG(hex``);
|
||||
export const progressTimer1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressTimer2 = screen.unpackPNG(hex``);
|
||||
export const progressTimer2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressTimer3 = screen.unpackPNG(hex``);
|
||||
export const progressTimer3 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressTimer4 = screen.unpackPNG(hex``);
|
||||
export const progressTimer4 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressWaterLevel0 = screen.unpackPNG(hex``);
|
||||
export const progressWaterLevel0 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressWaterLevel1 = screen.unpackPNG(hex``);
|
||||
export const progressWaterLevel1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressWaterLevel2 = screen.unpackPNG(hex``);
|
||||
export const progressWaterLevel2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const progressWaterLevel3 = screen.unpackPNG(hex``);
|
||||
export const progressWaterLevel3 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemAccept1 = screen.unpackPNG(hex``);
|
||||
export const systemAccept1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemAccept2 = screen.unpackPNG(hex``);
|
||||
export const systemAccept2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemBox = screen.unpackPNG(hex``);
|
||||
export const systemBox = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemDecline1 = screen.unpackPNG(hex``);
|
||||
export const systemDecline1 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemDecline2 = screen.unpackPNG(hex``);
|
||||
export const systemDecline2 = image.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
}
|
@ -41,10 +41,10 @@ namespace brick {
|
||||
* An image
|
||||
* @param image the image
|
||||
*/
|
||||
//% blockId=mood_image_picker block="%image" shim=TD_ID
|
||||
//% image.fieldEditor="images"
|
||||
//% image.fieldOptions.columns=4
|
||||
//% image.fieldOptions.width=400
|
||||
//% blockId=mood_image_picker block="%mood" shim=TD_ID
|
||||
//% mood.fieldEditor="images"
|
||||
//% mood.fieldOptions.columns=4
|
||||
//% mood.fieldOptions.width=400
|
||||
//% group="Screen" weight=0 blockHidden=1
|
||||
export function __moodImagePicker(mood: Mood): Mood {
|
||||
return mood;
|
@ -4,18 +4,21 @@
|
||||
"files": [
|
||||
"README.md",
|
||||
"ns.ts",
|
||||
"startup.ts"
|
||||
"startup.ts",
|
||||
"images.jres",
|
||||
"images.ts",
|
||||
"mood.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"base": "file:../base",
|
||||
"core": "file:../core",
|
||||
"screen": "file:../screen",
|
||||
"music": "file:../music",
|
||||
"color-sensor": "file:../color-sensor",
|
||||
"touch-sensor": "file:../touch-sensor",
|
||||
"ultrasonic-sensor": "file:../ultrasonic-sensor",
|
||||
"gyro-sensor": "file:../gyro-sensor",
|
||||
"infrared-sensor": "file:../infrared-sensor",
|
||||
"mood": "file:../mood"
|
||||
"infrared-sensor": "file:../infrared-sensor"
|
||||
},
|
||||
"public": true
|
||||
}
|
||||
|
3
libs/game/pxt.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"additionalFilePath": "../../node_modules/pxt-common-packages/libs/game"
|
||||
}
|
@ -37,11 +37,11 @@ namespace sensors {
|
||||
* @param sensor the gyroscope to query the request
|
||||
*/
|
||||
//% help=sensors/gyro/angle
|
||||
//% block="%sensor|angle"
|
||||
//% block="**gyro** %this|angle"
|
||||
//% blockId=gyroGetAngle
|
||||
//% parts="gyroscope"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% this.fieldEditor="ports"
|
||||
//% weight=64 blockGap=8
|
||||
//% group="Gyro Sensor"
|
||||
angle(): number {
|
||||
@ -57,12 +57,12 @@ namespace sensors {
|
||||
* @param sensor the gyroscope to query the request
|
||||
*/
|
||||
//% help=sensors/gyro/rate
|
||||
//% block="%sensor|rate"
|
||||
//% block="**gyro** %this|rate"
|
||||
//% blockId=gyroGetRate
|
||||
//% parts="gyroscope"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% weight=65 blockGap=8
|
||||
//% this.fieldEditor="ports"
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Gyro Sensor"
|
||||
rate(): number {
|
||||
if (this.calibrating)
|
||||
@ -82,18 +82,18 @@ namespace sensors {
|
||||
* Forces a calibration of the gyro. Must be called when the sensor is completely still.
|
||||
*/
|
||||
//% help=sensors/gyro/reset
|
||||
//% block="reset %sensor|"
|
||||
//% blockId=gyroReset
|
||||
//% block="reset **gyro** %this|"
|
||||
//% blockId=gyroReset
|
||||
//% parts="gyroscope"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% weight=50
|
||||
//% this.fieldEditor="ports"
|
||||
//% weight=50
|
||||
//% group="Gyro Sensor"
|
||||
reset(): void {
|
||||
if (this.calibrating) return; // already in calibration mode
|
||||
|
||||
this.calibrating = true;
|
||||
// may be triggered by a button click,
|
||||
// may be triggered by a button click,
|
||||
// give time for robot to settle
|
||||
pause(700);
|
||||
// send a reset command
|
||||
@ -127,7 +127,7 @@ namespace sensors {
|
||||
|
||||
/**
|
||||
* Enables or disable drift correction
|
||||
* @param enabled
|
||||
* @param enabled
|
||||
*/
|
||||
//%
|
||||
setDriftCorrection(enabled: boolean) {
|
||||
@ -135,15 +135,15 @@ namespace sensors {
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstance whenUsed block="gyro 2" weight=95 jres=icons.port2
|
||||
//% fixedInstance whenUsed block="2" weight=95 jres=icons.port2
|
||||
export const gyro2: GyroSensor = new GyroSensor(2)
|
||||
|
||||
//% fixedInstance whenUsed block="gyro 1" jres=icons.port1
|
||||
//% fixedInstance whenUsed block="1" jres=icons.port1
|
||||
export const gyro1: GyroSensor = new GyroSensor(1)
|
||||
|
||||
//% fixedInstance whenUsed block="gyro 3" jres=icons.port3
|
||||
//% fixedInstance whenUsed block="3" jres=icons.port3
|
||||
export const gyro3: GyroSensor = new GyroSensor(3)
|
||||
|
||||
//% fixedInstance whenUsed block="gyro 4" jres=icons.port4
|
||||
//% fixedInstance whenUsed block="4" jres=icons.port4
|
||||
export const gyro4: GyroSensor = new GyroSensor(4)
|
||||
}
|
||||
|