U8Glib and analog inputs.

Hi

The main problem is, that the picture loop is always executed. It is better to redraw the display only in those cases where the content of the screen has changed. My suggestion is to introduce a flag "is_update_required" and execute the picture loop depending on this flag:

void loop(void) {
    getInputs(); 
    menuSelection();    // this procedure should set "is_update_required"
 
    if ( is_update_required )
    {
        // picture loop
        u8g.firstPage(); 
        do {
          draw();
        }
        // Serial.println("drawing");
        while( u8g.nextPage() );
        is_update_required = 0; // reset the update flag to avoid another redraw
    }
}

Once your program has detected a valid menu change, then the "is_update_required" must be set.
See also this tutorial for U8glib: Google Code Archive - Long-term storage for Google Code Project Hosting.

One more note: The "Menu" addon M2tklib for U8glib also includes this mechanism.

Oliver