mirror of
https://github.com/nacabaro/nacapet.git
synced 2026-10-01 15:41:37 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include "display.h"
|
||||
|
||||
void tft_initDisplay(TFT_eSPI &tft, uint16_t color) {
|
||||
tft.init();
|
||||
tft.setRotation(0);
|
||||
tft.fillScreen(TFT_RED);
|
||||
}
|
||||
|
||||
void tft_initScreenBuffer(TFT_eSprite &buffer, uint16_t color) {
|
||||
buffer.createSprite(SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
|
||||
buffer.fillSprite(color);
|
||||
buffer.setTextColor(TFT_BLACK);
|
||||
buffer.setTextSize(4);
|
||||
buffer.pushSprite(0, 0);
|
||||
}
|
||||
|
||||
void tft_drawBuffer(TFT_eSprite &buffer) {
|
||||
buffer.pushSprite(0, 0);
|
||||
}
|
||||
|
||||
void tft_clearBuffer(TFT_eSprite &buffer, uint16_t color) {
|
||||
buffer.fillSprite(color);
|
||||
}
|
||||
|
||||
void tft_drawCenteredText(TFT_eSprite &buffer, const char* text, int factor, int y) {
|
||||
size_t textWidth = strlen(text) * factor * 6;
|
||||
int x = (SCREEN_WIDTH - textWidth) / 2;
|
||||
buffer.setTextSize(factor);
|
||||
buffer.drawString(text, x, y);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef DISPLAY_H
|
||||
#define DISPLAY_H
|
||||
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
const int SCREEN_WIDTH = 240;
|
||||
const int SCREEN_HEIGHT = 240;
|
||||
|
||||
void tft_initDisplay(TFT_eSPI &tft, uint16_t color = TFT_WHITE);
|
||||
void tft_initScreenBuffer(TFT_eSprite &spr, uint16_t color = TFT_WHITE);
|
||||
void tft_drawBuffer(TFT_eSprite &buffer);
|
||||
void tft_clearBuffer(TFT_eSprite &buffer, uint16_t color = TFT_WHITE);
|
||||
void tft_drawCenteredText(TFT_eSprite &buffer, const char* text, int factor, int y);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user