BioRadioDeviceEventMarkerButtonPushed Event |
Namespace: GLNeuroTech.Devices.BioRadio
using System; using GLNeuroTech.Devices.BioRadio; namespace BioRadioAPIExamples { public class EventButtonPress { /// <summary> /// This sample method will connect to a device at the given mac ID and subscribe to the BioRadio button pressed event. /// The subscribed method will output the time of each button press to the console. /// </summary> public static void SubscribeToButtonPressEvent(long macID) { var bioRadioDeviceManager = new BioRadioDeviceManager(); var connectedBioRadio = bioRadioDeviceManager.GetBluetoothDevice(macID); // Subscribe to be notified when the BioRadio event button is pressed connectedBioRadio.EventMarkerButtonPushed += new EventHandler<BioRadioButtonEventArgs>(ButtonPressed); connectedBioRadio.StartAcquisition(); while (!Console.KeyAvailable) { ClearBuffers(connectedBioRadio); } connectedBioRadio.StopAcquisition(); connectedBioRadio.Disconnect(); connectedBioRadio.Dispose(); } private static void ClearBuffers(BioRadioDevice connectedBioRadio) { foreach (var signalGroup in connectedBioRadio.SignalGroups) { foreach (BioRadioSignal signal in signalGroup) { var samples = signal.GetScaledValueArray(); } } } // Raised when BioRadio button is Pressed public static void ButtonPressed(object o, BioRadioButtonEventArgs e) { Console.WriteLine("The BioRadio hardware button was pressed at: " + e.PressedTime); } } }