adding setpixel
This commit is contained in:
		@@ -68,6 +68,10 @@
 | 
			
		||||
  "screen.print|param|text": "the text to print on the screen, eg: \"Hello world\"",
 | 
			
		||||
  "screen.print|param|x": "the starting position's x coordinate, eg: 0",
 | 
			
		||||
  "screen.print|param|y": "the starting position's x coordinate, eg: 0",
 | 
			
		||||
  "screen.setPixel": "Sets a pixel on or off",
 | 
			
		||||
  "screen.setPixel|param|on": "a value indicating if the pixel should be on or off",
 | 
			
		||||
  "screen.setPixel|param|x": "the starting position's x coordinate, eg: 0",
 | 
			
		||||
  "screen.setPixel|param|y": "the starting position's x coordinate, eg: 0",
 | 
			
		||||
  "serial": "Reading and writing data over a serial connection.",
 | 
			
		||||
  "serial.writeDmesg": "Send DMESG debug buffer over serial."
 | 
			
		||||
}
 | 
			
		||||
@@ -75,6 +75,7 @@
 | 
			
		||||
  "output.setStatusLight|block": "set status light %pattern=led_pattern",
 | 
			
		||||
  "output|block": "output",
 | 
			
		||||
  "screen.print|block": "print %text| at x: %x| y: %y",
 | 
			
		||||
  "screen.setPixel|block": "set pixel %on| at x: %x| y: %y",
 | 
			
		||||
  "screen|block": "screen",
 | 
			
		||||
  "serial|block": "serial",
 | 
			
		||||
  "{id:category}Control": "Control",
 | 
			
		||||
 
 | 
			
		||||
@@ -78,13 +78,21 @@ namespace screen {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export function setPixel(x: number, y: number, mode = Draw.Normal) {
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets a pixel on or off
 | 
			
		||||
     * @param on a value indicating if the pixel should be on or off
 | 
			
		||||
     * @param x the starting position's x coordinate, eg: 0
 | 
			
		||||
     * @param y the starting position's x coordinate, eg: 0
 | 
			
		||||
     */
 | 
			
		||||
    //% blockId=screen_setpixel block="set pixel %on| at x: %x| y: %y"
 | 
			
		||||
    //% weight=98 group="Brick" blockNamespace=output
 | 
			
		||||
    //% x.min=0 x.max=178 y.min=0 y.max=128 on.fieldEditor=toggleonoff
 | 
			
		||||
    export function setPixel(on: boolean, x: number, y: number) {
 | 
			
		||||
        x |= 0
 | 
			
		||||
        y |= 0
 | 
			
		||||
        if (0 <= x && x < DAL.LCD_WIDTH && 0 <= y && y < DAL.LCD_HEIGHT)
 | 
			
		||||
            _setPixel(x, y, mode)
 | 
			
		||||
            _setPixel(x, y, on ? Draw.Normal : Draw.Clear)
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Show text on the screen.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user