Thank you all for your suggestions.
J-M-L:
And the code is?Usually best way to speed up things is to not display something if it has not changed. Are you testing for this or always displaying everything in the loop?
Could you please show me an example of how to implement this?
PieterP:
Every time you refresh the display, you have to push over 1KiB of data over the I²C connection. This takes a lot of time. You can reduce the time by increasing the I²C clock speed:
Wire - Arduino ReferencePieter
Thank you, I will be reading up on this later tonight.
Here is a snippet of the code displaying. the function is in loop and i can see how its constantly updating.
void DisplayBattery() {
//code for displaying battery 1 and 2 "battery bars"
myOLED.drawRect(4, 53, 53, 57); //batt 1 rect X,Y,x,y
myOLED.drawRect(54, 54, 55, 56); //batt1 nub
myOLED.drawRect(4, 59, 53, 63); //batt 2 rect X,Y,x,y
myOLED.drawRect(54, 60, 55, 62); //batt 2 nub
myOLED.update();
//batt1
if (Batt1Percent >= 0 && Batt1Percent <= 10) {
myOLED.clrLine(5,54,53,54);
myOLED.clrLine(5,55,53,55);
myOLED.clrLine(5,56,53,56); //print 0 battery block
myOLED.update();
}
else if (Batt1Percent > 10 && Batt1Percent <= 40) {
myOLED.drawLine(5,54,16,54);
myOLED.drawLine(5,55,16,55); //batt1 bar
myOLED.drawLine(5,56,16,56);
myOLED.clrLine(17,54,53,54);
myOLED.clrLine(17,55,53,55);
myOLED.clrLine(17,56,53,56); //print 1 battery blocks
myOLED.update();
}
else if (Batt1Percent > 40 && Batt1Percent <= 60) {
myOLED.drawLine(5,54,28,54);
myOLED.drawLine(5,55,28,55); //batt1 bar
myOLED.drawLine(5,56,28,56);
myOLED.clrLine(29,54,53,54);
myOLED.clrLine(29,55,53,55);
myOLED.clrLine(29,56,53,56); //print 2 battery blocks
myOLED.update();
}
else if (Batt1Percent > 60 && Batt1Percent <= 80) {
myOLED.drawLine(5,54,40,54);
myOLED.drawLine(5,55,40,55); //batt1 bar
myOLED.drawLine(5,56,40,56);
myOLED.clrLine(41,54,53,54);
myOLED.clrLine(41,55,53,55);
myOLED.clrLine(41,56,53,56);
myOLED.update() ; //print 3 battery blocks
}
else if (Batt1Percent > 80 && Batt1Percent <= 100) {
myOLED.drawLine(5,54,53,54);
myOLED.drawLine(5,55,53,55); //batt1 bar
myOLED.drawLine(5,56,53,56); //print 4 battery blocks
myOLED.update();
}
//batt 2
if (Batt2Percent >= 0 && Batt2Percent <= 10) {
//print 0 battery block
myOLED.clrLine(5,60,53,60);
myOLED.clrLine(5,61,53,61);
myOLED.clrLine(5,62,53,62);
myOLED.update();
}
else if (Batt2Percent > 10 && Batt2Percent <= 40) {
myOLED.drawLine(5,60,16,60);
myOLED.drawLine(5,61,16,61); //bat2 bar
myOLED.drawLine(5,62,16,62);
myOLED.clrLine(17,60,53,60);
myOLED.clrLine(17,61,53,61);
myOLED.clrLine(17,62,53,62);
myOLED.update();
//print 1 battery blocks
}
else if (Batt2Percent > 40 && Batt2Percent <= 60) {
myOLED.drawLine(5,60,28,60);
myOLED.drawLine(5,61,28,61); //bat2 bar
myOLED.drawLine(5,62,28,62);
myOLED.clrLine(29,60,53,60);
myOLED.clrLine(29,61,53,61);
myOLED.clrLine(29,62,53,62);
myOLED.update(); //print 2 battery blocks
}
Here is a very terrible schematic of the design. =)
