diff --git a/watch-library/shared/driver/thermistor_driver.c b/watch-library/shared/driver/thermistor_driver.c index 73bdef4..8ce5934 100644 --- a/watch-library/shared/driver/thermistor_driver.c +++ b/watch-library/shared/driver/thermistor_driver.c @@ -45,7 +45,15 @@ void thermistor_driver_disable(void) { // Disable the enable pin's output circuitry. watch_disable_digital_output(THERMISTOR_ENABLE_PIN); } - +#if __EMSCRIPTEN__ +#include +float thermistor_driver_get_temperature(void) +{ + return EM_ASM_DOUBLE({ + return temp_c || 25.0; + }); +} +#else float thermistor_driver_get_temperature(void) { // set the enable pin to the level that powers the thermistor circuit. watch_set_pin_level(THERMISTOR_ENABLE_PIN, THERMISTOR_ENABLE_VALUE); @@ -56,3 +64,4 @@ float thermistor_driver_get_temperature(void) { return watch_utility_thermistor_temperature(value, THERMISTOR_HIGH_SIDE, THERMISTOR_B_COEFFICIENT, THERMISTOR_NOMINAL_TEMPERATURE, THERMISTOR_NOMINAL_RESISTANCE, THERMISTOR_SERIES_RESISTANCE); } +#endif diff --git a/watch-library/simulator/shell.html b/watch-library/simulator/shell.html index 29fbed0..9cdb290 100644 --- a/watch-library/simulator/shell.html +++ b/watch-library/simulator/shell.html @@ -905,6 +905,11 @@
+

Temp.

+
+ C + +
@@ -962,6 +967,7 @@ lat = 0; lon = 0; tx = ""; + temp_c = 25.0; function updateLocation(location) { lat = Math.round(location.coords.latitude * 100); lon = Math.round(location.coords.longitude * 100); @@ -1038,10 +1044,25 @@ document.getElementById(skin).checked = true; setSkin(skin); } + + function setTemp() { + let tempInput = document.getElementById("temp-c"); + if (!tempInput) { + return console.warn("no input found"); + } + if (tempInput.value == "") { + return console.warn("no value in input"); + } + + try { + temp_c = Number.parseFloat(tempInput.value); + } catch (e) { + return console.warn("input value is not a valid float:", tempInput.value, e); + } + } loadPrefs(); {{{ SCRIPT }}} -