Total Pageviews

Showing posts with label TFT. Show all posts
Showing posts with label TFT. Show all posts

Saturday, October 29, 2016

1.8" TFT display with ST7735B

   I buy an small 1.8" TFT display with ST7735B driver and I try to connect directly to Arduino Uno board as I see on net... but result was not good... display is almost white
and just disconnect accidentaly the GND I can see something...
   So, I search on Arduino forums and on net (article INSTRUCTABLES: Arduino TFT display and font library ) and I found a solution like Nokia 5110 monochrome display .. I put 1k resistor on each data pins to Arduino to display:
and I tested more Arduino library for this display with ST7735 driver (from Adafruit, TFT library, ucglib library, etc) and I made  move to see .. movie is named ST7735B display with Arduino board

NOTE: Original article is in roumanian language, see Afisaj TFT de 1,8" cu driver ST7735B !!!

Friday, November 14, 2014

2.4" touch TFT LCD shield

   I purchased from ebay  a cheap 2.4" touch TFT LCD shield for Arduino Uno:
   For control the display I try library recomanded by buyer but not work at me. I search on net and I found article named A 2.4″ TFT TOUCHSCREEN SHIELD FOR ARDUINO
   Smoke and Wires change TFT libray from Adafruit for works with this display. The new library is SWTFT. You must have alse Touch Screen library and Adafruit GFX library.
   First, I tryed examples from SWTFT library and I made a movie:
and few pics:
   For understund the example from SWTFT library, I change the sketch and my results are:


   Finally, I try this:

and my sketch is:
// Original code provided by Smoke And Wires
// http://www.smokeandwires.co.nz
// This code has been taken from the Adafruit TFT Library and modified
//  by us for use with our TFT Shields / Modules
// For original code / licensing please refer to
// https://github.com/adafruit/TFTLCD-Library

// adapted sketch by niq_ro from http://arduinotehniq.blogspot.com/
// ver. 1m5 - 13.11.2014, Craiova - Romania

#include <Adafruit_GFX.h>    // Core graphics library
#include "SWTFT.h" // Hardware-specific library

// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
// #define LCD_CS A3 // Chip Select goes to Analog 3
// #define LCD_CD A2 // Command/Data goes to Analog 2
// #define LCD_WR A1 // LCD Write goes to Analog 1
// #define LCD_RD A0 // LCD Read goes to Analog 0

// #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
//   D0 connects to digital pin 8  (Notice these are
//   D1 connects to digital pin 9   NOT in order!)
//   D2 connects to digital pin 2
//   D3 connects to digital pin 3
//   D4 connects to digital pin 4
//   D5 connects to digital pin 5
//   D6 connects to digital pin 6
//   D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).


#include <Adafruit_GFX.h>    // Core graphics library
#include <SWTFT.h> // Hardware-specific library
#include <TouchScreen.h>




#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

// Assign human-readable names to some common 16-bit color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
//#define ROZ     0xFD20
#define ROZ     0xFBE0
#define GRI     0xBDF7
// http://stackoverflow.com/questions/13720937/c-defined-16bit-high-color
// http://wiibrew.org/wiki/U16_colors

SWTFT tft;

#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;
int ics; 

void setup(void) {
  Serial.begin(9600);
  Serial.println(F("Paint!"));
  
  tft.reset();
  
  uint16_t identifier = tft.readID();

  Serial.print(F("LCD driver chip: "));
  Serial.println(identifier, HEX);
    

  tft.begin(identifier);

  tft.fillScreen(BLACK);
  tft.fillRect(0, 0, 320, 240, BLACK);
  tft.setRotation(3);
  tft.setCursor(30, 100);
  tft.setTextColor(RED);  tft.setTextSize(3);
  tft.println("LCD driver chip: ");
  tft.setCursor(100, 150);
  tft.setTextColor(BLUE);
  tft.println(identifier, HEX);

delay(2000);
tft.fillRect(0, 0, 320, 240, BLACK);
  
tft.setRotation(0);
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
  tft.fillRect(0, BOXSIZE, BOXSIZE, BOXSIZE, YELLOW);
  tft.fillRect(0, BOXSIZE*2, BOXSIZE, BOXSIZE, GREEN);
  tft.fillRect(0, BOXSIZE*3, BOXSIZE, BOXSIZE, CYAN);
  tft.fillRect(0, BOXSIZE*4, BOXSIZE, BOXSIZE, BLUE);
  tft.fillRect(0, BOXSIZE*5, BOXSIZE, BOXSIZE, MAGENTA);
  tft.fillRect(0, BOXSIZE*6, BOXSIZE, BOXSIZE, GRI);
  tft.fillRect(0, BOXSIZE*7, BOXSIZE, BOXSIZE,  ROZ);
//tft.fillRect(BOXSIZE, BOXSIZE, BOXSIZE, BOXSIZE, WHITE);
 
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
  currentcolor = RED;


 cifre (WHITE);
  pinMode(13, OUTPUT);
}

#define MINPRESSURE 10
#define MAXPRESSURE 1000

