From caa345776f3f1ac0b1b7c6723e90b021ede60ed8 Mon Sep 17 00:00:00 2001 From: SpectralVectors Date: Sat, 21 Jan 2023 15:10:36 -0500 Subject: [PATCH] _drive file added _drive contains a variable passed from Blender and the user's PC, it will update when the user presses 'Autodetect' in the Blender addon, and the code will now autofill the location of the pico's drive storage, meaning the user will no longer have to manually specify the location of the 'Scripts' file --- Pico/code.py | 1 + Pico/lib/BoardSetup/_base.py | 18 +++++++++--------- Pico/lib/BoardSetup/_drive.py | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 Pico/lib/BoardSetup/_drive.py diff --git a/Pico/code.py b/Pico/code.py index 4c26b0a..8d3467c 100644 --- a/Pico/code.py +++ b/Pico/code.py @@ -60,6 +60,7 @@ # Check for input in an infinite loop while True: + # Button 0 - Page Change if button0.value: page += 1 diff --git a/Pico/lib/BoardSetup/_base.py b/Pico/lib/BoardSetup/_base.py index 7639104..f8a265e 100644 --- a/Pico/lib/BoardSetup/_base.py +++ b/Pico/lib/BoardSetup/_base.py @@ -5,6 +5,7 @@ from adafruit_hid.keyboard import Keyboard from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS from adafruit_hid.mouse import Mouse +from ._drive import drive # Importing the shortened keycodes from BoardSetup._shortcodes import * @@ -14,19 +15,18 @@ text = KeyboardLayoutUS(kb) mouse = Mouse(usb_hid.devices) -# The location of the Pico storage and Scripts folder -drive = 'G:' +# The location of the Scripts folder path = '/lib/Scripts/' -# Helper function to make running scripts only a single line -def run_script(script): - kb.send(shift,ctrl,alt,insert) - wait(0.1) - print(f"exec(open('{drive}{path}{script}').read())") - # Helper function to allow running commands in the background def command(command): kb.send(shift,ctrl,alt,insert) wait(0.1) print(f"import bpy;{command}") - kb.send(left,right) \ No newline at end of file + kb.send(left,right) + +# Helper function to make running scripts only a single line +def run_script(script): + kb.send(shift,ctrl,alt,insert) + wait(0.1) + print(f"exec(open('{drive}{path}{script}').read())") diff --git a/Pico/lib/BoardSetup/_drive.py b/Pico/lib/BoardSetup/_drive.py new file mode 100644 index 0000000..bd7068c --- /dev/null +++ b/Pico/lib/BoardSetup/_drive.py @@ -0,0 +1 @@ +drive = 'G:' \ No newline at end of file