added showIcon api
This commit is contained in:
		@@ -43,6 +43,7 @@
 | 
				
			|||||||
  "basic.showAnimation": "Shows a sequence of LED screens as an animation.",
 | 
					  "basic.showAnimation": "Shows a sequence of LED screens as an animation.",
 | 
				
			||||||
  "basic.showAnimation|param|interval": "time in milliseconds between each redraw",
 | 
					  "basic.showAnimation|param|interval": "time in milliseconds between each redraw",
 | 
				
			||||||
  "basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
 | 
					  "basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
 | 
				
			||||||
 | 
					  "basic.showIcon": "Draws the selected icon on the LED screen",
 | 
				
			||||||
  "basic.showLeds": "Draws an image on the LED screen.",
 | 
					  "basic.showLeds": "Draws an image on the LED screen.",
 | 
				
			||||||
  "basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
 | 
					  "basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
 | 
				
			||||||
  "basic.showLeds|param|leds": "the pattern of LED to turn on/off",
 | 
					  "basic.showLeds|param|leds": "the pattern of LED to turn on/off",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,6 +61,46 @@
 | 
				
			|||||||
  "Gesture.TiltLeft|block": "tilt left",
 | 
					  "Gesture.TiltLeft|block": "tilt left",
 | 
				
			||||||
  "Gesture.TiltRight": "Raised when the screen is pointing right",
 | 
					  "Gesture.TiltRight": "Raised when the screen is pointing right",
 | 
				
			||||||
  "Gesture.TiltRight|block": "tilt right",
 | 
					  "Gesture.TiltRight|block": "tilt right",
 | 
				
			||||||
 | 
					  "IconNames.Angry|block": "angry",
 | 
				
			||||||
 | 
					  "IconNames.Asleep|block": "asleep",
 | 
				
			||||||
 | 
					  "IconNames.Butterfly|block": "butterfly",
 | 
				
			||||||
 | 
					  "IconNames.Chessboard|block": "chess board",
 | 
				
			||||||
 | 
					  "IconNames.Confused|block": "confused",
 | 
				
			||||||
 | 
					  "IconNames.Cow|block": "cow",
 | 
				
			||||||
 | 
					  "IconNames.Diamond|block": "diamond",
 | 
				
			||||||
 | 
					  "IconNames.Duck|block": "duck",
 | 
				
			||||||
 | 
					  "IconNames.EigthNote|block": "eigth note",
 | 
				
			||||||
 | 
					  "IconNames.Fabulous|block": "fabulous",
 | 
				
			||||||
 | 
					  "IconNames.Ghost|block": "ghost",
 | 
				
			||||||
 | 
					  "IconNames.Giraffe|block": "giraffe",
 | 
				
			||||||
 | 
					  "IconNames.Happy|block": "happy",
 | 
				
			||||||
 | 
					  "IconNames.Heart|block": "heart",
 | 
				
			||||||
 | 
					  "IconNames.House|block": "house",
 | 
				
			||||||
 | 
					  "IconNames.LeftTriangle|block": "left triangle",
 | 
				
			||||||
 | 
					  "IconNames.Meh|block": "meh",
 | 
				
			||||||
 | 
					  "IconNames.No|block": "no",
 | 
				
			||||||
 | 
					  "IconNames.Pacman|block": "pac man",
 | 
				
			||||||
 | 
					  "IconNames.Pitchfork|block": "pitchfork",
 | 
				
			||||||
 | 
					  "IconNames.QuarterNote|block": "quarter note",
 | 
				
			||||||
 | 
					  "IconNames.Rabbit|block": "rabbit",
 | 
				
			||||||
 | 
					  "IconNames.Rollerskate|block": "roller skate",
 | 
				
			||||||
 | 
					  "IconNames.Sad|block": "sad",
 | 
				
			||||||
 | 
					  "IconNames.Silly|block": "silly",
 | 
				
			||||||
 | 
					  "IconNames.Skull|block": "skull",
 | 
				
			||||||
 | 
					  "IconNames.SmallDiamond|block": "small diamond",
 | 
				
			||||||
 | 
					  "IconNames.SmallHeart|block": "small heart",
 | 
				
			||||||
 | 
					  "IconNames.SmallSquare|block": "small square",
 | 
				
			||||||
 | 
					  "IconNames.Snake|block": "snake",
 | 
				
			||||||
 | 
					  "IconNames.Square|block": "square",
 | 
				
			||||||
 | 
					  "IconNames.StickFigure|block": "stick figure",
 | 
				
			||||||
 | 
					  "IconNames.Surprised|block": "surprised",
 | 
				
			||||||
 | 
					  "IconNames.Sword|block": "sword",
 | 
				
			||||||
 | 
					  "IconNames.TShirt|block": "t-shirt",
 | 
				
			||||||
 | 
					  "IconNames.Target|block": "target",
 | 
				
			||||||
 | 
					  "IconNames.Tortoise|block": "tortoise",
 | 
				
			||||||
 | 
					  "IconNames.Triangle|block": "triangle",
 | 
				
			||||||
 | 
					  "IconNames.Umbrella|block": "umbrella",
 | 
				
			||||||
 | 
					  "IconNames.Yes|block": "yes",
 | 
				
			||||||
  "LedSpriteProperty.Blink|block": "blink",
 | 
					  "LedSpriteProperty.Blink|block": "blink",
 | 
				
			||||||
  "LedSpriteProperty.Brightness|block": "brightness",
 | 
					  "LedSpriteProperty.Brightness|block": "brightness",
 | 
				
			||||||
  "LedSpriteProperty.Direction|block": "direction",
 | 
					  "LedSpriteProperty.Direction|block": "direction",
 | 
				
			||||||
