forked from Wren6991/PicoDVI
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adafruit_CPFS compatibility (example included)
- Loading branch information
1 parent
971b104
commit 40fdf7a
Showing
4 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
This example shows how to use PicoDVI and a board's flash filesystem (i.e. | ||
CIRCUITPY drive) simultaneously. This can be useful for loading graphics | ||
files, saving game state in emulators, etc. To keep this simple, it's just | ||
a mash-up of the existing PicoDVI '1bit_text' and Adafruit_CPFS 'simple' | ||
examples, but the same principles certainly apply to other modes. | ||
To start, you first need to temporarily install CircuitPython on the board | ||
to initialize the flash filesystem, which can then be loaded up with the | ||
files you need. https://circuitpython.org/downloads | ||
With the filesystem prepared, one can then work with the Arduino code... | ||
SUPER IMPORTANT: you MUST have current versions of several libraries and | ||
the Earle Philhower arduino-pico core installed. Failure to have all the | ||
right pieces will wipe out any data stored on the drive! | ||
arduino-pico (via Arduino board manager) 3.3.0 or later | ||
Adafruit_CPFS (via Library manager) 1.0.1 or later | ||
Adafruit_SPIFlash (") 4.2.0 or later | ||
That said, it's still a smart idea to keep a backup of any data you install | ||
on the board. These libraries combined are asking a LOT of the RP2040 chip, | ||
it's always possible there may be some hiccup and you'll have ot start over | ||
with the CircuitPython install and drive setup. | ||
*/ | ||
|
||
#include <PicoDVI.h> // For DVI video out | ||
#include <Adafruit_CPFS.h> // For accessing the CIRCUITPY drive | ||
|
||
FatVolume *fs = NULL; // CIRCUITPY flash filesystem, as a FAT pointer | ||
|
||
// This example uses 80x30 monochrome text mode. See other PicoDVI examples | ||
// for color, bitmapped graphics, widescreen, alternate boards, etc. | ||
DVItext1 display(DVI_RES_640x240p60, adafruit_feather_dvi_cfg); | ||
|
||
void setup() { // Runs once on startup | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
|
||
// Start the CIRCUITPY flash filesystem. SUPER IMPORTANT: NOTICE THE | ||
// EXTRA PARAMETERS HERE. This is REQUIRED when using PicoDVI and | ||
// Adafruit_CPFS together. | ||
fs = Adafruit_CPFS::begin(-1, NULL, false); | ||
|
||
if (!display.begin()) { // Start DVI, slow blink LED if insufficient RAM | ||
for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1); | ||
} | ||
|
||
if (fs == NULL) { // If CIRCUITPY filesystem is missing or malformed... | ||
// Show error message & fast blink LED to indicate problem. Full stop. | ||
display.println("Can't access board's CIRCUITPY drive."); | ||
display.println("Has CircuitPython been previously installed?"); | ||
for (;;) digitalWrite(LED_BUILTIN, (millis() / 250) & 1); | ||
} // else valid CIRCUITPY drive, proceed... | ||
|
||
// As in Adafruit_CPFS 'simple' example, allow USB events to settle... | ||
delay(2500); | ||
Adafruit_CPFS::change_ack(); | ||
|
||
// Then access files and directories using any SdFat calls (open(), etc.) | ||
|
||
// Because fs is a pointer, we use "->" indirection rather than "." access. | ||
// display pointer is cast to print_t so ls() treats it just like Serial. | ||
fs->ls((print_t *)&display, LS_R | LS_SIZE); // List initial drive contents | ||
} | ||
|
||
void loop() { | ||
if (Adafruit_CPFS::changed()) { // Anything changed on CIRCUITPY drive? | ||
Adafruit_CPFS::change_ack(); // Got it, thanks. | ||
display.println("CIRCUITPY drive contents changed."); | ||
fs->ls((print_t *)&display, LS_R | LS_SIZE); // List updated drive contents | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name=PicoDVI - Adafruit Fork | ||
version=1.0.7 | ||
version=1.1.0 | ||
author=Luke Wren (Wren6991) | ||
maintainer=Adafruit <info@adafruit.com> | ||
sentence=Arduino library for RP2040 DVI output, based on PicoDVI | ||
paragraph=Arduino library for RP2040 DVI output, based on PicoDVI | ||
category=Display | ||
url=https://github.com/adafruit/PicoDVI | ||
architectures=rp2040 | ||
depends=Adafruit GFX Library | ||
depends=Adafruit GFX Library, Adafruit CPFS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters