summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml4
-rw-r--r--.gitignore1
-rw-r--r--README.md2
-rw-r--r--make.mk4
-rwxr-xr-xmovement/make/make_alternate_fw.sh6
-rw-r--r--watch-library/simulator/shell.html10
-rw-r--r--watch-library/simulator/watch/watch_led.c10
7 files changed, 29 insertions, 8 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3ed1ff26..b150afb1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -44,7 +44,7 @@ jobs:
run: emmake make
working-directory: 'movement/make'
- name: Archive simulator build
- working-directory: 'movement/make/build'
+ working-directory: 'movement/make/build-sim'
run: |
cp watch.html index.html
tar -czf simulator.tar.gz index.html watch.wasm watch.js
@@ -52,4 +52,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: simulator.tar.gz
- path: movement/make/build/simulator.tar.gz
+ path: movement/make/build-sim/simulator.tar.gz
diff --git a/.gitignore b/.gitignore
index 1100e911..06256b71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
**/build/
+**/build-sim/
*.b#*
*.bin
*.d
diff --git a/README.md b/README.md
index 4a82312d..68a501c9 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ You may want to test out changes in the emulator first. To do this, you'll need
```
cd movement/make
emmake make
-python3 -m http.server 8000 -d build
+python3 -m http.server -d build-sim
```
Finally, visit [watch.html](http://localhost:8000/watch.html) to see your work.
diff --git a/make.mk b/make.mk
index 2fe89d75..446ad6fe 100644
--- a/make.mk
+++ b/make.mk
@@ -1,5 +1,9 @@
##############################################################################
+ifndef EMSCRIPTEN
BUILD = ./build
+else
+BUILD = ./build-sim
+endif
BIN = watch
ifndef BOARD
diff --git a/movement/make/make_alternate_fw.sh b/movement/make/make_alternate_fw.sh
index 575c9e52..739c8557 100755
--- a/movement/make/make_alternate_fw.sh
+++ b/movement/make/make_alternate_fw.sh
@@ -28,9 +28,9 @@ do
make clean
emmake make FIRMWARE=$VARIANT
mkdir "$sim_dir/$variant/"
- mv "build/watch.wasm" "$sim_dir/$variant/"
- mv "build/watch.js" "$sim_dir/$variant/"
- mv "build/watch.html" "$sim_dir/$variant/index.html"
+ mv "build-sim/watch.wasm" "$sim_dir/$variant/"
+ mv "build-sim/watch.js" "$sim_dir/$variant/"
+ mv "build-sim/watch.html" "$sim_dir/$variant/index.html"
done
echo "Done."
diff --git a/watch-library/simulator/shell.html b/watch-library/simulator/shell.html
index 80e1e2ea..7b38a9aa 100644
--- a/watch-library/simulator/shell.html
+++ b/watch-library/simulator/shell.html
@@ -51,6 +51,14 @@
<stop offset="0.94" stop-color="#000d00" stop-opacity="0.05"/>
<stop offset="1" stop-opacity="0"/>
</radialGradient>
+ <filter id="ledcolor">
+ <feColorMatrix in="SourceGraphic" type="matrix"
+ values=" 0 0 0 0 0
+ 0 1 0 0 0
+ 0 0 0 0 0
+ 0 0 0 1 0 "/>
+
+ </filter>
</defs>
<g id="Calque">
<g id="Contours">
@@ -71,7 +79,7 @@
<rect x="293.5" y="520" width="683" height="334" rx="34.68" style="fill: #777b7a"/>
</g>
<g id="light" style="opacity: 0">
- <rect x="293.5" y="520" width="683" height="334" rx="34.68" style="fill: url(#Dégradé_sans_nom_3)"/>
+ <rect x="293.5" y="520" width="683" height="334" rx="34.68" style="fill: url(#Dégradé_sans_nom_3)" filter="url(#ledcolor)"/>
</g>
</g>
<g id="Textes">
diff --git a/watch-library/simulator/watch/watch_led.c b/watch-library/simulator/watch/watch_led.c
index 068da8bd..636dc74f 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);
}