Skip to content

Commit a6e5cd7

Browse files
committed
Change the timestamp for the csv file(now the csv file records only in microseconds) and adding extra relevant information like Arduino board, sampling rate in csv file recording at top.
1 parent 06ad971 commit a6e5cd7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

chords.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def read_arduino_data(ser, csv_writer=None, inverted=False):
166166
channel_data.append(float(value)) # Convert to float and add to channel data
167167

168168
if csv_writer: # If CSV logging is enabled, write the data to the CSV file
169-
current_timestamp = datetime.now().strftime('%H:%M:%S:%f') # Get the current timestamp
169+
current_timestamp = datetime.now().strftime('%f') # Get the timestamp only in microseconds
170170
csv_writer.writerow([current_timestamp, counter] + channel_data)
171171
if lsl_outlet: # If LSL streaming is enabled, send the data to the LSL stream
172172
lsl_outlet.push_sample(channel_data)
@@ -230,6 +230,9 @@ def parse_data(ser, lsl_flag=False, csv_flag=False, verbose=False, run_time=None
230230
csv_file = open(csv_filename, mode='w', newline='') if csv_flag else None # Open CSV file if logging is
231231
if csv_file:
232232
csv_writer = csv.writer(csv_file) # Create CSV writer
233+
csv_writer.writerow([f"Arduino Board: {board}"])
234+
csv_writer.writerow([f"Sampling Rate (samples per second): {supported_boards[board]}"])
235+
csv_writer.writerow([]) # Blank row for separation
233236
csv_writer.writerow(['Timestamp', 'Counter', 'Channel1', 'Channel2', 'Channel3', 'Channel4', 'Channel5', 'Channel6']) # Write header
234237

235238
end_time = time.time() + run_time if run_time else None

0 commit comments

Comments
 (0)