void loop()
{
  digitalWrite(13, HIGH);
  // Recently Point was renamed TSPoint in the TouchScreen library
  // If you are using an older version of the library, use the
  // commented definition instead.
  // Point p = ts.getPoint();
  TSPoint p = ts.getPoint();
  digitalWrite(13, LOW);

  // if sharing pins, you'll need to fix the directions of the touchscreen pins
  //pinMode(XP, OUTPUT);
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //pinMode(YM, OUTPUT);

  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
  /*  
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
  */      
if (p.y < (TS_MINY-5)) stergere();
    // scale from 0->1023 to tft.width
    p.x = tft.width()-(map(p.x, TS_MINX, TS_MAXX, tft.width(), 0));
    p.y = tft.height()-(map(p.y, TS_MINY, TS_MAXY, tft.height(), 0));
  /*  
    Serial.print("("); Serial.print(p.x);
    Serial.print(", "); Serial.print(p.y);
    Serial.println(")");
  */  
    if (p.x < BOXSIZE) {
       oldcolor = currentcolor;

       if (p.y < BOXSIZE) { 
         currentcolor = RED; 
         tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE); 
//         text (currentcolor);
       } else if (p.y < BOXSIZE*2) {
         currentcolor = YELLOW;
         tft.drawRect(0, BOXSIZE, BOXSIZE, BOXSIZE, WHITE);
//         text (currentcolor);
       } else if (p.y < BOXSIZE*3) {
         currentcolor = GREEN;
         tft.drawRect(0, BOXSIZE*2, BOXSIZE, BOXSIZE, WHITE);
//         text (currentcolor);
       } else if (p.y < BOXSIZE*4) {
         currentcolor = CYAN;
         tft.drawRect(0, BOXSIZE*3, BOXSIZE, BOXSIZE, WHITE);       
//         text (currentcolor);
       } else if (p.y < BOXSIZE*5) {
         currentcolor = BLUE;
         tft.drawRect(0, BOXSIZE*4, BOXSIZE, BOXSIZE, WHITE);        
//         text (currentcolor);
       } else if (p.y < BOXSIZE*6) {
         currentcolor = MAGENTA;
         tft.drawRect(0,BOXSIZE*5, BOXSIZE, BOXSIZE, WHITE);        
//         text (currentcolor);
       } else if (p.y < BOXSIZE*7) {
         currentcolor = GRI;
         tft.drawRect(0,BOXSIZE*6, BOXSIZE, BOXSIZE, WHITE);        
//         text (currentcolor);
       } else if (p.y < BOXSIZE*8) {
         currentcolor = ROZ;
         tft.drawRect(0,BOXSIZE*7, BOXSIZE, BOXSIZE, WHITE);
         stergere();        
       }

text (currentcolor);
//cifre (currentcolor);
       if (oldcolor != currentcolor) {
          if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
          if (oldcolor == YELLOW) tft.fillRect(0, BOXSIZE, BOXSIZE, BOXSIZE, YELLOW);
          if (oldcolor == GREEN) tft.fillRect(0, BOXSIZE*2, BOXSIZE, BOXSIZE, GREEN);
          if (oldcolor == CYAN) tft.fillRect(0, BOXSIZE*3, BOXSIZE, BOXSIZE, CYAN);
          if (oldcolor == BLUE) tft.fillRect(0, BOXSIZE*4, BOXSIZE, BOXSIZE, BLUE);
          if (oldcolor == MAGENTA) tft.fillRect(0, BOXSIZE*5, BOXSIZE, BOXSIZE, MAGENTA);
          if (oldcolor == GRI) tft.fillRect(0, BOXSIZE*6, BOXSIZE, BOXSIZE, GRI);
          if (oldcolor == ROZ) tft.fillRect(0, BOXSIZE*7, BOXSIZE, BOXSIZE, ROZ);
     cifre (currentcolor);  
     }
      
    }
   // if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
/*
if (((p.y-PENRADIUS) > 5) && ((p.y+PENRADIUS) < tft.height())) {
   tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
    }
*/
if (((p.x-PENRADIUS) > BOXSIZE) && ((p.x+PENRADIUS) < tft.width())) {
   tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
    }

  }
}

void text (int culoare) 
{
tft.setRotation(3);
tft.setCursor(70, 80);
          tft.setTextColor(culoare);  tft.setTextSize(5);
 /*         tft.println("niq_ro");
          tft.setCursor(12, 130); tft.setTextSize(3);
          tft.println("www.tehnic.go.ro");
          tft.setCursor(20, 165); tft.setTextSize(2);
          tft.println("nicuflorica.blogspot.ro");
*/
          tft.setCursor(5, 220); tft.setTextSize(2);
          tft.println("arduinotehniq.blogspot.com");
tft.setRotation(0);
}

void cifre (int culoare)
{
// number for "buttons"
 tft.setRotation(3);
 tft.setTextColor(culoare);
 tft.setTextSize(3);
 tft.drawLine(0, 0, 40, 40, culoare);
 tft.drawLine(0, 40, 40, 0, culoare);
// tft.setCursor(15, 10);
// tft.println("1");
 tft.setCursor(55, 10);
 tft.println("1");
 tft.setCursor(95, 10);
 tft.println("2");
 tft.setCursor(135, 10);
 tft.println("3");
 tft.setCursor(175, 10);
 tft.println("4");
 tft.setCursor(215, 10);
 tft.println("5");
 tft.setCursor(255, 10);
 tft.println("6");
 tft.setCursor(295, 10);
 tft.println("7");
  
 tft.setRotation(0);
}

void stergere ()
{
      Serial.println("erase");
      // press the bottom of the screen to erase 
 //     tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
   tft.fillRect(0, 0, 240, 320, BLACK);
   tft.setRotation(0);
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
  tft.fillRect(0, BOXSIZE, BOXSIZE, BOXSIZE, YELLOW);
  tft.fillRect(0, BOXSIZE*2, BOXSIZE, BOXSIZE, GREEN);
  tft.fillRect(0, BOXSIZE*3, BOXSIZE, BOXSIZE, CYAN);
  tft.fillRect(0, BOXSIZE*4, BOXSIZE, BOXSIZE, BLUE);
  tft.fillRect(0, BOXSIZE*5, BOXSIZE, BOXSIZE, MAGENTA);
  tft.fillRect(0, BOXSIZE*6, BOXSIZE, BOXSIZE, GRI);
  tft.fillRect(0, BOXSIZE*7, BOXSIZE, BOXSIZE,  ROZ);
//tft.fillRect(BOXSIZE, BOXSIZE, BOXSIZE, BOXSIZE, WHITE);
 
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
  currentcolor = RED;
     cifre (WHITE);  
    }
   

Saturday, October 18, 2014

Weather station with Arduino Due on 2.2" TFT display

Note: This article is a rearrangement of article from http://arduinotehniq.blogspot.ro/2014/09/arduino-due-and-22-tft-display-with.html

   A usual weather station for domestic use must give us information about temperature and humidity, but a good weather station give us information about pressure, too.
   I design a weater station with 2.2" TFT display with ILI9341 driver.
 I did several experimets with Arduino Uno, then Arduino Mega and my conclusion is that development board are too slow for this display; so, I change classical Arduino board with next step, for me, Arduino Due.
   Arduino Due works with 3.3V logical level like ILI9341 driver, so in schematic we not need the logical level convertor (eg CD4050) from 5V to 3.3V as in case use Arduino Uno or Mega.
   For control the colour display with ILI9341, I use graphical library named ucglib, derivated from u8glib library for monochrome graphical display.
   I decided to use BMP180 sensor for give information about temperature and pressure & DHT11 sensor for give just humidity value, because is not accurate at temperature reading.
   My schematic for sensors at Arduino Due is:
   In my case, real ensemble is:
   For upload a sketch in Arduino Due must install a  new version of Arduino IDE, named 1.5.7 Beta (in future, version will be changed, but now 1.5.7 Beta is current version).
   For DHT11 sensor must use a new library compatible with Due, I found in a article named  Class for DHTxx sensors (xx = 11-21-22-33-44) and for BMP180 I use  Adafruit-BMP085.
   I write some original sketches for this weather station, and last is:
