Go Down

Topic: Using arrays to select files? (Read 229 times) previous topic - next topic

bfata

Hi everyone! Sorry for the n00b question, but I'm really struggling a lot with this project and don't know where to turn.

I'm working on a project where, when you hit a button, an LCD screen displays different .bmp images. I have the screen up and running, but I'm confused about using arrays to select from a group of images. I want the button to grab a random image from an array of .bmp files (lets say 5).

In the end, I'd like to have 5 buttons, each accessing 5 different arrays of image names, so that they can be displayed on the screen. I'm using the Adafruit 2.2" TFT LCD screen with MicroSD Card Reader, so the images are stored on a MicroSD card. I'm also using the AdafruitHX8340B Library as well as the Adafruit_GFX library to control the LCD.

Your help is greatly appreciated.

PaulS

Quote
Your help is greatly appreciated.

What, exactly, do you need help with?

Can you get a list of files on the SD card? Can you count them? Can you generate a random number? Can you tell when a switch has been pressed?

Why one of 5 images, if there are more than 5 on the card? How will the 5 be chosen?

Your requirements are not well defined.

dhenry

You don't need five *FILE open concurrently: all you need is to have one *FILE open pointing to one of those 5 files. Presummably the file names are known at run time so you can store their file names into an array (of unsigned char *). Once a button is pressed, you randomly pick up one of those five strings and use that to open a *FILE to retrieve the image data. At the end of it, you close the *FILE.

You probably want to remember the previous file name so that you don't pick it up again as the next file.

PaulS


majenko

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Go Up