-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.py
More file actions
executable file
·37 lines (27 loc) · 1.04 KB
/
boot.py
File metadata and controls
executable file
·37 lines (27 loc) · 1.04 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
import board
import digitalio
import storage
import os
# See if we need to mount the drive read-only on the Matrix S3
# side so the computer side can edit files.
button_pin = board.BUTTON_DOWN # Change this to the actual pin connected to your button
# Create a digital input object for the button
button = digitalio.DigitalInOut(button_pin)
button.direction = digitalio.Direction.INPUT
button.pull = digitalio.Pull.UP # You may need to adjust the pull direction based on your circuit
drive_state = not button.value
# False makes the USB drive read-only to the computer
# storage.remount("/", False)
print(f"Drive mount logic is: {drive_state}")
storage.remount("/", drive_state)
def remove_file(filename):
try:
os.remove(filename)
except OSError:
print(f"File {filename} could not be deleted.")
# See if the user wants to reset the Wifi and default settings
button = digitalio.DigitalInOut(board.BUTTON_UP)
if button.value is False:
remove_file("secrets.py")
remove_file("settings.json")
remove_file("error_log")