diff --git a/libs/ev3/pxt.json b/libs/ev3/pxt.json index 5a3c7634..0e7ea956 100644 --- a/libs/ev3/pxt.json +++ b/libs/ev3/pxt.json @@ -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", diff --git a/libs/mood/README.md b/libs/mood/README.md new file mode 100644 index 00000000..30472f26 --- /dev/null +++ b/libs/mood/README.md @@ -0,0 +1,3 @@ +# mood + +A package to put the EV3 in various moods. \ No newline at end of file diff --git a/libs/mood/_locales/mood-jsdoc-strings.json b/libs/mood/_locales/mood-jsdoc-strings.json new file mode 100644 index 00000000..9443af72 --- /dev/null +++ b/libs/mood/_locales/mood-jsdoc-strings.json @@ -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" +} \ No newline at end of file diff --git a/libs/mood/_locales/mood-strings.json b/libs/mood/_locales/mood-strings.json new file mode 100644 index 00000000..af2e7bb9 --- /dev/null +++ b/libs/mood/_locales/mood-strings.json @@ -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" +} \ No newline at end of file diff --git a/libs/mood/mood.ts b/libs/mood/mood.ts new file mode 100644 index 00000000..99ac27b9 --- /dev/null +++ b/libs/mood/mood.ts @@ -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); +} \ No newline at end of file diff --git a/libs/mood/pxt.json b/libs/mood/pxt.json new file mode 100644 index 00000000..762582c5 --- /dev/null +++ b/libs/mood/pxt.json @@ -0,0 +1,14 @@ +{ + "name": "mood", + "description": "The EV3 mood library", + "files": [ + "README.md", + "mood.ts" + ], + "testFiles": [ + ], + "public": true, + "dependencies": { + "core": "file:../core" + } +} \ No newline at end of file diff --git a/pxtarget.json b/pxtarget.json index 271749c8..d923b828 100644 --- a/pxtarget.json +++ b/pxtarget.json @@ -16,6 +16,7 @@ "libs/infrared-sensor", "libs/gyro-sensor", "libs/chassis", + "libs/mood", "libs/ev3", "libs/storage", "libs/datalog",