Skip to content

Commit

Permalink
round inline
Browse files Browse the repository at this point in the history
  • Loading branch information
fisher-alice committed Oct 19, 2022
1 parent 2241d8e commit 385be4e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Sensor extends Withinable {
},
scaled: {
get() {
let mapped, constrain, rounded;
let mapped, constrain;

if (state.scale && raw !== null) {
if (options.type === "digital") {
Expand All @@ -206,8 +206,7 @@ class Sensor extends Withinable {

mapped = Fn.fmap(raw, this.range[0], this.range[1], state.scale[0], state.scale[1]);
// Code.org: round scaled sensor values
rounded = Math.round(mapped);
constrain = Fn.constrain(rounded, state.scale[0], state.scale[1]);
constrain = Fn.constrain(Math.round(mapped), state.scale[0], state.scale[1]);

return constrain;
}
Expand Down

0 comments on commit 385be4e

Please sign in to comment.