NOTE: This gem is not yet released, its complete('ish) but I'm finishing documentation and final testing/code tidying. If you pull it locally you will be able to build it and install it as a gem.
A ruby gem for connecting to the NeuroSky mindset
The current parser uses state_machine, this appears to be quite slow and will be replaced in the next update
require 'mindset' find_mindset = false use_mock_mindset = true if find_mindset # Discover your mindset - It must be in pairing mode puts Mindset::Device.scan else address = "00:13:EF:00:4B:46" # E.g. channel = 3 # I will give some help on this before the gem is released :-) device = if use_mock_mindset mock = Mindset::MockDevice.new(1024, true) mock.queue_event_attention(22) mock else Mindset::Device.new() end # Create the stream parser and payload parser (with the default logger) parser = Mindset::ByteParser.new(Mindset::PayloadParser.new(Mindset::EventLogger.new)) # Parse the stream device.listen(address, channel) do |device| Mindset::StreamParser.parse(device, parser) end end
This has only been tested on Ubuntu. This version will not work on Windows, due to the need to compile native extensions. This should be addressed in the next version. Although I can do this, if anyone feels like adding the code, please go for it.
When I release this gem: sudo gem install mindset, in the meantime you can pull and install locally by building a package
(The MIT License)
Copyright © 2011 Mangled
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.