/*
original sketch by niq_ro from http://nicuflorica.blogspot.comhttp://arduinotehniq.blogspot.com using ucglib library
version for 2.2" TFT with ILI9341  - 2014.07.29, Craiova - Romania
use Universal uC Color Graphics Library from https://code.google.com/p/ucglib/
*/
#include <SPI.h>
#include "Ucglib.h"
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 6 , /*cs=*/ 5, /*reset=*/ 4); // at Uno
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); // at Mega
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 52, /*data=*/ 51, /*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 76, /*data=*/ 75, /*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega
Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega or Due
/*

Due  |Mega | Uno | TFT - ILI9341
----------------------
D22  | D22 | D4  | RESET
D24  | D24 | D5  | CS
D26  | D26 | D6  | D/C
 ?   | ?   | LED (via 220 ohms resistor at 5V)
MOSI | D51 | D11 | MOSI
MISO | D50 | D12 | MISO
SCK  | D52 | D13 | SCK
-----------------------------
with CD4050 adapter or 10k resistor, power supply and logical levels is 3.3V
schematic: http://nicuflorica.blogspot.ro/2014/07/afisaj-grafic-color-qvga-de-22-cu.html
*/

#include <dht.h> 
// from http://playground.arduino.cc/Main/DHTLib
dht DHT;

// https://github.com/adafruit/Adafruit-BMP085-Library
#include <Wire.h>
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;

float t1, t2;
float t10, t20;
float t11, t21;
float t12, t22;
float t13, t23;
int h11, h12;
int p1, p2;

void setup() {
delay(1000);
bmp.begin();

ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.clearScreen();
ucg.setFont(ucg_font_ncenR14r);
ucg.setColor(255, 0, 255);
ucg.setColor(1, 255, 0,0);

  ucg.setRotate90();
  ucg.setColor(255, 255, 255); // culoare alba
  ucg.drawFrame(0,0,320,240); //   
  ucg.setFont(ucg_font_courB24); // 20 pixel height
  ucg.setColor(255, 0, 0); // culoare rosie
  ucg.setPrintPos(60,30);
  ucg.print("Ministatie");
  ucg.setColor(0, 255, 0); // culoare verde
  ucg.setColor(0, 255, 0);
  ucg.setColor(0, 0, 255); // culoare albastru
  ucg.setPrintPos(17, 60);
  ucg.print("meteo cu DHT11");
  ucg.setPrintPos(55, 90);
  ucg.setColor(5, 255, 0); // culoare verde
  ucg.print("si BMP180");
  ucg.setFont(ucg_font_fur17r); // 17 pixel height
  ucg.setColor(255, 255, 0); // culoare galbena
  ucg.setPrintPos(25,120);
  ucg.print("ecran grafic 2,2'' (5,6cm)");
  ucg.setFont(ucg_font_courB24); // 20 pixel height 
  ucg.setColor(0, 255, 255); // culoare bleo
  ucg.setPrintPos(10,150);
  ucg.print("QVGA cu ILI9341");
  ucg.setColor(255, 0, 255); // culoare mov
  ucg.setPrintPos(20,180);
  ucg.print("versiune 4.4.0");
  ucg.setFont(ucg_font_fur17r); // 17 pixel height
  ucg.setColor(255, 255, 255); // culoare alb
  ucg.setPrintPos(60,210);
  ucg.print("realizat de niq_ro");

delay(5000);
ucg.clearScreen();
t13=40.0;
h12=40.0;
p2 = 900;
}

void loop() {
 // BMP180 part 
 int p1 = bmp.readPressure()/101.325;
 p1 = p1 * 0.760;
     
 // DHT11 part
 int chk = DHT.read11(37);
 delay(1000);
// timeout;
 int h11 = DHT.humidity; 
 if (DHT.humidity < 0) h11 = 0;

// BMP180 part 2
t12 = bmp.readTemperature();
int t15 = t12;
float t16 = 10*t15;
t16 = t16/10;

t16 = t12;
if (t16 != t13) 
{
temperaturi(t16, t13, 20, 0); // temperature, old temperature, x,y
termometre(t16, 20);
}

if (h11 != h12) 
{
// umiditate(h11, h12, 115, 90); // humidity, old humidity, x, y
 umiditate(h11, h12, 40, 180); // humidity, old humidity, x, y
 barca (h11, h12);
}


if (p1 != p2) 
{
 presiune(p1, p2, 100, 60); // pressure, old pressure, x, y
// barca (h11, h12);
}



//}
delay (2000); 
t13=t16;
h12=h11;
p2=p1;
} // final de program, se revine de la inceput

void temperaturi(float t3, float t4, int ics, int igrec)
{
int t5 = t3;
int t6 = t4;
ucg.setFont(ucg_font_courB24);    
if (t3*t4 < 0)
{ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
 ucg.drawHLine(ics+7, qy + igrec , 105);
}
}
int t51 = t5/10;
int t61 = t6/10;
ucg.setColor(0, 0, 0); 
if (t51 != t61)
{
for (int qy = 39 ; qy < 60; qy++) 
{
ucg.drawHLine(ics+28, qy + igrec , 21);
}
}
t5 = t3 - t51*10;
t6 = t4 - t61*10;
if (t5 != t6)
{
for (int qy = 39 ; qy < 60; qy++) 
{
ucg.drawHLine(ics+49, qy + igrec , 21);
}
} 
for (int qy = 39 ; qy < 60; qy++) 
{
 ucg.drawHLine(ics+91, qy + igrec , 21);
}
ucg.setColor(255, 0, 0);  
ucg.setPrintPos(10 + ics, 30 + igrec);
//ucg.print("t  :"); 
ucg.print("temperatura:"); 
ucg.setPrintPos(10 + ics, 60 + igrec);
if (t3 > 10.0) ucg.print("+");
else
 if (t3>0.0) ucg.print(" +");
