Skip to content

Commit

Permalink
Update for Pico W, update sprite smooth font rendering
Browse files Browse the repository at this point in the history
Update example for Pico W

If a background colour is not specified for smooth font rendering in a sprite then read the sprite background pixel colour.
  • Loading branch information
Bodmer committed Jul 22, 2022
1 parent ec23732 commit cc9787d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Extensions/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,8 @@ void TFT_eSprite::drawGlyph(uint16_t code)
{
uint16_t fg = textcolor;
uint16_t bg = textbgcolor;
bool getBG = false;
if (fg == bg) getBG = true;

// Check if cursor has moved
if (last_cursor_x != cursor_x)
Expand Down Expand Up @@ -2551,7 +2553,7 @@ void TFT_eSprite::drawGlyph(uint16_t code)
else drawFastHLine( fxs, y + cy, fl, fg);
fl = 0;
}
if (getColor) bg = getColor(x + cx, y + cy);
if (getBG) bg = readPixel(x + cx, y + cy);
drawPixel(x + cx, y + cy, alphaBlend(pixel, fg, bg));
}
else
Expand Down
2 changes: 1 addition & 1 deletion TFT_eSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_
#define _TFT_eSPIH_

#define TFT_ESPI_VERSION "2.4.73"
#define TFT_ESPI_VERSION "2.4.74"

// Bit level feature flags
// Bit 0 set: viewport capability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void renderFace(float t) {
face.setTextDatum(MC_DATUM);

// The background colour will be read during the character rendering
face.setTextColor(CLOCK_FG);
face.setTextColor(CLOCK_FG, CLOCK_BG);

// Text offset adjustment
constexpr uint32_t dialOffset = CLOCK_R - 10;
Expand All @@ -143,7 +143,7 @@ static void renderFace(float t) {
}

// Add text (could be digital time...)
face.setTextColor(LABEL_FG);
face.setTextColor(LABEL_FG, CLOCK_BG);
face.drawString("TFT_eSPI", CLOCK_R, CLOCK_R * 0.75);

// Draw minute hand
Expand Down
2 changes: 1 addition & 1 deletion examples/Smooth Graphics/Anti-aliased_Clock/NTP_Time.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#ifdef ESP8266
// ESP8266
#include <ESP8266WiFi.h>
#elif defined(ARDUINO_ARCH_MBED) || defined(ARDUINO_ARCH_RP2040)
#elif (defined(ARDUINO_ARCH_MBED) || defined(ARDUINO_ARCH_RP2040)) && !defined(ARDUINO_RASPBERRY_PI_PICO_W)
// RP2040 Nano Connect
#include <WiFiNINA.h>
#else
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TFT_eSPI",
"version": "2.4.73",
"version": "2.4.74",
"keywords": "Arduino, tft, display, ttgo, LilyPi, WT32-SC01, ePaper, display, Pico, RP2040 Nano Connect, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, ST7796, RM68140, SSD1351, SSD1963, ILI9225, HX8357D, GC9A01, R61581",
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, RP2040, ESP8266, ESP32 and STM32",
"repository":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TFT_eSPI
version=2.4.73
version=2.4.74
author=Bodmer
maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32
Expand Down

0 comments on commit cc9787d

Please sign in to comment.