Class: Artoo::Drivers::Neurosky
- Inherits:
-
Driver
- Object
- Driver
- Artoo::Drivers::Neurosky
- Defined in:
- lib/artoo/drivers/neurosky.rb
Overview
The neurosky driver behaviors
Instance Method Summary collapse
- #handle_message_events ⇒ Object
- #handle_packet(packet) ⇒ Object
-
#start_driver ⇒ Object
Start driver and any required connections.
Instance Method Details
#handle_message_events ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/artoo/drivers/neurosky.rb', line 23 def begin while true do packets = connection.read_packet return if packets.empty? packets.each { |pkt| handle_packet(pkt) } end #rescue ::Mindset::Connection::TimeoutError, Interrupt => e #cont = false end end |
#handle_packet(packet) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/artoo/drivers/neurosky.rb', line 37 def handle_packet(packet) case when packet[:wave] publish(event_topic_name("update"), "wave", packet[:wave]) publish(event_topic_name("wave"), packet[:wave]) when packet[:signal_quality] publish(event_topic_name("update"), "signal_quality", packet[:signal_quality]) publish(event_topic_name("signal_quality"), packet[:signal_quality]) when packet[:attention] publish(event_topic_name("update"), "attention", packet[:attention]) publish(event_topic_name("attention"), packet[:attention]) when packet[:meditation] publish(event_topic_name("update"), "meditation", packet[:meditation]) publish(event_topic_name("meditation"), packet[:meditation]) when packet[:blink] publish(event_topic_name("update"), "blink", packet[:blink]) publish(event_topic_name("blink"), packet[:blink]) when packet[:delta] publish(event_topic_name("update"), "eeg", packet) publish(event_topic_name("eeg"), packet) else puts packet.inspect end end |
#start_driver ⇒ Object
Start driver and any required connections
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/artoo/drivers/neurosky.rb', line 9 def start_driver begin every(interval) do end super rescue Exception => e Logger.error "Error starting Neurosky driver!" Logger.error e. Logger.error e.backtrace.inspect end end |