else
 if (t3<0.0)
{
 t3=-t3;
 if (t3 > 10.0) ucg.print("-");
else
 if (t3 > 0.0) ucg.print(" -");
}  
if (t3==0.0) ucg.print("  ");
ucg.print(t3,1); 
ucg.print(" C"); 
ucg.setFont(ucg_font_fur17r); 
ucg.setPrintPos(30 + ics, 35 + igrec);
//if (igrec == 0) ucg.print("int"); 
//else ucg.print("ext"); 
ucg.setPrintPos(115 + ics, 50 + igrec);
ucg.print("o"); 

ucg.setPrintPos(75 + ics, 60 + igrec);
ucg.print(",");


}

void termometre (float t, int ics1)
{
ucg.setColor(255, 255, 255);  
ucg.drawFrame(ics1-4,10,9,200); 
ucg.drawCircle(ics1,220,10,UCG_DRAW_ALL);  
for (int a = 0; a < 10; a++)
{
ucg.drawLine(ics1-5,20+20*a,ics1-7,20+20*a);
ucg.drawLine(ics1+5,20+20*a,ics1+7,20+20*a);
}
ucg.drawLine(ics1-10,140,ics1+10,140);  
ucg.setFont(ucg_font_courB24);    
ucg.setPrintPos(13 + ics1, 149);
ucg.print("0 C"); 
ucg.setFont(ucg_font_fur17r); 
ucg.setPrintPos(37 + ics1, 135);
ucg.print("o"); 
int lin = 140 - 2*t;
ucg.setColor(0, 0, 0);  // black 
ucg.drawBox(ics1-2,21, 5, lin+5);
ucg.setColor(255, 0, 0);  
ucg.drawDisc(ics1,220,8,UCG_DRAW_ALL);  
ucg.drawBox(ics1-2,lin, 5, 210-lin);
}

void umiditate(int h3, int h4, int zet, int igrec1)
{
  ucg.setFont(ucg_font_courB24); // 20 pixel height   

// sterg semnul ??
int h51 = h3/10;
int h61 = h4/10;

ucg.setColor(0, 0, 0); 

// sterg zeci daca e cazul
if (h51 != h61)
{
//ucg.setColor(255, 255, 0); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
//  ucg.drawHLine(zet+28, qy + igrec1 , 21);
  ucg.drawHLine(zet+40, qy + igrec1, 42);
}
}
  int h5 = h3 - h51*10;
  int h6 = h4 - h61*10;

// sterg unitati daca e cazul
//if ((t5 != t6) || (t5-t6>0.2))
if (h5 != h6)
{
//ucg.setColor(0, 255, 0); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
  ucg.drawHLine(zet+79, qy + igrec1 , 21);
}
} 

 ucg.setColor(0, 255, 255);  
 ucg.setPrintPos(zet, 30 + igrec1);
 ucg.print("umiditate:"); 


//ucg.setFont(ucg_font_fub42n); // 20 pixel height   
ucg.setPrintPos(40 + zet, 60 + igrec1);
//if (h3 > 10) ucg.print("+");
if (h3 > 10) ucg.print(" ");
else
{
//ucg.setColor(255, 255, 255); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
  ucg.drawHLine(zet+40, qy + igrec1 , 42);
}
if (igrec1 <30) ucg.setColor(255, 255, 0);  
else ucg.setColor(0, 255, 255); 
ucg.setPrintPos(61 + zet, 60 + igrec1);
//ucg.print("+");
ucg.print(" ");
}
 ucg.print(h3); 
 ucg.print("%"); 
}


void barca (int h, int h2) // new humidity, old humidity.,
{
int xx = 280; 
int yy = 230;

//sterg barca
//ucg.setColor(100,100,100);  
ucg.setColor(0,0,0);  
ucg.drawBox(xx-25, yy-20-h2, 50, 30);


//sterg apa
//ucg.setColor(125, 125, 125);  
ucg.setColor(0, 0, 0);  
ucg.drawBox(xx-35, yy+10-h2, 70, h2-h);

//desenez apa
ucg.setColor(0, 255, 255);  
ucg.drawBox(xx-35, yy+10-h, 70, h);

//desenz barcuta;
//desenez carena
ucg.setColor(255, 255, 0);  
ucg.drawBox(xx-20, yy-h, 40, 10);
ucg.drawTriangle(xx-25, yy-h, xx-20, yy-h, xx-20, yy+10-h);
ucg.drawTriangle(xx+25, yy-h, xx+20, yy-h, xx+20, yy+10-h);
//desenez catarg
ucg.drawBox(xx-1, yy-20-h, 2, 20);
//desenez velele
ucg.setColor(0, 0, 255); // vela albastra  
ucg.drawTriangle(xx+2, yy-20-h, xx+2, yy-h, xx+20, yy-h);
ucg.setColor(255, 0, 0); // vela rosie  
ucg.drawTriangle(xx-2, yy-15-h, xx-2, yy-h, xx-20, yy-h);
}