@@ -105,6 +145,7 @@
 | 
				
			|||||||
  "basic.pause|block": "pause (ms) %pause",
 | 
					  "basic.pause|block": "pause (ms) %pause",
 | 
				
			||||||
  "basic.rgbw|block": "red %red|green %green|blue %blue|white %white",
 | 
					  "basic.rgbw|block": "red %red|green %green|blue %blue|white %white",
 | 
				
			||||||
  "basic.setLedColor|block": "set led to %color=color_id",
 | 
					  "basic.setLedColor|block": "set led to %color=color_id",
 | 
				
			||||||
 | 
					  "basic.showIcon|block": "show icon %i",
 | 
				
			||||||
  "basic.showLeds|block": "show leds",
 | 
					  "basic.showLeds|block": "show leds",
 | 
				
			||||||
  "basic.showNumber|block": "show|number %number",
 | 
					  "basic.showNumber|block": "show|number %number",
 | 
				
			||||||
  "basic.showString|block": "show|string %text",
 | 
					  "basic.showString|block": "show|string %text",
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										523
									
								
								libs/core/icons.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										523
									
								
								libs/core/icons.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,523 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					The MIT License (MIT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Copyright (c) 2013-2016 The MicroPython-on-micro:bit Developers, as listed
 | 
				
			||||||
 | 
					in the accompanying AUTHORS file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Images from file microbitconstimage.cpp https://github.com/bbcmicrobit/micropython
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum IconNames {
 | 
				
			||||||
 | 
					    //% block="heart"
 | 
				
			||||||
 | 
					    Heart = 0,
 | 
				
			||||||
 | 
					    //% block="small heart"
 | 
				
			||||||
 | 
					    SmallHeart,
 | 
				
			||||||
 | 
					    //% block="yes"
 | 
				
			||||||
 | 
					    Yes,
 | 
				
			||||||
 | 
					    //% block="no"
 | 
				
			||||||
 | 
					    No,
 | 
				
			||||||
 | 
					    //% block="happy"
 | 
				
			||||||
 | 
					    Happy,
 | 
				
			||||||
 | 
					    //% block="sad"
 | 
				
			||||||
 | 
					    Sad,
 | 
				
			||||||
 | 
					    //% block="confused"
 | 
				
			||||||
 | 
					    Confused,
 | 
				
			||||||
 | 
					    //% block="angry"
 | 
				
			||||||
 | 
					    Angry,
 | 
				
			||||||
 | 
					    //% block="asleep"
 | 
				
			||||||
 | 
					    Asleep,
 | 
				
			||||||
 | 
					    //% block="surprised"
 | 
				
			||||||
 | 
					    Surprised,
 | 
				
			||||||
 | 
					    //% block="silly"
 | 
				
			||||||
 | 
					    Silly,
 | 
				
			||||||
 | 
					    //% block="fabulous"
 | 
				
			||||||
 | 
					    Fabulous,
 | 
				
			||||||
 | 
					    //% block="meh"
 | 
				
			||||||
 | 
					    Meh,
 | 
				
			||||||
 | 
					    //% block="t-shirt"
 | 
				
			||||||
 | 
					    TShirt,
 | 
				
			||||||
 | 
					    //% block="roller skate"
 | 
				
			||||||
 | 
					    Rollerskate,
 | 
				
			||||||
 | 
					    //% block="duck"
 | 
				
			||||||
 | 
					    Duck,
 | 
				
			||||||
 | 
					    //% block="house"
 | 
				
			||||||
 | 
					    House,
 | 
				
			||||||
 | 
					    //% block="tortoise"
 | 
				
			||||||
 | 
					    Tortoise,
 | 
				
			||||||
 | 
					    //% block="butterfly"
 | 
				
			||||||
 | 
					    Butterfly,
 | 
				
			||||||
 | 
					    //% block="stick figure"
 | 
				
			||||||
 | 
					    StickFigure,
 | 
				
			||||||
 | 
					    //% block="ghost"
 | 
				
			||||||
 | 
					    Ghost,
 | 
				
			||||||
 | 
					    //% block="sword"
 | 
				
			||||||
 | 
					    Sword,
 | 
				
			||||||
 | 
					    //% block="giraffe"
 | 
				
			||||||
 | 
					    Giraffe,
 | 
				
			||||||
 | 
					    //% block="skull"
 | 
				
			||||||
 | 
					    Skull,
 | 
				
			||||||
 | 
					    //% block="umbrella"
 | 
				
			||||||
 | 
					    Umbrella,
 | 
				
			||||||
 | 
					    //% block="snake"
 | 
				
			||||||
 | 
					    Snake,
 | 
				
			||||||
 | 
					    //% block="rabbit"
 | 
				
			||||||
 | 
					    Rabbit,
 | 
				
			||||||
 | 
					    //% block="cow"
 | 
				
			||||||
 | 
					    Cow,
 | 
				
			||||||
 | 
					    //% block="quarter note"
 | 
				
			||||||
 | 
					    QuarterNote,
 | 
				
			||||||
 | 
					    //% block="eigth note"
 | 
				
			||||||
 | 
					    EigthNote,
 | 
				
			||||||
 | 
					    //% block="pitchfork"
 | 
				
			||||||
 | 
					    Pitchfork,
 | 
				
			||||||
 | 
					    //% block="pac man"
 | 
				
			||||||
 | 
					    Pacman,
 | 
				
			||||||
 | 
					    //% block="target"
 | 
				
			||||||
 | 
					    Target,
 | 
				
			||||||
 | 
					    //% block="triangle"
 | 
				
			||||||
 | 
					    Triangle,
 | 
				
			||||||
 | 
					    //% block="left triangle"
 | 
				
			||||||
 | 
					    LeftTriangle,
 | 
				
			||||||
 | 
					    //% block="chess board"
 | 
				
			||||||
 | 
					    Chessboard,
 | 
				
			||||||
 | 
					    //% block="diamond"
 | 
				
			||||||
 | 
					    Diamond,
 | 
				
			||||||
 | 
					    //% block="small diamond"
 | 
				
			||||||
 | 
					    SmallDiamond,
 | 
				
			||||||
 | 
					    //% block="square"
 | 
				
			||||||
 | 
					    Square,
 | 
				
			||||||
 | 
					    //% block="small square"
 | 
				
			||||||
 | 
					    SmallSquare, 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum ArrowNames {
 | 
				
			||||||
 | 
					    //% blockIdentity=images.arrowNumber
 | 
				
			||||||
 | 
					    North = 0,
 | 
				
			||||||
 | 
					    //% blockIdentity=images.arrowNumber
 | 
				
			||||||
 | 
					    NorthEast,
 | 
				
			||||||
 | 
					    //% blockIdentity=images.arrowNumber
 | 
				
			||||||
 | 
					    East,
 | 
				
			||||||
 | 
					    //% blockIdentity=images.arrowNumber
 | 
				
			||||||
 | 
					    SouthEast,
 | 
				
			||||||
 | 
					    //% blockIdentity=images.arrowNumber
 | 
				
			||||||
 | 
					    South,
 | 
				
			||||||
 | 
					    //% blockIdentity=images.arrowNumber 
 | 
				
			||||||
 | 
					    SouthWest,
 | 
				
			||||||
 | 
					    //% blockIdentity=images.arrowNumber
 | 
				
			||||||
 | 
					    West,
 | 
				
			||||||
 | 
					    //% blockIdentity=images.arrowNumber
 | 
				
			||||||
 | 
					    NorthWest,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace basic {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Draws the selected icon on the LED screen
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    //% weight=90 blockGap=8
 | 
				
			||||||
 | 
					    //% blockId=basic_show_icon 
 | 
				
			||||||
 | 
					    //% block="show icon %i" icon="\uf00a"
 | 
				
			||||||
 | 
					    //% parts="ledmatrix"
 | 
				
			||||||
 | 
					    //% help=basic/show-icon
 | 
				
			||||||
 | 
					    export function showIcon(icon: IconNames) {
 | 
				
			||||||
 | 
					        let res = images.iconImage(icon)
 | 
				
			||||||
 | 
					        res.showImage(0)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //% weight=50 blockGap=8
 | 
				
			||||||
 | 
					    //% blockId=basic_show_arrow 
 | 
				
			||||||
 | 
					    //% block="show arrow %i=device_arrow"
 | 
				
			||||||
 | 
					    //% parts="ledmatrix"
 | 
				
			||||||
 | 
					    //% advanced=true
 | 
				
			||||||
 | 
					    //% help=basic/show-arrow
 | 
				
			||||||
 | 
					    export function showArrow(i: number) {
 | 
				
			||||||
 | 
					        let res = images.arrowImage(i)
 | 
				
			||||||
 | 
					        res.showImage(0)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace images {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function getArrow(i : ArrowNames): string {
 | 
				
			||||||
 | 
					            switch(i) {
 | 
				
			||||||
 | 
					            // compass directions
 | 
				
			||||||
 | 
					            case ArrowNames.North: return `    
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        # . # . #
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            case ArrowNames.NorthEast: return ` 
 | 
				
			||||||
 | 
					                                        . . # # #
 | 
				
			||||||
 | 
					                                        . . . # #
 | 
				
			||||||
 | 
					                                        . . # . #
 | 
				
			||||||
 | 
					                                        . # . . .
 | 
				
			||||||
 | 
					                                        # . . . .`;
 | 
				
			||||||
 | 
					            case  ArrowNames.East: return ` 
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . . # .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . . . # .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            case ArrowNames.SouthEast: return ` 
 | 
				
			||||||
 | 
					                                        # . . . .
 | 
				
			||||||
 | 
					                                        . # . . .
 | 
				
			||||||
 | 
					                                        . . # . #
 | 
				
			||||||
 | 
					                                        . . . # #
 | 
				
			||||||
 | 
					                                        . . # # #`;
 | 
				
			||||||
 | 
					            case ArrowNames.South: return ` 
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        # . # . #
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            case ArrowNames.SouthWest: return ` 
 | 
				
			||||||
 | 
					                                        . . . . #
 | 
				
			||||||
 | 
					                                        . . . # .
 | 
				
			||||||
 | 
					                                        # . # . .
 | 
				
			||||||
 | 
					                                        # # . . .
 | 
				
			||||||
 | 
					                                        # # # . .`;
 | 
				
			||||||
 | 
					            case ArrowNames.West: return ` 
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # . . .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . # . . .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            case ArrowNames.NorthWest: return ` 
 | 
				
			||||||
 | 
					                                        # # # . .
 | 
				
			||||||
 | 
					                                        # # . . .
 | 
				
			||||||
 | 
					                                        # . # . .
 | 
				
			||||||
 | 
					                                        . . . # .
 | 
				
			||||||
 | 
					                                        . . . . #`;
 | 
				
			||||||
 | 
					            default:                return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        `;
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    function getIcon(i: IconNames): string {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            switch (i) {
 | 
				
			||||||
 | 
					            case IconNames.Heart : return `
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            case IconNames.SmallHeart : return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . . . .`;
 | 
				
			||||||
 | 
					                                            //faces
 | 
				
			||||||
 | 
					            case IconNames.Happy: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        . # # # .`;
 | 
				
			||||||
 | 
					            case IconNames.Sad: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        # . . . #`;
 | 
				
			||||||
 | 
					            case IconNames.Confused: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        # . # . #`;
 | 
				
			||||||
 | 
					            case IconNames.Angry: return `
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        # . # . #`;
 | 
				
			||||||
 | 
					            case IconNames.Asleep: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        # # . # #
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . . . .`;
 | 
				
			||||||
 | 
					            case IconNames.Surprised: return `
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            case IconNames.Silly: return `
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . . . # #
 | 
				
			||||||
 | 
					                                        . . . # #`;
 | 
				
			||||||
 | 
					            case IconNames.Fabulous: return `
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        # # . # #
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . # # # .`;
 | 
				
			||||||
 | 
					            case IconNames.Meh: return `
 | 
				
			||||||
 | 
					                                        # # . # #
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . # .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # . . .`;
 | 
				
			||||||
 | 
					            case IconNames.Yes: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . #
 | 
				
			||||||
 | 
					                                        . . . # .
 | 
				
			||||||
 | 
					                                        # . # . .
 | 
				
			||||||
 | 
					                                        . # . . .`;
 | 
				
			||||||
 | 
					            case IconNames.No: return `
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        # . . . #`;
 | 
				
			||||||
 | 
					            case IconNames.Triangle: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . . . . .`;
 | 
				
			||||||
 | 
					            case IconNames.LeftTriangle: return `
 | 
				
			||||||
 | 
					                                        # . . . .
 | 
				
			||||||
 | 
					                                        # # . . .
 | 
				
			||||||
 | 
					                                        # . # . .
 | 
				
			||||||
 | 
					                                        # . . # .
 | 
				
			||||||
 | 
					                                        # # # # #`;
 | 
				
			||||||
 | 
					            case IconNames.Chessboard: return `
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        # . # . #
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        # . # . #
 | 
				
			||||||
 | 
					                                        . # . # .`;
 | 
				
			||||||
 | 
					            case IconNames.Diamond: return `
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            case IconNames.SmallDiamond: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . . . .`;
 | 
				
			||||||
 | 
					            case IconNames.Square: return `
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        # # # # #`;
 | 
				
			||||||
 | 
					            case IconNames.SmallSquare: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . . . .`;
 | 
				
			||||||
 | 
					                                            // The following images were designed by Abbie Brooks.
 | 
				
			||||||
 | 
					            case IconNames.TShirt: return `
 | 
				
			||||||
 | 
					                                        # # . # #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . # # # .`;
 | 
				
			||||||
 | 
					            case IconNames.Rollerskate: return `
 | 
				
			||||||
 | 
					                                        . . . # #
 | 
				
			||||||
 | 
					                                        . . . # #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . # . # .`;
 | 
				
			||||||
 | 
					            case IconNames.Duck: return `
 | 
				
			||||||
 | 
					                                        . # # . .
 | 
				
			||||||
 | 
					                                        # # # . .
 | 
				
			||||||
 | 
					                                        . # # # #
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . .. . .`;
 | 
				
			||||||
 | 
					            case IconNames.House: return `
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . # . # .`;
 | 
				
			||||||
 | 
					            case IconNames.Tortoise: return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . . . . .`;
 | 
				
			||||||
 | 
					            case IconNames.Butterfly: return `
 | 
				
			||||||
 | 
					                                        # # . # #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        # # . # #`;
 | 
				
			||||||
 | 
					            case IconNames.StickFigure: return `
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        # . . . #`;
 | 
				
			||||||
 | 
					            case IconNames.Ghost: return `
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        # . # . #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        # . # . #`;
 | 
				
			||||||
 | 
					            case IconNames.Sword: return `
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            case IconNames.Giraffe: return `
 | 
				
			||||||
 | 
					                                        # # . . .
 | 
				
			||||||
 | 
					                                        . # . . .
 | 
				
			||||||
 | 
					                                        . # . . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . # . # .`;
 | 
				
			||||||
 | 
					            case IconNames.Skull: return `
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        # . # . #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . # # # .`;
 | 
				
			||||||
 | 
					            case IconNames.Umbrella: return `
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        # . # . .
 | 
				
			||||||
 | 
					                                        # # # . .`;
 | 
				
			||||||
 | 
					            case IconNames.Snake: return `
 | 
				
			||||||
 | 
					                                        # # . . .
 | 
				
			||||||
 | 
					                                        # # . # #
 | 
				
			||||||
 | 
					                                        . # . # .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . . . .`;
 | 
				
			||||||
 | 
					                                        // animals    
 | 
				
			||||||
 | 
					            case IconNames.Rabbit: return `
 | 
				
			||||||
 | 
					                                        # . # . .
 | 
				
			||||||
 | 
					                                        # . # . .
 | 
				
			||||||
 | 
					                                        # # # # .
 | 
				
			||||||
 | 
					                                        # # . # .
 | 
				
			||||||
 | 
					                                        # # # # .`;
 | 
				
			||||||
 | 
					            case IconNames.Cow: return `
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        # . . . #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					                                        // musical notes
 | 
				
			||||||
 | 
					            case IconNames.QuarterNote: return `
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        # # # . .
 | 
				
			||||||
 | 
					                                        # # # . .`;
 | 
				
			||||||
 | 
					            case IconNames.EigthNote: return `
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . # # .
 | 
				
			||||||
 | 
					                                        . . # . #
 | 
				
			||||||
 | 
					                                        # # # . .
 | 
				
			||||||
 | 
					                                        # # # . .`;
 | 
				
			||||||
 | 
					                                        // other icons
 | 
				
			||||||
 | 
					            case IconNames.Pitchfork: return `
 | 
				
			||||||
 | 
					                                        # . # . #
 | 
				
			||||||
 | 
					                                        # . # . #
 | 
				
			||||||
 | 
					                                        # # # # #
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            case IconNames.Pacman: return `
 | 
				
			||||||
 | 
					                                        . # # # #
 | 
				
			||||||
 | 
					                                        # # # # .
 | 
				
			||||||
 | 
					                                        # # # . .
 | 
				
			||||||
 | 
					                                        # # # # .
 | 
				
			||||||
 | 
					                                        . # # # #`;
 | 
				
			||||||
 | 
					            case IconNames.Target: return `
 | 
				
			||||||
 | 
					                                        . . # . .
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        # # . # #
 | 
				
			||||||
 | 
					                                        . # # # .
 | 
				
			||||||
 | 
					                                        . . # . .`;
 | 
				
			||||||
 | 
					            default:                return `
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        . . . . .
 | 
				
			||||||
 | 
					                                        `;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //% weight=50 blockGap=8
 | 
				
			||||||
 | 
					    //% blockId=device_arrow block="%arrow"
 | 
				
			||||||
 | 
					    //% shim=TD_ID
 | 
				
			||||||
 | 
					    export function arrowNumber(arrow: ArrowNames): number {
 | 
				
			||||||
 | 
					        return arrow;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //% weight=50 blockGap=8
 | 
				
			||||||
 | 
					    //% blockId=builtin_arrow_image block="arrow image %i=device_arrow"
 | 
				
			||||||
 | 
					    export function arrowImage(i: ArrowNames): Image {
 | 
				
			||||||
 | 
					        let res = images.createImage(`
 | 
				
			||||||
 | 
					            . . . . .
 | 
				
			||||||
 | 
					            . . . . .
 | 
				
			||||||
 | 
					            . . . . .
 | 
				
			||||||
 | 
					            . . . . .
 | 
				
			||||||
 | 
					            . . . . .
 | 
				
			||||||
 | 
					            `)
 | 
				
			||||||
 | 
					        return set(res, getArrow(i));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //% weight=50 blockGap=8
 | 
				
			||||||
 | 
					    //% blockId=builtin_image block="icon image %i"
 | 
				
			||||||
 | 
					    export function iconImage(i: IconNames): Image {
 | 
				
			||||||
 | 
					        let res = images.createImage(`
 | 
				
			||||||
 | 
					                . . . . .
 | 
				
			||||||
 | 
					                . . . . .
 | 
				
			||||||
 | 
					                . . . . .
 | 
				
			||||||
 | 
					                . . . . .
 | 
				
			||||||
 | 
					                . . . . .
 | 
				
			||||||
 | 
					                `)
 | 
				
			||||||
 | 
					        return set(res, getIcon(i));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function set(res: Image, s: string) {
 | 
				
			||||||
 | 
					        let j = 0;
 | 
				
			||||||
 | 
					        for (let x of s) {
 | 
				
			||||||
 | 
					            if (x == "." || x == "#") {
 | 
				
			||||||
 | 
					                res.setPixel(j % 5, j / 5, x == "#")
 | 
				
			||||||
 | 
					                j++
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -32,6 +32,7 @@
 | 
				
			|||||||
        "pins.ts",
 | 
					        "pins.ts",
 | 
				
			||||||
        "serial.cpp",
 | 
					        "serial.cpp",
 | 
				
			||||||
        "serial.ts",
 | 
					        "serial.ts",
 | 
				
			||||||
 | 
					        "icons.ts",
 | 
				
			||||||
        "buffer.cpp",
 | 
					        "buffer.cpp",
 | 
				
			||||||
        "pxtparts.json",
 | 
					        "pxtparts.json",
 | 
				
			||||||
        "parts/speaker.svg",
 | 
					        "parts/speaker.svg",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user