libx52  0.3.2
Saitek X52/X52Pro drivers for Linux/Unix
Enumerations | Functions
Clock control

Enumerations

enum  libx52_clock_id { LIBX52_CLOCK_1 , LIBX52_CLOCK_2 , LIBX52_CLOCK_3 }
 List of supported clocks on the MFD. More...
 
enum  libx52_clock_format { LIBX52_CLOCK_FORMAT_12HR , LIBX52_CLOCK_FORMAT_24HR }
 Supported clock formats. More...
 
enum  libx52_date_format { LIBX52_DATE_FORMAT_DDMMYY , LIBX52_DATE_FORMAT_MMDDYY , LIBX52_DATE_FORMAT_YYMMDD }
 Supported date formats. More...
 

Functions

int libx52_set_clock (libx52_device *x52, time_t time, int local)
 Set the clock. More...
 
int libx52_set_clock_timezone (libx52_device *x52, libx52_clock_id clock, int offset)
 Set the timezone for the secondary and tertiary clocks. More...
 
int libx52_set_clock_format (libx52_device *x52, libx52_clock_id clock, libx52_clock_format format)
 Set whether the clock is displayed in 12 hour or 24 hour format. More...
 
int libx52_set_time (libx52_device *x52, uint8_t hour, uint8_t minute)
 Set the hour and minute on clock 1. More...
 
int libx52_set_date (libx52_device *x52, uint8_t dd, uint8_t mm, uint8_t yy)
 Set the date. More...
 
int libx52_set_date_format (libx52_device *x52, libx52_date_format format)
 Set the date format for the MFD date display. More...
 

Detailed Description

Control the clocks on the MFD

Enumeration Type Documentation

◆ libx52_clock_format

Supported clock formats.

Enumerator
LIBX52_CLOCK_FORMAT_12HR 

12-hour display on the MFD clock

LIBX52_CLOCK_FORMAT_24HR 

24-hour display on the MFD clock

◆ libx52_clock_id

List of supported clocks on the MFD.

Enumerator
LIBX52_CLOCK_1 

Primary clock on the MFD, indicated by the number 1

LIBX52_CLOCK_2 

Secondary clock on the MFD, indicated by the number 2

LIBX52_CLOCK_3 

Tertiary clock on the MFD, indicated by the number 3

◆ libx52_date_format

Supported date formats.

Enumerator
LIBX52_DATE_FORMAT_DDMMYY 

Date format DD-MM-YY

LIBX52_DATE_FORMAT_MMDDYY 

Date format MM-DD-YY

LIBX52_DATE_FORMAT_YYMMDD 

Date format YY-MM-DD

Function Documentation

◆ libx52_set_clock()

int libx52_set_clock ( libx52_device x52,
time_t  time,
int  local 
)

Set the clock.

This function sets the primary clock's date and time with the specified Unix time value. time can be obtained from time(2). local controls whether the primary clock displays local time or GMT.

If this function is called again within the same minute as calculated by localtime(3) or gmtime(3), it will return LIBX52_ERROR_TRY_AGAIN, as it does not require any updates to be written to the joystick. However, if the call changes the timezone from local time to GMT or vice-versa, then the function will return 0, since it requires a write to the device to update the clock with the new timezone.

The secondary and tertiary clocks are driven off the primary clock and set using libx52_set_clock_timezone.

Parameters
[in]x52Pointer to the device context
[in]timeTime value from time(3)
[in]local0 for GM time, non-zero for localtime
Returns

◆ libx52_set_clock_format()

int libx52_set_clock_format ( libx52_device x52,
libx52_clock_id  clock,
libx52_clock_format  format 
)

Set whether the clock is displayed in 12 hour or 24 hour format.

The clocks on the X52 Pro MFD are all displayed as HH:MM, but can be set to display it in 12-hour (AM/PM) or 24-hour format. The default format if not specified is 12-hour.

Limitations
The hardware has a limitation that it cannot display 12:00 am in 12 hour mode - instead it will display as 00:00 am
Parameters
[in]x52Pointer to the device context
[in]clocklibx52_clock_id
[in]formatlibx52_clock_format
Returns
  • 0 on success
  • LIBX52_ERROR_INVALID_PARAM if x52 is not valid, or if either of clock or format are outside their respective ranges.

◆ libx52_set_clock_timezone()

int libx52_set_clock_timezone ( libx52_device x52,
libx52_clock_id  clock,
int  offset 
)

Set the timezone for the secondary and tertiary clocks.

The X52 Pro has a total of 3 clock displays. The secondary and tertiary clocks are controlled as an offset from the primary clock in minutes. However, for convenience, the X52 library calculates this offset internally and only requires you to set the timezone as the number of minutes east of UTC. offset is limited to ± 1440 minutes, and any offset outside this range will result in a return value of LIBX52_ERROR_OUT_OF_RANGE

Example
// Set clock 2 timezone to Pacific Standard Time (UTC-08:00)
// Set clock 3 timezone to Indian Standard Time (UTC+05:30)
int libx52_set_clock_timezone(libx52_device *x52, libx52_clock_id clock, int offset)
Set the timezone for the secondary and tertiary clocks.
@ LIBX52_CLOCK_2
Definition: libx52.h:57
Parameters
[in]x52Pointer to the device context
[in]clocklibx52_clock_id, cannot be LIBX52_CLOCK_1
[in]offsetOffset in minutes from GMT (east is positive, west is negative)
Returns

◆ libx52_set_date()

int libx52_set_date ( libx52_device x52,
uint8_t  dd,
uint8_t  mm,
uint8_t  yy 
)

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.

Parameters
[in]x52Pointer to the device context
[in]ddDay to display
[in]mmMonth to display
[in]yyYear to display
Returns

◆ libx52_set_date_format()

int libx52_set_date_format ( libx52_device x52,
libx52_date_format  format 
)

Set the date format for the MFD date display.

If not set, the date format defaults to DD-MM-YY

Parameters
[in]x52Pointer to the device context
[in]formatlibx52_date_format
Returns

◆ libx52_set_time()

int libx52_set_time ( libx52_device x52,
uint8_t  hour,
uint8_t  minute 
)

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.

Parameters
[in]x52Pointer to the device context
[in]hourHour to display
[in]minuteMinute to display
Returns