Commit 505ca81a authored by Bodmer's avatar Bodmer

Complete viewport update

parent ee91f723
......@@ -359,9 +359,13 @@ bool TFT_eSPI::getUnicodeIndex(uint16_t unicode, uint16_t *index)
// Expects file to be open
void TFT_eSPI::drawGlyph(uint16_t code)
{
uint16_t fg = textcolor;
uint16_t bg = textbgcolor;
if (code < 0x21)
{
if (code == 0x20) {
//if (fg!=bg) fillRect(cursor_x, cursor_y, gFont.spaceWidth, gFont.yAdvance, bg);
cursor_x += gFont.spaceWidth;
return;
}
......@@ -377,18 +381,15 @@ void TFT_eSPI::drawGlyph(uint16_t code)
uint16_t gNum = 0;
bool found = getUnicodeIndex(code, &gNum);
uint16_t fg = textcolor;
uint16_t bg = textbgcolor;
if (found)
{
if (textwrapX && (cursor_x + gWidth[gNum] + gdX[gNum] > _width))
if (textwrapX && (cursor_x + gWidth[gNum] + gdX[gNum] > width()))
{
cursor_y += gFont.yAdvance;
cursor_x = 0;
}
if (textwrapY && ((cursor_y + gFont.yAdvance) >= _height)) cursor_y = 0;
if (textwrapY && ((cursor_y + gFont.yAdvance) >= height())) cursor_y = 0;
if (cursor_x == 0) cursor_x -= gdX[gNum];
uint8_t* pbuffer = nullptr;
......@@ -402,15 +403,17 @@ void TFT_eSPI::drawGlyph(uint16_t code)
}
#endif
int16_t xs = 0;
uint32_t dl = 0;
uint8_t pixel;
int16_t cy = cursor_y + gFont.maxAscent - gdY[gNum];
int16_t cx = cursor_x + gdX[gNum];
int16_t xs = cx;
uint32_t dl = 0;
uint8_t pixel;
startWrite(); // Avoid slow ESP32 transaction overhead for every pixel
//if (fg!=bg) fillRect(cursor_x, cursor_y, gxAdvance[gNum], gFont.yAdvance, bg);
for (int y = 0; y < gHeight[gNum]; y++)
{
#ifdef FONT_FS_AVAILABLE
......
This diff is collapsed.
......@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_
#define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.3.0"
#define TFT_ESPI_VERSION "2.3.1"
/***************************************************************************************
** Section 1: Load required header files
......@@ -736,10 +736,13 @@ class TFT_eSPI : public Print {
int32_t addr_row, addr_col; // Window position - used to minimise window commands
// Viewport variables
int32_t _vpX, _vpY, _vpW, _vpH;
int32_t _vpX, _vpY, _vpW, _vpH; // Note: x start, y start, x end + 1, y end + 1
int32_t _xDatum;
int32_t _yDatum;
int32_t _xWidth;
int32_t _yHeight;
bool _vpDatum;
bool _vpOoB;
uint32_t fontsloaded; // Bit field of fonts loaded
......
......@@ -45,12 +45,11 @@ void loop() {
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4);
if (drawTime < 100) tft.drawString("Font 1 not loaded!", 0, 108, 2);
delay(4000);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
drawTime = millis();
drawTime = millis();
for (int i = 0; i < 1000; i++) {
tft.drawNumber(i, 0, 0, 2);
......@@ -60,12 +59,11 @@ void loop() {
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4);
if (drawTime < 200) tft.drawString("Font 2 not loaded!", 0, 108, 2);
delay(4000);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
drawTime = millis();
drawTime = millis();
for (int i = 0; i < 1000; i++) {
tft.drawNumber(i, 0, 0, 4);
......@@ -75,12 +73,11 @@ void loop() {
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4);
if (drawTime < 200) tft.drawString("Font 4 not loaded!", 0, 108, 2);
delay(4000);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
drawTime = millis();
drawTime = millis();
for (int i = 0; i < 1000; i++) {
yield(); tft.drawNumber(i, 0, 0, 6);
......@@ -90,12 +87,11 @@ void loop() {
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4);
if (drawTime < 200) tft.drawString("Font 6 not loaded!", 0, 108, 2);
delay(4000);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
drawTime = millis();
drawTime = millis();
for (int i = 0; i < 1000; i++) {
yield(); tft.drawNumber(i, 0, 0, 7);
......@@ -105,12 +101,11 @@ void loop() {
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.drawFloat(drawTime / 2890.0, 3, 0, 80, 4);
if (drawTime < 200) tft.drawString("Font 7 not loaded!", 0, 108, 2);
delay(4000);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
drawTime = millis();
drawTime = millis();
for (int i = 0; i < 100; i++) {
yield(); tft.drawNumber(i, 0, 0, 8);
......@@ -120,8 +115,7 @@ void loop() {
tft.setTextColor(TFT_RED, TFT_BLACK);
tft.drawFloat(drawTime / 190.0, 3, 0, 80, 4);
if (drawTime < 200) tft.drawString("Font 8 not loaded!", 0, 108, 2);
delay(4000);
}
......
......@@ -89,7 +89,7 @@ void setup() {
spr.setTextColor(TFT_WHITE, bg_color);
spr.setTextDatum(MC_DATUM);
spr.setTextPadding(spr_width);
spr.drawNumber(0, spr_width/2, 0);
spr.drawNumber(0, spr_width/2, spr.fontHeight()/2);
spr.pushSprite(DIAL_CENTRE_X - spr_width / 2, DIAL_CENTRE_Y - spr.fontHeight() / 2);
// Plot the label text
......@@ -203,7 +203,7 @@ void plotNeedle(int16_t angle, uint16_t ms_delay)
}
// Update the number at the centre of the dial
spr.drawNumber(old_angle+120, spr_width/2, 0);
spr.drawNumber(old_angle+120, spr_width/2, spr.fontHeight()/2);
spr.pushSprite(120 - spr_width / 2, 120 - spr.fontHeight() / 2);
// Slow needle down slightly as it approaches the new position
......
......@@ -132,7 +132,7 @@ void loop() {
for (int16_t angle = 30; angle <= 360; angle += 30)
{
spr.fillSprite(TFT_BLACK); // Clear the Sprite
spr.drawNumber(num, 20, 15, 4); // Plot number, in Sprite at 15,15 and with font 4
spr.drawNumber(num, 20, 15, 4); // Plot number, in Sprite at 20,15 and with font 4
spr.pushRotated(angle, TFT_BLACK); // Plot rotated Sprite, black being transparent
num++;
}
......@@ -143,7 +143,7 @@ void loop() {
for (int16_t angle = -90; angle < 270; angle += 30)
{
spr.fillSprite(TFT_BLACK); // Clear the Sprite
spr.drawNumber(angle+90, 15, 15, 4); // Plot number, in Sprite at 15,15 and with font 4
spr.drawNumber(angle+90, 20, 15, 4); // Plot number, in Sprite at 20,15 and with font 4
spr.pushRotated(angle, TFT_BLACK); // Plot rotated Sprite, black being transparent
num++;
}
......
{
"name": "TFT_eSPI",
"version": "2.3.0",
"version": "2.3.1",
"keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140",
"description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32",
"repository":
......
name=TFT_eSPI
version=2.3.0
version=2.3.1
author=Bodmer
maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment