From 9d5ca35e839cc66574477fca26960e1571b90c1b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 11 Jan 2018 08:47:09 -0800 Subject: [PATCH] fix battery encoding --- libs/core/input.ts | 2 +- sim/state/analog.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/core/input.ts b/libs/core/input.ts index eb9f03be..9b407a66 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -93,7 +93,7 @@ namespace sensors.internal { init(); return { temp: analogMM.getNumber(NumberFormat.Int16LE, AnalogOff.BatteryTemp), - current: analogMM.getNumber(NumberFormat.Int16LE, AnalogOff.BatteryCurrent) + current: Math.round(analogMM.getNumber(NumberFormat.Int16LE, AnalogOff.BatteryCurrent) / 10); } } diff --git a/sim/state/analog.ts b/sim/state/analog.ts index 9f9ea664..195c04cd 100644 --- a/sim/state/analog.ts +++ b/sim/state/analog.ts @@ -30,8 +30,8 @@ namespace pxsim { data, beforeMemRead: () => { //console.log("analog before read"); - data[AnalogOff.BatteryTemp] = 21; // TODO simulate this - data[AnalogOff.BatteryCurrent] = 100; // TODO simulate this + util.map16Bit(data, AnalogOff.BatteryTemp, 21); + util.map16Bit(data, AnalogOff.BatteryCurrent, 900); const inputNodes = ev3board().getInputNodes(); for (let port = 0; port < DAL.NUM_INPUTS; port++) { const node = inputNodes[port];