Ralph_S_Bacon:
Do what Robin2 suggests but also note that you have a 'clear' command in your main loop.
In the datasheets I have for I2C LCD displays it states clearly that clearing the display takes many tens of milliseconds whereas writing a single dot takes microseconds.
Try taking that out of your main loop (or read the datasheet and confirm to your own satisfaction about the speed of clearing the display).
Hello
I did take the clear off of it, noted it earlier, the example program is the same as the one i posted earlier. Just switched the:
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE, BLACK);
display.setCursor(random(1, 50),random(1, 50));
display.print("jou jou jou");
display.display();
Part to simply draw one random pixel:
display.drawPixel(random(1, 128),random(1,65),WHITE);
display.display();
Every time i use the display.display(); the program freezes enough that the mouse sensor can overflow. I can display.dawpixels as much i like. But refreshing the display is what makes the program stall.
I also tested the step motor, and can do at least 5 step per loop. This yielded enough fast movement in the motor, and no overflow. Single step was way to slow, and 10 gave overflow.
I can then just start reading the mouse sensor multiple times per loop, so i will read it again after the step motor movement, before OLED update. If i can get the OLED to work fast enough.
So i think what i´m doing is doable, if i get the OLED working faster.
I timed the one pixel loop, takes 40ms.
First I was reading 5 registers from the mouse sensor, this way it took 43ms. With just the one registry i need read, takes 40ms. And if i do not draw any pixels on the OLED, 6-7ms. The mouse sensor is really fast to read.
I also tested with delay, that i can have about 25ms delay between mouse sensor reads. So i´m about 7ms too slow currently when i draw just one pixel and there is no step motors or anything else in the loop.
Maybe the Adafruit library is just really slow.
Seems my timings are about the same as posted here, ill start looking into this. Seems it is doable.
http://forum.arduino.cc/index.php?topic=286837.0
Thanks for the idea of timing, now i know about what i need and how much time i got to do it.
If anyone knows some ready made library/solution to fast I2C OLED update, please let me know. Im not a marvel in coding
My background is in QBasic 4.5 in the 90´s 