December 30, 2012

TFT Touch Shield : Temperature And Timer

Instead of version 2.0 I've received the TFT Touch Shield Version 1.0 from Seeedstudio. This version doesn't have a SD-card and uses lots of pins for the communication. Version 2.0 instead uses the SPI protocol for communication. So, my blog post about SPI isn't necessary.

But this also simplifies the first version of my project:
  • display inside and outside temperatures
  • implement a timer with touch buttons

Temperature Measurement

For the temperature measurement I'm using two DS18S20 temperature sensors from maxim integrated (see also my posting Temperature Sensors DS18B20). The TFT Touch Shield Version 1.0 uses nearly all pins from the Arduino board. Only analog pin A4 and A5 aren't used and those pins can be used as digital input pins. The DS18S20 temperature sensors are using the 1-wire interface and therefore only one pin is needed for the measurement.

The DS18S20 example code uses a delay(1000) which blocks the application and touch buttons of the timer. I've split the temperature measurement into two parts and the second part will be called after one second.

TFT and Touch Library

I've been using the TFT and Touch library which is mentioned in the Seeedstudio forum 2.8" TFT Shield Link : TFT_TouchScreen_for_Arduino_1.0.zip

This library is straight forward:

  • draw text with position, size and color
  • draw rectangles filled or not filled with position, width, height, and color
  • draw lines (not used at the moment)
  • and getting the touch position is also simple: just read the x and y position and it is also possible the get the z position for pressure. Depending on the position you can simulate a button (see timer).
The TFT Touch Shield isn't very fast (maybe Version 2.0 with an other chip is faster). You can see it when the TFT is drawing the items.
Drawing some text doesn't erase the previous text. Therefore the old text has to be overwritten overdrawn. For the temperature display I've been drawing a gray rectangle before the next temperature text is shown which results to a flickering view.
For the timer display I've reduced the flickering. I've been comparing each character from the old value with the new one and if it doesn't differ, I replace the values with a space. Therefore the old value isn't overwritten. Only those characters which differs has to be erased by a black color and drawn new.

The library also comes with a font. Each character is drawn by a 8x8 pixels. The text can have different sizes, but as bigger the size the more you can see the pixels (there's no anti-aliasing). Only ASCII characters from 0x20 (32dec) to 0x7e (126dec) are supported. This means umlauts aren't supported. 

Timer

For the timer I've been using a plus and minus sign to adjust the time by increases or decreases. Clicking on the time the timer starts to count down. To get the position and the button is very simple (as mentioned above). I've defined an area around the buttons and if the touch position is inside this area, the value changes or the timer starts. For the plus / minus button there's also a visual feedback by changing the color of the button in blue.

Source Code

... is available on github: https://github.com/choas/arduino-choas/tree/master/TftTouchTemperature

Next Version


This is my first simple version for a temperature display and timer. For the next version a temperature diagram would be nice to see the temperature changes during day and night. To switch between normal view and diagram view an image would be also nice.

I think version 2.0 of the TFT Touch Shield with a SD card simplifies this by reading an image and storing / reading the temperature data ...


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.