Merge branch 'feat_storage' into V4

This commit is contained in:
JW 2021-11-28 04:30:32 +01:00
commit aed6e16c9a
3 changed files with 4 additions and 5 deletions

View File

@ -685,7 +685,7 @@
"serial.writeValue": "Write a name:value pair as a line to the serial port.", "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|name": "name of the value stream, eg: x",
"serial.writeValue|param|value": "to write", "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": "Reads a key value pair from the non volatile storage as a number",
"storage.getNumber|param|key": "the key for accesing the value", "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", "storage.getString": "Reads a key value pair from the non volatile storage as a string",

View File

@ -49,7 +49,7 @@ namespace storage {
//% blockId=storage_put_number //% blockId=storage_put_number
//% group="Put" //% group="Put"
export function putNumber(key: StorageSlots, value: number) : void { export function putNumber(key: StorageSlots, value: number) : void {
let managedValue = (value * 1000) | 0; let managedValue = Math.floor(value * 1000);
putValueInt(storagesInt[key], managedValue); putValueInt(storagesInt[key], managedValue);
} }

View File

@ -1,15 +1,14 @@
namespace pxsim.storage { namespace pxsim.storage {
function putValue(key: string, value: string) : void { export function putValue(key: string, value: string) : void {
sessionStorage.setItem('simulatorValue_'+key, value); 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+""); sessionStorage.setItem('simulatorValue_'+key, value+"");
} }
export function getValue(key: string) : string { export function getValue(key: string) : string {
if(sessionStorage.getItem('simulatorValue_'+key)) { if(sessionStorage.getItem('simulatorValue_'+key)) {
return sessionStorage.getItem('simulatorValue_'+key); return sessionStorage.getItem('simulatorValue_'+key);