exstats: fix steps being negative/handle step count increment between stats

master
Rob Pilling 2024-04-27 11:07:24 +01:00
parent 89ea6d0045
commit b387365797
1 changed files with 1 additions and 0 deletions

View File

@ -102,6 +102,7 @@ var stats = {};
const DATA_FILE = "exstats.json"; const DATA_FILE = "exstats.json";
// Load the state from a saved file if there was one // Load the state from a saved file if there was one
state = Object.assign(state, require("Storage").readJSON(DATA_FILE,1)||{}); state = Object.assign(state, require("Storage").readJSON(DATA_FILE,1)||{});
state.startSteps = Bangle.getStepCount() - (state.lastSteps - state.startSteps);
// force step history to a uint8array // force step history to a uint8array
state.stepHistory = new Uint8Array(state.stepHistory); state.stepHistory = new Uint8Array(state.stepHistory);
// when we exit, write the current state // when we exit, write the current state