Pages: [1]   Go Down
Author Topic: Using arrays to select files?  (Read 219 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 2
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50890
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50890
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@dhenry:
What is a *FILE?
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@dhenry:
What is a *FILE?
The Messier catalog?
Logged

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

Pages: [1]   Go Up
Jump to: