diff --git a/watch-library/simulator/shell.html b/watch-library/simulator/shell.html index 80e1e2e..7b38a9a 100644 --- a/watch-library/simulator/shell.html +++ b/watch-library/simulator/shell.html @@ -51,6 +51,14 @@ + + + + @@ -71,7 +79,7 @@ - + diff --git a/watch-library/simulator/watch/watch_led.c b/watch-library/simulator/watch/watch_led.c index 068da8b..636dc74 100644 --- a/watch-library/simulator/watch/watch_led.c +++ b/watch-library/simulator/watch/watch_led.c @@ -32,7 +32,15 @@ void watch_disable_leds(void) {} void watch_set_led_color(uint8_t red, uint8_t green) { EM_ASM({ - document.getElementById('light').style.opacity = $1 / 255; + // the watch svg contains an feColorMatrix filter with id ledcolor + // and a green svg gradient that mimics the led being on + // https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feColorMatrix + // this changes the color of the gradient to match the red+green combination + let filter = document.getElementById("ledcolor"); + let color_matrix = filter.children[0].values.baseVal; + color_matrix[1].value = $0 / 255; // red value + color_matrix[6].value = $1 / 255; // green value + document.getElementById('light').style.opacity = Math.min(255, $0 + $1) / 255; }, red, green); }