def menu(title, selection, options = {})
      return nil if selection.empty?
      options[:number]    = true if options[:number].nil?
      options[:timeout] ||= Device::IO.timeout
      key, selected = pagination(title, options, selection) do |collection, line_zero|
        collection.each_with_index do |value,i|
          display = value.is_a?(Array) ? value[0] : value
          if options[:number]
            Device::Display.print("#{i+1} #{display}", i+line_zero, 0)
          else
            unless display.to_s.empty?
              Device::Display.print("#{display}", i+line_zero, 0)
            end
          end
        end
      end

      if key == Device::IO::ENTER || key == Device::IO::CANCEL
        options[:default]
      else
        selected
      end
    end
def menu(title, selection, options = {})
      return nil if selection.empty?
      options[:number]    = true if options[:number].nil?
      options[:timeout] ||= Device::IO.timeout
      key, selected = pagination(title, options, selection) do |collection, line_zero|
        collection.each_with_index do |value,i|
          display = value.is_a?(Array) ? value[0] : value
          if options[:number]
            Device::Display.print("#{i+1} #{display}", i+line_zero, 0)
          else
            unless display.to_s.empty?
              Device::Display.print("#{display}", i+line_zero, 0)
            end
          end
        end
      end

      if key == Device::IO::ENTER || key == Device::IO::CANCEL
        options[:default]
      else
        selected
      end
    end
Create a form menu.

 @param title [String] Text to display on line 0. If nil title won't be
   displayed and Display.clear won't be called on before the option show.
 @param selection [Hash] Hash (display text => value that will return)
   containing the list options.
 @param options [Hash] Hash containing options to change the menu behaviour.

 @example
   options = {
     # default value to return if enter, you can work with complex data.
     :default => 10,
     # Add number to label or not
     :number => true,
     # Input Timeout in miliseconds
     :timeout => 30_000
   }

   selection = {
     "option X" => 10,
     "option Y" => 11
   }

   menu("Option menu", selection, options)