EasyManua.ls Logo

Adafruit ESP32-S3 - The boot.py File

Adafruit ESP32-S3
263 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Simply connect the STEMMA QT cable from the STEMMA QT port on your board to th
e STEMMA QT port on the MCP9808.
The boot.py File
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
CircuitPython Essentials Storage CP Filesystem boot.py file
"""
import time
import board
import digitalio
import storage
import neopixel
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
button = digitalio.DigitalInOut(board.BUTTON)
button.switch_to_input(pull=digitalio.Pull.UP)
# Turn the NeoPixel white for one second to indicate when to press the boot button.
pixel.fill((255, 255, 255))
time.sleep(1)
# If the button is connected to ground, the filesystem is writable by CircuitPython
storage.remount("/", readonly=button.value)
The storage.remount() command has a readonly keyword argument. This
argument refers to the read/write state of CircuitPython. It does NOT refer to the read/
write state of your computer.
When the button is pressed, it returns False . The readonly argument in boot.py is
set to the value of the button. When the value=True , the CIRCUITPY drive is read-
only to CircuitPython (and writable by your computer). When the value=False , the C
IRCUITPY drive is writable by CircuitPython (and read-only by your computer).
The filesystem will NOT automatically be set to read-only on creation of this file!
You'll still be able to edit files on CIRCUITPY after saving this boot.py.
©Adafruit Industries Page 166 of 263

Table of Contents

Related product manuals