b. Set Date Time

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 14 - CleO Utility Widgets >

b. Set Date Time

This section shows how to utilize the SetDateTime widget using the rotary utility. You may use SetDateTime() widget to get the keyboard on the screen.

 

 

Command Prototype

 

uint16_t SetDateTime(const char* Prompt, uint32_t &Epoch);

 

Parameters

Description

Prompt

text displayed on top of the widget screen

Epoch

to store selected time in epoch

 

 

Code

 

 

void setup()

{

 uint32_t t0;

 int16_t year, month, day, h, m, s, wday;

 char buf[20];

 

/* Initialize CleO - needs to be done only once */

 CleO.begin();

 

/* Invoke widget */

 CleO.SetDateTime("DateTime", t0);

 

/* Convert epoch time to date/time */

 CleO.EpochToDate(t0, year, month, day, h, m, s, wday);

 

/* Start building a screen frame */

 CleO.Start();

 

 sprintf(buf, "Time: %02d:%02d:%02d", h, m, s);

 CleO.StringExt(FONT_MEDIUM, 160, 240, LIGHT_GREEN, MM, 0, 0, buf);

 

 sprintf(buf, "Date: %02d/%02d/%04d", day, month + 1, year);

 CleO.StringExt(FONT_MEDIUM, 160, 300, LIGHT_GREEN, MM, 0, 0, buf);

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop() { }

 

 

Description

 

The above code snippet shows how to select date and time using the SetDateTime() widget.

 

Note: Make sure to perform the screen calibration. For details, refer to Tutorial 19 - Miscellaneous Commands > a. Screen Calibration.

 

 

Output

 

Here is the output displayed upon executing the code snippet -

 

IMG_8416

 

2 SetDateTime