diff --git a/lib/intval/index.js b/lib/intval/index.js index 287fd3c..cc8a6b4 100644 --- a/lib/intval/index.js +++ b/lib/intval/index.js @@ -51,6 +51,10 @@ intval._release = { intval._microDelay = 10 // delay after stop signal before stopping motors intval._pin = {} +/** + * + */ + intval.init = function () { if (!fs.existsSync('./state')) fs.mkdirSync('./state') storage.init({ @@ -66,7 +70,7 @@ intval.init = function () { forgiveParseErrors: false // [NEW] }).then(intval._restoreState).catch((err) => { log.warn('init', err) - intval._setState() + intval.reset() intval._declarePins() }) @@ -75,7 +79,6 @@ intval.init = function () { } intval._restoreState = function (res) { - //console.dir(res) storage.getItem('_state', 'test').then(intval._setState).catch((err) => { intval._setState(undefined) log.error('_restoreState', err) @@ -308,7 +311,7 @@ intval._releaseClosedState = function (now) { } intval.reset = function () { - intval._setState(undefined) + intval._setState() intval._storeState() }