updated gyrobox
This commit is contained in:
parent
f057964a50
commit
e50c88008a
@ -139,12 +139,12 @@ function computeTimestep() {
|
|||||||
control.timer3.reset()
|
control.timer3.reset()
|
||||||
}
|
}
|
||||||
sensors.color1.onColorDetected(ColorSensorColor.Green, function () {
|
sensors.color1.onColorDetected(ColorSensorColor.Green, function () {
|
||||||
music.playTone(2000, 100)
|
moods.winking.show()
|
||||||
controlDrive = 150
|
controlDrive = 150
|
||||||
controlSteering = 0
|
controlSteering = 0
|
||||||
})
|
})
|
||||||
sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {
|
sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {
|
||||||
music.playTone(2000, 100)
|
moods.middleRight.show()
|
||||||
controlSteering = 70
|
controlSteering = 70
|
||||||
})
|
})
|
||||||
// apply power to motors
|
// apply power to motors
|
||||||
@ -153,11 +153,11 @@ function controlMotors() {
|
|||||||
motors.largeD.setSpeed(power - controlSteering * 0.1)
|
motors.largeD.setSpeed(power - controlSteering * 0.1)
|
||||||
}
|
}
|
||||||
sensors.color1.onColorDetected(ColorSensorColor.Yellow, function () {
|
sensors.color1.onColorDetected(ColorSensorColor.Yellow, function () {
|
||||||
music.playTone(2000, 100)
|
moods.middleLeft.show()
|
||||||
controlSteering = -70
|
controlSteering = -70
|
||||||
})
|
})
|
||||||
sensors.color1.onColorDetected(ColorSensorColor.White, function () {
|
sensors.color1.onColorDetected(ColorSensorColor.White, function () {
|
||||||
music.playTone(2000, 100)
|
moods.sad.show();
|
||||||
controlDrive = -75
|
controlDrive = -75
|
||||||
})
|
})
|
||||||
timestep = 0.014
|
timestep = 0.014
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"brick.Mood": "A mood",
|
"brick.Mood": "A mood",
|
||||||
"brick.Mood.show": "Shows the mood on the EV3",
|
"brick.Mood.show": "Shows the mood on the EV3",
|
||||||
|
"brick.showMood": "Shows a mood",
|
||||||
"moods.angry": "An angry mood",
|
"moods.angry": "An angry mood",
|
||||||
"moods.awake": "A awake mood",
|
"moods.awake": "A awake mood",
|
||||||
"moods.dizzy": "A dizzy mood",
|
"moods.dizzy": "A dizzy mood",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"brick.Mood.show|block": "show mood %mood=mood_image_picker",
|
"brick.showMood|block": "show mood %mood=mood_image_picker",
|
||||||
"brick|block": "brick",
|
"brick|block": "brick",
|
||||||
"moods|block": "moods",
|
"moods|block": "moods",
|
||||||
"{id:category}Brick": "Brick",
|
"{id:category}Brick": "Brick",
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
namespace brick {
|
namespace brick {
|
||||||
|
/**
|
||||||
|
* Shows a mood
|
||||||
|
*/
|
||||||
|
//% weight=90
|
||||||
|
//% blockId=moodShow block="show mood %mood=mood_image_picker"
|
||||||
|
//% weight=101 group="Screen" blockGap=8
|
||||||
|
export function showMood(mood: Mood) {
|
||||||
|
if(mood)
|
||||||
|
mood.show();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mood
|
* A mood
|
||||||
*/
|
*/
|
||||||
//% fixedInstances
|
//% fixedInstances
|
||||||
export class Mood {
|
export class Mood {
|
||||||
image: Image;
|
private image: Image;
|
||||||
sound: Sound;
|
private sound: Sound;
|
||||||
light: BrickLight;
|
private light: BrickLight;
|
||||||
|
|
||||||
constructor(image: Image, sound: Sound, light: BrickLight) {
|
constructor(image: Image, sound: Sound, light: BrickLight) {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
@ -17,13 +28,11 @@ namespace brick {
|
|||||||
/**
|
/**
|
||||||
* Shows the mood on the EV3
|
* Shows the mood on the EV3
|
||||||
*/
|
*/
|
||||||
//% weight=90
|
|
||||||
//% blockId=moodShow block="show mood %mood=mood_image_picker"
|
|
||||||
//% weight=101 group="Screen" blockGap=8
|
|
||||||
show() {
|
show() {
|
||||||
brick.setLight(this.light);
|
brick.setLight(this.light);
|
||||||
brick.showImage(this.image);
|
brick.showImage(this.image);
|
||||||
music.playSoundEffectUntilDone(this.sound);
|
music.playSoundEffectUntilDone(this.sound);
|
||||||
|
loops.pause(20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +47,7 @@ namespace brick {
|
|||||||
//% group="Screen" weight=0 blockHidden=1
|
//% group="Screen" weight=0 blockHidden=1
|
||||||
export function __moodImagePicker(mood: Mood): Mood {
|
export function __moodImagePicker(mood: Mood): Mood {
|
||||||
return mood;
|
return mood;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace moods {
|
namespace moods {
|
||||||
@ -59,7 +68,7 @@ namespace moods {
|
|||||||
*/
|
*/
|
||||||
//% fixedInstance jres=images.eyesTiredMiddle
|
//% fixedInstance jres=images.eyesTiredMiddle
|
||||||
export const tired = new brick.Mood(images.eyesTiredMiddle, sounds.expressionsSneezing, BrickLight.OrangeFlash);
|
export const tired = new brick.Mood(images.eyesTiredMiddle, sounds.expressionsSneezing, BrickLight.OrangeFlash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An angry mood
|
* An angry mood
|
||||||
*/
|
*/
|
||||||
@ -83,30 +92,30 @@ namespace moods {
|
|||||||
*/
|
*/
|
||||||
//% fixedInstance jres=images.eyesKnockedOut
|
//% fixedInstance jres=images.eyesKnockedOut
|
||||||
export const knockedOut = new brick.Mood(images.eyesKnockedOut, sounds.informationError, BrickLight.RedFlash);
|
export const knockedOut = new brick.Mood(images.eyesKnockedOut, sounds.informationError, BrickLight.RedFlash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looking around left
|
* Looking around left
|
||||||
*/
|
*/
|
||||||
//% fixedInstance jres=images.eyesMiddleLeft
|
//% fixedInstance jres=images.eyesMiddleLeft
|
||||||
export const middleLeft = new brick.Mood(images.eyesMiddleLeft, sounds.informationAnalyze, BrickLight.Off);
|
export const middleLeft = new brick.Mood(images.eyesMiddleLeft, sounds.informationAnalyze, BrickLight.Off);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looking around right
|
* Looking around right
|
||||||
*/
|
*/
|
||||||
//% fixedInstance jres=images.eyesMiddleRight
|
//% fixedInstance jres=images.eyesMiddleRight
|
||||||
export const middleRight = new brick.Mood(images.eyesMiddleRight, sounds.informationAnalyze, BrickLight.Off);
|
export const middleRight = new brick.Mood(images.eyesMiddleRight, sounds.informationAnalyze, BrickLight.Off);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In love mood
|
* In love mood
|
||||||
*/
|
*/
|
||||||
//% fixedInstance jres=images.eyesLove
|
//% fixedInstance jres=images.eyesLove
|
||||||
export const love = new brick.Mood(images.eyesLove, sounds.expressionsMagicWand, BrickLight.GreenPulse);
|
export const love = new brick.Mood(images.eyesLove, sounds.expressionsMagicWand, BrickLight.GreenPulse);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In laughing mood
|
* In laughing mood
|
||||||
*/
|
*/
|
||||||
//% fixedInstance jres=images.eyesWinking
|
//% fixedInstance jres=images.eyesWinking
|
||||||
export const winking = new brick.Mood(images.eyesWinking, sounds.expressionsLaughing1, BrickLight.GreenFlash);
|
export const winking = new brick.Mood(images.eyesWinking, sounds.expressionsLaughing1, BrickLight.GreenFlash);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In a neutral mood
|
* In a neutral mood
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"music.setTempo": "Set the tempo a number of beats per minute (bpm).",
|
"music.setTempo": "Set the tempo a number of beats per minute (bpm).",
|
||||||
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
||||||
"music.setVolume": "Set the output volume of the sound synthesizer.",
|
"music.setVolume": "Set the output volume of the sound synthesizer.",
|
||||||
"music.setVolume|param|volume": "the volume 0...256, eg: 128",
|
"music.setVolume|param|volume": "the volume 0...100, eg: 50",
|
||||||
"music.stopAllSounds": "Play a tone through the speaker for some amount of time.",
|
"music.stopAllSounds": "Play a tone through the speaker for some amount of time.",
|
||||||
"music.tempo": "Return the tempo in beats per minute (bpm).\nTempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play."
|
"music.tempo": "Return the tempo in beats per minute (bpm).\nTempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play."
|
||||||
}
|
}
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace music {
|
namespace music {
|
||||||
|
|
||||||
uint8_t currVolume = 2;
|
uint8_t currVolume = 50;
|
||||||
uint8_t *lmsSoundMMap;
|
uint8_t *lmsSoundMMap;
|
||||||
|
|
||||||
int writeDev(void *data, int size) {
|
int writeDev(void *data, int size) {
|
||||||
@ -25,16 +25,16 @@ int writeDev(void *data, int size) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the output volume of the sound synthesizer.
|
* Set the output volume of the sound synthesizer.
|
||||||
* @param volume the volume 0...256, eg: 128
|
* @param volume the volume 0...100, eg: 50
|
||||||
*/
|
*/
|
||||||
//% weight=96
|
//% weight=96
|
||||||
//% blockId=synth_set_volume block="set volume %volume"
|
//% blockId=synth_set_volume block="set volume %volume"
|
||||||
//% parts="speaker" blockGap=8
|
//% parts="speaker" blockGap=8
|
||||||
//% volume.min=0 volume.max=256
|
//% volume.min=0 volume.max=100
|
||||||
//% help=music/set-volume
|
//% help=music/set-volume
|
||||||
//% weight=1
|
//% weight=1
|
||||||
void setVolume(int volume) {
|
void setVolume(int volume) {
|
||||||
currVolume = max(0, min(100, volume * 100 / 256));
|
currVolume = max(0, min(100, volume));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SOUND_CMD_BREAK 0
|
#define SOUND_CMD_BREAK 0
|
||||||
|
4
libs/music/shims.d.ts
vendored
4
libs/music/shims.d.ts
vendored
@ -3,12 +3,12 @@ declare namespace music {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the output volume of the sound synthesizer.
|
* Set the output volume of the sound synthesizer.
|
||||||
* @param volume the volume 0...256, eg: 128
|
* @param volume the volume 0...100, eg: 50
|
||||||
*/
|
*/
|
||||||
//% weight=96
|
//% weight=96
|
||||||
//% blockId=synth_set_volume block="set volume %volume"
|
//% blockId=synth_set_volume block="set volume %volume"
|
||||||
//% parts="speaker" blockGap=8
|
//% parts="speaker" blockGap=8
|
||||||
//% volume.min=0 volume.max=256
|
//% volume.min=0 volume.max=100
|
||||||
//% help=music/set-volume
|
//% help=music/set-volume
|
||||||
//% weight=1 shim=music::setVolume
|
//% weight=1 shim=music::setVolume
|
||||||
function setVolume(volume: int32): void;
|
function setVolume(volume: int32): void;
|
||||||
|
Loading…
Reference in New Issue
Block a user