我有一个 ESP32-S3-Matrix,我已将其编程为显示数字 99 并在按下按钮时倒计时至 0。矩阵使用默认字体正确显示数字 99,但它被切断了显示(太大了)。
我想将字体交换为 TomThumb.h,因为它很小(只有 5x7)并且可以解决问题,但每当我加载此字体时,LED 就不再出现。没有报告错误或警告。 GFX 中的字体似乎不起作用。仅默认。有什么想法吗?
相关代码如下:
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Fonts/TomThumb.h> // If this is commented out, display works fine. I have also tried other fonts.
// Define the matrix size and pin
#define MATRIX_WIDTH 8
#define MATRIX_HEIGHT 8
#define MATRIX_PIN 14 // Change this to your data pin
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_PIN,
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE,
NEO_RGB + NEO_KHZ800);
int number = 99;
void setup() {
matrix.begin();
matrix.setBrightness(1); // Kept to 1 so it doesn't burn my eyes out
matrix.setTextWrap(false);
matrix.setFont(&TomThumb); // If this is commented out, display works fine.
matrix.setTextColor(matrix.Color(255, 0, 0)); // Red color for digits
// Set up the boot button as an input
pinMode(0, INPUT_PULLUP); // Assuming the boot button is connected to GPIO 0
}
...
谢谢!
在这里回答我自己的问题。问题是根据字体基线调整光标偏移。默认基线位于顶部,因此 0,0 工作正常,但其他基线与底部对齐,这意味着您需要将其“推”回显示屏上。谢谢!