/* 2012 Copyright (c) Seeed Technology Inc. Authors: Albert.Miao & Loovee, Visweswara R (with initializtion code from TFT vendor) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef TFTv2_h #define TFTv2_h #include "stm32f446xx.h" #include "LCD.h" //Basic Colors #define RED 0xf800 #define GREEN 0x07e0 #define BLUE 0x001f #define BLACK 0x0000 #define YELLOW 0xffe0 #define WHITE 0xffff //Other Colors #define CYAN 0x07ff #define BRIGHT_RED 0xf810 #define GRAY1 0x8410 #define GRAY2 0x4208 //TFT resolution 240*320 #define MIN_X 0 #define MIN_Y 0 #define MAX_X 319 #define MAX_Y 239 #ifndef INT8U #define INT8U uint8_t #endif #ifndef INT16U #define INT16U uint16_t #endif extern INT8U simpleFont[][8]; #define FONT_SPACE 6 #define FONT_X 8 #define FONT_Y 8 typedef xy_t Point_t; class Button_t { public: // rechteckige Taste zeichnen, Position ist Zentrum, Dimension ist Breite (x) und Höhe (y) des Rechtecks, // LineColor Farbe des Rahmens und FillColor Füllfarbe void draw(Point_t Position, Point_t Dimension, INT16U LineColor, INT16U FillColor); // schreibt zentrierten Text in Taste void setText(const char* Text, int16_t Size, INT16U Color); // Variante für 2 Textzeilen void setText(const char* Text1, const char* Text2, int16_t Size, INT16U Color); // ändert Farbe der Umrandung entsprechend Parameter void hilite(INT16U Color); // setzt Farbe der Umrandung wieder zurück void unhilite(void); // übermalt Fläche der Taste mit übergebener Farbe void remove(INT16U Color); // prüft, ob übergebene Koordinaten im Feld der Taste liegen (z.B. ein Touch) int touch(Point_t Point); private: Point_t LeftTop, WidthHigh; // linke obere Ecke und Länge/Breite des Rechtecks INT16U LineColor; // normale Farbe der Umrandung }; class TFT { public: void setPixel(INT16U poX, INT16U poY,INT16U color); void drawChar(INT8U ascii,INT16U poX, INT16U poY,INT16U size, INT16U fgcolor); void drawString(char *string,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor); void drawString(const char *string,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor) { drawString((char*)string, poX, poY, size, fgcolor); } void fillRectangle(INT16U poX, INT16U poY, INT16U length, INT16U width, INT16U color); void drawLine(INT16U x0,INT16U y0,INT16U x1,INT16U y1,INT16U color); void drawVerticalLine(INT16U poX, INT16U poY,INT16U length,INT16U color); void drawHorizontalLine(INT16U poX, INT16U poY,INT16U length,INT16U color); void drawRectangle(INT16U poX, INT16U poY, INT16U length,INT16U width,INT16U color); void drawCircle(int poX, int poY, int r,INT16U color); void fillCircle(int poX, int poY, int r,INT16U color); void drawTriangle(int poX1, int poY1, int poX2, int poY2, int poX3, int poY3, INT16U color); INT8U drawNumber(long long_num,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor); INT8U drawFloat(float floatNumber,INT8U decimal,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor); INT8U drawFloat(float floatNumber,INT16U poX, INT16U poY,INT16U size,INT16U fgcolor); }; #endif /********************************************************************************************************* END FILE *********************************************************************************************************/