Merge branch 'feat_storage' into V4
This commit is contained in:
commit
aed6e16c9a
@ -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",
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user