diff --git a/lib/libx52/Makefile.am b/lib/libx52/Makefile.am index b69e9f7..9ac00ed 100644 --- a/lib/libx52/Makefile.am +++ b/lib/libx52/Makefile.am @@ -5,7 +5,7 @@ lib_LTLIBRARIES = libx52.la # Core libx52 library # This library handles the USB communication between the host and the X52 libx52_la_SOURCES = x52_control.c x52_core.c x52_date_time.c x52_mfd_led.c -libx52_la_LDFLAGS = -version-info 2:1:1 -lusb-1.0 +libx52_la_LDFLAGS = -version-info 3:0:2 -lusb-1.0 # Header files that need to be copied x52includedir = $(includedir)/x52pro diff --git a/lib/libx52/libx52.h b/lib/libx52/libx52.h index 1190b97..c29ee80 100644 --- a/lib/libx52/libx52.h +++ b/lib/libx52/libx52.h @@ -285,6 +285,36 @@ int libx52_set_clock_format(libx52_device *x52, libx52_clock_id clock, libx52_clock_format format); +/** + * @brief Set the hour and minute on clock 1 + * + * This is a raw API which can be used for manual control if the user + * so desires, however, it will not update the timezone or the date + * values. + * + * @param[in] x52 Pointer to the device + * @param[in] hour Hour to display + * @param[in] minute Minute to display + * + * @returns 0 on success, \c -EINVAL if \p x52 is not valid + */ +int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute); + +/** + * @brief Set the date + * + * This is a raw API which can be used for manual control if the user + * so desires, however, it will not update the timezone or the time values. + * + * @param[in] x52 Pointer to the device + * @param[in] dd Day to display + * @param[in] mm Month to display + * @param[in] yy Year to display + * + * @returns 0 on success, \c -EINVAL if \p x52 is not valid + */ +int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy); + /** * @brief Set the date format for the MFD date display * diff --git a/lib/libx52/x52_date_time.c b/lib/libx52/x52_date_time.c index a8fc690..1a7f335 100644 --- a/lib/libx52/x52_date_time.c +++ b/lib/libx52/x52_date_time.c @@ -57,10 +57,7 @@ int libx52_set_clock(libx52_device *x52, time_t time, int local) x52->date_month != local_date_month || x52->date_year != local_date_year) { - x52->date_day = local_date_day; - x52->date_month = local_date_month; - x52->date_year = local_date_year; - set_bit(&x52->update_mask, X52_BIT_MFD_DATE); + libx52_set_date(x52, local_date_day, local_date_month, local_date_year); update_required = 1; } @@ -68,9 +65,7 @@ int libx52_set_clock(libx52_device *x52, time_t time, int local) if (x52->time_hour != local_time_hour || x52->time_minute != local_time_minute) { - x52->time_hour = local_time_hour; - x52->time_minute = local_time_minute; - set_bit(&x52->update_mask, X52_BIT_MFD_TIME); + libx52_set_time(x52, local_time_hour, local_time_minute); update_required = 1; } @@ -86,6 +81,33 @@ int libx52_set_clock(libx52_device *x52, time_t time, int local) return (update_required ? 0 : -EAGAIN); } +int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute) +{ + if (!x52) { + return -EINVAL; + } + + x52->time_hour = hour; + x52->time_minute = minute; + set_bit(&x52->update_mask, X52_BIT_MFD_TIME); + + return 0; +} + +int libx52_set_date(libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy) +{ + if (!x52) { + return -EINVAL; + } + + x52->date_day = dd; + x52->date_month = mm; + x52->date_year = yy; + set_bit(&x52->update_mask, X52_BIT_MFD_DATE); + + return 0; +} + int libx52_set_clock_timezone(libx52_device *x52, libx52_clock_id clock, int offset) { if (!x52) {