#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); sprite.fillScreen(0x0000); } void TFT_Handler::draw_box(short int x, short int y, short int size_x, short int size_y, int color) { sprite.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) { sprite.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) { sprite.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) { sprite.setTextColor(color); sprite.setTextSize(size); sprite.drawString(str.c_str(), x, y); } void TFT_Handler::draw_button(short x, short y, short size_x, short size_y, int color, bool pressed, std::string str) { if (pressed) { sprite.fillRect(x - 2, y - 2, size_x + 2, size_y + 2, COL_BLACK); sprite.fillRect(x - 1, y - 1, size_x + 1, size_y + 1, COL_DARK_GREY); sprite.fillRect(x + 2, y + 2, size_x + 2, size_y + 2, COL_WHITE); sprite.fillRect(x, y, size_x, size_y, color); sprite.setTextColor(COL_BLACK); sprite.setTextSize(1); sprite.drawString(str.c_str(), x, y); } else { sprite.fillRect(x, y, size_x, size_y, color); sprite.fillRect(x, y, size_x, size_y, color); sprite.fillRect(x, y, size_x, size_y, color); } } void TFT_Handler::fill_screen(int color) { sprite.fillScreen(color); } void TFT_Handler::push_sprite() { sprite.pushSprite(0, 0); }