def read_packet_buffer
      packets = @data[:wave][@wave_idx, 64].map { |val| 
                Packet.factory(:wave, val)  }
      @wave_idx += 64
      @wave_idx = 0 if @wave_idx >= @data[:wave].count

      if @counter == 7
        packets << Packet.factory(:delta, @data[:delta][@esense_idx])
        packets << Packet.factory(:theta, @data[:theta][@esense_idx])
        packets << Packet.factory(:lo_alpha, @data[:lo_alpha][@esense_idx])
        packets << Packet.factory(:hi_alpha, @data[:hi_alpha][@esense_idx])
        packets << Packet.factory(:lo_beta, @data[:lo_beta][@esense_idx])
        packets << Packet.factory(:hi_beta, @data[:hi_beta][@esense_idx])
        packets << Packet.factory(:lo_gamma, @data[:lo_gamma][@esense_idx])
        packets << Packet.factory(:mid_gamma, @data[:mid_gamma][@esense_idx])
        packets << Packet.factory(:signal_quality, 
                                  @data[:signal_quality][@esense_idx])
        packets << Packet.factory(:attention, @data[:attention][@esense_idx])
        packets << Packet.factory(:meditation, @data[:meditation][@esense_idx])
        packets << Packet.factory(:blink, @data[:blink][@esense_idx])
        @esense_idx += 1
        @esense_idx = 0 if @esense_idx >= @data[:delta].count
      end

      @counter = (@counter + 1) % 8
      packets
    end
def read_packet_buffer
      packets = @data[:wave][@wave_idx, 64].map { |val| 
                Packet.factory(:wave, val)  }
      @wave_idx += 64
      @wave_idx = 0 if @wave_idx >= @data[:wave].count

      if @counter == 7
        packets << Packet.factory(:delta, @data[:delta][@esense_idx])
        packets << Packet.factory(:theta, @data[:theta][@esense_idx])
        packets << Packet.factory(:lo_alpha, @data[:lo_alpha][@esense_idx])
        packets << Packet.factory(:hi_alpha, @data[:hi_alpha][@esense_idx])
        packets << Packet.factory(:lo_beta, @data[:lo_beta][@esense_idx])
        packets << Packet.factory(:hi_beta, @data[:hi_beta][@esense_idx])
        packets << Packet.factory(:lo_gamma, @data[:lo_gamma][@esense_idx])
        packets << Packet.factory(:mid_gamma, @data[:mid_gamma][@esense_idx])
        packets << Packet.factory(:signal_quality, 
                                  @data[:signal_quality][@esense_idx])
        packets << Packet.factory(:attention, @data[:attention][@esense_idx])
        packets << Packet.factory(:meditation, @data[:meditation][@esense_idx])
        packets << Packet.factory(:blink, @data[:blink][@esense_idx])
        @esense_idx += 1
        @esense_idx = 0 if @esense_idx >= @data[:delta].count
      end

      @counter = (@counter + 1) % 8
      packets
    end
=begin rdoc
Simulate a read of the Mindset device by returning an Array of Packet objects.
This assumes it will be called 8 times a second.

According to the MDT, Mindset packets are sent at the following intervals:
  1 packet per second: eSense, ASIC EEG, POOR_SIGNAL
  512 packets per second: RAW

Each read will therefore return 64 RAW packets. Every eighth read will also 
return 1 eSense, ASIC_EEG, and POOR_SIGNAL packet.
=end