void presiune (int p3, int p4, int zeti, int igreci)
{
  ucg.setFont(ucg_font_courB24); // 20 pixel height   

// sterg semnul ??
int p51 = p3/10;
int p61 = p4/10;

//ucg.setColor(0, 0, 0); 
ucg.setColor(100, 0, 0); 

// sterg zeci daca e cazul
if (p51 != p61)
{
//ucg.setColor(255, 255, 255); 
ucg.setColor(0, 0, 0); 
for (int qy3 = 39 ; qy3 < 60; qy3++) 
{
//  ucg.drawHLine(zet+28, qy + igrec1 , 21);
//  ucg.drawHLine(zeti+40, qy3 + igreci, 42);
  ucg.drawHLine(zeti+61, qy3 + igreci, 42);
}
}
  int p5 = p3 - p51*10;
  int p6 = p4 - p61*10;

// sterg unitati daca e cazul
//if ((t5 != t6) || (t5-t6>0.2))
if (p5 != p6)
{
//ucg.setColor(0, 255, 0); 
ucg.setColor(0, 0, 0); 
for (int qy4 = 39 ; qy4 < 60; qy4++) 
{
//  ucg.drawHLine(zeti+79, qy4 + igreci , 21);
  ucg.drawHLine(zeti+100, qy4 + igreci , 21);
}
} 

 ucg.setColor(255, 255, 0);  
 ucg.setPrintPos(zeti, 30 + igreci);
 ucg.print("presiune:"); 


//ucg.setFont(ucg_font_fub42n); // 20 pixel height   
ucg.setPrintPos(40 + zeti, 60 + igreci);
//if (h3 > 10) ucg.print("+");
if (p3 > 10) ucg.print(" ");
else
{
//ucg.setColor(255, 255, 255); 
ucg.setColor(0, 0, 0); 
for (int qy5 = 39 ; qy5 < 60; qy5++) 
{
//  ucg.drawHLine(zeti+40, qy5 + igreci , 42);
  ucg.drawHLine(zeti+61, qy5 + igreci , 42);
}
ucg.setColor(255, 255, 0); 
ucg.setPrintPos(61 + zeti, 60 + igreci);
//ucg.print("+");
ucg.print(" ");
}
 ucg.print(p3); 
 ucg.print("mm Hg"); 
}
   I made few movies in time of tests, and 2 are in (my) english:
weather station with Arduino Due on ILI9341 2.2" TFT display
weather station with Arduino Due on ILI9341 2.2" TFT display (2)
  All information on display are in roumanian language, by is easy to change "temperatura" in "temperature", "umiditate" in "humidity" and "presiune" in "pressure".


   Bibliography:
1)Afisaj grafic color QVGA de 2,2" cu integrat ILI9341 conectat la Arduino
2)Afisaj grafic color QVGA de 2,2" cu integrat ILI9341 conectat la Arduino (2)
3)Afisaj grafic color QVGA de 2,2" cu integrat ILI9341 conectat la Arduino (3)
4)Afisaj grafic color QVGA de 2,2" cu integrat ILI9341 conectat la Arduino (4)
5)Arduino Due si afisajul QVGA de 2,2" (5,6cm) comandat de ILI9341
6)How to Connect a ILI9341 Display
7)http://arduino.cc/ (whole site, includind forum

Tuesday, September 23, 2014

Arduino Due and 2.2" TFT display with ILI9341 driver

   I recently purchased an Arduino Due development board to control 2.2" TFT color graphic display with ILI9341 driver.
   First, I use Arduino Uno then I use Arduino Mega for control this display. Between Arduino board (Uno or Mega) I use CD4050 for convert voltage level, because Uno and mega works with 5V logical level and display with ILI9341 driver works with 3.3V.
   After several attempts I chose ucglib library because is like u8glb library, that I used it at monochrome Nokia mobile displays (like Nokia 3310 display with 84x48 resolution using PCD8544 driver or Nokia 3410 display with 95x64 resolution using PCF8812 driver 3410) or at monochrome display with 128x64 resolution using ST7920 driver.
   I tested with very good results the ucglib library with Arduino Uno & Due for control the colour graphic display with 320x240 resolution using ILI9341 driver and I write few article in roumanian language, who is my native language.
   Also, I write an article in roumanian language with Arduino Due who control the colour graphic display with 320x240 resolution using ILI9341 driver: Arduino Due si afisajul QVGA de 2,2" (5,6cm) comandat de ILI9341.
   Now, I make a summary of that article for interested people...
   Arduino Due is more powerfull then other Arduino boards, becouse runs at 3.3V (maximum tolerate voltage at input or output pins is 3.3V).
   Using informations from article named How to Connect a ILI9341 Display I connect directly pins from Arduino Due and display, like in this picture:
   In my case, schematic is:
   First, I made a weather station with DTH11 sensor for humidity and BMP180 for pressure and temperature, schematic is:
   Then, I simplified the sketch for using just DHT11 sensor for humidity and temperature:
   Practical, wirred is:
   My original sketck for full weather station with BMP180 and DHT11 is:
/*
original sketch by niq_ro from http://nicuflorica.blogspot.com using ucglib library
version for 2.2" TFT with ILI9341  - 2014.07.29, Craiova - Romania
use Universal uC Color Graphics Library from https://code.google.com/p/ucglib/
*/
#include <SPI.h>
#include "Ucglib.h"
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 6 , /*cs=*/ 5, /*reset=*/ 4); // at Uno
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); // at Mega
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 52, /*data=*/ 51, /*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 76, /*data=*/ 75, /*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega
Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega and Due
/*

Due  |Mega | Uno | TFT - ILI9341
----------------------
D22  | D22 | D4  | RESET
D24  | D24 | D5  | CS
D26  | D26 | D6  | D/C
 ?   | ?   | LED (via 220 ohms resistor at 5V)
MOSI | D51 | D11 | MOSI
MISO | D50 | D12 | MISO
SCK  | D52 | D13 | SCK
-----------------------------
with CD4050 adapter or 10k resistor, power supply and logical levels is 3.3V
schematic: http://nicuflorica.blogspot.ro/2014/07/afisaj-grafic-color-qvga-de-22-cu.html
*/

#include <dht.h> 
// from http://playground.arduino.cc/Main/DHTLib
dht DHT;

float t1, t2;
float t10, t20;
float t11, t21;
float t12, t22;
float t13, t23;
int h11, h12;

