I’m trying to use Adafruit GFX Canvas in St7735 0.96’’ 160x80 tft display with arduino nano. Without Canvas all work ok, but flickering on screen updates. With Canvas I see only garbage.
What I'm doing wrong? Please, help!
My code:
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include "FreeMonoBold24pt7b.h"
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
#define TFT_BLK 3
#define BRIGHTNESS 16 // tft backlight brightness 0-255
Adafruit_ST7735 tft = Adafruit_ST7735 (TFT_CS, TFT_DC, TFT_RST);
GFXcanvas1 canvas (160, 80);
void setup()
{
analogWrite (TFT_BLK, BRIGHTNESS);
tft.initR (INITR_MINI160x80);
tft.fillScreen (0x0000);
tft.setRotation (1);
canvas.setFont (&FreeMonoBold24pt7b); // Use custom font and
canvas.setTextSize(1);
}
void loop (void)
{
canvas.fillScreen (0x0000); // Clear canvas (not display)
canvas.setCursor (0, 24); // Pos. is BASE LINE when using fonts!
canvas.println ("10");
tft.drawBitmap (0, 24, canvas.getBuffer(), canvas.width(), canvas.height(), 0xFFFF, 0x0000);
delay(250);
canvas.fillScreen (0x0000); // Clear canvas (not display)
canvas.setCursor (0, 24); // Pos. is BASE LINE when using fonts!
canvas.println ("20");
tft.drawBitmap (0, 24, canvas.getBuffer(), canvas.width(), canvas.height(), 0xFFFF, 0x0000);
delay(250);
canvas.fillScreen (0x0000); // Clear canvas (not display)
canvas.setCursor (0, 24); // Pos. is BASE LINE when using fonts!
canvas.println ("30");
tft.drawBitmap (0, 24, canvas.getBuffer(), canvas.width(), canvas.height(), 0xFFFF, 0x0000);
delay(250);
}
