From 0f1b1165932b7f5c5fa84512915379c9c075bff9 Mon Sep 17 00:00:00 2001 From: JW Date: Sun, 28 Nov 2021 04:30:27 +0100 Subject: [PATCH] fix int/float values --- libs/core/_locales/core-jsdoc-strings.json | 2 +- libs/core/storage.ts | 2 +- sim/state/storage.ts | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index df251620..737ca3f6 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -685,7 +685,7 @@ "serial.writeValue": "Write a name:value pair as a line to the serial port.", "serial.writeValue|param|name": "name of the value stream, eg: x", "serial.writeValue|param|value": "to write", - "storage": "Provides access to persistent storage functionality.\n\r\nProvides access to persistent storage functionality.", + "storage": "Provides access to persistent storage functionality.\n\nProvides access to persistent storage functionality.", "storage.getNumber": "Reads a key value pair from the non volatile storage as a number", "storage.getNumber|param|key": "the key for accesing the value", "storage.getString": "Reads a key value pair from the non volatile storage as a string", diff --git a/libs/core/storage.ts b/libs/core/storage.ts index f8f298dd..417becf6 100644 --- a/libs/core/storage.ts +++ b/libs/core/storage.ts @@ -49,7 +49,7 @@ namespace storage { //% blockId=storage_put_number //% group="Put" export function putNumber(key: StorageSlots, value: number) : void { - let managedValue = (value * 1000) | 0; + let managedValue = Math.floor(value * 1000); putValueInt(storagesInt[key], managedValue); } diff --git a/sim/state/storage.ts b/sim/state/storage.ts index 5c67a83c..92c7fa97 100644 --- a/sim/state/storage.ts +++ b/sim/state/storage.ts @@ -1,15 +1,14 @@ namespace pxsim.storage { - function putValue(key: string, value: string) : void { + export function putValue(key: string, value: string) : void { sessionStorage.setItem('simulatorValue_'+key, value); } - function putValueInt(key: string, value: number) : void { + export function putValueInt(key: string, value: number) : void { sessionStorage.setItem('simulatorValue_'+key, value+""); } - export function getValue(key: string) : string { if(sessionStorage.getItem('simulatorValue_'+key)) { return sessionStorage.getItem('simulatorValue_'+key);