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