void setup() {
delay(1000);

ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.clearScreen();
ucg.setFont(ucg_font_ncenR14r);
ucg.setColor(255, 0, 255);
ucg.setColor(1, 255, 0,0);

  ucg.setRotate90();
  ucg.setColor(255, 255, 255); // culoare alba
  ucg.drawFrame(0,0,320,240); //   
  ucg.setFont(ucg_font_courB24); // 20 pixel height
  ucg.setColor(255, 0, 0); // culoare rosie
  ucg.setPrintPos(60,30);
  ucg.print("Ministatie");
  ucg.setColor(0, 255, 0); // culoare verde
  ucg.setColor(0, 255, 0);
  ucg.setColor(0, 0, 255); // culoare albastru
  ucg.setPrintPos(17, 60);
  ucg.print("meteo cu DHT11");
//  ucg.setPrintPos(55, 90);
//  ucg.setColor(5, 255, 0); // culoare verde
//  ucg.print("si BMP180");
  ucg.setFont(ucg_font_fur17r); // 17 pixel height
  ucg.setColor(255, 255, 0); // culoare galbena
  ucg.setPrintPos(25,120);
  ucg.print("ecran grafic 2,2'' (5,6cm)");
  ucg.setFont(ucg_font_courB24); // 20 pixel height 
  ucg.setColor(0, 255, 255); // culoare bleo
  ucg.setPrintPos(10,150);
  ucg.print("QVGA cu ILI9341");
  ucg.setColor(255, 0, 255); // culoare mov
  ucg.setPrintPos(20,180);
  ucg.print("versiune 4.5.0");
  ucg.setFont(ucg_font_fur17r); // 17 pixel height
  ucg.setColor(255, 255, 255); // culoare alb
  ucg.setPrintPos(60,210);
  ucg.print("realizare niq_ro");

delay(5000);
ucg.clearScreen();
t13=40.0;
h12=40.0;
}

void loop() {
     
 // DHT11 part
 int chk = DHT.read11(37);
 delay(1000);
// timeout;
 int h11 = DHT.humidity; 
 if (DHT.humidity < 0) h11 = 0;

 int t12 = DHT.temperature;
int t15 = t12;
float t16 = 10*t15;
t16 = t16/10;

t16 = t12;
if (t16 != t13) 
{
temperaturi(t16, t13, 20, 0); // temperature, old temperature, x,y
termometre(t16, 20);
}

if (h11 != h12) 
{
// umiditate(h11, h12, 115, 90); // humidity, old humidity, x, y
 umiditate(h11, h12, 40, 180); // humidity, old humidity, x, y
 barca (h11, h12);
}




//}
delay (30000); 
t13=t16;
h12=h11;
} // final de program, se revine de la inceput

void temperaturi(float t3, float t4, int ics, int igrec)
{
int t5 = t3;
int t6 = t4;
ucg.setFont(ucg_font_courB24);    
if (t3*t4 < 0)
{ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
 ucg.drawHLine(ics+7, qy + igrec , 105);
}
}
int t51 = t5/10;
int t61 = t6/10;
ucg.setColor(0, 0, 0); 
if (t51 != t61)
{
for (int qy = 39 ; qy < 60; qy++) 
{
ucg.drawHLine(ics+28, qy + igrec , 21);
}
}
t5 = t3 - t51*10;
t6 = t4 - t61*10;
if (t5 != t6)
{
for (int qy = 39 ; qy < 60; qy++) 
{
ucg.drawHLine(ics+49, qy + igrec , 21);
}
} 
for (int qy = 39 ; qy < 60; qy++) 
{
 ucg.drawHLine(ics+91, qy + igrec , 21);
}
ucg.setColor(255, 0, 0);  
ucg.setPrintPos(10 + ics, 30 + igrec);
//ucg.print("t  :"); 
ucg.print("temperatura:"); 
ucg.setPrintPos(10 + ics, 60 + igrec);
if (t3 > 10.0) ucg.print("+");
else
 if (t3>0.0) ucg.print(" +");
else
 if (t3<0.0)
{
 t3=-t3;
 if (t3 > 10.0) ucg.print("-");
else
 if (t3 > 0.0) ucg.print(" -");
}  
if (t3==0.0) ucg.print("  ");
ucg.print(t3,1); 
ucg.print(" C"); 
ucg.setFont(ucg_font_fur17r); 
ucg.setPrintPos(30 + ics, 35 + igrec);
//if (igrec == 0) ucg.print("int"); 
//else ucg.print("ext"); 
ucg.setPrintPos(115 + ics, 50 + igrec);
ucg.print("o"); 

ucg.setPrintPos(75 + ics, 60 + igrec);
ucg.print(",");


}

void termometre (float t, int ics1)
{
ucg.setColor(255, 255, 255);  
ucg.drawFrame(ics1-4,10,9,200); 
ucg.drawCircle(ics1,220,10,UCG_DRAW_ALL);  
for (int a = 0; a < 10; a++)
{
ucg.drawLine(ics1-5,20+20*a,ics1-7,20+20*a);
ucg.drawLine(ics1+5,20+20*a,ics1+7,20+20*a);
}
ucg.drawLine(ics1-10,140,ics1+10,140);  
ucg.setFont(ucg_font_courB24);    
ucg.setPrintPos(13 + ics1, 149);
ucg.print("0 C"); 
ucg.setFont(ucg_font_fur17r); 
ucg.setPrintPos(37 + ics1, 135);
ucg.print("o"); 
int lin = 140 - 2*t;
ucg.setColor(0, 0, 0);  // black 
ucg.drawBox(ics1-2,21, 5, lin+5);
ucg.setColor(255, 0, 0);  
ucg.drawDisc(ics1,220,8,UCG_DRAW_ALL);  
ucg.drawBox(ics1-2,lin, 5, 210-lin);
}

void umiditate(int h3, int h4, int zet, int igrec1)
{
  ucg.setFont(ucg_font_courB24); // 20 pixel height   

// sterg semnul ??
int h51 = h3/10;
int h61 = h4/10;

ucg.setColor(0, 0, 0); 

// sterg zeci daca e cazul
if (h51 != h61)
{
//ucg.setColor(255, 255, 0); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
//  ucg.drawHLine(zet+28, qy + igrec1 , 21);
  ucg.drawHLine(zet+40, qy + igrec1, 42);
}
}
  int h5 = h3 - h51*10;
  int h6 = h4 - h61*10;

// sterg unitati daca e cazul
//if ((t5 != t6) || (t5-t6>0.2))
if (h5 != h6)
{
//ucg.setColor(0, 255, 0); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
  ucg.drawHLine(zet+79, qy + igrec1 , 21);
}
} 

 ucg.setColor(0, 255, 255);  
 ucg.setPrintPos(zet, 30 + igrec1);
 ucg.print("umiditate:"); 


//ucg.setFont(ucg_font_fub42n); // 20 pixel height   
ucg.setPrintPos(40 + zet, 60 + igrec1);
//if (h3 > 10) ucg.print("+");
if (h3 > 10) ucg.print(" ");
else
{
//ucg.setColor(255, 255, 255); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
  ucg.drawHLine(zet+40, qy + igrec1 , 42);
}
if (igrec1 <30) ucg.setColor(255, 255, 0);  
else ucg.setColor(0, 255, 255); 
ucg.setPrintPos(61 + zet, 60 + igrec1);
//ucg.print("+");
ucg.print(" ");
}
 ucg.print(h3); 
 ucg.print("%"); 
}


