Hi again,
I tried it and ran into several issues with display/touch. The first main one is that it is not setting the SPI to the right set of registers when it you are touching things…
Main issue is in: SelectedBtn
I hacked it up to look like:
[code]void SelectedBtn(int x1, int y1, int x2, int y2)
{
RestoreSPIRegs(SPIR_TS);
do{
! ts.bufferEmpty();
RestoreSPIRegs(SPIR_TFT);
tft.drawRoundRect (x1, y1, x2, y2, 7, ILI9341_RED);
tft.drawRoundRect (x1+1, y1+1, x2-2, y2-2, 7, ILI9341_RED);
tft.drawRoundRect (x1+2, y1+2, x2-4, y2-4, 7, ILI9341_RED);
RestoreSPIRegs(SPIR_TS);
}
while ( ts.touched());
RestoreSPIRegs(SPIR_TFT);
tft.drawRoundRect (x1, y1, x2, y2, 7, ILI9341_WHITE);
tft.drawRoundRect (x1+1, y1+1, x2-2, y2-2, 7, ILI9341_WHITE);
tft.drawRoundRect (x1+2, y1+2, x2-4, y2-4, 7, ILI9341_WHITE);
}[/code]
Note: I left the line in: ! ts.bufferEmpty();
But I think it is leftover and should probably be removed…
The slider may have some issues with mapping where the knob is and some interference between it and selecting the Next/Prev screen buttons… I have not debugged yet. Note: You obviously see flashing going on when moving the knob. Could probably minimize this, by only redrawing what you have to, which is a little more complex. That is you only need to redraw where the knob was before and can potentially optimize more and only redraw the part of where the knob was that it is not currently… , but this takes a bit more logic…
Also personally if it were me doing this, I would probably setup up a set of graphic objects like button, knob, … which are subclasses of some main class like graphic object. The graphic object would have some standard properties, like maybe a rectangle, maybe text, maybe some colors… It would also have some virtual functions, like draw, pressed… That the classes like button and slider would implement… Pages would simply be a collection of objects. This would have a little more overhead, but makes it easier to reuse things… Just a thought.
Kurt