Motoo: i din't change the pixel() function, anyway try to put the enable/disable just prior and after calling touch reading, that's the place in your code where it hurts less. You are polling the touch ic every loop even if there is no touch activity, so the less gpio activity on CS, the more the speed.
I decided to go with CS fixed enabled to give display priority and speed, cause every digitalout activity takes time, and an unified library for all displays with 4-5 class inheritages builds up and array of array of array of array of pointers to functions :)
Peter: thanks for taking a look, and sorry if your original code now looks like messy:)
about #ifdef USE_CS, it's in protocol because was there when i wrote something per-display, but i don't #define it anywhere. What i tought about use/not use and when use cs, is try the best to avoid code to decide at runtime, so put it permanently low in Protocol and publish a method to disable it. If we tell Graphic class to call BusEnable() prior and after it's job, or directly tell Graphics to do _CS=0/1, would be ok for big jobs like printing a big font or a big filled rect, but if you are plotting 2pixels lines like a graph as Matoo does, it will be a performance killer. From another point of view, who needs the spi bus freed? Not the display itself (unless a bit in the spi protocol gets lost cause of bad wiring, the display slave spi will go "out of sync"), but rather something that shares the spi bus, so, that's why i tought the best place to handle CS was manually and outside and let the other slave decide if he wants the bus.
About driver control like set_orientation, TFT has the standard ones and some ILI specific, like the ones used to get device id. Anyway i left them virtual void, so you can override in init. I already do some override in UC1608, because it's too much far from standard. Similar can be for ILI932x, which have different cmds for set page/column address...., or a controller that does not have orientation can have a dummy set_orientation() overridden in its Init.
In LCD/TFT the lowlevel wr_cmd8 wr_data8 etc are "replicated" (protected wr_cmd8 is redirected to proto->wr_cmd8) for this reason, to be used by derived class (Init) without knowing the final protocol. I know it's not the best way to redirect a function, but probably the compiler does a good optimization.
About spi 9bit, i think it's doable like another Protocol class SPI9, with some tricks like send 8bit cmd, rightshift data and insert DC bit on top, then the last 8bit chunk will just send data bit0 as MSB then 7 zeroes as padding, the driver will intend 7 zeroes as part of the next byte, so will stay there waiting the 8th bit to accept the byte, but we drive cs hi-low to interrupt. I'm doing somethin similar to read with dummy bit in SPI8::rd_reg_data32(unsigned char reg)
Hi all, don't know if i'm going on the right way with this lib, i saw performance loss is not so much, so...take a look. I'm going to add pixelread, readID and PAR_16, i've already done it for per-display, just need to think about the most standardized way to do it.
Here is a demo to have a try I think IST3020 init can be used with the more common ST7565 with veryfew adjustement, sadly i've not yet an ST7565.
Import programUniGraphic_demo
UniGraphic demo for TFT and LCD, par or spi
Last commit 25 Jan 2022 by Geremia G