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) {
|
||||
await stopLEDsAccordingly(config);
|
||||
config.timestamp = new Date().getTime();
|
||||
let indices = getIndices(config);
|
||||
for (let index = 0; index < indices.length; index++) {
|
||||
let indexes = getIndices(config);
|
||||
for (let index = 0; index < indexes.length; index++) {
|
||||
const tmpConfig = JSON.parse(JSON.stringify(config));
|
||||
await singleAnimation(tmpConfig, indices[index]);
|
||||
await singleAnimation(tmpConfig, indexes[index]);
|
||||
if (index === 0) {
|
||||
await setColorIfRandom(config);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ async function simple(config) {
|
|||
return {
|
||||
status: 'ok',
|
||||
color: config.color,
|
||||
indices: indices,
|
||||
indexes: indexes,
|
||||
time: (new Date().getTime() - config.timestamp) + 'ms'
|
||||
};
|
||||
}
|
||||
|
@ -66,14 +66,14 @@ async function complex(config) {
|
|||
await stopLEDsAccordingly(config);
|
||||
config.timestamp = new Date().getTime();
|
||||
}
|
||||
let indices = getIndices(config);
|
||||
for (let index = 0; index < indices.length; index++) {
|
||||
let indexes = getIndices(config);
|
||||
for (let index = 0; index < indexes.length; index++) {
|
||||
if (shouldLEDFinish(config)) {
|
||||
clearLedState(config.options.index);
|
||||
return { status: 'ok', time: (new Date().getTime() - config.timestamp) + 'ms' };
|
||||
}
|
||||
const tmpConfig = JSON.parse(JSON.stringify(config));
|
||||
await singleAnimation(tmpConfig, indices[index]);
|
||||
await singleAnimation(tmpConfig, indexes[index]);
|
||||
config.repetitions.done++;
|
||||
}
|
||||
return await complex(config);
|
||||
|
@ -82,14 +82,14 @@ async function complex(config) {
|
|||
// power the blinkstick (or just a specific led) off
|
||||
async function powerOff(config) {
|
||||
config.timestamp = new Date().getTime();
|
||||
let indices = getIndices(config);
|
||||
let indexes = getIndices(config);
|
||||
if (config.options.index === constants.ALL) {
|
||||
LEDAnimations.set(constants.ALL, { stop: new Date().getTime() });
|
||||
}
|
||||
for (let index = 0; index < indices.length; index++) {
|
||||
await stopLEDAnimation(indices[index]);
|
||||
await singleAnimation(JSON.parse(JSON.stringify(config)), indices[index]);
|
||||
logger.info('led \'' + indices[index] + '\' powered off');
|
||||
for (let index = 0; index < indexes.length; index++) {
|
||||
await stopLEDAnimation(indexes[index]);
|
||||
await singleAnimation(JSON.parse(JSON.stringify(config)), indexes[index]);
|
||||
logger.info('led \'' + indexes[index] + '\' powered off');
|
||||
}
|
||||
if (config.options.index === constants.ALL) {
|
||||
const blinkstick = await findBlinkstick();
|
||||
|
@ -97,7 +97,7 @@ async function powerOff(config) {
|
|||
LEDAnimations.clear();
|
||||
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
|
||||
|
@ -169,7 +169,7 @@ async function setColorIfRandom(config) {
|
|||
}
|
||||
|
||||
async function stopLEDsAccordingly(config) {
|
||||
if (LEDAnimations.size === 0) {
|
||||
if (LEDAnimations.size === 0 && config.mode !== constants.MODE_BLINK && config.mode !== constants.MODE_PULSE) {
|
||||
return;
|
||||
}
|
||||
if (config.options.index === constants.ALL) {
|
||||
|
|
Loading…
Reference in a new issue