From 90db3e61f55d6012f9a1175ad5a438d1827dae6e Mon Sep 17 00:00:00 2001 From: Kai Vogelgesang Date: Fri, 23 Jun 2023 15:50:43 +0200 Subject: [PATCH] Update webserial default code --- webserial/src/editor/defaultCode.ts | 102 ++++++++++++++++------------ 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/webserial/src/editor/defaultCode.ts b/webserial/src/editor/defaultCode.ts index 03cbd9f..20096b4 100644 --- a/webserial/src/editor/defaultCode.ts +++ b/webserial/src/editor/defaultCode.ts @@ -98,51 +98,69 @@ class MovingHead extends Fixture implements GenericRGBW { } } -class Flower extends Fixture implements GenericRGBW { - - setBrightness(value: number, strobe?: boolean): void { - // dimmer seems unsupported :( - this.setChannel(7, (strobe || false) ? 255 * value : 0); - } - - setRGBW(rgb: [number, number, number], w?: number): void { - const [r, g, b] = rgb; - this.setChannel(1, r); - this.setChannel(2, g); - this.setChannel(3, b); - this.setChannel(4, w || 0); - } - - setAP(a: number, p: number) { - this.setChannel(5, a); - this.setChannel(6, p); - } - - /** - * Set the rotation speed - * @param speed Between -1 (clockwise) and 1 (counterclockwise) - */ - setRotation(direction: number) { - const val = (direction < 0) - ? /* clockwise */ lib.remap(direction, [0, -1], [0, 128], true) - : /* counterclockwise */ lib.remap(direction, [0, 1], [129, 255], true); - - this.setChannel(8, val); - } - - setMacro(pattern: number, speed: number) { - this.setChannel(9, pattern); - this.setChannel(10, speed); - } - -} +// class Flower extends Fixture implements GenericRGBW { +// +// setBrightness(value: number, strobe?: boolean): void { +// // dimmer seems unsupported :( +// this.setChannel(7, (strobe || false) ? 255 * value : 0); +// } +// +// setRGBW(rgb: [number, number, number], w?: number): void { +// const [r, g, b] = rgb; +// this.setChannel(1, r); +// this.setChannel(2, g); +// this.setChannel(3, b); +// this.setChannel(4, w || 0); +// } +// +// setAP(a: number, p: number) { +// this.setChannel(5, a); +// this.setChannel(6, p); +// } +// +// /** +// * Set the rotation speed +// * @param speed Between -1 (clockwise) and 1 (counterclockwise) +// */ +// setRotation(direction: number) { +// const val = (direction < 0) +// ? /* clockwise */ lib.remap(direction, [0, -1], [0, 128], true) +// : /* counterclockwise */ lib.remap(direction, [0, 1], [129, 255], true); +// +// this.setChannel(8, val); +// } +// +// setMacro(pattern: number, speed: number) { +// this.setChannel(9, pattern); +// this.setChannel(10, speed); +// } +// +// } // ****************** // * CODE GOES HERE * // ****************** -let color = lib.hsl2rgb(360 * t, 100, 50); +let color = lib.hsl2rgb(360 * (t / 7), 100, 50); -let par = new Par(1); -par.setBrightness(1); -par.setRGBW(color); \ No newline at end of file +const pars = [ + new Par(1), + new Par(41), +]; + +const heads = [ + new MovingHead(120), + new MovingHead(140), + new MovingHead(160), + new MovingHead(100), +]; + +for (let par of pars) { + par.setBrightness(1); + par.setRGBW(color); +} + +for (let head of heads) { + head.setBrightness(1); + head.setRGBW(color); +} \ No newline at end of file