-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbehaviour_stop.py
More file actions
executable file
·42 lines (33 loc) · 1.61 KB
/
behaviour_stop.py
File metadata and controls
executable file
·42 lines (33 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Stop and initialize the Arduino behaviour set up.
Author: Candice Lee and Ziyue Liu
Date: 2025-12-09
"""
import os
import config_loader
import upload_and_write as UW
def run_behaviour():
"""Stop and initialize Arduino hardware to safe state."""
# Load configuration
config = config_loader.load_config()
arduino_config = config_loader.get_arduino_config(config)
paths_config = config_loader.get_paths_config(config)
# Get Arduino settings
port = arduino_config.get('port', 'COM17')
fqbn = arduino_config.get('fqbn', 'arduino:avr:uno')
# Get sketch paths (use relative paths from config)
script_dir = os.path.dirname(os.path.abspath(__file__))
sketch_rel = arduino_config.get('sketches', {}).get('pavlovian_texture',
'Arduino/PavlovianTexture/PavlovianTexture.ino')
stop_sketch_rel = arduino_config.get('sketches', {}).get('initialize_and_end',
'Arduino/initialize_and_end/initialize_and_end.ino')
sketch = os.path.join(script_dir, sketch_rel)
stop_sketch = os.path.join(script_dir, stop_sketch_rel)
# Get save paths (dummy values for stop function)
save_folder_path = paths_config.get('data_save_folder', './Behaviour_data')
temp_path = paths_config.get('temp_compilation_folder', './temp_arduino')
# Initialize and run stop sequence
uw = UW.UploadAndWrite(port, fqbn, sketch, stop_sketch, save_folder_path, temp_path)
uw.stop()
if __name__ == "__main__":
run_behaviour()