BayEOS-Arduino  1.8.0_0.0.4
TFTStream.cpp
1 #include "TFTStream.h"
2 
3 TFTStream::TFTStream(UTFT *utft, char *tx_buffer, uint8_t rows, uint8_t cols){
4  _utft=utft;
5  _tx_buffer=tx_buffer;
6  _rows=rows;
7  _cols=cols;
8  _first_row=1;
9 /* for(int i=0;i<((int)_rows*(_cols+1));i++){
10  _tx_buffer[i]=0;
11  }
12  */
13 }
14 
15 void TFTStream::begin(void){
16  _utft->InitLCD(PORTRAIT);
17  _utft->setFont(SmallFont);
18  _utft->clrScr();
19  _on=1;
20 }
21 
22 void TFTStream::end(void){
23  _on=0;
24 }
25 
26 
27 size_t TFTStream::write(uint8_t c){
28  if(c==13) return 1;
29  if(c==10){
30  do{
31  write(' ');
32  } while(_ccol);
33  return 1;
34  }
35  _tx_buffer[(int)_ccol+(_crow*(1+_cols))]=c;
36  _ccol++;
37  if(_ccol==_cols){
38 // _tx_buffer[(int)_ccol+(_crow*(1+_cols))]=0;
39  _ccol=0;
40  _crow++;
41  _first_row++;
42  if(_first_row==_rows) _first_row=0;
43  if(_crow==_rows){
44  _crow=0;
45  }
46  for(uint8_t i=0; i<_cols;i++){
47  _tx_buffer[(int) i+(_crow*(1+_cols))]=' ';
48  }
49  }
50  return 1;
51 }
52 
53 
54 void TFTStream::flush(void){
55  if(! _on) return;
56  int offset;
57  for(uint8_t i=0;i<_rows;i++){
58  offset=((i+_first_row) % _rows)*(_cols+1);
59  _utft->print(_tx_buffer+offset,0,12*i);
60  }
61 
62 }
Definition: UTFT.h:192