Skip to content

Commit

Permalink
sim: sharp neoled brighness curve
Browse files Browse the repository at this point in the history
  • Loading branch information
JerwuQu committed May 19, 2024
1 parent 5b6c2cd commit 8cd6d86
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion simulator/src/ui/leds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ export class LEDs extends LitElement {
@state() public neopixels: [number, number, number, number, number] = [0, 0, 0, 0, 0];
@state() public redLed: boolean = false;

amp(v: number): number {
return Math.log(v * 100 + 1) * 25;
}

render () {
return html`
<div class="leds">
<div class="neopixels">
${this.neopixels.map(_ => {
const [r, g, b] = unpack888(_);
return html`<div class="led-wrapper"><div class="led" style="--color: rgb(${r}, ${g}, ${b})"></div></div>`;
return html`<div class="led-wrapper"><div class="led" style="--color: rgb(${this.amp(r)}, ${this.amp(g)}, ${this.amp(b)})"></div></div>`;
})}
</div>
<div class="led-wrapper"><div class="led" style="--color: rgba(255, 0, 0, ${this.redLed ? 1 : 0.4});"></div></div>
Expand Down

0 comments on commit 8cd6d86

Please sign in to comment.