Skip to content

Commit

Permalink
Use i2c AD python scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianpaulsen committed Feb 28, 2024
1 parent 80712dd commit 0191253
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion py_scripts/make_cpp_files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import os
import shutil

ARDUINO_FILE_EXTENSION = ".ino"
TARGET_FILE_EXTENSION = ".cpp"
EXAMPLE_FOLDER = "examples"

# Create a .cpp file for all the .ino files in the examples dir (CAUTION: will overwrite existing)
print("PRE_SCRIPT: Copying .ino file contents to .cpp files.")
os.system(f'find examples -type f -name "*.ino" -exec bash -c \'for file; do cp "$file" "$(dirname "$file")/$(basename "$file" .ino).cpp"; done\' _ {{}} +')
for e in os.listdir(EXAMPLE_FOLDER):
if os.path.isdir(f"{EXAMPLE_FOLDER}/{e}") and os.path.isfile(f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}"):
arduino_file =f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}"
cpp_file = f"{EXAMPLE_FOLDER}/{e}/{e}{TARGET_FILE_EXTENSION}"
shutil.copyfile(arduino_file, cpp_file)
print(f'\tcopied {arduino_file} to {cpp_file}')
print("\t>> Done.")

0 comments on commit 0191253

Please sign in to comment.