Time Input Dialog for Graphic LCD

GUI Frameworks of all modern OS like Windows, Linux (Qt & GTK+), MAC etc have a concept of standard dialogs. For example all applications running under Windows shows the same file open dialog for selecting a file. Similarly their are standard dialogs for folder selection, colour selection, font selection etc. This concept has several advantages, and the most important is a easy user interface. Since the user is already familiar with file selection in one application, he/she can use file open dialog of any application. Building on the same concept our GUI framework for ProGFX (avr glcd driver) will too have many standard dialogs for common user interface. In this tutorial we will build the "Time Input Dialog" that helps programmer ask the user to input time. The time could be anything like :-

  • "On" or "Off" time for a relay in a timer application.
  • Alarm time in an alarm clock application.
  • Period start time in a school bell application.
  • And many others.

The programmer just need to call the function.


void ShowGetTimeDlg(uint8_t *h,uint8_t *m,uint8_t *s,uint8_t *am_pm)

It takes four parameters hour, minutes, second and am_pm. All parameters are passed by reference(pointer actually), this is because the function modifies the value of those variables. It shows a dialog as shown below :-

gui time input dialog for glcd

Time Input Dialog

The user can use the LEFT and RIGHT navigation keys on D-PAD to move from one field to another (like hour, minutes, seconds etc.). Then he/she can use the UP and DOWN key to increase/decrease the value of that field. Once the user has entered the time they can press OK to end the dialog. As soon as user presses OK button the values are copied to the variables h,m,s,am_pm. If the user presses CANCEL in place of OK the variables are not changed.

Example Usage


//Declare variables
uint8_t h,m,s,am_pm;

//Initialize variables
h=10;
m=10;
s=20;
am_pm=AM;

//Show the time input dialog
ShowGetTimeDlg(&h,&m,&s,&am_pm);

The above code will show the time input dialog with initial time of 10:10:20 AM if the user change time and press OK the variable h,m,s,am_pm will be changed accordingly. But if user presses cancel (even after modifying time) the variables (h,m,s,am_pm) will retain their original value i.e. 10:10:20 AM.

 

Hardware

You can run the above code in our GLCD Development Board, otherwise you may build the circuit as shown below.

GLCD Development Board Schematic

GLCD Development Board Schematic

NOTE

  • The Fuse Byte of ATmega32 must be set as follows. (LOW Fuse = 0xFF, HIGH Fuse = 0xC9).
  • Adjust RV1 until you get a clear display.

 

Downloads for GLCD Time Input Dialog

By
Avinash Gupta
Facebook, Follow on Twitter.
www.AvinashGupta.com
me@avinashgupta.com

Facing problem with your embedded, electronics or robotics project? We are here to help!
Post a help request.

Avinash

Avinash Gupta is solely focused on free and high quality tutorial to make learning embedded system fun !

More Posts - Website

Follow Me:
FacebookLinkedInGoogle Plus

11 thoughts on “Time Input Dialog for Graphic LCD

  • By Uttam Dutta - Reply

    It is that what is wanted, There is so much thing to explore after this tutorial, a window is opened now ! Thank you so much , you are doing great job.
    Thanks and regards,
    Uttam Dutta

  • By Hari - Reply

    Nice job Mr.Avinash. Your tutorials are very good. Great. All the best.:)

  • By Biruk - Reply

    Hey can any one help me with an electronic billboard that displays an animated text, number or image just like on an advertisement billboard, using Proteus & IAR or can be with anything but i really want the design & the c file. Thanks!!

  • By vinayak - Reply

    touch screen for this demo board

  • By 2ndGenCore_i5 - Reply

    Dear Sir, Please post a tutorial on how a memory card is interfaced with ATmega series microcontrollers. Please give more insight into how to access the files in a memory card using a microcontroller and GLCD without using a Personal computer. e.g. If we interface a touchscreen to uC,in which format the data collected from touchscreen will be stored in memory card? If i want to display images from memory card how can i display them? Any suggestions on this project?Also share some useful links . Please reply as early as possible.Thanks in advance!!

  • By bharat - Reply

    Dear Avinash
    I can not found dpad.c in complete AVR sorce code .zip file.

    • By Avinash - Reply

      @bhart, did you found michaeljackson.c in the zip file? The point is that why you expect to find dpad.c in the file?

      • By bharat -

        Dear Avinash,
        sorry for waste your time.

        i have GLCD development board, i try to compile hex(avrsudio4) from GetTimeDlgDEMOPROG.zip given in the tutorial “Time Input Dialog for Graphic LCD”. The project ask for dpad.c, if you got me than give some hints.

    • By Avinash - Reply

      Sorry, but its all tested you are doing something wrong. You have to find out what. It is not possible for to help so many people by holding their finger. You have to do something for yourself.

      • By ajay -

        sorry to say but dpad.c is not in zip-

  • By Serg - Reply

    Sorry,
    Can`t find the file “dpad.c” in ZIP
    AVR Studio no compile these project.

Leave a Reply

Your email address will not be published. Required fields are marked *


six × = 12

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>