Compare commits

...

3 Commits

Author SHA1 Message Date
f1880897d4 0.0.68 2018-01-16 16:08:53 -08:00
ad2e82060d removing BrickLight blockIdenity notations 2018-01-16 15:59:40 -08:00
d1bb19e30e adding a mood block (image+sound+light) 2018-01-16 14:52:49 -08:00
9 changed files with 157 additions and 11 deletions

View File

@ -4,34 +4,24 @@
*/
const enum BrickLight {
//% block=off enumval=0
//% blockIdentity=brick.lightPattern
Off = 0,
//% block=green enumval=1
//% blockIdentity=brick.lightPattern
Green = 1,
//% block=red enumval=2
//% blockIdentity=brick.lightPattern
Red = 2,
//% block=orange enumval=3
//% blockIdentity=brick.lightPattern
Orange = 3,
//% block="green flash" enumval=4
//% blockIdentity=brick.lightPattern
GreenFlash = 4,
//% block="red flash" enumval=5
//% blockIdentity=brick.lightPattern
RedFlash = 5,
//% block="orange flash" enumval=6
//% blockIdentity=brick.lightPattern
OrangeFlash = 6,
//% block="green pulse" enumval=7
//% blockIdentity=brick.lightPattern
GreenPulse = 7,
//% block="red pulse" enumval=8
//% blockIdentity=brick.lightPattern
RedPulse = 8,
//% block="orange pulse" enumval=9
//% blockIdentity=brick.lightPattern
OrangePulse = 9,
}

View File

@ -10,6 +10,7 @@
"base": "file:../base",
"core": "file:../core",
"music": "file:../music",
"mood": "file:../mood",
"color-sensor": "file:../color-sensor",
"touch-sensor": "file:../touch-sensor",
"ultrasonic-sensor": "file:../ultrasonic-sensor",

3
libs/mood/README.md Normal file
View File

@ -0,0 +1,3 @@
# mood
A package to put the EV3 in various moods.

View File

@ -0,0 +1,16 @@
{
"brick.Mood": "A mood",
"brick.Mood.show": "Shows the mood on the EV3",
"brick.angry": "An angry mood",
"brick.awake": "A awake mood",
"brick.dizzy": "A dizzy mood",
"brick.knockedOut": "A knocked out mood",
"brick.love": "In love mood",
"brick.middleLeft": "Looking around left",
"brick.middleRight": "Looking around right",
"brick.neutral": "In a neutral mood",
"brick.sad": "A sad mood",
"brick.sleeping": "A sleeping mood",
"brick.tired": "A tired mood",
"brick.winking": "In laughing mood"
}

View File

@ -0,0 +1,6 @@
{
"brick.Mood.show|block": "show mood %mood=mood_image_picker",
"brick|block": "brick",
"{id:category}Brick": "Brick",
"{id:group}Screen": "Screen"
}

115
libs/mood/mood.ts Normal file
View File

@ -0,0 +1,115 @@
namespace brick {
/**
* A mood
*/
//% fixedInstances
export class Mood {
image: Image;
sound: Sound;
light: BrickLight;
constructor(image: Image, sound: Sound, light: BrickLight) {
this.image = image;
this.sound = sound;
this.light = light;
}
/**
* Shows the mood on the EV3
*/
//% weight=90
//% blockId=moodShow block="show mood %mood=mood_image_picker"
//% weight=101 group="Screen" blockGap=8
show() {
brick.setLight(this.light);
brick.showImage(this.image);
if (this.sound)
music.playSoundEffect(this.sound);
}
}
/**
* 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
//% group="Screen" weight=0 blockHidden=1
export function __moodImagePicker(mood: Mood): Mood {
return mood;
}
/**
* A sleeping mood
*/
//% fixedInstance jres=images.eyesSleeping
export const sleeping = new Mood(images.eyesSleeping, sounds.expressionsSnoring, BrickLight.OrangePulse);
/**
* A awake mood
*/
//% fixedInstance jres=images.eyesAwake
export const awake = new Mood(images.eyesAwake, sounds.informationActivate, BrickLight.Orange);
/**
* A tired mood
*/
//% fixedInstance jres=images.eyesTiredMiddle
export const tired = new Mood(images.eyesTiredMiddle, sounds.expressionsSneezing, BrickLight.OrangeFlash);
/**
* An angry mood
*/
//% fixedInstance jres=images.eyesAngry
export const angry = new Mood(images.eyesAngry, sounds.animalsDogGrowl, BrickLight.RedPulse);
/**
* A sad mood
*/
//% fixedInstance jres=images.eyesTear
export const sad = new Mood(images.eyesTear, sounds.animalsDogWhine, BrickLight.Red);
/**
* A dizzy mood
*/
//% fixedInstance jres=images.eyesDizzy
export const dizzy = new Mood(images.eyesDizzy, sounds.expressionsUhOh, BrickLight.OrangeFlash);
/**
* A knocked out mood
*/
//% fixedInstance jres=images.eyesKnockedOut
export const knockedOut = new Mood(images.eyesKnockedOut, sounds.informationError, BrickLight.RedFlash);
/**
* Looking around left
*/
//% fixedInstance jres=images.eyesMiddleLeft
export const middleLeft = new Mood(images.eyesMiddleLeft, sounds.informationAnalyze, BrickLight.Off);
/**
* Looking around right
*/
//% fixedInstance jres=images.eyesMiddleRight
export const middleRight = new Mood(images.eyesMiddleRight, sounds.informationAnalyze, BrickLight.Off);
/**
* In love mood
*/
//% fixedInstance jres=images.eyesLove
export const love = new Mood(images.eyesLove, sounds.expressionsMagicWand, BrickLight.GreenPulse);
/**
* In laughing mood
*/
//% fixedInstance jres=images.eyesWinking
export const winking = new Mood(images.eyesWinking, sounds.expressionsLaughing1, BrickLight.GreenFlash);
/**
* In a neutral mood
*/
//% fixedInstance jres=images.eyesNeutral
export const neutral = new Mood(images.eyesNeutral, undefined, BrickLight.Green);
}

14
libs/mood/pxt.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "mood",
"description": "The EV3 mood library",
"files": [
"README.md",
"mood.ts"
],
"testFiles": [
],
"public": true,
"dependencies": {
"core": "file:../core"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "pxt-ev3",
"version": "0.0.67",
"version": "0.0.68",
"description": "LEGO Mindstorms EV3 for Microsoft MakeCode",
"private": true,
"keywords": [

View File

@ -16,6 +16,7 @@
"libs/infrared-sensor",
"libs/gyro-sensor",
"libs/chassis",
"libs/mood",
"libs/ev3",
"libs/storage",
"libs/datalog",