Skip to content

Update examples with umount #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions examples/bitmapsaver_screenshot_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
import storage
from adafruit_bitmapsaver import save_pixels

TAKE_SCREENSHOT = False # Set to True to take a screenshot

spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.SD_CS)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")

print("Taking Screenshot...")
save_pixels("/sd/screenshot.bmp")
print("Screenshot taken")
if TAKE_SCREENSHOT:
print("Taking Screenshot... ")
save_pixels("/sd/screenshot.bmp")
print("Screenshot Saved")
storage.umount(vfs)
print("SD Card Unmounted") # Do not remove SD card until unmounted
11 changes: 8 additions & 3 deletions examples/bitmapsaver_screenshot_tft_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
DISPLAY_WIDTH = 480
DISPLAY_HEIGHT = 320

TAKE_SCREENSHOT = False # Set to True to take a screenshot

# Initialize Protocol Busses and SD Card
spi = board.SPI()
cs = digitalio.DigitalInOut(board.D5)
Expand All @@ -33,6 +35,9 @@
virtual_root = "/sd"
storage.mount(vfs, virtual_root)

print("Taking Screenshot... ")
save_pixels("/sd/screenshot.bmp", display)
print("Screenshot taken")
if TAKE_SCREENSHOT:
print("Taking Screenshot... ")
save_pixels("/sd/screenshot.bmp", display)
print("Screenshot Saved")
storage.umount(vfs)
print("SD Card Unmounted") # Do not remove SD card until unmounted
10 changes: 8 additions & 2 deletions examples/bitmapsaver_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

# pylint:disable=invalid-name

TAKE_SCREENSHOT = False # Set to True to take a screenshot

print("Setting up SD card")
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.SD_CS)
Expand Down Expand Up @@ -50,5 +52,9 @@
else:
bitmap[x, y] = 0

print("Saving bitmap")
save_pixels("/sd/test.bmp", bitmap, palette)
if TAKE_SCREENSHOT:
print("Taking Screenshot... ")
save_pixels("/sd/screenshot.bmp", bitmap, palette)
print("Screenshot Saved")
storage.umount(vfs)
print("SD Card Unmounted") # Do not remove SD card until unmounted