Update map.js
This commit is contained in:
parent
d1e1741539
commit
7be119deb7
1 changed files with 3 additions and 9 deletions
|
|
@ -5,27 +5,25 @@ export default {
|
||||||
name: "Map",
|
name: "Map",
|
||||||
colour: 120,
|
colour: 120,
|
||||||
description: "Scale a value from one range of numbers to another",
|
description: "Scale a value from one range of numbers to another",
|
||||||
|
|
||||||
connections: {
|
connections: {
|
||||||
mode: "value",
|
mode: "value",
|
||||||
output: "number",
|
output: "number",
|
||||||
},
|
},
|
||||||
|
|
||||||
template: `
|
template: `
|
||||||
Map
|
Map
|
||||||
Value: %VALUE
|
Value: %VALUE
|
||||||
From: %FROM_RANGE
|
From: %FROM_RANGE
|
||||||
To: %TO_RANGE
|
To: %TO_RANGE
|
||||||
`,
|
`,
|
||||||
|
|
||||||
inputs: {
|
inputs: {
|
||||||
VALUE: {
|
VALUE: {
|
||||||
|
description: "The number to scale from the original range to the target range.",
|
||||||
check: "expression",
|
check: "expression",
|
||||||
bytecodeProperty: "value",
|
bytecodeProperty: "value",
|
||||||
shadow: 'io_math_number'
|
shadow: 'io_math_number'
|
||||||
},
|
},
|
||||||
|
|
||||||
FROM_RANGE: {
|
FROM_RANGE: {
|
||||||
|
description: "The original range that the input value comes from (e.g., sensor readings from 0 to 1023).",
|
||||||
check: 'range',
|
check: 'range',
|
||||||
bytecodeProperty: "from",
|
bytecodeProperty: "from",
|
||||||
shadow: {
|
shadow: {
|
||||||
|
|
@ -42,8 +40,8 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
TO_RANGE: {
|
TO_RANGE: {
|
||||||
|
description: "The target range to scale the value to (e.g., convert to 0.0-1.0 for percentages).",
|
||||||
check: 'range',
|
check: 'range',
|
||||||
bytecodeProperty: "to",
|
bytecodeProperty: "to",
|
||||||
shadow: {
|
shadow: {
|
||||||
|
|
@ -61,7 +59,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
generators: {
|
generators: {
|
||||||
json: (block, generator) => {
|
json: (block, generator) => {
|
||||||
const
|
const
|
||||||
|
|
@ -69,11 +66,9 @@ export default {
|
||||||
from = JSON.parse(generator.valueToCode(block, 'FROM_RANGE', 0)),
|
from = JSON.parse(generator.valueToCode(block, 'FROM_RANGE', 0)),
|
||||||
to = JSON.parse(generator.valueToCode(block, 'TO_RANGE', 0)),
|
to = JSON.parse(generator.valueToCode(block, 'TO_RANGE', 0)),
|
||||||
payload = { mapValue: { value, from, to }}
|
payload = { mapValue: { value, from, to }}
|
||||||
|
|
||||||
return [ JSON.stringify(payload), 0 ]
|
return [ JSON.stringify(payload), 0 ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
regenerators: {
|
regenerators: {
|
||||||
json: (blockObject, helpers) => {
|
json: (blockObject, helpers) => {
|
||||||
const
|
const
|
||||||
|
|
@ -111,7 +106,6 @@ export default {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
return { type: 'math_map', inputs }
|
return { type: 'math_map', inputs }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue