Project tutorial
HSVClock

HSVClock © CC BY

A colourful clock with a Seeed TFT shield, fast refresh in landscape mode, simple Touch interface, Daylight Savings Time adjustment.

  • 6,090 views
  • 6 comments
  • 12 respects

Components and supplies

About this project

HSV Clock

When I visited the US last, I picked up a Seeed 2.8" TFT Touch Shield (V1.0) from a RadioShack. I used it to make a colourful clock for my father for his 80th birthday.

YouTube

The important points are

  • The clock face is based on a grid of rectangular cells. The cell corners are distorted by small random amounts and each cell is divided by a random diagonal. A random spread of colours is applied across the cells and each triangle is shaded to give a 3D look. Internally, the colours are represented as HSV (Hue, Saturation & Value) but converted to RGB for sending to the LCD. The time is displayed with a simple font by colouring certain cells in the complimentary colours.
  • The enclosure is laser-cut bamboo, designed in Inkscape, cut by Ponoko.
  • Unfortunately, the shield has no mounting holes so I effectively clamp it into the enclosure against the front face. An Arduino Uno piggybacks on the shield via the header pins.
  • I needed I2C access to an external RTC (DS3232). The shield doesn’t expose unused pins so I used a Uno which has extra SDA/SCL pins. I made a low-profile header connector for these which sits under the shield. I pulled power and ground from a similar connector on the ICSP pins, also under the shield.
  • I added simple Daylight Savings Time support to the sketch (one less clock to set twice a year!). Rather than deal with logic like “the last Sunday in September” it relies on a small table of specific start & end dates for future years (for New Zealand in my case).
  • I simplified the Touch library code to make the touch screen just act as a 4x4 grid of de-bounced buttons. For example, the time is set by touching the bottom left and top right corners.
  • I made some fairly heroic efforts to speed up the rendering: a repaint of the cells takes about a quarter of a second. The rendering is based around writing horizontal rows of pixels of a particular colour. I use a modified Bresenham algorithm to compute the horizontal extents of a series of pairs of lines which constitute triangles a given cell. The code which sends the pixels to the LCD is based on the library but in-lined, unrolled, simplified and optimised. Since pixel colour data is written across multiple PORTx’s, all the values are pre-computed when the colour is selected, so setting N pixels in a row to that colour is faster.
  • The LCD is used in landscape orientation. I struggled for a long time to get the screen to update in horizontal rows. The datasheet for the controller is confusing. There are commands to set the “cursor” location, “DRAM Horizontal/Vertical Address Set (R20h, R21h)”. Pixel data is written at the cursor location and the cursor updates, wrapping onto the next line when needed etc. There’s also a command to change the screen orientation, “Entry Mode (R03h)”, which also talks about adjusting the cursor row and column increments. However, I found that changing the orientation to Landscape then positioning the cursor did not work. The solution I eventually found (which may be buried in the datasheet) is to use the “window” command instead of the cursor command; “Horizontal and Vertical RAM Address Position (R50h, R51h, R52h, R53h)”. Setting the coordinates of the top-left corner of the window means pixel data starts there and updates horizontally (in landscape).

Circuit

The circuit is simply

  • the TFT shield mounted on the Uno.
  • +5VDC, Ground, SDA & SDL go from the labelled pins on the Uno to the RTC module. Shown in the first three photos below (shield removed). Note that for access reasons, power/ground comes from the ICSP1 connector.
Fritzing
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages[9014] = [{ URL: 'https://hackster.imgix.net/uploads/image/file/26374/HSVClock_bb.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Circuit (minus the shield)', type: 'image' }];
      Photos
      if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages[8998] = [{ URL: 'https://hackster.imgix.net/uploads/image/file/26330/DSC06968.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Uno with low-profile connectors to RTC', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26331/DSC06973.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Low profile connector for SDA/SCL (Yellow)', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26332/DSC06974.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Connector for power for RTC from ICSP (and blob of liquid insulation to dim power LED)', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26333/DSC06984.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Laser-cut front face of enclosure and \"clamp\" plate to secure the shield.', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26334/DSC06985.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Showing clamped shield', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26335/DSC06987.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Front of clamped shield', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26336/DSC06990.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Assembly', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26337/DSC06993.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Gluing', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26338/DSC07065.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Assembly', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26339/DSC07066.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'The stack - shield, Uno, RTC and a bit of foam', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26340/DSC07075.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Inside enclosure', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26341/DSC07080.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'The back showing touch interface: tap top-left & bottom-right to go into time-setting mode.  Top-right & bottom-left to change display mode', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26342/DSC07091.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Finished - front', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26343/DSC07092.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Finished - back', type: 'image' },{ URL: 'https://hackster.imgix.net/uploads/image/file/26344/DSC07096.JPG?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: 'Running, 3:07', type: 'image' }];

      Comments

      Similar projects you might like

      Analog Clock using 1Sheeld Graphical LCD

      Project tutorial by Ahmed El-Hinidy

      • 4,391 views
      • 0 comments
      • 9 respects

      Colorful Clock

      Project tutorial by zou wei

      • 6,359 views
      • 2 comments
      • 12 respects

      ArduinoPhone

      Project tutorial by ye xiaobo

      • 5,803 views
      • 3 comments
      • 19 respects

      DCF77 Analyzer/Clock v2.0

      Project tutorial by Erik de Ruiter

      • 34,929 views
      • 21 comments
      • 80 respects

      Arduino Shield NCS314 NIXIE Tubes Clock IN-14

      Project tutorial by Team GRA_AND_AFCH

      • 34,010 views
      • 9 comments
      • 91 respects

      Talking Clock 2 - (Bilingual: EN-PT)

      Project showcase by LAGSILVA

      • 17,793 views
      • 37 comments
      • 64 respects
      Add projectSign up / Login