adding setpixel
This commit is contained in:
parent
ea6bfa03bd
commit
0e1a3b7e6b
@ -68,6 +68,10 @@
|
|||||||
"screen.print|param|text": "the text to print on the screen, eg: \"Hello world\"",
|
"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|x": "the starting position's x coordinate, eg: 0",
|
||||||
"screen.print|param|y": "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": "Reading and writing data over a serial connection.",
|
||||||
"serial.writeDmesg": "Send DMESG debug buffer over serial."
|
"serial.writeDmesg": "Send DMESG debug buffer over serial."
|
||||||
}
|
}
|
@ -75,6 +75,7 @@
|
|||||||
"output.setStatusLight|block": "set status light %pattern=led_pattern",
|
"output.setStatusLight|block": "set status light %pattern=led_pattern",
|
||||||
"output|block": "output",
|
"output|block": "output",
|
||||||
"screen.print|block": "print %text| at x: %x| y: %y",
|
"screen.print|block": "print %text| at x: %x| y: %y",
|
||||||
|
"screen.setPixel|block": "set pixel %on| at x: %x| y: %y",
|
||||||
"screen|block": "screen",
|
"screen|block": "screen",
|
||||||
"serial|block": "serial",
|
"serial|block": "serial",
|
||||||
"{id:category}Control": "Control",
|
"{id:category}Control": "Control",
|
||||||
|
@ -78,14 +78,22 @@ 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
|
x |= 0
|
||||||
y |= 0
|
y |= 0
|
||||||
if (0 <= x && x < DAL.LCD_WIDTH && 0 <= y && y < DAL.LCD_HEIGHT)
|
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.
|
* Show text on the screen.
|
||||||
* @param text the text to print on the screen, eg: "Hello world"
|
* @param text the text to print on the screen, eg: "Hello world"
|
||||||
|
Loading…
Reference in New Issue
Block a user