  */
 
 #include <du-ino_function.h>
+#include <du-ino_widgets.h>
 #include <du-ino_scales.h>
 #include <avr/pgmspace.h>
 

    }
  }

 private:
  float note_cv(int octave, uint8_t key, uint8_t note)
  {
    return (float)octave + (float)key / 12.0 + (float)note / 12.0;
  }

  void get_note_indicator_coordinates(uint8_t note, uint16_t * x, uint16_t * y)
  {
    switch(note)
    {
      case 0: // C
        *x = 6;
        *y = 54;
        break;
      case 1: // Db
        *x = 15;
        *y = 29;
        break;
      case 2: // D
        *x = 24;
        *y = 54;
        break;
      case 3: // Eb
        *x = 33;
        *y = 29;
        break;
      case 4: // E
        *x = 42;
        *y = 54;
        break;
      case 5: // F
        *x = 60;
        *y = 54;
        break;
      case 6: // Gb
        *x = 69;
        *y = 29;
        break;
      case 7: // G
        *x = 78;
        *y = 54;
        break;
      case 8: // Ab
        *x = 87;
        *y = 29;
        break;
      case 9: // A
        *x = 96;
        *y = 54;
        break;
      case 10: // Bb
        *x = 105;
        *y = 29;
        break;
      case 11: // B
        *x = 114;
        *y = 54;
        break;
    }
  }

  void invert_current_selection()
  {
    if(main_selected)
    {
      int16_t x, y;
      get_note_indicator_coordinates(note_selected, &x, &y);
      Display.draw_pixel(x, y, DUINO_SH1106::Inverse);
      Display.draw_pixel(x + 2, y, DUINO_SH1106::Inverse);
      Display.draw_pixel(x + 4, y, DUINO_SH1106::Inverse);
      Display.draw_pixel(x + 6, y, DUINO_SH1106::Inverse);
      Display.draw_pixel(x, y + 2, DUINO_SH1106::Inverse);
      Display.draw_pixel(x, y + 4, DUINO_SH1106::Inverse);
      Display.draw_pixel(x, y + 6, DUINO_SH1106::Inverse);
      Display.draw_pixel(x + 2, y + 6, DUINO_SH1106::Inverse);
      Display.draw_pixel(x + 4, y + 6, DUINO_SH1106::Inverse);
      Display.draw_pixel(x + 6, y + 6, DUINO_SH1106::Inverse);
      Display.draw_pixel(x + 6, y + 2, DUINO_SH1106::Inverse);
      Display.draw_pixel(x + 6, y + 4, DUINO_SH1106::Inverse);
      if(y == 29)
      {
        Display.display(x, x + 6, 3, 4);
      }
      else
      {
        Display.display(x, x + 6, 6, 7);
      }
    }
    else
    {
      switch(top_selected)
      {
        case 0: // trigger mode
          Display.fill_rect(76, 0, 9, 9, DUINO_SH1106::Inverse);
          Display.display(76, 84, 0, 1);
          break;
        case 1: // key
          Display.fill_rect(90, 0, 13, 9, DUINO_SH1106::Inverse);
          Display.display(90, 102, 0, 1);
          break;
        case 2: // scale
          Display.fill_rect(108, 0, 19, 9, DUINO_SH1106::Inverse);
          Display.display(108, 126, 0, 1);
          break;
      }
    }
  }

  void display_trigger_mode()
  {
    bool selected = !main_selected && top_selected == 0;
    Display.fill_rect(77, 1, 7, 7, selected ? DUINO_SH1106::White : DUINO_SH1106::Black);

    Display.draw_bitmap_7(77, 1, icons, trigger_mode, selected ? DUINO_SH1106::Black : DUINO_SH1106::White);

    Display.display(77, 83, 0, 0);
  }

  void display_key()
  {
    bool selected = !main_selected && top_selected == 1;
    Display.fill_rect(91, 1, 11, 7, selected ? DUINO_SH1106::White : DUINO_SH1106::Black);

    bool sharp = false;
    unsigned char letter;

    Display.draw_du_logo_sm(0, 0, DUINO_SH1106::White);
    Display.draw_text(16, 0, "QNTZR", DUINO_SH1106::White);

    // draw kays
    draw_left_key(1, 11);     // C
    draw_black_key(13, 11);   // Db
    draw_center_key(19, 11);  // D
    draw_black_key(31, 11);   // Eb
    draw_right_key(37, 11);   // E
    draw_left_key(55, 11);    // F
    draw_black_key(67, 11);   // Gb
    draw_center_key(73, 11);  // G
    draw_black_key(85, 11);   // Ab
    draw_center_key(91, 11);  // A
    draw_black_key(103, 11);  // Bb
    draw_right_key(109, 11);  // B

    invert_note(current_displayed_note);
    widget_setup(container_outer_);
    Display.display_all();

    display_trigger_mode();
