-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
joy-it
committed
Jul 10, 2020
1 parent
d4f65fc
commit c774fbb
Showing
14 changed files
with
1,026 additions
and
23 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# MakeCode | ||
built | ||
node_modules | ||
yotta_modules | ||
yotta_targets | ||
pxt_modules | ||
_site | ||
*.db | ||
*.tgz | ||
.header.json | ||
.simstate.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Copyright (c) Microsoft Corporation | ||
|
||
All rights reserved. | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | ||
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software | ||
is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT | ||
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
# MakeCode Package for Joy-IT Joy-Car | ||
|
||
This library provides a Microsoft Makecode package for the Joy-IT Joy-Car. | ||
See https://joy-it.net/en/products/mb-joy-car/ for more details. | ||
|
||
## Driving | ||
You can drive the Joy-Car forwards or backwards by using the `drive(...)` block. Within this block you specify the direction aswell as the speed in percent from 0 to 100. | ||
Both motors will be driven in the selected direction with the selected speed. | ||
```blocks | ||
// Move the Joy-Car forwards at 100% speed | ||
JoyCar.drive(FRDirection.Forward, 100) | ||
// Move the Joy-Car backwards at 40% speed | ||
JoyCar.drive(FRDirection.Reverse, 40) | ||
``` | ||
|
||
## Turning | ||
You can use the `turn(...)` block to drive forwards or backwards in combination with turning left or right. | ||
You can specify the orientation (forward, reverse), direction (left, right) aswell as the speed (0 - 100%) and the size of the curve-radius (0-5). | ||
The larger the curve-radius the wider the turn will be (0 = very sharp turn, 5 = very wide turn). | ||
```blocks | ||
// Turn forwards and left with 100% speed and a very sharp curve | ||
JoyCar.turn(FRDirection.Forward, LRDirection.Left, 100, 0) | ||
// Turn right and reverse with 50% speed and a wide curve | ||
JoyCar.turn(FRDirection.Reverse, LRDirection.Right, 50, 5) | ||
``` | ||
|
||
## Stopping | ||
Use `stop(...)` to either brake with an intense stop or with declining speed. | ||
```blocks | ||
// Intense Stop | ||
JoyCar.stop(StopIntensity.Intense) | ||
// Soft Stop | ||
JoyCar.stop(StopIntensity.Soft) | ||
``` | ||
|
||
## Servo Control | ||
You can set the angle (0 - 180) of the two optional servos which are connected to pin P1 and P13 of the micro:bit by using `servo(...)`. | ||
```blocks | ||
// Set Servo 1 to 90 | ||
JoyCar.servo(1, 90) | ||
// Set Servo 2 to 45 | ||
JoyCar.servo(2, 45) | ||
``` | ||
|
||
## Bias | ||
Both motors will probably, due to manufacturing tolerances, not spin at the very same speed. This can result in driving small curves when you intend to drive straight forward or backward. In this case you can set a global bias with `bias(...)` which will slow down the speed-signal for the specific motor. This shall compensate any speed differences. | ||
```blocks | ||
// Reduce Left Motor Speed permanently by 5% | ||
JoyCar.bias(LRDirection.Left, 5) | ||
// Reduce Right Motor Speed permanently by 2% | ||
JoyCar.bias(LRDirection.Right, 2) | ||
``` | ||
|
||
## PWM-Signals | ||
You can also send direct PWM-Signals to all four channels (Channel 2, Channel 3, Channel 4 & Channel 5) of the motor-controller by using `drivePwm(...)`. | ||
```blocks | ||
// Set PWM signal 255 to Channel 2 | ||
JoyCar.drivePwm(255, 0, 0, 0) | ||
// Set PWM signal 100 to Channel 3 | ||
JoyCar.drivePwm(0, 100, 0, 0) | ||
// Set PWM signal 255 to Channel 4 and 5 | ||
Joycar.drivePwm(0, 0, 255, 255) | ||
``` | ||
|
||
## Headlights | ||
Turn on/off the headlights (white light from the two front LED modules) by using `light(...)`. | ||
```blocks | ||
// Turn on the headlights | ||
JoyCar.light(ToggleSwitch.On) | ||
// Turn off the headlights | ||
JoyCar.light(ToggleSwitch.Off) | ||
``` | ||
|
||
## Brakelights | ||
Turn on/off the brakelight (red light from the two rear LED modules) by using `brake(...)`. | ||
```blocks | ||
// Turn on the brakelights | ||
JoyCar.brakelight(ToggleSwitch.On) | ||
// Turn off the brakelights | ||
JoyCar.brakelight(ToggleSwitch.Off) | ||
``` | ||
|
||
## Indicators | ||
Turn on/off the indicators (flashing orange light from the front and rear LED module on the left or right side) for a specific side with `indicator(...)`. | ||
```blocks | ||
// Turn on the left indicators | ||
JoyCar.indicator(ToggleSwitch.On, SensorLRSelection.Left) | ||
// Turn off the right indicators | ||
JoyCar.indicator(ToggleSwitch.Off, SensorLRSelection.Right) | ||
``` | ||
## Hazard Lights | ||
Turn on/off the hazard lights (flashing orange light from all LED modules) with `hazardlights(...)`. | ||
```blocks | ||
// Turn hazard lights on | ||
JoyCar.hazardlights(ToggleSwitch.On) | ||
// Turn hazard lights off | ||
JoyCar.hazardlights(ToggleSwitch.Off) | ||
``` | ||
|
||
## Reverse Lights | ||
Turn on/off the reverse lights (white light from the rear LED modules) with `reversinglight(...)`. | ||
```blocks | ||
// Turn on reverse lights | ||
JoyCar.reversinglight(ToggleSwitch.On) | ||
// Turn off reverse lights | ||
JoyCar.reversinglight(ToggleSwitch.Off) | ||
``` | ||
|
||
## Ultrasonic Sensor | ||
Check the ultrasonic sensor with `sonar()`. The return value is the distance to the closest object measured from the sensor. The sensor is connected to the pins P12 (echo) and P8 (trigger) of the micro:bit. | ||
```block | ||
// Measure distance | ||
JoyCar.sonar() | ||
``` | ||
|
||
## Linefinder Sensor | ||
Check the linefinder sensors with `linefinder(...)`. The function returns true if a line was detected. The sensors are connected to channel 3, 4 & 5 of the IO-Expander. | ||
```block | ||
// Check the left Linefinder Sensor | ||
JoyCar.linefinder(SensorLCRSelection.Left) | ||
// Check the center Linefinder Sensor | ||
JoyCar.linefinder(SensorLCRSelection.Center) | ||
// Check the right Linefinder Sensor | ||
JoyCar.linefinder(SensorLCRSelection.Right) | ||
``` | ||
|
||
## Obstacle Sensor | ||
Check the obstacle sensors with `obstacleavoidance(...)`. The function returns true if an obstacle was detected. The sensors are connected to channel 1 & 2 of the IO-Expander. | ||
```block | ||
// Check left obstacle sensor | ||
JoyCar.obstacleavoidance(SensorLRSelection.Left) | ||
// Check right obstacle sensor | ||
JoyCar.obstacleavoidance(SensorLRSelection.Right) | ||
``` | ||
|
||
## Speed Sensor | ||
Check the speed sensors with `speed(...)`. The function returns true if the light is interrupted by the perforated disc on the motor. | ||
```block | ||
// Check left speed sensor | ||
JoyCar.speed(SensorLRSelection.Left) | ||
// Check right speed sensor | ||
JoyCar.speed(SensorLRSelection.Right) | ||
``` | ||
|
||
## Buzzer | ||
Play predefined melodies with the buzzer with `buzzer()`. You can also specifiy repeat options. | ||
```block | ||
// Play the Dadadadum Sound once | ||
JoyCar.buzzer(Melodies.Dadadadum, MelodyOptions.Once) | ||
// Play the Nyan Sound on repeat | ||
JoyCar.buzzer(Melodies.Nyan, MelodyOptions.Forever) | ||
``` | ||
|
||
## Read Battery Voltage | ||
Read the current battery voltage from the ADC on the AnalogPin2 by using `readAdc()`. | ||
```block | ||
// Print battery voltage to console | ||
serial.writeString(JoyCar.readAdc()); | ||
``` | ||
|
||
## Supported targets | ||
|
||
* for PXT/microbit | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"FRDirection": "Enumeration of forward/reverse directions", | ||
"JoyCar.bias": "Set Bias for Motors", | ||
"JoyCar.brakelight": "Turn on/off the brake light", | ||
"JoyCar.buzzer": "Buzzer", | ||
"JoyCar.drive": "Move Joy-Car forward or backwards with speed", | ||
"JoyCar.drivePwm": "Drive with PWM signals", | ||
"JoyCar.hazardlights": "Turn on/off hazard lights", | ||
"JoyCar.indicator": "Turn on/off left/right indicator", | ||
"JoyCar.light": "Turn on/off the front light", | ||
"JoyCar.linefinder": "Check left/center/right linefinder-sensor", | ||
"JoyCar.obstacleavoidance": "Check left/right obstacle-sensor", | ||
"JoyCar.readAdc": "Read input voltage", | ||
"JoyCar.reversinglight": "Turn on/off reverse light", | ||
"JoyCar.servo": "Control servo motors", | ||
"JoyCar.sonar": "Check sonar", | ||
"JoyCar.speed": "Check left/right speed-sensor", | ||
"JoyCar.stop": "Stop the motors.", | ||
"JoyCar.turn": "Move Joy-Car left or right. The higher the radius, the wider the curve will be.", | ||
"LRDirection": "Enumeration of left/right directions", | ||
"Melodies": "Enumeration of additional melodies", | ||
"SensorLCRSelection": "Enumeration of left/center/right sensors", | ||
"SensorLRSelection": "Enumeration of left/right sensors", | ||
"StopIntensity": "Enumeration of stop intensity", | ||
"ToggleSwitch": "Enumeration of on/off toggle switches" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"FRDirection.Forward|block": "forward", | ||
"FRDirection.Reverse|block": "reverse", | ||
"JoyCar.bias|block": "bias %direction by %percent", | ||
"JoyCar.brakelight|block": "Toggle brakelight%toggle", | ||
"JoyCar.buzzer|block": "start music %melody repeating %options", | ||
"JoyCar.drive|block": "drive%direction|at %speed|\\%", | ||
"JoyCar.drivePwm|block": "Drive with PWM signals on channel 2 %ch2, channel 3 %ch3, channel 4 %ch4, channel 5 %ch5", | ||
"JoyCar.hazardlights|block": "Turn %toggle hazard lights", | ||
"JoyCar.indicator|block": "Turn %toggle %selection indicator", | ||
"JoyCar.light|block": "Toggle light%toggle", | ||
"JoyCar.linefinder|block": "Check %selection linefinder-sensor", | ||
"JoyCar.obstacleavoidance|block": "Check %selection obstacle-sensor", | ||
"JoyCar.readAdc|block": "Read Input Voltage", | ||
"JoyCar.reversinglight|block": "Toggle reverse light%toggle", | ||
"JoyCar.servo|block": "Set servo no. %sensor to %angle degrees", | ||
"JoyCar.sonar|block": "Check ultrasonic-sensor", | ||
"JoyCar.speed|block": "Check %selection speed-sensor", | ||
"JoyCar.stop|block": "Stop motors%intensity", | ||
"JoyCar.turn|block": "drive%orientation %direction |at %speed| with radius-level %radius", | ||
"JoyCar|block": "JoyCar", | ||
"LRDirection.Left|block": "left", | ||
"LRDirection.Right|block": "right", | ||
"SensorLCRSelection.Center|block": "center", | ||
"SensorLCRSelection.Left|block": "left", | ||
"SensorLCRSelection.Right|block": "right", | ||
"SensorLRSelection.Left|block": "left", | ||
"SensorLRSelection.Right|block": "right", | ||
"StopIntensity.Intense|block": "Intense", | ||
"StopIntensity.Soft|block": "Soft", | ||
"ToggleSwitch.Off|block": "off", | ||
"ToggleSwitch.On|block": "on", | ||
"{id:category}JoyCar": "JoyCar", | ||
"{id:category}Joycar": "Joycar", | ||
"{id:subcategory}Additional Functions": "Additional Functions", | ||
"{id:subcategory}LEDs": "LEDs", | ||
"{id:subcategory}Motors": "Motors", | ||
"{id:subcategory}Sensors": "Sensors" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"FRDirection": "Auflistung der vor-/zurueck Funktionalitaet", | ||
"JoyCar.bias": "Setze Motorverzoegerung", | ||
"JoyCar.brakelight": "Bremslicht ein-/ausschalten", | ||
"JoyCar.buzzer": "Buzzer", | ||
"JoyCar.drive": "Fahre das Joy-Car vor/zurueck", | ||
"JoyCar.drivePwm": "Setze PWM-Signale", | ||
"JoyCar.hazardlights": "Warnblinker an-/ausschalten", | ||
"JoyCar.indicator": "Blinker ein-/ausschalten", | ||
"JoyCar.light": "Scheinwerfer ein-/ausschalten", | ||
"JoyCar.linefinder": "Linefinder-Sensoren pruefen", | ||
"JoyCar.obstacleavoidance": "Hindernis-Sensoren pruefen", | ||
"JoyCar.readAdc": "Batteriespannung auslesen", | ||
"JoyCar.reversinglight": "Rueckfahrlicht ein-/ausschalten", | ||
"JoyCar.servo": "Servomotoren steuern", | ||
"JoyCar.sonar": "Ultraschall-Sensor pruefen", | ||
"JoyCar.speed": "Speed-Sensoren pruefen", | ||
"JoyCar.stop": "Motoren anhalten", | ||
"JoyCar.turn": "Joy-Car nach links/rechts steuern. Je hoeher der Radius, desto groesser die Kurve.", | ||
"LRDirection": "Auflistung der Links/Rechts Funktionalitaet", | ||
"Melodies": "Auflistung der zusaetzlichen Melodien", | ||
"SensorLCRSelection": "Auflistung der Sensoren L/M/R", | ||
"SensorLRSelection": "Auflistung der Sensoren L/R", | ||
"StopIntensity": "Auflistung der Bremsintensitaet", | ||
"ToggleSwitch": "Auflistung der An/Aus Funktionalitaet" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"FRDirection.Forward|block": "Vor", | ||
"FRDirection.Reverse|block": "Zurueck", | ||
"JoyCar.bias|block": "Motorverzoegerung %direction um %percent", | ||
"JoyCar.brakelight|block": "Bremslicht %toggle", | ||
"JoyCar.buzzer|block": "Spiele Musik %melody wiederhole %options", | ||
"JoyCar.drive|block": "Fahre %direction|mit %speed|\\%", | ||
"JoyCar.drivePwm|block": "Setze PWM-Signale auf Kanal 2 %ch2, Kanal 3 %ch3, Kanal 4 %ch4, Kanal 5 %ch5", | ||
"JoyCar.hazardlights|block": "Warnblinker %toggle", | ||
"JoyCar.indicator|block": "Blinker %toggle auf Seite %selection", | ||
"JoyCar.light|block": "Licht %toggle", | ||
"JoyCar.linefinder|block": "Pruefe Linefinder-Sensor %selection", | ||
"JoyCar.obstacleavoidance|block": "Pruefe Hindernis-Sensor %selection", | ||
"JoyCar.readAdc|block": "Batteriespannung auslesen", | ||
"JoyCar.reversinglight|block": "Rueckfahrlicht %toggle", | ||
"JoyCar.servo|block": "Setze Servo %sensor auf %angle Grad", | ||
"JoyCar.sonar|block": "Pruefe Ultraschall-Sensor", | ||
"JoyCar.speed|block": "Pruefe Speed-Sensor %selection", | ||
"JoyCar.stop|block": "Halte Motoren an %intensity", | ||
"JoyCar.turn|block": "Fahre %orientation nach %direction|mit %speed| mit Radius-Level %radius", | ||
"JoyCar|block": "JoyCar", | ||
"LRDirection.Left|block": "Links", | ||
"LRDirection.Right|block": "Rechts", | ||
"SensorLCRSelection.Center|block": "Mitte", | ||
"SensorLCRSelection.Left|block": "Links", | ||
"SensorLCRSelection.Right|block": "Rechts", | ||
"SensorLRSelection.Left|block": "Links", | ||
"SensorLRSelection.Right|block": "Rechts", | ||
"StopIntensity.Intense|block": "hart", | ||
"StopIntensity.Soft|block": "sanft", | ||
"ToggleSwitch.Off|block": "Aus", | ||
"ToggleSwitch.On|block": "An", | ||
"{id:category}JoyCar": "JoyCar", | ||
"{id:category}Joycar": "Joycar", | ||
"{id:subcategory}Additional Functions": "Weitere Funktionen", | ||
"{id:subcategory}LEDs": "Beleuchtung", | ||
"{id:subcategory}Motors": "Motoren", | ||
"{id:subcategory}Sensors": "Sensoren" | ||
} |
Oops, something went wrong.