yeah, the loops are holding it back a tad i guess, i changed bargraph() into thisuint8_t Bargraph(uint8_t state) {
if (state==108) {
display.drawLine (5, 5, 5, 59, WHITE);
display.drawLine (15, 5, 15, 59, WHITE);
display.drawLine (5, 5, 15, 5, WHITE);
display.drawLine (5, 59, 15, 59, WHITE);
return 0;
}
if (state<50) {
display.drawLine(7, 58-state, 13, 58-state, WHITE);
state++;
return state;
}
else {
display.drawLine(7, 8+(state-50), 13, 8+(state-50), BLACK);
state++;
if (state>100) state=0;
return state;
}
}
since actually every line drawn is a 'state' . By now an 'if-else' is more efficient than a 'switch-case'
and i changed loop() to thisvoid loop() {
bargraphstate=Bargraph(bargraphstate);
display.display();
if (lastmoment + SPEED <millis()) {
twindotstate=Twin_Dots(twindotstate);
flashsquarestate=Flashing_Squares(flashsquarestate);
Random_Numbers();
//display.display(); // since this is now called every loop there is no need to specifically call it here anymore
lastmoment=millis();
}
}
Since the bargraph is running at maximum speed there is no conditional executing depending on the elapsed time. i suspect that drawing all the other things does slow it down momentarily though. Of course doing it like this for you defeats the purpose of training a little, but i overlooked the extra problems caused by bargraph having all these extra states, i should have gotten you to do the dots after i did the squares, but how about you find a way of slowing the bargraph down just a little bit..