private static string UID = "XYZ"; // Change XYZ to the UID of your Heart Rate Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletHeartRate hr = new BrickletHeartRate(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current heart rate (unit is bpm) int heartRate = hr.GetHeartRate(); Console.WriteLine("Heart Rate: " + heartRate + " bpm"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletHeartRate hr = new BrickletHeartRate(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register heart rate callback to function HeartRateCB hr.HeartRate += HeartRateCB; // Set period for heart rate callback to 1s (1000ms) // Note: The heart rate callback is only called every second // if the heart rate has changed since the last call! hr.SetHeartRateCallbackPeriod(1000); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletHeartRate hr = new BrickletHeartRate(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get threshold callbacks with a debounce time of 10 seconds (10000ms) hr.SetDebouncePeriod(10000); // Register heart rate reached callback to function HeartRateReachedCB hr.HeartRateReached += HeartRateReachedCB; // Configure threshold for heart rate "greater than 100 bpm" (unit is bpm) hr.SetHeartRateCallbackThreshold('>', 100, 0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Heart Rate Bricklet #endregion Fields #region Methods // Callback function for heart rate callback (parameter has unit bpm) static void HeartRateCB(BrickletHeartRate sender, int heartRate) { Console.WriteLine("Heart Rate: " + heartRate + " bpm"); }