void barca (int h, int h2) // new humidity, old humidity.,
{
int xx = 280; 
int yy = 230;

//sterg barca
//ucg.setColor(100,100,100);  
ucg.setColor(0,0,0);  
ucg.drawBox(xx-25, yy-20-h2, 50, 30);


//sterg apa
//ucg.setColor(125, 125, 125);  
ucg.setColor(0, 0, 0);  
ucg.drawBox(xx-35, yy+10-h2, 70, h2-h);

//desenez apa
ucg.setColor(0, 255, 255);  
ucg.drawBox(xx-35, yy+10-h, 70, h);

//desenz barcuta;
//desenez carena
ucg.setColor(255, 255, 0);  
ucg.drawBox(xx-20, yy-h, 40, 10);
ucg.drawTriangle(xx-25, yy-h, xx-20, yy-h, xx-20, yy+10-h);
ucg.drawTriangle(xx+25, yy-h, xx+20, yy-h, xx+20, yy+10-h);
//desenez catarg
ucg.drawBox(xx-1, yy-20-h, 2, 20);
//desenez velele
ucg.setColor(0, 0, 255); // vela albastra  
ucg.drawTriangle(xx+2, yy-20-h, xx+2, yy-h, xx+20, yy-h);
ucg.setColor(255, 0, 0); // vela rosie  
ucg.drawTriangle(xx-2, yy-15-h, xx-2, yy-h, xx-20, yy-h);
}
/
   Sketch for simplified weather station just DHT11 is: 
/*
original sketch by niq_ro from http://nicuflorica.blogspot.com using ucglib library
version for 2.2" TFT with ILI9341  - 2014.07.29, Craiova - Romania
use Universal uC Color Graphics Library from https://code.google.com/p/ucglib/
*/
#include <SPI.h>
#include "Ucglib.h"
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 6 , /*cs=*/ 5, /*reset=*/ 4); // at Uno
//Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); // at Mega
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 52, /*data=*/ 51, /*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega
//Ucglib_ILI9341_18x240x320_SWSPI ucg(/*sclk=*/ 76, /*data=*/ 75, /*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega
Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22); //at Mega and Due
/*

Due  |Mega | Uno | TFT - ILI9341
----------------------
D22  | D22 | D4  | RESET
D24  | D24 | D5  | CS
D26  | D26 | D6  | D/C
 ?   | ?   | LED (via 220 ohms resistor at 5V)
MOSI | D51 | D11 | MOSI
MISO | D50 | D12 | MISO
SCK  | D52 | D13 | SCK
-----------------------------
with CD4050 adapter or 10k resistor, power supply and logical levels is 3.3V
schematic: http://nicuflorica.blogspot.ro/2014/07/afisaj-grafic-color-qvga-de-22-cu.html
*/

#include <dht.h> 
// from http://playground.arduino.cc/Main/DHTLib
dht DHT;

float t1, t2;
float t10, t20;
float t11, t21;
float t12, t22;
float t13, t23;
int h11, h12;

void setup() {
delay(1000);

ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.clearScreen();
ucg.setFont(ucg_font_ncenR14r);
ucg.setColor(255, 0, 255);
ucg.setColor(1, 255, 0,0);

  ucg.setRotate90();
  ucg.setColor(255, 255, 255); // culoare alba
  ucg.drawFrame(0,0,320,240); //   
  ucg.setFont(ucg_font_courB24); // 20 pixel height
  ucg.setColor(255, 0, 0); // culoare rosie
  ucg.setPrintPos(60,30);
  ucg.print("Ministatie");
  ucg.setColor(0, 255, 0); // culoare verde
  ucg.setColor(0, 255, 0);
  ucg.setColor(0, 0, 255); // culoare albastru
  ucg.setPrintPos(17, 60);
  ucg.print("meteo cu DHT11");
//  ucg.setPrintPos(55, 90);
//  ucg.setColor(5, 255, 0); // culoare verde
//  ucg.print("si BMP180");
  ucg.setFont(ucg_font_fur17r); // 17 pixel height
  ucg.setColor(255, 255, 0); // culoare galbena
  ucg.setPrintPos(25,120);
  ucg.print("ecran grafic 2,2'' (5,6cm)");
  ucg.setFont(ucg_font_courB24); // 20 pixel height 
  ucg.setColor(0, 255, 255); // culoare bleo
  ucg.setPrintPos(10,150);
  ucg.print("QVGA cu ILI9341");
  ucg.setColor(255, 0, 255); // culoare mov
  ucg.setPrintPos(20,180);
  ucg.print("versiune 4.5.0");
  ucg.setFont(ucg_font_fur17r); // 17 pixel height
  ucg.setColor(255, 255, 255); // culoare alb
  ucg.setPrintPos(60,210);
  ucg.print("realizare niq_ro");

delay(5000);
ucg.clearScreen();
t13=40.0;
h12=40.0;
}

void loop() {
     
 // DHT11 part
 int chk = DHT.read11(37);
 delay(1000);
// timeout;
 int h11 = DHT.humidity; 
 if (DHT.humidity < 0) h11 = 0;

 int t12 = DHT.temperature;
int t15 = t12;
float t16 = 10*t15;
t16 = t16/10;

t16 = t12;
if (t16 != t13) 
{
temperaturi(t16, t13, 20, 0); // temperature, old temperature, x,y
termometre(t16, 20);
}

if (h11 != h12) 
{
// umiditate(h11, h12, 115, 90); // humidity, old humidity, x, y
 umiditate(h11, h12, 40, 180); // humidity, old humidity, x, y
 barca (h11, h12);
}




//}
delay (30000); 
t13=t16;
h12=h11;
} // final de program, se revine de la inceput

