# Set peripheral MAC as well as HM-10 serial port peripheral_MAC = "A810872197C7" serial_port = "COM9" # Define if data should be live-plotted live_plot = True # Define if data should be written out to file write_flag = True # Define if we should read from BLE or from a file # If False, we read from BLE; if True, we read from file and will use the sampling_period (in seconds) read_flag = False sampling_freq = 20 # [Hz] sampling_period = 1 / sampling_freq # [s] hr_calc = Hr("ir_data_train.csv") neeee = 0 # Open the files and read and write if necessary if write_flag: write_filename = "data_train_walk.csv" # We use this to make sure the file is saved in the script directory and not the dir Python is executing from current_dir = os.path.dirname(os.path.abspath(__file__)) write_file_path = current_dir + "\\" + write_filename write_file = open(write_file_path, 'w') write_file.write('{0}, {1}, {2} \n'.format("t", "reading", "imuVal")) # Write the headers for csv file if read_flag: read_filename = "Heartrate_test_LPF.csv" # We use this to make sure the file is saved in the script directory and not the dir Python is executing from
""" This is where the main code starts """ while True: try: # Take care of some initializations initialize_buffers() initialize_ble() lowpass_filt = Filter(sampling_frequency=sampling_freq, filter_frequency=4, filter_type='low') highpass_filt = Filter(sampling_frequency=sampling_freq, filter_frequency=0.5, filter_type='high') ############################ added ######################################## hr_calc = Hr(train_file=files[0], window_length=100, plot=False) hr_calc1 = Hr(train_file=files[1], window_length=100, plot=False) timer_1 = Timer(period=sampling_period) pedometer = Pedometer(pfiles[0], pfiles[1]) # If we are plotting our data # Call the animation with our update_data() function # This will call our function repeatedly and plot the results if live_plot: # create animation object # Plot about 1/5 of the data in the buffer an = AnimatedFigure(update_data, plot_samples=200, debug=True) axes = an.axes axes[0].set_title('Data') axes[0].set_xlabel('Time (s)') axes[0].set_ylabel('IMU Value (au)')
while True: try: # Take care of some initializations initialize_buffers() initialize_ble() # Instantiate filters lowpass_filt = Filter(sampling_frequency=sampling_freq, filter_frequency=4, filter_type='low') highpass_filt = Filter(sampling_frequency=sampling_freq, filter_frequency=0.5, filter_type='high') # Instantiate Hr class hr_calc = Hr(train_file="../Objective1/ir_data_train.csv", plot=False) # If we are plotting our data # Call the animation with our update_data() function # This will call our function repeatedly and plot the results if live_plot: # create animation object # Plot about 1/5 of the data in the buffer an = AnimatedFigure(update_data, plot_samples=200, debug=False) axes = an.axes axes[0].set_title('Data') axes[0].set_xlabel('Time (s)') axes[0].set_ylabel('IMU Value (au)') axes[1].set_title('Data') axes[1].set_xlabel('Time (s)')
while True: try: # Take care of some initializations initialize_buffers() initialize_ble() # Instantiate filters lowpass_filt = Filter(sampling_frequency=sampling_freq, filter_frequency=4, filter_type='low') highpass_filt = Filter(sampling_frequency=sampling_freq, filter_frequency=0.5, filter_type='high') # Instantiate Hr class hr_calc = Hr(train_file="ir_data_train.csv", plot=True) # If we are plotting our data # Call the animation with our update_data() function # This will call our function repeatedly and plot the results if live_plot: # create animation object # Plot about 1/5 of the data in the buffer an = AnimatedFigure(update_data, plot_samples=200, debug=False) axes = an.axes axes[0].set_title('Data') axes[0].set_xlabel('Time (s)') axes[0].set_ylabel('IR Value (au)') axes[1].set_title('Data') axes[1].set_xlabel('Time (s)')