Hardware Reference
In-Depth Information
Most modules and shields that use the ST7735 controller also have an SD-card
slot that can read micro-SD cards. They are an excellent way to store large amounts
of data like images. Because SD-card controllers use SPI and the ST7735 device
is also an SPI device, it is easy to combine the two; they both share the MOSI/
MISO/CLK lines. All that is needed is another slave select pin.
CROSS REFERENCE SPI is explained in more detail in Chapter 7. SD card
usage is explained in Chapter 12.
To load an image directly from an SD card, use loadImage() :
PImage image = screen.loadImage(name);
The name parameter is the i lename to be loaded from an SD card. This
function returns a PImage object. A PImage object is the base class used to draw
bitmap images onto a TFT screen. It contains the image data and can be used
to write an image to a specii c place on the screen. When this object has been
loaded, you can retrieve information about it. You can use two functions to get
the image width and height, and another function verii es the validity of the data.
width = image.width();
height = image.height();
These two functions are called on the PImage object, and both functions return
an int , corresponding to the width and height of the image in pixels.
To verify that the PImage object is valid, use isValid() :
result = image.isValid();
This function, called on the PImage object, returns a boolean; true if the image
is valid and false if there is a problem.
To display an image at specii c coordinates, use image() :
screen.image(image, xPos, yPos);
The image parameter is the PImage object created when using the loadIm-
age() function. The xPos and yPos parameters are the coordinates where the
top-left corner of the image will be displayed.
Example Application
In the previous chapter, you created a system capable of data logging the level
of sunlight. It is time to take that example a little further and to create a visual
data logger application. Just how much light is there outside? And what is the
temperature? Now you can put that together visually on a TFT screen.
 
Search WWH ::




Custom Search