neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
933 stars 189 forks source link

Titlebar #337

Open tilchl opened 3 years ago

tilchl commented 3 years ago

I've been trying to implement a header/titlebar above the panel for the menu

const panel panels[] MEMMODE = {{0, 1, tft_WIDTH / fontW, tft_HEIGHT / fontH}};

this gets me an epmty space aobve the menu.

void drawHeader() {
  tft.fillScreen(TFT_WHITE);
  tft.setTextSize(2);
  tft.setTextColor(TFT_BLACK,TFT_WHITE);
  tft.setTextDatum(MC_DATUM);
  tft.drawString(String(hostname),0,0);
  if (wifi_connected){
    // draw a green wifi logo
  } else {
    // draw a grey wifi logo
  }
}

This code does what i want it to do as long as i call it in the setup. When i try to call it after the idleEnd event the titlebar gets drawn but i think due to nav.poll() the screen gets filled with the bgColor right after.

result idle(menuOut& o,idleEvent e) {
  if (e==idling) {
      // Idle stuff
  }
  if(e==idleEnd){
    drawHeader();
  }
  return proceed;
}

if i call nav.refresh() manually only the panel gets refreshed Is there a way to "attach" a function to nav.poll() to laverage the menuEvents?

Thanks in advance also thank you for arduinoMenu in general

ps: using tft_eSPI