PocketPutr/Desktop_Test/tft_handler.cpp

49 lines
1.2 KiB
C++

#include "GLOBALS.h"
#include "tft_handler.h"
void TFT_Handler::init(DISPLAY_STATE* display_state) {
_display_state = display_state;
tft.setColorDepth(16);
tft.init();
tft.setRotation(3);
tft.fillScreen(0x0000);
sprite.setColorDepth(16);
sprite.setPsram(true);
sprite.createSprite(480, 320);
}
void TFT_Handler::start_draw() {
tft.startWrite();
}
void TFT_Handler::end_draw() {
tft.endWrite();
}
void TFT_Handler::draw_box(short int x, short int y, short int size_x, short int size_y, int color) {
tft.fillRect(x, y, size_x, size_y, color);
}
void TFT_Handler::draw_rect(short int x, short int y, short int size_x, short int size_y, short int thickness, int color) {
tft.drawRect(x, y, size_x, size_y, color);
}
void TFT_Handler::draw_line(short int x1, short int y1, short int x2, short int y2, int color) {
tft.drawLine(x1, y1, x2, y2, color);
}
void TFT_Handler::draw_text(short int x, short int y, const std::string& str, int color, short int size) {
tft.setTextColor(color);
tft.setTextSize(size);
tft.drawString(str.c_str(), x, y);
}
void TFT_Handler::fill_screen(int color) {
tft.fillScreen(color);
}
void TFT_Handler::push_sprite() {
sprite.pushSprite(0, 0);
}