Open
Description
Issue:
Unable to set some colors to WiDo2 HUB LED
Reason for behavior:
Incorrect code of function setLightHue (args) in src scratch-vm/src/extensions/scratch3_wedo2/index.js
WiDo2 LED color is not HUE or RGB color.
- If we use HUE with s: 1, v: 1 - then black (off) color impossible.
- If we use 3 byte RGB color - then we can't get orange or light green color. because Wedo 2 only distinguishes between 0 or 1 in each color byte. FF0001 is same with 020033, and 000201 is same with 00BFFB
ToDo:
Use 1-byte color scheme.
Code correction:
//1)Change function setLightHue (args) to
setLightHue (args) {
// Convert number to [0,10] interval
let inputColor = Cast.toNumber(args.HUE);
inputColor = MathUtil.wrapClamp(inputColor , 0, 10);
this._peripheral.setLED_one_byteinputColor);
return new Promise(resolve => {
window.setTimeout(() => {
resolve();
}, BLESendInterval);
});
}
// 2) After function setLED (inputRGB) create new
setLED_one_byte (input) {
//There We need to put only 1 byte
//and get the cmd array of 4 elements instead of 6
const weDoColor = [
input ];
const cmd = this.generateOutputCommand(
WeDo2ConnectID.LED,
WeDo2Command.WRITE_RGB,
weDoColor
);
return this.send(BLECharacteristic.OUTPUT_COMMAND, cmd);
}
This solution is tested and works on my Scratch instance.
Metadata
Metadata
Assignees
Labels
No labels