McMajan Library Pack  v 2.00
Improve your Arduino !
Ss_TFT.h
Go to the documentation of this file.
1 /*
2  Ss_TFT - Library V1.0 written by Stefano Smania
3  www.mcmajan.com
4  November 2013
5 
6  This library controls shield ITBD02-28 (http://imall.iteadstudio.com/development-platform/arduino/shields/im120417020.html)
7  It's compatible with Mega, Uno Arduino Boards directly or via shift register
8 
9  this work is based on original ITBD02 TFT LCD Module v1.2 Created by ITead studio. Alex, 7/2/2010. iteadstudio.com
10 
11 */
12 
13 
14 
15 
16 //#include <Ss_FastArduino.
17 #ifndef Ss_TFT_h
18 #define Ss_TFT_h
19 
20 
21 #include "Ss_McMajan_Config.h"
22 #include "Ss_BitmapFonts.h"
23 
24 
25 #define Ss_TFT_VERSION 1
26 
27 
28 /*
29 #ifndef USE_FASTARDUINO
30 //#warning FastArduino not defined inside Ss_TFT.h. I'LL USE DEFAULT FUNCTIONS!!
31  #define FastdigitalWrite(a,b) digitalWrite(a,b)
32  #define FastshiftOut(a,b,d) shiftOut(a,b,MSBFIRST,d)
33 #endif*/
34 
35 
36 
37 
38 /*#define Ss_LEFT 0
39 #define Ss_CENTER 2
40 #define Ss_RIGHT 3*/
41 
42 #define Touch_Limit
43 
44 #define Ss_PORTRAIT 0
45 #define Ss_LANDSCAPE 1
46 
47 #ifdef USE_HC595
48  #include <Ss_hc595.h>
49  //#warning HC595 MODALITY IS ACTIVE!!!
50 
51 
52 #ifndef _595_h
53 
54  #error You selected USE_HC595 without including hc595.h in you sketch!! YOU MUST INCLUDE hc595.h IN YOUR SKETCH.
55  #endif
56  #endif
57 
58 
59 #ifdef SS_USEDIRECTPORT
60  #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
61  #define LCD_RS_HIGH PORTF |= B0100000; // A5 HIGH
62  #define LCD_RS_LOW PORTF &= ~ B0100000; // A5 LOW
63  #define LCD_WR_HIGH PORTF |= B0010000; // A4 HIGH
64  #define LCD_WR_LOW PORTF &= ~ B0010000; // A4 LOW
65  #define LCD_CS_HIGH PORTF |= B0001000; // A3 HIGH
66  #define LCD_CS_LOW PORTF &= ~ B0001000; // A3 LOW
67  #else
68  #define LCD_RS_HIGH PORTC |= B0100000; // A5 HIGH
69  #define LCD_RS_LOW PORTC &= ~ B0100000; // A5 LOW
70  #define LCD_WR_HIGH PORTC |= B0010000; // A4 HIGH
71  #define LCD_WR_LOW PORTC &= ~ B0010000; // A4 LOW
72  #define LCD_CS_HIGH PORTC |= B0001000; // A3 HIGH
73  #define LCD_CS_LOW PORTC &= ~ B0001000; // A3 LOW
74  #endif
75 
76 #else
77  #define LCD_RS_HIGH FastdigitalWrite(LCD_RS,HIGH);
78  #define LCD_RS_LOW FastdigitalWrite(LCD_RS,LOW);
79  #define LCD_WR_HIGH FastdigitalWrite(LCD_WR,HIGH);
80  #define LCD_WR_LOW FastdigitalWrite(LCD_WR,LOW);
81  #define LCD_CS_HIGH FastdigitalWrite(LCD_CS,HIGH);
82  #define LCD_CS_LOW FastdigitalWrite(LCD_CS,LOW);
83 #endif
84 
85 
86 
87 //hc595 My595(12,11,13,2); // latch,clock,data,number of 74hc595
88 
89 
90 
91 
92 #define FPixel(x,y) SetXY(x, y, x, y);LCD_RS_HIGH LCD_Write8x2(ForeColor);
93 
94 
95 struct Font
96 {
105  unsigned short font_x_space;
106  unsigned short font_y_space;
107 };
108 
109 /*
110 UTouch(byte tclk, byte tcs, byte tdin, byte dout, byte irq); UTouch myTouch(A1,A3,A0,8,9);
111 */
112 class Ss_TFT
113 {
114  public:
115  int TouchRawX ,TouchRawY; // valore raw letto dal sensore (da 0 a 4095 - 12 bit)
116  int TouchRawCalibX ,TouchRawCalibSCR_XX; // valori X mini e massimi in raw del pannello
117  int TouchRawCalibY,TouchRawCalibSCR_YY; // come sopra ma sulla Y
118  int Tc_X,Tc_Y;
119 
120  Ss_TFT();
121 
122  #ifdef USE_HC595
123  #ifdef _595_h
124  hc595 * My595;
125  #endif
126  #endif
128  /*!It sets the display orientation. When you create the instance, the Display is sets to the portrait orientation. You can force this setting using SetLANDSCAPE or SetPORTRAIT. The coordinate 0,0 is on the right upper corner.*/
129  inline void SetLANDSCAPE() { bitSet(Service,1);SCR_WIDTH=SCR_HH;SCR_HEIGHT=SCR_WW;}
130  /*!It sets the display orientation. When you create the instance, the Display is sets to the portrait orientation. You can force this setting using SetLANDSCAPE or SetPORTRAIT. The coordinate 0,0 is on the right upper corner.*/
131  inline void SetPORTRAIT() { bitClear(Service,1);SCR_WIDTH=SCR_WW;SCR_HEIGHT=SCR_HH;}
132  void GetLandscapePoint(int *,int *);
133  void SetFont(uint8_t * font,uint8_t x=0,uint8_t y=0,uint8_t spx=0,uint8_t spy=0);
134  void SetFontOption(const uint8_t);
135 
136 
137 
138 
139  void CleanLCD(unsigned short rgb=0xFFFF);
140  void Initialize();
141 
142  void Touchpin(int tclk,int tcs,int tdin,int dout, int irq);
143  void TouchGetPoint();
144  bool TouchReady();
145  void TouchInitial();
146  unsigned int TouchGetX();
147  unsigned int TouchGetY();
148 
149  void RectFill(int sx, int sy, int ex, int ey,bool force=0);
150  void Rect(int,int,int,int);
151 
152  void Circle(int , int , int );
153  void CircleFill(int , int , int );
154  //void CircleFillE(int , int , int);
155  void plot4pointsE(int, int, int, int);
156 
157  void plot4points(int, int, int, int);
158 
159 
160 
161 
162  void CheckPoint(int*,int*);
163 
164 
165  void SetFcolor(uint8_t,uint8_t,uint8_t);
166  void SetBcolor(uint8_t,uint8_t,uint8_t);
167  void SetFBcolor(int FC,int BC);
168  //void Dispshowchar(int x, int y, char val);
169  void DisplayString(int x,int y, char *st,uint8_t options=0);
170 
171 
172  void d32s(short,short,uint8_t);
173  //void dds(short,short,uint8_t);
174  void DisplayChar(short,short,uint8_t,uint8_t option=0);
175  void DisplayBitmapChar(int,int,uint8_t,uint8_t option=0);
176 
177 
178  //void Linex(int,int, int , int );
179 
180 
181 
182 
183 
184 
185  void Pixel(int x, int y);
186  void Line(int sx,int sy, int ex, int ey);
187  void LineVS(int x,int y, int l);
188  void LineHS(int x,int y, int l);
189  void HLine( short x, short y, short l);
190  void VLine( short x, short y, short l);
191 
193  unsigned short ForeColor;
194  unsigned short BackColor;
196 
197 
198 void LCD_Write_CD(unsigned short,unsigned short);
199 
202 
203  void LCD_Write8(uint8_t);
204  void LCD_Write8x2(unsigned short);
205  void LCD_Write_DATA8(unsigned short);
206  void LCD_Write_COMM8(unsigned short);
207 
208 
209  //void main_W_com_data(int com1,int dat1);
210  void SetXY(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);
211  void Write7843(uint8_t num);
212  unsigned int Read7843();
213 };
214 
215 
216 #endif
unsigned short SCR_WIDTH
Definition: Ss_TFT.h:195
void DisplayBitmapChar(int, int, uint8_t, uint8_t option=0)
Definition: Ss_TFT.cpp:941
void HLine(short x, short y, short l)
Definition: Ss_TFT.cpp:458
int LCD_REST
Definition: Ss_TFT.h:201
void d32s(short, short, uint8_t)
Definition: Ss_TFT.cpp:648
uint8_t font_type
Definition: Ss_TFT.h:100
void Circle(int, int, int)
Definition: Ss_TFT.cpp:576
void CircleFill(int, int, int)
Definition: Ss_TFT.cpp:631
int T_CS
Definition: Ss_TFT.h:200
uint8_t c_max
Definition: Ss_TFT.h:102
int T_IRQ
Definition: Ss_TFT.h:200
void LCD_Write_CD(unsigned short, unsigned short)
Definition: Ss_TFT.cpp:225
void CheckPoint(int *, int *)
Definition: Ss_TFT.cpp:361
unsigned short font_y_space
Definition: Ss_TFT.h:106
void plot4points(int, int, int, int)
Definition: Ss_TFT.cpp:614
void VLine(short x, short y, short l)
Definition: Ss_TFT.cpp:473
int Tc_Y
Definition: Ss_TFT.h:118
uint8_t * memory_pointer
Definition: Ss_TFT.h:97
uint8_t x_size
Definition: Ss_TFT.h:98
Font LocalFont
Definition: Ss_TFT.h:127
void SetFontOption(const uint8_t)
Definition: Ss_TFT.cpp:910
void SetFBcolor(int FC, int BC)
Definition: Ss_TFT.cpp:447
uint8_t sp_y
Definition: Ss_TFT.h:104
void GetLandscapePoint(int *, int *)
Definition: Ss_TFT.cpp:1162
int TouchRawY
Definition: Ss_TFT.h:115
unsigned short SCR_HH
Definition: Ss_TFT.h:195
void DisplayChar(short, short, uint8_t, uint8_t option=0)
Definition: Ss_TFT.cpp:921
bool TouchReady()
Definition: Ss_TFT.cpp:1300
void plot4pointsE(int, int, int, int)
uint8_t sp_x
Definition: Ss_TFT.h:103
uint8_t Service
Definition: Ss_TFT.h:192
void SetXY(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
Definition: Ss_TFT.cpp:231
#define FastdigitalWrite(a, b)
int T_CLK
Definition: Ss_TFT.h:200
void LineVS(int x, int y, int l)
Definition: Ss_TFT.cpp:487
unsigned short SCR_HEIGHT
Definition: Ss_TFT.h:195
uint8_t c_min
Definition: Ss_TFT.h:101
void LCD_Write8x2(unsigned short)
Definition: Ss_TFT.cpp:115
void SetFont(uint8_t *font, uint8_t x=0, uint8_t y=0, uint8_t spx=0, uint8_t spy=0)
Definition: Ss_TFT.cpp:881
Definition: Ss_TFT.h:95
void SetPORTRAIT()
Definition: Ss_TFT.h:131
uint8_t y_size
Definition: Ss_TFT.h:99
int TouchRawCalibSCR_YY
Definition: Ss_TFT.h:117
Definition: Ss_TFT.h:112
int TouchRawCalibX
Definition: Ss_TFT.h:116
int LCD_CS
Definition: Ss_TFT.h:201
void DisplayString(int x, int y, char *st, uint8_t options=0)
Definition: Ss_TFT.cpp:1132
void CleanLCD(unsigned short rgb=0xFFFF)
Definition: Ss_TFT.cpp:416
unsigned short SCR_WW
Definition: Ss_TFT.h:195
int TouchRawX
Definition: Ss_TFT.h:115
void SetLANDSCAPE()
Definition: Ss_TFT.h:129
int T_DIN
Definition: Ss_TFT.h:200
unsigned short SCR_YY
Definition: Ss_TFT.h:195
void SetFcolor(uint8_t, uint8_t, uint8_t)
Definition: Ss_TFT.cpp:429
void Write7843(uint8_t num)
Definition: Ss_TFT.cpp:1199
Ss_TFT()
Definition: Ss_TFT.cpp:8
int TouchRawCalibY
Definition: Ss_TFT.h:117
#define LCD_RS_HIGH
Definition: Ss_TFT.h:77
int LCD_RS
Definition: Ss_TFT.h:201
int TouchRawCalibSCR_XX
Definition: Ss_TFT.h:116
void Rect(int, int, int, int)
Definition: Ss_TFT.cpp:347
void LCD_Write8(uint8_t)
Definition: Ss_TFT.cpp:62
void LineHS(int x, int y, int l)
Definition: Ss_TFT.cpp:491
unsigned short font_x_space
Definition: Ss_TFT.h:105
void LCD_Write_DATA8(unsigned short)
Definition: Ss_TFT.cpp:219
void TouchInitial()
Definition: Ss_TFT.cpp:1191
void RectFill(int sx, int sy, int ex, int ey, bool force=0)
Definition: Ss_TFT.cpp:378
unsigned int TouchGetX()
Definition: Ss_TFT.cpp:1309
void Pixel(int x, int y)
Definition: Ss_TFT.cpp:1153
void SetBcolor(uint8_t, uint8_t, uint8_t)
Definition: Ss_TFT.cpp:438
int Tc_X
Definition: Ss_TFT.h:118
void Line(int sx, int sy, int ex, int ey)
Definition: Ss_TFT.cpp:502
unsigned short SCR_XX
Definition: Ss_TFT.h:195
unsigned int Read7843()
Definition: Ss_TFT.cpp:1226
int LCD_WR
Definition: Ss_TFT.h:201
unsigned short BackColor
Definition: Ss_TFT.h:194
void TouchGetPoint()
Definition: Ss_TFT.cpp:1247
unsigned short ForeColor
Definition: Ss_TFT.h:193
int T_DOUT
Definition: Ss_TFT.h:200
void Touchpin(int tclk, int tcs, int tdin, int dout, int irq)
Definition: Ss_TFT.cpp:1176
unsigned int TouchGetY()
Definition: Ss_TFT.cpp:1316
void LCD_Write_COMM8(unsigned short)
Definition: Ss_TFT.cpp:212
void Initialize()
Definition: Ss_TFT.cpp:245