Finalise viewport changes
This commit is contained in:
1 parent
505ca81a70
commit
b1f8cae069
10 files changed
+102
-52
No files matched your search
@@ -311,7 +311,7 @@ void loop()
|
||||
// It takes 30ms to calculate the 30,000 random numbers so this is not a true drawPixel speed test
|
||||
for (int i=0; i<10000; i++)
|
||||
{
|
||||
myGLCD.drawPixel(2+random(316), 16+random(209),random(0xFFFF));
|
||||
myGLCD.drawPixel(2+random(TFT_W - 3), 16+random(TFT_H - 31),random(0xFFFF));
|
||||
}
|
||||
#else
|
||||
// Draw 10,000 pixels to fill a 100x100 pixel box, better drawPixel speed test
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Viewport Demo
|
||||
|
||||
// See viewport_commands tab
|
||||
// See viewport_commands tab for details of functions available
|
||||
|
||||
// This example uses the viewport commands to create a "virtual TFT" within the
|
||||
// normal TFT display area. This allows a sketch written for a smaller screen to
|
||||
@@ -36,34 +36,6 @@ void setup() {
|
||||
tft.init();
|
||||
tft.setRotation(1);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
|
||||
/*
|
||||
tft.setViewport(VP_X, VP_Y, VP_W, VP_H); // By default the 0,0 coordinate datum is
|
||||
// moved to top left corner of viewport
|
||||
// Note: tft.width() and tft.height() now return viewport size
|
||||
// Other command options:
|
||||
//tft.setViewport(VP_X, VP_Y, VP_W, VP_H, true); // Explicitly set datum to viewport corner
|
||||
|
||||
//tft.setViewport(VP_X, VP_Y, VP_W, VP_H, false); // Create viewport but datum stays at TFT corner
|
||||
// Note: tft.width() and tft.height() now return TFT size
|
||||
|
||||
w = tft.getViewportWidth(); // Always returns width of viewport
|
||||
h = tft.getViewportHeight(); // Always returns height of viewport
|
||||
|
||||
tft.frameViewport(TFT_GREEN, -2); // Draw a rectangle of width 2 outside (negative width) viewport
|
||||
tft.frameViewport(TFT_RED, 10); // Draw a rectangle of width 10 inside (positive width) viewport
|
||||
|
||||
// tft.resetViewport(); // Command to reset viewport to "normal" full TFT screen
|
||||
// Graphics will not be drawn to the TFT outside a viewport until
|
||||
// this command is used!
|
||||
|
||||
// tft.setRotation(2); // Using setRotation rotates the whole TFT screen it does not just
|
||||
// rotate the viewport (this is a possible future enhancement).
|
||||
// Redraw all graphics after a rotation since some TFT's do not
|
||||
// re-map the TFT graphics RAM to the screen pixels as expected.
|
||||
delay(1000);
|
||||
*/
|
||||
}
|
||||
|
||||
void loop()
|
||||
@@ -140,5 +112,5 @@ void plotBox(void)
|
||||
tft.drawRect(0,0, 40,40, TFT_BLUE);
|
||||
tft.setTextDatum(MC_DATUM);
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.drawNumber( random(100), 20, 23, 4);
|
||||
tft.drawNumber( random(100), 20, 23, 4); // Number in font 4
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
// Create a viewport at TFT screen coordinated X,y of width W and height H
|
||||
// Create a viewport at TFT screen coordinated X,Y of width W and height H
|
||||
tft.setViewport(X, Y, W, H); // By default the 0,0 coordinate datum is moved to top left
|
||||
// corner of viewport
|
||||
// Note: tft.width() and tft.height() now return viewport size!
|
||||
@@ -10,11 +10,14 @@
|
||||
// To create a viewport that keeps the coordinate datum at top left of TFT, use false parameter
|
||||
tft.setViewport(VP_X, VP_Y, VP_W, VP_H, false); // Note: tft.width() and tft.height() return TFT size!
|
||||
|
||||
// To get width of viewport
|
||||
uint16_t w = tft.getViewportWidth(); // Always returns width of viewport
|
||||
|
||||
// To get height of viewport
|
||||
uint16_t h = tft.getViewportHeight(); // Always returns height of viewport
|
||||
// To get viewport x, y coordinates, width, height and datum position flag
|
||||
int32_t x = tft.getViewportX(); // Always returns viewport x coordinate relative to screen left edge
|
||||
int32_t y = tft.getViewportY(void); // Always returns viewport y coordinate relative to screen top edge
|
||||
int32_t w = tft.getViewportWidth(); // Always returns width of viewport
|
||||
int32_t h = tft.getViewportHeight(); // Always returns height of viewport
|
||||
bool f = tft.getViewportDatum(); // Datum of the viewport (false = TFT corner, true = viewport corner)
|
||||
// To check if all or part of an area is in the viewport
|
||||
checkViewport(x, y, w, h); // Retruns "true" if all or part of area is in viewport
|
||||
|
||||
// To draw a rectangular frame outside viewport of width W (when W is negative)
|
||||
tft.frameViewport(TFT_RED, -W); // Note setting the width to a large negative value will clear the screen
|
||||
@@ -29,5 +32,9 @@
|
||||
// this command is used! ( The exception is using the frameViewport command
|
||||
// detailed above with a negative width.)
|
||||
|
||||
|
||||
*/
|
||||
// Note:
|
||||
// Using setRotation rotates the whole TFT screen it does not just
|
||||
// rotate the viewport (this is a possible future enhancement).
|
||||
// Redraw all graphics after a rotation since some TFT's do not
|
||||
// re-map the TFT graphics RAM to the screen pixels as expected.
|
||||
*/
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This sketch demonstrates the Adafruit graphicstest sketch running in a
|
||||
viewport (aka window) within the TFT screen area. To do this line 37 has
|
||||
been added. Line 38 outlines the viewport.
|
||||
been added. Line 39 draws a frame outside the viewport.
|
||||
|
||||
This sketch uses the GLCD font (font 1) only.
|
||||
|
||||
@@ -35,6 +35,7 @@ void setup() {
|
||||
|
||||
// Create a viewport 220 x 300 pixels
|
||||
tft.setViewport(10,10,220,300);
|
||||
|
||||
tft.frameViewport(TFT_RED, -1); // 1 pixel wide frame around viewport
|
||||
|
||||
yield(); Serial.println(F("Benchmark Time (microseconds)"));
|
||||
|
||||
Reference in new issue
Block a user