void temperaturi(float t3, float t4, int ics, int igrec)
{
int t5 = t3;
int t6 = t4;
ucg.setFont(ucg_font_courB24);    
if (t3*t4 < 0)
{ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
 ucg.drawHLine(ics+7, qy + igrec , 105);
}
}
int t51 = t5/10;
int t61 = t6/10;
ucg.setColor(0, 0, 0); 
if (t51 != t61)
{
for (int qy = 39 ; qy < 60; qy++) 
{
ucg.drawHLine(ics+28, qy + igrec , 21);
}
}
t5 = t3 - t51*10;
t6 = t4 - t61*10;
if (t5 != t6)
{
for (int qy = 39 ; qy < 60; qy++) 
{
ucg.drawHLine(ics+49, qy + igrec , 21);
}
} 
for (int qy = 39 ; qy < 60; qy++) 
{
 ucg.drawHLine(ics+91, qy + igrec , 21);
}
ucg.setColor(255, 0, 0);  
ucg.setPrintPos(10 + ics, 30 + igrec);
//ucg.print("t  :"); 
ucg.print("temperatura:"); 
ucg.setPrintPos(10 + ics, 60 + igrec);
if (t3 > 10.0) ucg.print("+");
else
 if (t3>0.0) ucg.print(" +");
else
 if (t3<0.0)
{
 t3=-t3;
 if (t3 > 10.0) ucg.print("-");
else
 if (t3 > 0.0) ucg.print(" -");
}  
if (t3==0.0) ucg.print("  ");
ucg.print(t3,1); 
ucg.print(" C"); 
ucg.setFont(ucg_font_fur17r); 
ucg.setPrintPos(30 + ics, 35 + igrec);
//if (igrec == 0) ucg.print("int"); 
//else ucg.print("ext"); 
ucg.setPrintPos(115 + ics, 50 + igrec);
ucg.print("o"); 

ucg.setPrintPos(75 + ics, 60 + igrec);
ucg.print(",");


}

void termometre (float t, int ics1)
{
ucg.setColor(255, 255, 255);  
ucg.drawFrame(ics1-4,10,9,200); 
ucg.drawCircle(ics1,220,10,UCG_DRAW_ALL);  
for (int a = 0; a < 10; a++)
{
ucg.drawLine(ics1-5,20+20*a,ics1-7,20+20*a);
ucg.drawLine(ics1+5,20+20*a,ics1+7,20+20*a);
}
ucg.drawLine(ics1-10,140,ics1+10,140);  
ucg.setFont(ucg_font_courB24);    
ucg.setPrintPos(13 + ics1, 149);
ucg.print("0 C"); 
ucg.setFont(ucg_font_fur17r); 
ucg.setPrintPos(37 + ics1, 135);
ucg.print("o"); 
int lin = 140 - 2*t;
ucg.setColor(0, 0, 0);  // black 
ucg.drawBox(ics1-2,21, 5, lin+5);
ucg.setColor(255, 0, 0);  
ucg.drawDisc(ics1,220,8,UCG_DRAW_ALL);  
ucg.drawBox(ics1-2,lin, 5, 210-lin);
}

void umiditate(int h3, int h4, int zet, int igrec1)
{
  ucg.setFont(ucg_font_courB24); // 20 pixel height   

// sterg semnul ??
int h51 = h3/10;
int h61 = h4/10;

ucg.setColor(0, 0, 0); 

// sterg zeci daca e cazul
if (h51 != h61)
{
//ucg.setColor(255, 255, 0); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
//  ucg.drawHLine(zet+28, qy + igrec1 , 21);
  ucg.drawHLine(zet+40, qy + igrec1, 42);
}
}
  int h5 = h3 - h51*10;
  int h6 = h4 - h61*10;

// sterg unitati daca e cazul
//if ((t5 != t6) || (t5-t6>0.2))
if (h5 != h6)
{
//ucg.setColor(0, 255, 0); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
  ucg.drawHLine(zet+79, qy + igrec1 , 21);
}
} 

 ucg.setColor(0, 255, 255);  
 ucg.setPrintPos(zet, 30 + igrec1);
 ucg.print("umiditate:"); 


//ucg.setFont(ucg_font_fub42n); // 20 pixel height   
ucg.setPrintPos(40 + zet, 60 + igrec1);
//if (h3 > 10) ucg.print("+");
if (h3 > 10) ucg.print(" ");
else
{
//ucg.setColor(255, 255, 255); 
ucg.setColor(0, 0, 0); 
for (int qy = 39 ; qy < 60; qy++) 
{
  ucg.drawHLine(zet+40, qy + igrec1 , 42);
}
if (igrec1 <30) ucg.setColor(255, 255, 0);  
else ucg.setColor(0, 255, 255); 
ucg.setPrintPos(61 + zet, 60 + igrec1);
//ucg.print("+");
ucg.print(" ");
}
 ucg.print(h3); 
 ucg.print("%"); 
}


void barca (int h, int h2) // new humidity, old humidity.,
{
int xx = 280; 
int yy = 230;

//sterg barca
//ucg.setColor(100,100,100);  
ucg.setColor(0,0,0);  
ucg.drawBox(xx-25, yy-20-h2, 50, 30);


//sterg apa
//ucg.setColor(125, 125, 125);  
ucg.setColor(0, 0, 0);  
ucg.drawBox(xx-35, yy+10-h2, 70, h2-h);

//desenez apa
ucg.setColor(0, 255, 255);  
ucg.drawBox(xx-35, yy+10-h, 70, h);

//desenz barcuta;
//desenez carena
ucg.setColor(255, 255, 0);  
ucg.drawBox(xx-20, yy-h, 40, 10);
ucg.drawTriangle(xx-25, yy-h, xx-20, yy-h, xx-20, yy+10-h);
ucg.drawTriangle(xx+25, yy-h, xx+20, yy-h, xx+20, yy+10-h);
//desenez catarg
ucg.drawBox(xx-1, yy-20-h, 2, 20);
//desenez velele
ucg.setColor(0, 0, 255); // vela albastra  
ucg.drawTriangle(xx+2, yy-20-h, xx+2, yy-h, xx+20, yy-h);
ucg.setColor(255, 0, 0); // vela rosie  
ucg.drawTriangle(xx-2, yy-15-h, xx-2, yy-h, xx-20, yy-h);
}
/
   I made two movies for understand better what is on display:
   Information are displayed in the roumanian language, but you may change easy...
   For upload sketch for Arduino Due must update Arduino IDE software; now current version is Arduino IDE 1.5.7. BETA

   I wait with interest your views and comments!!!