minor fix
This commit is contained in:
parent
6ede57f7ff
commit
12d11aebd3
1 changed files with 14 additions and 14 deletions
|
@ -44,10 +44,10 @@ async function findBlinkstick(index, ignoreFilter) {
|
||||||
async function simple(config) {
|
async function simple(config) {
|
||||||
await stopLEDsAccordingly(config);
|
await stopLEDsAccordingly(config);
|
||||||
config.timestamp = new Date().getTime();
|
config.timestamp = new Date().getTime();
|
||||||
let indices = getIndices(config);
|
let indexes = getIndices(config);
|
||||||
for (let index = 0; index < indices.length; index++) {
|
for (let index = 0; index < indexes.length; index++) {
|
||||||
const tmpConfig = JSON.parse(JSON.stringify(config));
|
const tmpConfig = JSON.parse(JSON.stringify(config));
|
||||||
await singleAnimation(tmpConfig, indices[index]);
|
await singleAnimation(tmpConfig, indexes[index]);
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
await setColorIfRandom(config);
|
await setColorIfRandom(config);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ async function simple(config) {
|
||||||
return {
|
return {
|
||||||
status: 'ok',
|
status: 'ok',
|
||||||
color: config.color,
|
color: config.color,
|
||||||
indices: indices,
|
indexes: indexes,
|
||||||
time: (new Date().getTime() - config.timestamp) + 'ms'
|
time: (new Date().getTime() - config.timestamp) + 'ms'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -66,14 +66,14 @@ async function complex(config) {
|
||||||
await stopLEDsAccordingly(config);
|
await stopLEDsAccordingly(config);
|
||||||
config.timestamp = new Date().getTime();
|
config.timestamp = new Date().getTime();
|
||||||
}
|
}
|
||||||
let indices = getIndices(config);
|
let indexes = getIndices(config);
|
||||||
for (let index = 0; index < indices.length; index++) {
|
for (let index = 0; index < indexes.length; index++) {
|
||||||
if (shouldLEDFinish(config)) {
|
if (shouldLEDFinish(config)) {
|
||||||
clearLedState(config.options.index);
|
clearLedState(config.options.index);
|
||||||
return { status: 'ok', time: (new Date().getTime() - config.timestamp) + 'ms' };
|
return { status: 'ok', time: (new Date().getTime() - config.timestamp) + 'ms' };
|
||||||
}
|
}
|
||||||
const tmpConfig = JSON.parse(JSON.stringify(config));
|
const tmpConfig = JSON.parse(JSON.stringify(config));
|
||||||
await singleAnimation(tmpConfig, indices[index]);
|
await singleAnimation(tmpConfig, indexes[index]);
|
||||||
config.repetitions.done++;
|
config.repetitions.done++;
|
||||||
}
|
}
|
||||||
return await complex(config);
|
return await complex(config);
|
||||||
|
@ -82,14 +82,14 @@ async function complex(config) {
|
||||||
// power the blinkstick (or just a specific led) off
|
// power the blinkstick (or just a specific led) off
|
||||||
async function powerOff(config) {
|
async function powerOff(config) {
|
||||||
config.timestamp = new Date().getTime();
|
config.timestamp = new Date().getTime();
|
||||||
let indices = getIndices(config);
|
let indexes = getIndices(config);
|
||||||
if (config.options.index === constants.ALL) {
|
if (config.options.index === constants.ALL) {
|
||||||
LEDAnimations.set(constants.ALL, { stop: new Date().getTime() });
|
LEDAnimations.set(constants.ALL, { stop: new Date().getTime() });
|
||||||
}
|
}
|
||||||
for (let index = 0; index < indices.length; index++) {
|
for (let index = 0; index < indexes.length; index++) {
|
||||||
await stopLEDAnimation(indices[index]);
|
await stopLEDAnimation(indexes[index]);
|
||||||
await singleAnimation(JSON.parse(JSON.stringify(config)), indices[index]);
|
await singleAnimation(JSON.parse(JSON.stringify(config)), indexes[index]);
|
||||||
logger.info('led \'' + indices[index] + '\' powered off');
|
logger.info('led \'' + indexes[index] + '\' powered off');
|
||||||
}
|
}
|
||||||
if (config.options.index === constants.ALL) {
|
if (config.options.index === constants.ALL) {
|
||||||
const blinkstick = await findBlinkstick();
|
const blinkstick = await findBlinkstick();
|
||||||
|
@ -97,7 +97,7 @@ async function powerOff(config) {
|
||||||
LEDAnimations.clear();
|
LEDAnimations.clear();
|
||||||
logger.info('blinkstick powered off');
|
logger.info('blinkstick powered off');
|
||||||
}
|
}
|
||||||
return { status: 'ok', indices: indices, time: (new Date().getTime() - config.timestamp) + 'ms' };
|
return { status: 'ok', indexes: indexes, time: (new Date().getTime() - config.timestamp) + 'ms' };
|
||||||
}
|
}
|
||||||
|
|
||||||
// animations
|
// animations
|
||||||
|
@ -169,7 +169,7 @@ async function setColorIfRandom(config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stopLEDsAccordingly(config) {
|
async function stopLEDsAccordingly(config) {
|
||||||
if (LEDAnimations.size === 0) {
|
if (LEDAnimations.size === 0 && config.mode !== constants.MODE_BLINK && config.mode !== constants.MODE_PULSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (config.options.index === constants.ALL) {
|
if (config.options.index === constants.ALL) {
|
||||||
|
|
Loading…
Reference in a new issue