Here are my steps now.
1
Plug RP2040 in cmputer
2
Put RP2040 in boot loader mode
3
To disable dot files, type on terminal:
sudo mdutil -i off -d /Volumes/RPI-RP2
4
Clear invisible Mac files
5
Unlock files using TextEdit
6
Nuke using terminal: cp -X /Users/admin/Desktop/flash_nuke.uf2 /Volumes/RPI-RP2
7
Clear invisible Mac files(Shift command . to see invisible files)
8
re-unlock files
9
To disable dot files, type on terminal:
sudo mdutil -i off -d /Volumes/RPI-RP2
10
Apply Circuit Python using terminal: cp -X /Users/admin/Desktop/CIRCUIT.UF2 /Volumes/RPI-RP2
11
Clear invisible files
12
Unlock files if needed
13
To disable dot files, type on terminal:
sudo mdutil -i off -d /Volumes/CIRCUITPY
14
Copy GIF file on RP2040
15
To disable dot files, type on terminal:
sudo mdutil -i off -d /Volumes/CIRCUITPY
16
Open Arduino 1.8.19
17
Install the libraries you need
18
Select port and verify Drive Board is selected
19
Verify and upload the code
I am wondering if there is another way to disable dot files creation. Also, I think it is still weird that the frame count stops at 3
RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
I found way do get rit of the ._ file !! I uses Blue Harvest Softweare to do so. Now my Serial monitor shows
Successfully opened GIF badger-172.gif; Canvas size = 320 x 172
frame count: 3
duration: 150 ms
max delay: 50 ms
min delay: 50 ms
0 2020-01-01 00:00 .Trashes
22 2020-01-01 00:00 code.py
0 2020-01-01 00:00 lib/
115 2020-01-01 00:00 boot_out.txt
86526 2022-11-21 16:10 badger-172.gif
Successfully opened GIF badger-172.gif; Canvas size = 320 x 172
frame count: 3
duration: 150 ms
max delay: 50 ms
min delay: 50 ms
0 2020-01-01 00:00 .Trashes
22 2020-01-01 00:00 code.py
0 2020-01-01 00:00 lib/
115 2020-01-01 00:00 boot_out.txt
86526 2022-11-21 16:10 badger-172.gif
Successfully opened GIF badger-172.gif; Canvas size = 320 x 172
And the code is running.
But my screen is still blue :( and I am still quesitoning why it would be 3 frames count.
Please le me know what is you serial monitor showing when the GIF is playing on your screen.
Successfully opened GIF badger-172.gif; Canvas size = 320 x 172
frame count: 3
duration: 150 ms
max delay: 50 ms
min delay: 50 ms
0 2020-01-01 00:00 .Trashes
22 2020-01-01 00:00 code.py
0 2020-01-01 00:00 lib/
115 2020-01-01 00:00 boot_out.txt
86526 2022-11-21 16:10 badger-172.gif
Successfully opened GIF badger-172.gif; Canvas size = 320 x 172
frame count: 3
duration: 150 ms
max delay: 50 ms
min delay: 50 ms
0 2020-01-01 00:00 .Trashes
22 2020-01-01 00:00 code.py
0 2020-01-01 00:00 lib/
115 2020-01-01 00:00 boot_out.txt
86526 2022-11-21 16:10 badger-172.gif
Successfully opened GIF badger-172.gif; Canvas size = 320 x 172
And the code is running.
But my screen is still blue :( and I am still quesitoning why it would be 3 frames count.
Please le me know what is you serial monitor showing when the GIF is playing on your screen.
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
Alo, do you know what is the maximum frames for a GIF playing on this drive? or if there are multiple GIFs, do you know just what is the maximum total wieigh possible to strore on the RP2040 CIRCUITPY
Thank you!
Thank you!
- mikeysklar
- Posts: 14165
- Joined: Mon Aug 01, 2016 8:10 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
It sounds like you have worked it out most of the code issues. If you are down to bluescreen then we are probably just looking at the example code having the wrong pinouts selected.
Have you been using this code deviation from the default guide?
There is a little bit of mention of limitations (frame/size) in the AnimatedGIF library docs. It is vague so you will have to test for yourself.
https://github.com/bitbank2/AnimatedGIF
Have you been using this code deviation from the default guide?
Code: Select all
#define TFT_CS 7
#define TFT_DC 8
#define TFT_RST 9
https://github.com/bitbank2/AnimatedGIF
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
yes, I am using the code deviation
#define TFT_CS 7
#define TFT_DC 8
#define TFT_RST 9
#define TFT_CS 7
#define TFT_DC 8
#define TFT_RST 9
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
Now, because my display is still not playing anything and my frame count is still 3, do you have any advice about what I could do?
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
I tried with the CPX-172.gif from Adafruit and it does something similar. The code is running but the frame count stops at 1 and the screen stays blue.
- mikeysklar
- Posts: 14165
- Joined: Mon Aug 01, 2016 8:10 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
Probably a library or Board Support Package has changed.
I'll try the latest and see what has changed since the last time I had my Mini GIF player running.
I'll try the latest and see what has changed since the last time I had my Mini GIF player running.
- CmdrVimes
- Posts: 15
- Joined: Tue Dec 06, 2022 10:02 am
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
@mikeysklar!
Thank you so much for helping Laila_Mestari!
I could not have gotten my players to work without your discovery of the pin numbers being incorrect!
I now have five working Mini GIF Players waiting to be mounted to their 3d printed cases.
I am going to take a wild swing and ask if there is a way to upload new GIFs once the sketch has been loaded? It seems the sketch keeps the P2040 from being seen as a filesystem. (If this isn't the right place to ask, can you please point me to where the right place is?)
Again, thanks for posting your suggestions! I wouldn't have been successful without your help.
Thank you so much for helping Laila_Mestari!
I could not have gotten my players to work without your discovery of the pin numbers being incorrect!
I now have five working Mini GIF Players waiting to be mounted to their 3d printed cases.
I am going to take a wild swing and ask if there is a way to upload new GIFs once the sketch has been loaded? It seems the sketch keeps the P2040 from being seen as a filesystem. (If this isn't the right place to ask, can you please point me to where the right place is?)
Again, thanks for posting your suggestions! I wouldn't have been successful without your help.
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
That’s wonderful! you are welcome @cmdrVimes
As for me, I am still not able to see anything playing on my screen and I can’t find the reason.
To people for who the project is working: how many frame counts do you see on the “frame count” line of your serial monitor when the GIF is playing? Any advice to what I should try?
As for me, I am still not able to see anything playing on my screen and I can’t find the reason.
To people for who the project is working: how many frame counts do you see on the “frame count” line of your serial monitor when the GIF is playing? Any advice to what I should try?
- CmdrVimes
- Posts: 15
- Joined: Tue Dec 06, 2022 10:02 am
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
Just to be clear...
Big thanks to mikeysklar for sorting everything out!
Big thanks to mikeysklar for sorting everything out!
- mikeysklar
- Posts: 14165
- Joined: Mon Aug 01, 2016 8:10 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
I didn't have any trouble running the following to show the badger-320.gif with Arduino IDE v1.8.19 on Ubuntu Linux.
Current code from mini-gif guide with pin changes to 7/8/9.
Arduino Libraries (you can see these during verbose compile / upload):
The Board Support file is: Raspberry Pi Pico/RP2040 Earle Philhower 2.6.4.
Make sure you running the same versions of Arduino IDE, libraries and board support file.
Open the Arduino IDE serial console to start the animation after u/l.
If everything is identical then we will need to go over wiring again.
Current code from mini-gif guide with pin changes to 7/8/9.
Code: Select all
// SPDX-FileCopyrightText: 2022 Limor Fried for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include <AnimatedGIF.h>
#include <SdFat.h>
#include <Adafruit_SPIFlash.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#define TFT_CS 7
#define TFT_DC 8
#define TFT_RST 9
#define DISPLAY_WIDTH 320
#define DISPLAY_HEIGHT 174
#define GIFDIRNAME "/"
#define NUM_LOOPS 5
#if defined(ARDUINO_ARCH_ESP32)
// ESP32 use same flash device that store code.
// Therefore there is no need to specify the SPI and SS
Adafruit_FlashTransport_ESP32 flashTransport;
#elif defined(ARDUINO_ARCH_RP2040)
// RP2040 use same flash device that store code for file system. Therefore we
// only need to specify start address and size (no need SPI or SS)
// By default (start=0, size=0), values that match file system setting in
// 'Tools->Flash Size' menu selection will be used.
// Adafruit_FlashTransport_RP2040 flashTransport;
// To be compatible with CircuitPython partition scheme (start_address = 1 MB,
// size = total flash - 1 MB) use const value (CPY_START_ADDR, CPY_SIZE) or
// subclass Adafruit_FlashTransport_RP2040_CPY. Un-comment either of the
// following line:
// Adafruit_FlashTransport_RP2040
// flashTransport(Adafruit_FlashTransport_RP2040::CPY_START_ADDR,
// Adafruit_FlashTransport_RP2040::CPY_SIZE);
Adafruit_FlashTransport_RP2040_CPY flashTransport;
#else
// On-board external flash (QSPI or SPI) macros should already
// defined in your board variant if supported
// - EXTERNAL_FLASH_USE_QSPI
// - EXTERNAL_FLASH_USE_CS/EXTERNAL_FLASH_USE_SPI
#if defined(EXTERNAL_FLASH_USE_QSPI)
Adafruit_FlashTransport_QSPI flashTransport;
#elif defined(EXTERNAL_FLASH_USE_SPI)
Adafruit_FlashTransport_SPI flashTransport(EXTERNAL_FLASH_USE_CS, EXTERNAL_FLASH_USE_SPI);
#else
#error No QSPI/SPI flash are defined on your board variant.h !
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
// file system object from SdFat
FatFileSystem fatfs;
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
AnimatedGIF gif;
File32 f, root;
void * GIFOpenFile(const char *fname, int32_t *pSize)
{
f = fatfs.open(fname);
if (f)
{
*pSize = f.size();
return (void *)&f;
}
return NULL;
} /* GIFOpenFile() */
void GIFCloseFile(void *pHandle)
{
File32 *f = static_cast<File32 *>(pHandle);
if (f != NULL)
f->close();
} /* GIFCloseFile() */
int32_t GIFReadFile(GIFFILE *pFile, uint8_t *pBuf, int32_t iLen)
{
int32_t iBytesRead;
iBytesRead = iLen;
File32 *f = static_cast<File32 *>(pFile->fHandle);
// Note: If you read a file all the way to the last byte, seek() stops working
if ((pFile->iSize - pFile->iPos) < iLen)
iBytesRead = pFile->iSize - pFile->iPos - 1; // <-- ugly work-around
if (iBytesRead <= 0)
return 0;
iBytesRead = (int32_t)f->read(pBuf, iBytesRead);
pFile->iPos = f->position();
return iBytesRead;
} /* GIFReadFile() */
int32_t GIFSeekFile(GIFFILE *pFile, int32_t iPosition)
{
int i = micros();
File32 *f = static_cast<File32 *>(pFile->fHandle);
f->seek(iPosition);
pFile->iPos = (int32_t)f->position();
i = micros() - i;
// Serial.printf("Seek time = %d us\n", i);
return pFile->iPos;
} /* GIFSeekFile() */
// Draw a line of image directly on the LCD
void GIFDraw(GIFDRAW *pDraw)
{
uint8_t *s;
uint16_t *d, *usPalette, usTemp[320];
int x, y, iWidth;
iWidth = pDraw->iWidth;
// Serial.printf("Drawing %d pixels\n", iWidth);
if (iWidth + pDraw->iX > DISPLAY_WIDTH)
iWidth = DISPLAY_WIDTH - pDraw->iX;
usPalette = pDraw->pPalette;
y = pDraw->iY + pDraw->y; // current line
if (y >= DISPLAY_HEIGHT || pDraw->iX >= DISPLAY_WIDTH || iWidth < 1)
return;
s = pDraw->pPixels;
if (pDraw->ucDisposalMethod == 2) // restore to background color
{
for (x=0; x<iWidth; x++)
{
if (s[x] == pDraw->ucTransparent)
s[x] = pDraw->ucBackground;
}
pDraw->ucHasTransparency = 0;
}
// Apply the new pixels to the main image
if (pDraw->ucHasTransparency) // if transparency used
{
uint8_t *pEnd, c, ucTransparent = pDraw->ucTransparent;
int x, iCount;
pEnd = s + iWidth;
x = 0;
iCount = 0; // count non-transparent pixels
while(x < iWidth)
{
c = ucTransparent-1;
d = usTemp;
while (c != ucTransparent && s < pEnd)
{
c = *s++;
if (c == ucTransparent) // done, stop
{
s--; // back up to treat it like transparent
}
else // opaque
{
*d++ = usPalette[c];
iCount++;
}
} // while looking for opaque pixels
if (iCount) // any opaque pixels?
{
tft.startWrite();
tft.setAddrWindow(pDraw->iX+x, y, iCount, 1);
tft.writePixels(usTemp, iCount, false, false);
tft.endWrite();
x += iCount;
iCount = 0;
}
// no, look for a run of transparent pixels
c = ucTransparent;
while (c == ucTransparent && s < pEnd)
{
c = *s++;
if (c == ucTransparent)
iCount++;
else
s--;
}
if (iCount)
{
x += iCount; // skip these
iCount = 0;
}
}
}
else
{
s = pDraw->pPixels;
// Translate the 8-bit pixels through the RGB565 palette (already byte reversed)
for (x=0; x<iWidth; x++)
usTemp[x] = usPalette[*s++];
tft.startWrite();
tft.setAddrWindow(pDraw->iX, y, iWidth, 1);
tft.writePixels(usTemp, iWidth, false, false);
tft.endWrite();
}
} /* GIFDraw() */
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("Adafruit SPIFlash Animated GIF Example");
// Initialize flash library and check its chip ID.
if (!flash.begin()) {
Serial.println("Error, failed to initialize flash chip!");
while(1);
}
Serial.print("Flash chip JEDEC ID: 0x"); Serial.println(flash.getJEDECID(), HEX);
// First call begin to mount the filesystem. Check that it returns true
// to make sure the filesystem was mounted.
if (!fatfs.begin(&flash)) {
Serial.println("Failed to mount filesystem!");
Serial.println("Was CircuitPython loaded on the board first to create the filesystem?");
while(1);
}
Serial.println("Mounted filesystem!");
if (!root.open(GIFDIRNAME)) {
Serial.println("Open dir failed");
}
while (f.openNext(&root, O_RDONLY)) {
f.printFileSize(&Serial);
Serial.write(' ');
f.printModifyDateTime(&Serial);
Serial.write(' ');
f.printName(&Serial);
if (f.isDir()) {
// Indicate a directory.
Serial.write('/');
}
Serial.println();
f.close();
}
root.close();
tft.init(DISPLAY_HEIGHT, DISPLAY_WIDTH);
tft.fillScreen(ST77XX_BLUE);
tft.setRotation(1);
gif.begin(LITTLE_ENDIAN_PIXELS);
}
void loop() {
char thefilename[80];
if (!root.open(GIFDIRNAME)) {
Serial.println("Open GIF directory failed");
while (1);
}
while (f.openNext(&root, O_RDONLY)) {
f.printFileSize(&Serial);
Serial.write(' ');
f.printModifyDateTime(&Serial);
Serial.write(' ');
f.printName(&Serial);
if (f.isDir()) {
// Indicate a directory.
Serial.write('/');
}
Serial.println();
f.getName(thefilename, sizeof(thefilename)-1);
f.close();
if (strstr(thefilename, ".gif") || strstr(thefilename, ".GIF")) {
// found a gif mebe!
if (gif.open(thefilename, GIFOpenFile, GIFCloseFile, GIFReadFile, GIFSeekFile, GIFDraw)) {
GIFINFO gi;
Serial.printf("Successfully opened GIF %s; Canvas size = %d x %d\n", thefilename, gif.getCanvasWidth(), gif.getCanvasHeight());
if (gif.getInfo(&gi)) {
Serial.printf("frame count: %d\n", gi.iFrameCount);
Serial.printf("duration: %d ms\n", gi.iDuration);
Serial.printf("max delay: %d ms\n", gi.iMaxDelay);
Serial.printf("min delay: %d ms\n", gi.iMinDelay);
}
// play thru n times
for (int loops=0; loops<NUM_LOOPS; loops++) {
while (gif.playFrame(true, NULL));
gif.reset();
}
gif.close();
} else {
Serial.printf("Error opening file %s = %d\n", thefilename, gif.getLastError());
}
}
}
root.close();
}
Code: Select all
Using library AnimatedGIF at version 1.4.7 in folder: /home/sklarm/Arduino/libraries/AnimatedGIF
Using library SdFat_-_Adafruit_Fork at version 2.2.1 in folder: /home/sklarm/Arduino/libraries/SdFat_-_Adafruit_Fork
Using library SPI at version 1.0 in folder: /home/sklarm/.arduino15/packages/rp2040/hardware/rp2040/2.6.4/libraries/SPI
Using library Adafruit_SPIFlash at version 4.0.0 in folder: /home/sklarm/Arduino/libraries/Adafruit_SPIFlash
Using library Adafruit_GFX_Library at version 1.11.3 in folder: /home/sklarm/Arduino/libraries/Adafruit_GFX_Library
Using library Adafruit_BusIO at version 1.14.0 in folder: /home/sklarm/Arduino/libraries/Adafruit_BusIO
Using library Wire at version 1.0 in folder: /home/sklarm/.arduino15/packages/rp2040/hardware/rp2040/2.6.4/libraries/Wire
Using library Adafruit_ST7735_and_ST7789_Library at version 1.9.3 in folder: /home/sklarm/Arduino/libraries/Adafruit_ST7735_and_ST7789_Library
Make sure you running the same versions of Arduino IDE, libraries and board support file.
Open the Arduino IDE serial console to start the animation after u/l.
If everything is identical then we will need to go over wiring again.
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
- Laila_Mestari
- Posts: 50
- Joined: Wed Oct 12, 2022 8:00 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
Ans should I update the libraries?
- mikeysklar
- Posts: 14165
- Joined: Mon Aug 01, 2016 8:10 pm
Re: RP2040 and TFT, Mini GIF player "Error opening file" (black screen)
Make sure you library versions match mine (I believe they are also all current) as I can confirm they are working well together.
u/l is short of upload.
u/l is short of upload.
Please be positive and constructive with your questions and comments.