Could the U8glib Library cause delays or a sluggish performance of my code?

Hi, I am buiding a camera slider operated by a stepper motor. The stepper is using the AccellStepper Library. I got it to work fine with the Accell Stepper Library only, but if I combine it with my u8glib stuff for the display, the steps are very very slow. This makes me thing that somehow the u8glib stuff requires a long time to loop or uses some kind of delays. Even though I did not use any delays conciously.

Is it possible that I did some kind of mistake that makes the Draw() function take a long time to complete? Sure there could be other things causing this but I rulled them out.

The draw function is called in every loop.

void loop(void)
{
// Draw Menu Stuff
  u8g.firstPage();
  do
  {
    Draw();
  } while ( u8g.nextPage() );
}
void Draw  ()
{
  // graphic commands to redraw the complete screen should be placed here
  //u8g.setFont(u8g_font_unifont); // very big
  //u8g.setFont(u8g_font_5x8); //tiny but good, 9 lines possible
  u8g.setFont(u8g_font_6x10); //goog compromise, 8 lines possible
  switch (eValue) //Checks the eValue variable from the encoder and activates the cases in the switch.
  {
    case 1:
      u8g.drawStr( 0, 7, ">"); // Shows that line 1 is hovered over.
      
      while (EditingMode == true) //is true when button is presed once. If it is true, the value will be changed when the encoder is turned.
      {
        SettingValue = xDistance; //The encoder value is changed into original number.
        EncoderSettingValue(); //The encoder value is read.
        xDistance = SettingValue; // The line item value is changed to the encoder value. 
        //u8g.drawFrame(108,-1,20,9); //optional frame
        u8g.drawStr( 95, 7, "->");
        break;
      }
        SettingValue = 0; //This resets the setting value after it has been used before you move to the next line.
      
      //____________________________________________________________
      break; //leaves the while loop

    case 2:
      u8g.drawStr( 0, 15, ">"); // Shows that line 1 is hovered over.
      
      while (EditingMode == true) //is true when button is presed once. If it is true, the value will be changed when the encoder is turned.
      {
        SettingValue = yDistance; //The encoder value is changed into original number.
        EncoderSettingValue(); //The encoder value is read.
        yDistance = SettingValue; // The line item value is changed to the encoder value. 
        //u8g.drawFrame(108,-1,20,9); //optional frame
        u8g.drawStr( 95, 15, "->");
        break;
      }
        SettingValue = 0; //This resets the setting value after it has been used before you move to the next line.
      
      //____________________________________________________________
      break; //leaves the while loop
    case 3:
      u8g.drawStr( 0, 23, ">"); //Line3

      break;
    case 4:
      u8g.drawStr( 0, 31, ">"); //Line3

      break;
    case 5:
      u8g.drawStr( 0, 39, ">"); //Line3

      break;
    case 6:
      u8g.drawStr( 0, 47, ">"); //Line3

      break;
    case 7:
      u8g.drawStr( 0, 55, ">"); //Line3

      break;
    case 8:
      u8g.drawStr( 0, 63, ">"); //Line3

      break;

    default:
      Serial.println("error!");
      break;
  }

  u8g.drawStr( 0, 7, " 1 X-Travel"); //Line1
  u8g.setPrintPos(111, 7);
  u8g.print(xDistance);
  

  u8g.drawStr( 0, 15, " 2 Y-Travel"); //Line2
  u8g.setPrintPos(111, 15);
  u8g.print(yDistance);

  u8g.drawStr( 0, 23, " 3 Shutter"); //Line3
  u8g.setPrintPos(111, 23);
  u8g.print(ShutterSpeed);

  u8g.drawStr( 0, 31, " 4 Vib. Pause"); //Line4
  u8g.setPrintPos(111, 31);
  u8g.print(VibrationPause);

  u8g.drawStr( 0, 39, " 5 Slider Length"); //Line5
  u8g.setPrintPos(111, 39);
  u8g.print(SliderLength);

  u8g.drawStr( 0, 47, " 6 Area Width"); //Line6
  u8g.setPrintPos(111, 47);
  u8g.print(AreaWidth);

  u8g.drawStr( 0, 55, " 7 blank"); //Line7
  u8g.setPrintPos(111, 55);
  u8g.print("blank");

  u8g.drawStr( 0, 63, " 8 blank"); //Line8
  u8g.setPrintPos(111, 63);
  u8g.print("blank");

  //Encoder Position Debug Display at lowest line in the middle.
  u8g.setPrintPos(64, 63);
  u8g.print(eValue);


}

The draw function is called in every loop.

That's where your problem starts. Why is it necessary that you draw in every loop?

Post complete code if you want help from us.

You are right it is not and I changed to only update when things change. While it updates though, it still slows down the loop. Do you know why? Does the processor just need time to change every pixle?

Depending on the screen resolution it might have to draw the complete screen several times (as the Arduino memory is not big enough to hold the complete screen content) and transfer the data to the display. This needs some time.

Theoretically you can do that in several loop runs (one slice per loop run) but this make sense only in rare cases.