Files
TFT_eSPI/examples/Generic/drawXBitmap/drawXBitmap.ino
Bodmer 4a52f5e685 Add ability to set ST7735 tab color from sketch
Use line is form:
tft.init(1);
or:
tft.init(INITR_REDTAB);
// Enumerated the configurations in library are:
#define INITR_GREENTAB
0x0
#define INITR_REDTAB    0x1
#define INITR_BLACKTAB  0x2
#define
INITR_GREENTAB2 0x3 // Use if you get random pixels on two edges of
green tab display
#define INITR_GREENTAB3 0x4 // Use if you get random
pixels on edge(s) of 128x128 screen
#define INITR_GREENTAB128 0x5 // Use
if you only get part of 128x128 screen in rotation 0 & 1
#define INITB
0xB
2018-05-25 22:48:22 +01:00

62 lines
1.8 KiB
C++

// Example sketch to demonstrate the drawing of X BitMap (XBM)
// format image onto the display.
// Information on the X BitMap (XBM) format can be found here:
// https://en.wikipedia.org/wiki/X_BitMap
// This example is part of the TFT_eSPI library:
// https://github.com/Bodmer/TFT_eSPI
// Created by Bodmer 23/04/18
#include "xbm.h" // Sketch tab header for xbm images
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke library
void setup()
{
tft.begin(); // Initialise the display
tft.fillScreen(TFT_BLACK); // Black screen fill
}
void loop()
{
// Example 1
// =========
// Random x and y coordinates
int x = random(tft.width() - logoWidth);
int y = random(tft.height() - logoHeight);
// Draw bitmap with top left corner at x,y with foreground only color
// Bits set to 1 plot as the defined color, bits set to 0 are not plotted
// x y xbm xbm width xbm height color
tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE);
delay(500);
// Erase old one by drawing over with background colour
tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK);
// Example 2
// =========
// New random x and y coordinates
x = random(tft.width() - logoWidth);
y = random(tft.height() - logoHeight);
// Draw bitmap with top left corner at x,y with foreground and background colors
// Bits set to 1 plot as the defined fg color, bits set to 0 are plotted as bg color
// x y xbm xbm width xbm height fg color bg color
tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE, TFT_RED);
delay(500);
// Erase old one by drawing over with background colour
tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK, TFT_BLACK);
}