Merge pull request #476 from pimoroni/hel_more_inky_frame

add SD card example for Inky Frame
This commit is contained in:
Philip Howard 2022-08-08 10:05:04 +01:00 committed by GitHub
commit 54ef2ddfd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 2 deletions

View File

@ -91,6 +91,7 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te
* Automation 2040 W (inputs, outputs and relays, 6-40V compatible) - https://shop.pimoroni.com/products/automation-2040-w
* Inventor 2040 W (motors, servos, noise) - https://shop.pimoroni.com/products/inventor-2040-w
* Inky Frame 5.7" (7-colour E Ink) - https://shop.pimoroni.com/products/inky-frame-5-7
## Breakouts

View File

@ -10,6 +10,7 @@
- [PlaceKitten](#placekitten)
- [Quote of the Day](#quote-of-the-day)
- [Random Joke](#random-joke)
- [SD Card Test](#sd-card-test)
- [XKCD Daily](#xkcd-daily)
## PicoGraphics
@ -30,7 +31,9 @@ Finally for examples loading images, you'll need `sdcard.mpy` from `common/lib`.
### Button Test
[button_test.py](button_test.py)
This example shows you a simple, non-interrupt way of reading Inky Frame's buttons with a loop that checks to see if buttons are pressed.
Inky Frame's buttons (and the RTC alarm, busy signal from the screen and external trigger from the hack header) are connected to a shift register to help conserve pins, and to allow these inputs to wake the board up from sleep.
This example demonstrates a simple way of reading when a button has been pushed by reading the shift register and checking if the bit in a specific position is 0 or 1.
### Daily Activity
[inky_frame_daily_activity.py](inky_frame_daily_activity.py)
@ -38,7 +41,7 @@ This example shows you a simple, non-interrupt way of reading Inky Frame's butto
Generate a random activity from Bored API.
### Image Gallery
[/image_gallery](/image_gallery)
[/image_gallery](../inky_frame/image_gallery)
This photo frame example displays local images on Inky Frame and lets you switch between them with the buttons. Use `image_gallery.py` if your images are stored on your Pico, or `image_gallery_sd.py` if the images are on your SD card.
@ -74,6 +77,11 @@ Jokes are rendered into images "offline" by our feed2image service for two reaso
For bugs/contributions or to complain about a joke, see: https://github.com/pimoroni/feed2image
### SD Card Test
[sd_test.py](sd_test.py)
This simple example shows how to read and write from the SD card on Inky Frame.
### XKCD Daily
[inky_frame_xkcd_daily.py](inky_frame_xkcd_daily.py)

View File

@ -0,0 +1,26 @@
# This simple example shows how to read and write from the SD card on Inky Frame.
from machine import Pin, SPI
import sdcard
import os
# set up the SD card
sd_spi = SPI(0, sck=Pin(18, Pin.OUT), mosi=Pin(19, Pin.OUT), miso=Pin(16, Pin.OUT))
sd = sdcard.SDCard(sd_spi, Pin(22))
os.mount(sd, "/sd")
# create a file and add some text
# if this file already exists it will be overwritten
with open("/sd/inkytest.txt", "w") as f:
f.write("Hello Inky!\r\n")
f.close()
# open the file and append some text (useful for logging!)
with open("/sd/inkytest.txt", "a") as f:
f.write("We're appending some text\r\n")
f.close()
# read the file and print the contents to the console
with open("/sd/inkytest.txt", "r") as f:
data = f.read()
print(data)
f.close()