Hello
On my smartmatrix panel I’m wanting to display some bus information, like this:
73: Rotherham Intc. - Sheffield Intc. [FSYO] :
X78: Doncaster Frenchgate Intc. - Sheffield Intc. [FSYO]:
779: Ranmoor Park Road - Robin Hood Road [FSYO] :
82: Hall Park Head - Hartington Avenue [FSYO] :
20: Sycamore Road - Gaunt Close [FSYO] :
As this text is wider than the panel, I am wanting to scroll the text across. I have setup five scroll layers (but only showing one for brevity) like so:
SMARTMATRIX_ALLOCATE_GFX_MONO_LAYER(scrollLayer00, kMatrixWidth, kMatrixHeight, kMatrixWidth * 3, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
matrix.addLayer(&scrollLayer00);
const uint8_t scrollSpeed = 18;
scrollLayer00.setFont(font3x5);
scrollLayer00.setOffsetFromTop(0);
scrollLayer00.setMode(wrapForward);
scrollLayer00.setColor(rgb24(0xFFE0));
scrollLayer00.setSpeed(scrollSpeed);
And I have scrollLayer01, scrollLayer02, scrollLayer03, scrollLayer04 in addition.
Instead of setting up these layers as above I would like to have them in an array. So I can loop through them. This is so I can avoid code like this:
JsonArray bus = dataChunks[dataIdx].as<JsonArray>();
uint8_t line = 0;
makeOutputLine(bus[0]);
scrollLayer00.setOffsetFromTop((sl)-2);
scrollLayer00.start(pout, -1);
if (bus.size() == line) {
weatherLayer.swapBuffers();
dataIdx++;
return;
}
line++;
makeOutputLine(bus[1]);
scrollLayer01.setOffsetFromTop((sl+=8)-2);
scrollLayer01.start(pout, -1);
if (bus.size() == line) {
weatherLayer.swapBuffers();
dataIdx++;
return;
}
...etc...
what would like to do is something like:
int i =0;
for (JsonObject b : bus) {
makeOutputLine(b); // eg: 779: Ranmoor Park Road - Robin Hood Road [FSYO] :
scrollLayer[i].setOffsetFromTop((sl+=8)-2);
scrollLayer[i].start(pout, -1);
i++;
}
Can anyone help?
Thanks
Karl.