fix bottom scroller
This commit is contained in:
parent
2f22dafa2b
commit
12d0125d42
2 changed files with 23 additions and 14 deletions
|
|
@ -14,10 +14,22 @@ const getStanza = async (register) => {
|
||||||
register,
|
register,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log(register, stanzaCount, skip, randomStanza);
|
if (!randomStanza || !randomStanza[0].text) {
|
||||||
|
console.log(register, stanzaCount, skip, randomStanza, "no stanza found in db");
|
||||||
|
// try one more time
|
||||||
|
const anotherStanzaTry = await prisma.stanza.findMany({
|
||||||
|
skip: skip,
|
||||||
|
take: 1,
|
||||||
|
where: {
|
||||||
|
register,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return anotherStanzaTry[0].text;
|
||||||
|
}
|
||||||
return randomStanza[0].text;
|
return randomStanza[0].text;
|
||||||
};
|
};
|
||||||
// Play portal wave PCM data and set bands
|
// Play portal wave PCM data and set bands
|
||||||
|
// This file has been downsampled to 1000hz (1,000 samples per second)
|
||||||
const fileData = fs.readFileSync("/home/grace/portal/blackportal1000.wav");
|
const fileData = fs.readFileSync("/home/grace/portal/blackportal1000.wav");
|
||||||
const wavFileInfo = WavFileDecoder.getWavFileInfo(fileData);
|
const wavFileInfo = WavFileDecoder.getWavFileInfo(fileData);
|
||||||
const audioData = WavFileDecoder.decodeWavFile(fileData);
|
const audioData = WavFileDecoder.decodeWavFile(fileData);
|
||||||
|
|
@ -27,9 +39,9 @@ let register = "high";
|
||||||
let count = 0;
|
let count = 0;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const absSample = Math.abs(audioData.channelData[0][count]);
|
const absSample = Math.abs(audioData.channelData[0][count]);
|
||||||
if (count == 100) {
|
if (count == totalSamples - 1) {
|
||||||
//totalSamples - 1) {
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
console.log("total samples reached");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
count++;
|
count++;
|
||||||
|
|
@ -42,7 +54,6 @@ setInterval(() => {
|
||||||
register = "low";
|
register = "low";
|
||||||
}
|
}
|
||||||
sample = absSample;
|
sample = absSample;
|
||||||
console.log(count);
|
|
||||||
}, 1);
|
}, 1);
|
||||||
// Setup lcd screen
|
// Setup lcd screen
|
||||||
const lcd = new LCD(1, 0x27, 16, 2);
|
const lcd = new LCD(1, 0x27, 16, 2);
|
||||||
|
|
@ -56,7 +67,7 @@ let tagCharacterLocation = 0;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
lcd.printLineSync(1, " ");
|
lcd.printLineSync(1, " ");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
lcd.printLineSync(1, tag);
|
lcd.printLineSync(1, tag.substring(tagCharacterLocation, tag.length));
|
||||||
}, WAIT);
|
}, WAIT);
|
||||||
tagCharacterLocation++;
|
tagCharacterLocation++;
|
||||||
if (tagCharacterLocation > tag.length) {
|
if (tagCharacterLocation > tag.length) {
|
||||||
|
|
@ -76,11 +87,12 @@ while (true) {
|
||||||
stanzaText.length > 16 ? "" : Array(16 - stanzaText.length).join(" ");
|
stanzaText.length > 16 ? "" : Array(16 - stanzaText.length).join(" ");
|
||||||
totalTicks = stanzaText.length + endBuffer.length;
|
totalTicks = stanzaText.length + endBuffer.length;
|
||||||
}
|
}
|
||||||
|
if (!stanzaText) {
|
||||||
|
console.log("no stanza text in stanza scroller");
|
||||||
|
}
|
||||||
lcd.printLineSync(0, " ");
|
lcd.printLineSync(0, " ");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
lcd.printLineSync(0, `${totalTicks - characterLocation > 0
|
lcd.printLineSync(0, `${characterLocation < 16 ? Array(16 - characterLocation).join(" ") : ""}${stanzaText + endBuffer}`.substring(characterLocation, totalTicks));
|
||||||
? Array(16 - characterLocation).join(" ")
|
|
||||||
: ""}${stanzaText + endBuffer}`);
|
|
||||||
}, WAIT);
|
}, WAIT);
|
||||||
await timer(TICK);
|
await timer(TICK);
|
||||||
characterLocation++;
|
characterLocation++;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ setInterval(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
sample = absSample;
|
sample = absSample;
|
||||||
console.log(count);
|
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
||||||
// Setup lcd screen
|
// Setup lcd screen
|
||||||
|
|
@ -88,7 +87,7 @@ let tagCharacterLocation = 0;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
lcd.printLineSync(1, " ");
|
lcd.printLineSync(1, " ");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
lcd.printLineSync(1, tag);
|
lcd.printLineSync(1, tag.substring(tagCharacterLocation, tag.length));
|
||||||
}, WAIT);
|
}, WAIT);
|
||||||
|
|
||||||
tagCharacterLocation++;
|
tagCharacterLocation++;
|
||||||
|
|
@ -118,10 +117,8 @@ while (true) {
|
||||||
lcd.printLineSync(
|
lcd.printLineSync(
|
||||||
0,
|
0,
|
||||||
`${
|
`${
|
||||||
totalTicks - characterLocation > 0
|
characterLocation < 16 ? Array(16 - characterLocation).join(" ") : ""
|
||||||
? Array(16 - characterLocation).join(" ")
|
}${stanzaText + endBuffer}`.substring(characterLocation, totalTicks)
|
||||||
: ""
|
|
||||||
}${stanzaText + endBuffer}`
|
|
||||||
);
|
);
|
||||||
}, WAIT);
|
}, WAIT);
|
||||||
await timer(TICK);
|
await timer(TICK);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue