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);





text displayed on top of the widget screen


to store selected time in epoch






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 */



/* 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 */



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

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


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

 CleO.StringExt(FONT_MEDIUM, 400, 240 + 60, LIGHT_GREEN, MM, 0, 0, buf);


/* Display completed screen frame */




void loop() { }





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.





Here is the output displayed upon executing the code snippet -