diff options
Diffstat (limited to 'web/web_opts.c')
-rw-r--r-- | web/web_opts.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/web/web_opts.c b/web/web_opts.c index 0f37bba..945909f 100644 --- a/web/web_opts.c +++ b/web/web_opts.c @@ -3,6 +3,8 @@ #include "comp.h" #include <math.h> +#include <stdio.h> +#include <string.h> #include <emscripten/emscripten.h> @@ -11,8 +13,21 @@ int delay_ms = 1000; void opts_init() { EM_ASM(readOpts()); - EM_ASM({updateDelay($0)}, delay_ms); - EM_ASM({updateStdev($0)}, horizontal_stdev); + + char buf[64]; + sprintf(buf, "%d", delay_ms); + EM_ASM({elemSetValue($0, $1)}, "#delay", buf); + + int len = sprintf(buf, "%4.2f", horizontal_stdev); + char *dot = strchr(buf, '.'); + if (dot) { + for (char *ptr = buf + len - 1; ptr >= dot; --ptr) { + if (*ptr != '0' && *ptr != '.') + break; + *ptr = 0; + } + } + EM_ASM({elemSetValue($0, $1)}, "#stdev", buf); } EMSCRIPTEN_KEEPALIVE |