当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Arduino TFT - image()用法及代码示例


说明

将 SD 卡中的图像绘制到指定位置的屏幕上。

用法

screen.image(image, xPos, yPos);

参数

image:PImage 的命名实例。 xPos: int, x 轴上开始绘制的位置 yPos: int, y 轴上开始绘制的位置

返回

示例

// this example looks for a file named "logo.bmp"
//  on the SD card, and renders it to the screen
#include <Esplora.h>
#include <SPI.h>
#include <SD.h>
#include <TFT.h>            // Arduino TFT library

#define SD_CS    8  // Chip select line for SD card in Esplora

PImage logo;

void setup() {
  // initialize the screen
  EsploraTFT.begin();
  // initialize the SD card
  SD.begin(SD_CS);
  // set the background the black
  EsploraTFT.background(0, 0, 0);

  // load the image into the named instance of PImage
  logo = EsploraTFT.loadImage("arduino.bmp");

  // if it is a valid image file, turn the Esplora's LED green
   if (logo.isValid()) {
       Esplora.writeGreen(255);
  }
  else{
  // if it is not valid, turn the LED red
    Esplora.writeRed(255);
  }

  // draw the image on the screen starting at the top left corner
  EsploraTFT.image(logo, 0, 0);

}

void loop() {

}

相关用法


注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 TFT - image()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。