Update for spelling etc. in comments!

This commit is contained in:
Bodmer committed 2023-12-07 20:35:59 +00:00
1 parent aefcf5af63
commit d506a3c49d
197 files changed
+1006 -757

No files matched your search

@@ -70,7 +70,7 @@ void setup() {
TJpgDec.setSwapBytes(true);
// The jpeg decoder must be given the exact name of the rendering function above
TJpgDec.setCallback(tft_output);
TJpgDec.setcallback(tft_output);
tft.begin();
tft.setRotation(0);
@@ -128,7 +128,7 @@ void loop() {
// =======================================================================================
void createNeedle(void)
{
needle.setColorDepth(16);
needle.setcolorDepth(16);
needle.createSprite(NEEDLE_WIDTH, NEEDLE_LENGTH); // create the needle Sprite
needle.fillSprite(TFT_BLACK); // Fill with black
@@ -12,7 +12,7 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 1 bit Sprite occupies (width * height)/8 bytes in RAM. So,
A 1-bit Sprite occupies (width * height)/8 bytes in RAM. So,
for example, a 320 x 240 pixel Sprite occupies 9600 bytes.
*/
// A new setBitmapColor(fg_color, bg_color) function allows
@@ -76,7 +76,7 @@ void drawStar(int x, int y, int star_color)
// Create an 1 bit (2 colour) sprite 70x80 pixels (uses 70*80/8 = 700 bytes of RAM)
// Colour depths of 8 bits per pixel and 16 bits are also supported.
img.setColorDepth(BITS_PER_PIXEL); // Set colour depth first
img.setcolorDepth(BITS_PER_PIXEL); // Set colour depth first
img.createSprite(70, 80); // then create the sprite
// Fill Sprite with the colour that will be defined later as "transparent"
@@ -34,7 +34,7 @@ void setup(void)
tft.setRotation(0);
tft.fillScreen(TFT_BLUE);
img.setColorDepth(COLOR_DEPTH);
img.setcolorDepth(COLOR_DEPTH);
img.createSprite(RADIUS*2+1, RADIUS*2+1);
img.fillSprite(TFT_BLACK);
}
@@ -68,14 +68,14 @@ void loop() {
void yinyang(int x, int y, int start_angle, int r)
{
int x1 = 0; // getCoord() will update these
int x1 = 0; // getcoord() will update these
int y1 = 0;
getCoord(x, y, &x1, &y1, r/2, start_angle); // Get x1 ,y1
getcoord(x, y, &x1, &y1, r/2, start_angle); // Get x1 ,y1
img.fillCircle( x1, y1, r/2, TFT_WHITE);
img.fillCircle( x1, y1, r/8, TFT_BLACK);
getCoord(x, y, &x1, &y1, r/2, start_angle + 180);
getcoord(x, y, &x1, &y1, r/2, start_angle + 180);
img.fillCircle( x1, y1, r/2, TFT_BLACK);
img.fillCircle( x1, y1, r/8, TFT_WHITE);
@@ -87,7 +87,7 @@ void yinyang(int x, int y, int start_angle, int r)
// =========================================================================
// Coordinates are returned to caller via the xp and yp pointers
#define RAD2DEG 0.0174532925
void getCoord(int x, int y, int *xp, int *yp, int r, int a)
void getcoord(int x, int y, int *xp, int *yp, int r, int a)
{
float sx1 = cos( (a-90) * RAD2DEG );
float sy1 = sin( (a-90) * RAD2DEG );
+4 -4
View File
@@ -90,7 +90,7 @@ void loop() {
// =========================================================================
// Coordinates are returned to caller via the xp and yp pointers
#define DEG2RAD 0.0174532925
void getCoord(int x, int y, int *xp, int *yp, int r, float a)
void getcoord(int x, int y, int *xp, int *yp, int r, float a)
{
float sx1 = cos( -a * DEG2RAD );
float sy1 = sin( -a * DEG2RAD );
@@ -131,10 +131,10 @@ int plot_planets(void)
{
ang = Astronomy_EclipticLongitude(body[i], astro_time);
int x1 = 0; // getCoord() will update these
int x1 = 0; // getcoord() will update these
int y1 = 0;
getCoord(0, 0, &x1, &y1, i * 28, ang.angle); // Get x1 ,y1
getcoord(0, 0, &x1, &y1, i * 28, ang.angle); // Get x1 ,y1
img.fillSprite(TFT_TRANSPARENT);
img.fillCircle(9, 9, 9, TFT_BLACK);
@@ -149,7 +149,7 @@ int plot_planets(void)
int xm = 0;
int ym = 0;
getCoord(x1, y1, &xm, &ym, 15, 180 + ang.angle + mang.angle); // Get x1 ,y1
getcoord(x1, y1, &xm, &ym, 15, 180 + ang.angle + mang.angle); // Get x1 ,y1
img.fillSprite(TFT_TRANSPARENT);
img.fillCircle(9, 9, 7, TFT_BLACK);
@@ -10,7 +10,7 @@
// screen very simple. The rotation is clockwise with increasing angle. The angle is in
// degrees, an angle of 0 means no Sprite rotation.
// The pushRotated() function works with 1, 4, 8 and 16 bit per pixel (bpp) Sprites.
// The pushRotated() function works with 1, 4, 8 and 16-bit per pixel (bpp) Sprites.
// The original Sprite is unchanged so can be plotted again at a different angle.
@@ -20,7 +20,7 @@
// For 1 bpp Sprites the foreground and background colours are defined with the
// function spr.setBitmapColor(foregroundColor, backgroundColor).
// For 4 bpp Sprites the colour map index is used instead of the 16 bit colour
// For 4 bpp Sprites the colour map index is used instead of the 16-bit colour
// e.g. spr.setTextColor(5); // Green text in default colour map
// See "Transparent_Sprite_Demo_4bit" example for default colour map details
@@ -59,7 +59,7 @@ void loop() {
drawX(xw, yh); // Show where screen pivot is
// Create the Sprite
spr.setColorDepth(8); // Create an 8bpp Sprite of 60x30 pixels
spr.setcolorDepth(8); // Create an 8bpp Sprite of 60x30 pixels
spr.createSprite(64, 30); // 8bpp requires 64 * 30 = 1920 bytes
spr.setPivot(32, 55); // Set pivot relative to top left corner of Sprite
spr.fillSprite(TFT_BLACK); // Fill the Sprite with black
@@ -120,7 +120,7 @@ void loop() {
spr.deleteSprite();
spr.setColorDepth(8); // Create a 8bpp Sprite
spr.setcolorDepth(8); // Create a 8bpp Sprite
spr.createSprite(40, 30); // Create a new Sprite 40x30
spr.setPivot(20, 70); // Set Sprite pivot at 20,80
@@ -14,7 +14,7 @@
// The rotation angle is in degrees, an angle of 0 means no Sprite rotation.
// The pushRotated() function works with 1, 8 and 16 bit per pixel (bpp) Sprites.
// The pushRotated() function works with 1, 8 and 16-bit per pixel (bpp) Sprites.
// For 1 bpp Sprites the foreground and background colours are defined with the
// member function setBitmapColor(foregroundColor, backgroundColor).
@@ -99,7 +99,7 @@ void loop() {
void createDialScale(int16_t start_angle, int16_t end_angle, int16_t increment)
{
// Create the dial Sprite
dial.setColorDepth(8); // Size is odd (i.e. 91) so there is a centre pixel at 45,45
dial.setcolorDepth(8); // Size is odd (i.e. 91) so there is a centre pixel at 45,45
dial.createSprite(91, 91); // 8bpp requires 91 * 91 = 8281 bytes
dial.setPivot(45, 45); // set pivot in middle of dial Sprite
@@ -158,7 +158,7 @@ void plotDial(int16_t x, int16_t y, int16_t angle, String label, uint16_t val)
void createNeedle(void)
{
needle.setColorDepth(8);
needle.setcolorDepth(8);
needle.createSprite(11, 49); // create the needle Sprite 11 pixels wide by 49 high
needle.fillSprite(TFT_BLACK); // Fill with black
@@ -80,7 +80,7 @@ void setup()
// Send jpeg info to serial port
fex.jpegInfo("/Eye_80x64.jpg");
// Draw jpeg iamge in Sprite spr at 0,0
// Draw jpeg image in Sprite spr at 0,0
fex.drawJpeg("/Eye_80x64.jpg", 0 , 0, &spr);
}
@@ -105,7 +105,7 @@ void loop()
delay(1000);
// Push copies of Sprite rotated through increasing angles 0-360 degrees
// with 45 fegree increments
// with 45 degree increments
for (int16_t angle = 0; angle <= 360; angle += 45) {
spr.pushRotated(angle);
delay(500);
@@ -9,7 +9,7 @@
#########################################################################
*/
// Specify sprite 160 x 128 pixels (needs 40Kbytes of RAM for 16 bit colour)
// Specify sprite 160 x 128 pixels (needs 40Kbytes of RAM for 16-bit colour)
#define IWIDTH 160
#define IHEIGHT 128
@@ -31,7 +31,7 @@ void setup(void) {
tft.fillScreen(TFT_BLUE);
//img.setColorDepth(8); // Optionally set depth to 8 to halve RAM use
//img.setcolorDepth(8); // Optionally set depth to 8 to halve RAM use
img.createSprite(IWIDTH, IHEIGHT);
img.fillSprite(TFT_BLACK);
}
+4 -4
View File
@@ -14,12 +14,12 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 16 bit Sprite occupies (2 * width * height) bytes in RAM.
A 16-bit Sprite occupies (2 * width * height) bytes in RAM.
On a ESP8266 Sprite sizes up to 126 x 160 can be accommodated,
this size requires 40kBytes of RAM for a 16 bit colour depth.
this size requires 40kBytes of RAM for a 16-bit colour depth.
When 8 bit colour depth sprites are created they occupy
When 8-bit colour depth sprites are created they occupy
(width * height) bytes in RAM, so larger sprites can be
created, or the RAM required is halved.
@@ -47,7 +47,7 @@ void setup()
tft.init();
// Optionally set colour depth to 8 or 16 bits, default is 16 if not specified
// spr.setColorDepth(8);
// spr.setcolorDepth(8);
// Create a sprite of defined size
spr.createSprite(WIDTH, HEIGHT);
@@ -1,9 +1,9 @@
/*
Sketch to show how a 4 bit Sprite is created, how to draw pixels
Sketch to show how a 4-bit Sprite is created, how to draw pixels
and text within the Sprite and then push the Sprite onto
the display screen.
The advantage of 4 bit sprites is:
The advantage of 4-bit sprites is:
1. Small memory footprint
2. Any set of 16 colours can be specified
3. Colours can be changed without redrawing in Sprite
@@ -21,7 +21,7 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 4 bit Sprite occupies (width * height)/2 bytes in RAM.
A 4-bit Sprite occupies (width * height)/2 bytes in RAM.
*/
@@ -50,7 +50,7 @@ void setup()
tft.init();
// Set the sprite colour depth to 4
spr.setColorDepth(4);
spr.setcolorDepth(4);
// Create a sprite of defined size
spr.createSprite(WIDTH, HEIGHT);
@@ -64,7 +64,7 @@ void loop(void)
// Fill the whole sprite with color 0 (Sprite is in memory so not visible yet)
spr.fillSprite(0);
// create a color map with known colors (16 maximum for 4 bit Sprite
// create a color map with known colors (16 maximum for 4-bit Sprite
uint16_t cmap[16];
@@ -14,12 +14,12 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 16 bit Sprite occupies (2 * width * height) bytes in RAM.
A 16-bit Sprite occupies (2 * width * height) bytes in RAM.
On a ESP8266 Sprite sizes up to 126 x 160 can be accommodated,
this size requires 40kBytes of RAM for a 16 bit color depth.
this size requires 40kBytes of RAM for a 16-bit color depth.
When 8 bit color depth sprites are created they occupy
When 8-bit color depth sprites are created they occupy
(width * height) bytes in RAM, so larger sprites can be
created, or the RAM required is halved.
@@ -39,7 +39,7 @@ TFT_eSPI tft = TFT_eSPI(); // Declare object "tft"
TFT_eSprite spr = TFT_eSprite(&tft); // Declare Sprite object "spr" with pointer to "tft" object
byte red = 31; // Red is the top 5 bits of a 16 bit colour value
byte red = 31; // Red is the top 5 bits of a 16-bit colour value
byte green = 0;// Green is the middle 6 bits
byte blue = 0; // Blue is the bottom 5 bits
byte state = 0;
@@ -59,7 +59,7 @@ void setup()
// Initialise the TFT registers
tft.init();
spr.setColorDepth(4);
spr.setcolorDepth(4);
// Create a sprite of defined size
spr.createSprite(WIDTH, HEIGHT);
@@ -99,7 +99,7 @@ void loop(void)
}
// #########################################################################
// Return a 16 bit rainbow colour
// Return a 16-bit rainbow colour
// #########################################################################
unsigned int rainbow()
{
@@ -14,9 +14,9 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 16 bit Sprite occupies (2 * width * height) bytes in RAM.
A 16-bit Sprite occupies (2 * width * height) bytes in RAM.
An 8 bit Sprite occupies (width * height) bytes in RAM.
An 8-bit Sprite occupies (width * height) bytes in RAM.
*/
@@ -41,7 +41,7 @@ void setup() {
tft.fillScreen(TFT_BLACK);
// Create a sprite for the graph
graph1.setColorDepth(8);
graph1.setcolorDepth(8);
graph1.createSprite(128, 61);
graph1.fillSprite(TFT_BLUE); // Note: Sprite is filled with black when created
@@ -51,7 +51,7 @@ void setup() {
//graph1.setScrollRect(64, 0, 64, 61, TFT_DARKGREY); // Try this line to change the graph scroll area
// Create a sprite for the scrolling numbers
stext1.setColorDepth(8);
stext1.setcolorDepth(8);
stext1.createSprite(32, 64);
stext1.fillSprite(TFT_BLUE); // Fill sprite with blue
stext1.setScrollRect(0, 0, 32, 64, TFT_BLUE); // here we set scroll gap fill color to blue
@@ -59,7 +59,7 @@ void setup() {
stext1.setTextDatum(BR_DATUM); // Bottom right coordinate datum
// Create a sprite for Hello World
stext2.setColorDepth(8);
stext2.setcolorDepth(8);
stext2.createSprite(80, 16);
stext2.fillSprite(TFT_DARKGREY);
stext2.setScrollRect(0, 0, 40, 16, TFT_DARKGREY); // Scroll the "Hello" in the first 40 pixels
@@ -126,7 +126,7 @@ void numberBox(int num, int x, int y)
// Fill it with black
img.fillSprite(TFT_BLACK);
// Draw a backgorund of 2 filled triangles
// Draw a background of 2 filled triangles
img.fillTriangle( 0, 0, 0, 49, 40, 25, TFT_RED);
img.fillTriangle( 79, 0, 79, 49, 40, 25, TFT_DARKGREEN);
@@ -150,14 +150,14 @@ void numberBox(int num, int x, int y)
// #########################################################################
// Return a 16 bit rainbow colour
// Return a 16-bit rainbow colour
// #########################################################################
unsigned int rainbow(byte value)
{
// Value is expected to be in range 0-127
// The value is converted to a spectrum colour from 0 = red through to 127 = blue
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
byte red = 0; // Red is the top 5 bits of a 16-bit colour value
byte green = 0;// Green is the middle 6 bits
byte blue = 0; // Blue is the bottom 5 bits
@@ -3,7 +3,7 @@
This sketch scrolls a 1 bit per pixel (1 bpp) Sprite.
In a 1 bit Sprite any colour except TFT_BLACK turns a pixel "ON"
In a 1-bit Sprite any colour except TFT_BLACK turns a pixel "ON"
TFT_BLACK turns a pixel "OFF".
ON and OFF pixels can be set to any two colours before
@@ -24,7 +24,7 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 1 bit Sprite occupies (width * height)/8 bytes in RAM.
A 1-bit Sprite occupies (width * height)/8 bytes in RAM.
*/
@@ -1,5 +1,5 @@
/*
Sketch to show scrolling of the graphics in 4 bit sprites.
Sketch to show scrolling of the graphics in 4-bit sprites.
Scrolling in this way moves the pixels in a defined rectangle
within the Sprite. By default the whole sprite is scrolled.
The gap left by scrolling is filled with a defined colour.
@@ -14,7 +14,7 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 4 bit Sprite occupies (width * height)/2 bytes in RAM.
A 4-bit Sprite occupies (width * height)/2 bytes in RAM.
*/
#include <TFT_eSPI.h>
@@ -1,7 +1,7 @@
/*
Display "flicker free" scrolling text and updating number
This sketch uses 8 bit colour sprites to save RAM.
This sketch uses 8-bit colour sprites to save RAM.
Example for library:
https://github.com/Bodmer/TFT_eSPI
@@ -16,15 +16,15 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 16 bit colour Sprite occupies (2 * width * height) bytes.
A 16-bit colour Sprite occupies (2 * width * height) bytes.
An 8 bit colour Sprite occupies (width * height) bytes.
An 8-bit colour Sprite occupies (width * height) bytes.
On a ESP8266, 16 bit Sprite sizes up to 128 x 160 can be accommodated,
On a ESP8266, 16-bit Sprite sizes up to 128 x 160 can be accommodated,
this size requires 128*160*2 bytes (40kBytes) of RAM.
This sketch sets the colour depth to 8 bits so larger sprites can be
created. 8 bit colour sprites use half amount of RAM. If the colour
created. 8-bit colour sprites use half amount of RAM. If the colour
depth is not specified then 16 bits is assumed.
You need to make the sprite small enough to fit, with RAM spare for
@@ -137,7 +137,7 @@ void numberBox(int num, int x, int y)
// Fill it with black
img.fillSprite(TFT_BLACK);
// Draw a backgorund of 2 filled triangles
// Draw a background of 2 filled triangles
img.fillTriangle( 0, 0, 0, 49, 40, 25, TFT_RED);
img.fillTriangle( 79, 0, 79, 49, 40, 25, TFT_DARKGREEN);
@@ -161,14 +161,14 @@ void numberBox(int num, int x, int y)
// #########################################################################
// Return a 16 bit rainbow colour
// Return a 16-bit rainbow colour
// #########################################################################
unsigned int rainbow(byte value)
{
// Value is expected to be in range 0-127
// The value is converted to a spectrum colour from 0 = red through to 127 = blue
byte red = 0; // Red is the top 5 bits of a 16 bit colour value
byte red = 0; // Red is the top 5 bits of a 16-bit colour value
byte green = 0;// Green is the middle 6 bits
byte blue = 0; // Blue is the bottom 5 bits
@@ -1,5 +1,5 @@
// This **ONLY** works for 1 bpp Sprites due to lack of bounds checking in the
// Sprite pushImage() function for 8 and 16 bit Sprites (it is on the TO DO list)
// Sprite pushImage() function for 8 and 16-bit Sprites (it is on the TO DO list)
// Wrapping scroll example by Bodmer for the TFT_eSPI library
@@ -12,12 +12,12 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 16 bit Sprite occupies (2 * width * height) bytes in RAM.
A 16-bit Sprite occupies (2 * width * height) bytes in RAM.
On a ESP8266 Sprite sizes up to 126 x 160 can be accommodated,
this size requires 40kBytes of RAM for a 16 bit colour depth.
this size requires 40kBytes of RAM for a 16-bit colour depth.
When 8 bit colour depth sprites are created they occupy
When 8-bit colour depth sprites are created they occupy
(width * height) bytes in RAM, so larger sprites can be
created, or the RAM required is halved.
*/
@@ -76,7 +76,7 @@ void loop() {
// #########################################################################
void drawStar(int x, int y, int star_color)
{
// Create an 8 bit sprite 70x 80 pixels (uses 5600 bytes of RAM)
// Create an 8-bit sprite 70x 80 pixels (uses 5600 bytes of RAM)
img.setColorDepth(8);
img.createSprite(70, 80);
@@ -113,7 +113,7 @@ void numberBox(int x, int y, float num )
#define IWIDTH 80
#define IHEIGHT 35
// Create a 8 bit sprite 80 pixels wide, 35 high (2800 bytes of RAM needed)
// Create a 8-bit sprite 80 pixels wide, 35 high (2800 bytes of RAM needed)
img.setColorDepth(8);
img.createSprite(IWIDTH, IHEIGHT);
@@ -1,5 +1,5 @@
/*
Sketch to show creation of a 4 bit sprite with a transparent
Sketch to show creation of a 4-bit sprite with a transparent
background, then plot it on the TFT. The palette setup and
palette update functions are also shown in this example.
@@ -13,11 +13,11 @@
any position. If there is sufficient RAM then the Sprite can
be the same size as the screen and used as a frame buffer.
A 4 bit Sprite occupies (width * height)/2 bytes in RAM.
A 4-bit Sprite occupies (width * height)/2 bytes in RAM.
For example the "star" 70x80 Sprite uses 2800 bytes.
*/
// This is the default palette for 4 bit colour sprites
// This is the default palette for 4-bit colour sprites
// which is built into the library. You can create your
// own palette (use a different array name!). The palette
// is captured and stored in RAM by the Sprite class so a
@@ -80,25 +80,25 @@ void loop() {
// spr.createPalette(default_4bit_palette, 12);
// After rendering a Sprite you can change the palette to increase the range of colours
// plotted to the screen to the full 16 bit set.
// plotted to the screen to the full 16-bit set.
// Change palette colour 11 to violet
spr.setPaletteColor(11, TFT_VIOLET);
uint16_t color15 = spr.getPaletteColor(15); // The 16 bit colour in a palette can be read back
uint16_t color15 = spr.getPaletteColor(15); // The 16-bit colour in a palette can be read back
// Draw 50 sprites containing a "transparent" colour
for (int i = 0; i < 50; i++)
{
int x = random(tft.width() - 70);
int y = random(tft.height() - 80);
int c = random(15); // Random colour 0-14 (4 bit index into color map). Leave 15 for transparent.
int c = random(15); // Random colour 0-14 (4-bit index into color map). Leave 15 for transparent.
drawStar(x, y, c);
}
delay(2000);
// Change the palette to a 16 bit grey scale colour
// Change the palette to a 16-bit grey scale colour
for (uint8_t i = 0; i < 16; i++) {
// (i*16+i) produces a value in range 0-255 for the RGB colours
// Red Green Blue