Hi folks, so I have some working code using adafruit drivers (U8G2 too big it seems)
But when trying to add new function the display just fails to initialise and doesn't work!
What's weird is that it also simulates the same on Wokwi, but I might add a line that doesn't even directly affect the display, like println for serial out, and it will still kill the display!
Arduino IDE reports enough space, but I can't hep feeling there is a conflict, and I am not sure how I can resolve this!
Sounds like you are running short of ram. A quick look at the sketch shows you do not use the F() macro for text literals, those can eat up a lot of ram.
I really find that hard to believe, unless you are talking about the dynamic memory. The adafruit library uses the same 1024 bytes of memory for a display buffer, but allocates it at run-time so the compiler does not see it.
< edit > U8g2 also has an option to use a page buffer instead of a full buffer, that reduces the display buffer to about 1/8 the size on an SSD1306, but does require a slight modification to how you print to the display.
Big in what way, exactly? Flash (program) memory or RAM (dynamic) memory?
One difference between those two libraries is that U8G2 reserves the RAM memory it needs at compile time, so the IDE is able to tell you if it will not fit. The Adafruit library reserves the memory it needs at run time, so the IDE thinks it will fit and uploads it but once the code is running on the Arduino and tries to initialise the display, it finds out there is not enough memory after all and fails.
Ok folks so this must be a memory issue then, that does make sense! So I could go back to the U8G2 code and see more clearly how far over I am, and try putting the text into program memory if the dynamic is running short?
Although when I remove the headers it makes no difference. I will compile again with U8 and then report back if I cannot sort this out...
Out of interest are there any Atmel processors that would require minimal code change but offer greater scope?
Probably not. Your code is doing a lot of direct manipulation of timers, and that code will be unique to ATMEGA328. Everything else looks pretty standard Arduino code and should run on any Arduino or Arduino compatible board. Many of these boards have far more RAM and Flash memory.
It would be really helpful to us, in order to help you, if you could answer any questions we have asked before asking any further questions if your own. Just look for the "?" symbol. If you don't know the answer, please say so, rather than ignoring a question.