support for led.plotBrightness (#494)
* support for led.plotBrightness * fixing c++ build * fixed blockid
This commit is contained in:
		
				
					committed by
					
						
						Sam El-Husseini
					
				
			
			
				
	
			
			
			
						parent
						
							e1764567c5
						
					
				
				
					commit
					e7c1915076
				
			@@ -156,8 +156,12 @@
 | 
			
		||||
  "led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
 | 
			
		||||
  "led.plotBarGraph|param|high": "maximum value. If 0, maximum value adjusted automatically, eg: 0",
 | 
			
		||||
  "led.plotBarGraph|param|value": "current value to plot",
 | 
			
		||||
  "led.plot|param|x": "TODO",
 | 
			
		||||
  "led.plot|param|y": "TODO",
 | 
			
		||||
  "led.plotBrightness": "Turn on the specified LED with specific brightness using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
 | 
			
		||||
  "led.plotBrightness|param|brightness": "the brightness from 0 (off) to 255 (bright), eg:255",
 | 
			
		||||
  "led.plotBrightness|param|x": "the horizontal coordinate of the LED starting at 0",
 | 
			
		||||
  "led.plotBrightness|param|y": "the vertical coordinate of the LED starting at 0",
 | 
			
		||||
  "led.plot|param|x": "the horizontal coordinate of the LED starting at 0",
 | 
			
		||||
  "led.plot|param|y": "the vertical coordinate of the LED starting at 0",
 | 
			
		||||
  "led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
 | 
			
		||||
  "led.point|param|x": "TODO",
 | 
			
		||||
  "led.point|param|y": "TODO",
 | 
			
		||||
 
 | 
			
		||||
@@ -264,6 +264,7 @@
 | 
			
		||||
  "led.brightness|block": "brightness",
 | 
			
		||||
  "led.enable|block": "led enable %on",
 | 
			
		||||
  "led.plotBarGraph|block": "plot bar graph of %value |up to %high",
 | 
			
		||||
  "led.plotBrightness|block": "plot|x %x|y %y|value %brightness",
 | 
			
		||||
  "led.plot|block": "plot|x %x|y %y",
 | 
			
		||||
  "led.point|block": "point|x %x|y %y",
 | 
			
		||||
  "led.setBrightness|block": "set brightness %value",
 | 
			
		||||
 
 | 
			
		||||
@@ -13,15 +13,34 @@ namespace led {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
 | 
			
		||||
     * @param x TODO
 | 
			
		||||
     * @param y TODO
 | 
			
		||||
     * @param x the horizontal coordinate of the LED starting at 0
 | 
			
		||||
     * @param y the vertical coordinate of the LED starting at 0
 | 
			
		||||
     */
 | 
			
		||||
    //% help=led/plot weight=78
 | 
			
		||||
    //% blockId=device_plot block="plot|x %x|y %y" blockGap=8
 | 
			
		||||
    //% parts="ledmatrix"
 | 
			
		||||
    //% x.min=0 x.max=4 y.min=0 y.max=4
 | 
			
		||||
    void plot(int x, int y) {
 | 
			
		||||
      uBit.display.image.setPixelValue(x, y, 1);
 | 
			
		||||
      uBit.display.image.setPixelValue(x, y, 0xff);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Turn on the specified LED with specific brightness using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
 | 
			
		||||
     * @param x the horizontal coordinate of the LED starting at 0
 | 
			
		||||
     * @param y the vertical coordinate of the LED starting at 0
 | 
			
		||||
     * @param brightness the brightness from 0 (off) to 255 (bright), eg:255
 | 
			
		||||
     */
 | 
			
		||||
    //% help=led/plot weight=78
 | 
			
		||||
    //% blockId=device_plot_brightness block="plot|x %x|y %y|value %brightness" blockGap=8
 | 
			
		||||
    //% parts="ledmatrix"
 | 
			
		||||
    //% x.min=0 x.max=4 y.min=0 y.max=4 brightness.min=0 brightness.max=255
 | 
			
		||||
    //% advanced=true
 | 
			
		||||
    void plotBrightness(int x, int y, int brightness) {
 | 
			
		||||
        brightness = max(0, min(0xff, brightness));
 | 
			
		||||
        // enable greyscale as needed
 | 
			
		||||
        if (brightness != 0 && brightness != 0xff && uBit.display.getDisplayMode() != DISPLAY_MODE_GREYSCALE)
 | 
			
		||||
            uBit.display.setDisplayMode(DISPLAY_MODE_GREYSCALE);
 | 
			
		||||
        uBit.display.image.setPixelValue(x, y, brightness);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								libs/core/shims.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								libs/core/shims.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -441,8 +441,8 @@ declare namespace led {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
 | 
			
		||||
     * @param x TODO
 | 
			
		||||
     * @param y TODO
 | 
			
		||||
     * @param x the horizontal coordinate of the LED starting at 0
 | 
			
		||||
     * @param y the vertical coordinate of the LED starting at 0
 | 
			
		||||
     */
 | 
			
		||||
    //% help=led/plot weight=78
 | 
			
		||||
    //% blockId=device_plot block="plot|x %x|y %y" blockGap=8
 | 
			
		||||
@@ -450,6 +450,19 @@ declare namespace led {
 | 
			
		||||
    //% x.min=0 x.max=4 y.min=0 y.max=4 shim=led::plot
 | 
			
		||||
    function plot(x: number, y: number): void;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Turn on the specified LED with specific brightness using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
 | 
			
		||||
     * @param x the horizontal coordinate of the LED starting at 0
 | 
			
		||||
     * @param y the vertical coordinate of the LED starting at 0
 | 
			
		||||
     * @param brightness the brightness from 0 (off) to 255 (bright), eg:255
 | 
			
		||||
     */
 | 
			
		||||
    //% help=led/plot weight=78
 | 
			
		||||
    //% blockId=device_plot_brightness block="plot|x %x|y %y|value %brightness" blockGap=8
 | 
			
		||||
    //% parts="ledmatrix"
 | 
			
		||||
    //% x.min=0 x.max=4 y.min=0 y.max=4 brightness.min=0 brightness.max=255
 | 
			
		||||
    //% advanced=true shim=led::plotBrightness
 | 
			
		||||
    function plotBrightness(x: number, y: number, brightness: number): void;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
 | 
			
		||||
     * @param x TODO
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user