Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed brightness problem, fixed Chinese translation #54

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions _locales/neopixel-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"NeoPixelColors": "Well known colors for a NeoPixel strip",
"NeoPixelMode": "Different modes for RGB or RGB+W NeoPixel strips",
"neopixel": "Functions to operate NeoPixel strips.",
"neopixel.Strip": "A NeoPixel strip",
"neopixel.Strip.clear": "Turn off all LEDs.\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.easeBrightness": "Apply brightness to current colors using a quadratic easing function.",
"neopixel.Strip.length": "Gets the number of pixels declared on the strip",
"neopixel.Strip.power": "Estimates the electrical current (mA) consumed by the current light configuration.",
"neopixel.Strip.range": "Create a range of LEDs.",
"neopixel.Strip.range|param|length": "number of LEDs in the range. eg: 4",
"neopixel.Strip.range|param|start": "offset in the LED strip to start the range",
"neopixel.Strip.rotate": "Rotate LEDs forward.\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.rotate|param|offset": "number of pixels to rotate forward, eg: 1",
"neopixel.Strip.setBrightness": "Set the brightness of the strip. This flag only applies to future operation.",
"neopixel.Strip.setBrightness|param|brightness": "a measure of LED brightness in 0-255. eg: 255",
"neopixel.Strip.setMatrixColor": "Set LED to a given color (range 0-255 for r, g, b) in a matrix shaped strip\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.setMatrixColor|param|rgb": "RGB color of the LED",
"neopixel.Strip.setMatrixColor|param|x": "horizontal position",
"neopixel.Strip.setMatrixColor|param|y": "horizontal position",
"neopixel.Strip.setMatrixWidth": "Sets the number of pixels in a matrix shaped strip",
"neopixel.Strip.setMatrixWidth|param|width": "number of pixels in a row",
"neopixel.Strip.setPin": "Set the pin where the neopixel is connected, defaults to P0.",
"neopixel.Strip.setPixelColor": "Set LED to a given color (range 0-255 for r, g, b).\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.setPixelColor|param|pixeloffset": "position of the NeoPixel in the strip",
"neopixel.Strip.setPixelColor|param|rgb": "RGB color of the LED",
"neopixel.Strip.setPixelWhiteLED": "For NeoPixels with RGB+W LEDs, set the white LED brightness. This only works for RGB+W NeoPixels.",
"neopixel.Strip.setPixelWhiteLED|param|pixeloffset": "position of the LED in the strip",
"neopixel.Strip.setPixelWhiteLED|param|white": "brightness of the white LED",
"neopixel.Strip.shift": "Shift LEDs forward and clear with zeros.\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.shift|param|offset": "number of pixels to shift forward, eg: 1",
"neopixel.Strip.show": "Send all the changes to the strip.",
"neopixel.Strip.showBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
"neopixel.Strip.showBarGraph|param|high": "maximum value, eg: 255",
"neopixel.Strip.showBarGraph|param|value": "current value to plot",
"neopixel.Strip.showColor": "Shows all LEDs to a given color (range 0-255 for r, g, b).",
"neopixel.Strip.showColor|param|rgb": "RGB color of the LED",
"neopixel.Strip.showRainbow": "Shows a rainbow pattern on all LEDs.",
"neopixel.Strip.showRainbow|param|endHue": "the end hue value for the rainbow, eg: 360",
"neopixel.Strip.showRainbow|param|startHue": "the start hue value for the rainbow, eg: 1",
"neopixel.colors": "Gets the RGB value of a known color",
"neopixel.create": "Create a new NeoPixel driver for `numleds` LEDs.",
"neopixel.create|param|numleds": "number of leds in the strip, eg: 24,30,60,64",
"neopixel.create|param|pin": "the pin where the neopixel is connected.",
"neopixel.hsl": "Converts a hue saturation luminosity value into a RGB color",
"neopixel.hsl|param|h": "hue from 0 to 360",
"neopixel.hsl|param|l": "luminosity from 0 to 99",
"neopixel.hsl|param|s": "saturation from 0 to 99",
"neopixel.rgb": "Converts red, green, blue channels into a RGB color",
"neopixel.rgb|param|blue": "value of the blue channel between 0 and 255. eg: 255",
"neopixel.rgb|param|green": "value of the green channel between 0 and 255. eg: 255",
"neopixel.rgb|param|red": "value of the red channel between 0 and 255. eg: 255"
}
37 changes: 37 additions & 0 deletions _locales/neopixel-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"NeoPixelColors.Black|block": "black",
"NeoPixelColors.Blue|block": "blue",
"NeoPixelColors.Green|block": "green",
"NeoPixelColors.Indigo|block": "indigo",
"NeoPixelColors.Orange|block": "orange",
"NeoPixelColors.Purple|block": "purple",
"NeoPixelColors.Red|block": "red",
"NeoPixelColors.Violet|block": "violet",
"NeoPixelColors.White|block": "white",
"NeoPixelColors.Yellow|block": "yellow",
"NeoPixelMode.RGBW|block": "RGB+W",
"NeoPixelMode.RGB_RGB|block": "RGB (RGB format)",
"NeoPixelMode.RGB|block": "RGB (GRB format)",
"neopixel.Strip.clear|block": "%strip|clear",
"neopixel.Strip.easeBrightness|block": "%strip|ease brightness",
"neopixel.Strip.length|block": "%strip|length",
"neopixel.Strip.power|block": "%strip|power (mA)",
"neopixel.Strip.range|block": "%strip|range from %start|with %length|leds",
"neopixel.Strip.rotate|block": "%strip|rotate pixels by %offset",
"neopixel.Strip.setBrightness|block": "%strip|set brightness %brightness",
"neopixel.Strip.setMatrixColor|block": "%strip|set matrix color at x %x|y %y|to %rgb=neopixel_colors",
"neopixel.Strip.setMatrixWidth|block": "%strip|set matrix width %width",
"neopixel.Strip.setPixelColor|block": "%strip|set pixel color at %pixeloffset|to %rgb=neopixel_colors",
"neopixel.Strip.setPixelWhiteLED|block": "%strip|set pixel white LED at %pixeloffset|to %white",
"neopixel.Strip.shift|block": "%strip|shift pixels by %offset",
"neopixel.Strip.showBarGraph|block": "%strip|show bar graph of %value|up to %high",
"neopixel.Strip.showColor|block": "%strip|show color %rgb=neopixel_colors",
"neopixel.Strip.showRainbow|block": "%strip|show rainbow from %startHue|to %endHue",
"neopixel.Strip.show|block": "%strip|show",
"neopixel.colors|block": "%color",
"neopixel.create|block": "NeoPixel at pin %pin|with %numleds|leds as %mode",
"neopixel.hsl|block": "hue %h|saturation %s|luminosity %l",
"neopixel.rgb|block": "red %red|green %green|blue %blue",
"neopixel|block": "neopixel",
"{id:category}Neopixel": "Neopixel"
}
53 changes: 53 additions & 0 deletions _locales/zh-CN/neopixel-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"NeoPixelColors": "Well known colors for a NeoPixel strip",
"NeoPixelMode": "Different modes for RGB or RGB+W NeoPixel strips",
"neopixel": "Functions to operate NeoPixel strips.",
"neopixel.Strip": "A NeoPixel strip",
"neopixel.Strip.clear": "Turn off all LEDs.\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.easeBrightness": "Apply brightness to current colors using a quadratic easing function.",
"neopixel.Strip.length": "Gets the number of pixels declared on the strip",
"neopixel.Strip.power": "Estimates the electrical current (mA) consumed by the current light configuration.",
"neopixel.Strip.range": "Create a range of LEDs.",
"neopixel.Strip.range|param|length": "number of LEDs in the range. eg: 4",
"neopixel.Strip.range|param|start": "offset in the LED strip to start the range",
"neopixel.Strip.rotate": "Rotate LEDs forward.\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.rotate|param|offset": "number of pixels to rotate forward, eg: 1",
"neopixel.Strip.setBrightness": "Set the brightness of the strip. This flag only applies to future operation.",
"neopixel.Strip.setBrightness|param|brightness": "a measure of LED brightness in 0-255. eg: 255",
"neopixel.Strip.setMatrixColor": "Set LED to a given color (range 0-255 for r, g, b) in a matrix shaped strip\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.setMatrixColor|param|rgb": "RGB color of the LED",
"neopixel.Strip.setMatrixColor|param|x": "horizontal position",
"neopixel.Strip.setMatrixColor|param|y": "horizontal position",
"neopixel.Strip.setMatrixWidth": "Sets the number of pixels in a matrix shaped strip",
"neopixel.Strip.setMatrixWidth|param|width": "number of pixels in a row",
"neopixel.Strip.setPin": "Set the pin where the neopixel is connected, defaults to P0.",
"neopixel.Strip.setPixelColor": "Set LED to a given color (range 0-255 for r, g, b).\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.setPixelColor|param|pixeloffset": "position of the NeoPixel in the strip",
"neopixel.Strip.setPixelColor|param|rgb": "RGB color of the LED",
"neopixel.Strip.setPixelWhiteLED": "For NeoPixels with RGB+W LEDs, set the white LED brightness. This only works for RGB+W NeoPixels.",
"neopixel.Strip.setPixelWhiteLED|param|pixeloffset": "position of the LED in the strip",
"neopixel.Strip.setPixelWhiteLED|param|white": "brightness of the white LED",
"neopixel.Strip.shift": "Shift LEDs forward and clear with zeros.\nYou need to call ``show`` to make the changes visible.",
"neopixel.Strip.shift|param|offset": "number of pixels to shift forward, eg: 1",
"neopixel.Strip.show": "Send all the changes to the strip.",
"neopixel.Strip.showBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
"neopixel.Strip.showBarGraph|param|high": "maximum value, eg: 255",
"neopixel.Strip.showBarGraph|param|value": "current value to plot",
"neopixel.Strip.showColor": "Shows all LEDs to a given color (range 0-255 for r, g, b).",
"neopixel.Strip.showColor|param|rgb": "RGB color of the LED",
"neopixel.Strip.showRainbow": "Shows a rainbow pattern on all LEDs.",
"neopixel.Strip.showRainbow|param|endHue": "the end hue value for the rainbow, eg: 360",
"neopixel.Strip.showRainbow|param|startHue": "the start hue value for the rainbow, eg: 1",
"neopixel.colors": "Gets the RGB value of a known color",
"neopixel.create": "Create a new NeoPixel driver for `numleds` LEDs.",
"neopixel.create|param|numleds": "number of leds in the strip, eg: 24,30,60,64",
"neopixel.create|param|pin": "the pin where the neopixel is connected.",
"neopixel.hsl": "Converts a hue saturation luminosity value into a RGB color",
"neopixel.hsl|param|h": "hue from 0 to 360",
"neopixel.hsl|param|l": "luminosity from 0 to 99",
"neopixel.hsl|param|s": "saturation from 0 to 99",
"neopixel.rgb": "Converts red, green, blue channels into a RGB color",
"neopixel.rgb|param|blue": "value of the blue channel between 0 and 255. eg: 255",
"neopixel.rgb|param|green": "value of the green channel between 0 and 255. eg: 255",
"neopixel.rgb|param|red": "value of the red channel between 0 and 255. eg: 255"
}
37 changes: 37 additions & 0 deletions _locales/zh-CN/neopixel-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"NeoPixelColors.Black|block": "黑",
"NeoPixelColors.Blue|block": "蓝",
"NeoPixelColors.Green|block": "绿",
"NeoPixelColors.Indigo|block": "靛蓝",
"NeoPixelColors.Orange|block": "橙",
"NeoPixelColors.Purple|block": "紫",
"NeoPixelColors.Red|block": "红",
"NeoPixelColors.Violet|block": "紫罗兰",
"NeoPixelColors.White|block": "白",
"NeoPixelColors.Yellow|block": "黄色",
"NeoPixelMode.RGBW|block": "RGB+W",
"NeoPixelMode.RGB_RGB|block": "RGB (RGB顺序)",
"NeoPixelMode.RGB|block": "RGB (GRB顺序)",
"neopixel.Strip.clear|block": "%strip|清除显示",
"neopixel.Strip.easeBrightness|block": "%strip|减小亮度",
"neopixel.Strip.length|block": "%strip|长度",
"neopixel.Strip.power|block": "%strip|电流(mA)",
"neopixel.Strip.range|block": "%strip|从像素%start|开始 长度 %length|颗LED",
"neopixel.Strip.rotate|block": "%strip|循环像素 偏移量 %offset",
"neopixel.Strip.setBrightness|block": "%strip|设置亮度为 %brightness",
"neopixel.Strip.setMatrixColor|block": "%string|设置像素点 (坐标)x %x|y %y|颜色 %rgb=neopixel_colors",
"neopixel.Strip.setMatrixWidth|block": "%strip|设置矩阵宽度 %width",
"neopixel.Strip.setPixelColor|block": "%strip|设置颜色 像素%pixeloffset|为 %rgb=neopixel_colors",
"neopixel.Strip.setPixelWhiteLED|block": "%strip|设置白灯(RGB+W) 像素%pixeloffset|为 %white",
"neopixel.Strip.shift|block": "%strip|移动像素 偏移量%offset",
"neopixel.Strip.showBarGraph|block": "%strip|显示柱状图 值%value|最大值%high",
"neopixel.Strip.showColor|block":"%strip|显示颜色%rgb=neopixel_colors",
"neopixel.Strip.showRainbow|block": "%strip|显示彩虹特效 (色相)从%startHue|到%endHue",
"neopixel.Strip.show|block": "%strip|刷新显示",
"neopixel.colors|block": "%color",
"neopixel.create|block": "引脚%pin|初始化灯带|%numleds|颗LED(模式%mode|)",
"neopixel.hsl|block": "色相 %h|饱和度 %s|亮度 %l",
"neopixel.rgb|block": "RGB(红%red|绿%green|蓝%blue|)",
"neopixel|block": "流光溢彩灯",
"{id:category}Neopixel": "流光溢彩灯"
}
15 changes: 11 additions & 4 deletions neopixel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,16 @@ namespace neopixel {
//% weight=79
//% parts="neopixel"
show() {
// only supported in beta
// ws2812b.setBufferMode(this.pin, this._mode);
ws2812b.sendBuffer(this.buf, this.pin);
//ws2812b.sendBuffer(this.buf, this.pin);
for (let i = 0; i < 4; i++) {
pins.spiWrite(0);
}
for (let i = this.start * 4; i < (this._length + this.start) * 4; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a 4 number here? what does it represent?

pins.spiWrite(this.buf[i]);
}
for (let i = 0; i < (this._length + 15) / 16; i++) {
pins.spiWrite(0);
}
}

/**
Expand Down Expand Up @@ -500,7 +507,7 @@ namespace neopixel {
strip._length = numleds;
strip._mode = mode || NeoPixelMode.RGB;
strip._matrixWidth = 0;
strip.setBrightness(128)
strip.setBrightness(50)
strip.setPin(pin)
return strip;
}
Expand Down
Loading