mirror of https://github.com/nirenjan/libx52.git
Remove deprecated API functions
parent
548f2e9357
commit
2ccfd79bd6
|
@ -161,23 +161,6 @@ void libx52_exit(libx52_device *dev);
|
|||
*/
|
||||
int libx52_set_text(libx52_device *x52, uint8_t line, const char *text, uint8_t length);
|
||||
|
||||
/**
|
||||
* @brief Set the LED state
|
||||
*
|
||||
* The X52 pro has a total of 20 LEDs that can be individually turned on or off.
|
||||
* This function will allow you to control them. This function is deprecated
|
||||
* and should be replaced by \ref libx52_set_led_state.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @param[in] x52 Pointer to the device
|
||||
* @param[in] led LED index.
|
||||
* @param[in] state State of the LED, 0 for off, non-zero for on.
|
||||
*
|
||||
* @returns 0 on success, -errno on failure.
|
||||
*/
|
||||
int libx52_set_led(libx52_device *x52, uint8_t led, uint8_t state);
|
||||
|
||||
/**
|
||||
* @brief Set the LED state
|
||||
*
|
||||
|
@ -194,43 +177,6 @@ int libx52_set_led_state(libx52_device *x52,
|
|||
libx52_led_id led,
|
||||
libx52_led_state state);
|
||||
|
||||
/**
|
||||
* @brief Set the MFD date
|
||||
*
|
||||
* The X52 pro has a date display that is off by default. Writing a date will
|
||||
* show the date on the display.
|
||||
*
|
||||
* @deprecated This function is deprecated by \ref libx52_set_clock
|
||||
*
|
||||
* @param[in] x52 Pointer to the device
|
||||
* @param[in] day Day of the month (1 - 31)
|
||||
* @param[in] month Month of the year (1 - 12)
|
||||
* @param[in] year 2-digit year value
|
||||
* @param[in] format 0, 1 or 2, corresponding to yy-mm-dd, mm-dd-yy or
|
||||
* dd-mm-yy formats respectively
|
||||
*
|
||||
* @returns 0 on success, -errno on failure.
|
||||
*/
|
||||
int libx52_set_date(libx52_device *x52, uint8_t day, uint8_t month, uint8_t year, uint8_t format);
|
||||
|
||||
/**
|
||||
* @brief Set the MFD time
|
||||
*
|
||||
* The X52 pro has a time display that displays the time of day in either
|
||||
* 12 hour or 24 hour format. There is no associated timezone info, and the
|
||||
* user is responsible for setting the correct time in the required timezone.
|
||||
*
|
||||
* @deprecated This function is deprecated by \ref libx52_set_clock
|
||||
*
|
||||
* @param[in] x52 Pointer to the device
|
||||
* @param[in] hour Hour of the day (0 - 23)
|
||||
* @param[in] minute Minute of the hour (0 - 59)
|
||||
* @param[in] format 0 - 12 hour, 1 - 24 hour
|
||||
*
|
||||
* @returns 0 on success, -errno on failure.
|
||||
*/
|
||||
int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute, uint8_t format);
|
||||
|
||||
/**
|
||||
* @brief Set the clock
|
||||
*
|
||||
|
@ -253,19 +199,20 @@ int libx52_set_clock(libx52_device *x52, time_t time, int local);
|
|||
* 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 offset
|
||||
* from GMT.
|
||||
* from GMT. Offset is limited to +/- 1440 minutes, and any offset outside
|
||||
* this range will result in a return value of -EDOM
|
||||
*
|
||||
* @param[in] x52 Pointer to the device
|
||||
* @param[in] clock \ref libx52_clock_id, cannot be \ref
|
||||
* libx52_clock_primary
|
||||
* LIBX52_CLOCK_1
|
||||
* @param[in] offset Offset in minutes from GMT (east is positive, west
|
||||
* is negative)
|
||||
*
|
||||
* @returns 0 on success, -errno on failure
|
||||
*/
|
||||
int libx52_set_clock_offset(libx52_device *x52,
|
||||
libx52_clock_id clock,
|
||||
int offset);
|
||||
int libx52_set_clock_timezone(libx52_device *x52,
|
||||
libx52_clock_id clock,
|
||||
int offset);
|
||||
|
||||
/**
|
||||
* @brief Set whether the clock is displayed in 12 hour or 24 hour format.
|
||||
|
@ -348,26 +295,4 @@ int libx52_set_blink(libx52_device *x52, uint8_t state);
|
|||
*/
|
||||
int libx52_update(libx52_device *x52);
|
||||
|
||||
/* LED indices */
|
||||
#define X52_LED_FIRE 0x01
|
||||
#define X52_LED_A_RED 0x02
|
||||
#define X52_LED_A_GREEN 0x03
|
||||
#define X52_LED_B_RED 0x04
|
||||
#define X52_LED_B_GREEN 0x05
|
||||
#define X52_LED_D_RED 0x06
|
||||
#define X52_LED_D_GREEN 0x07
|
||||
#define X52_LED_E_RED 0x08
|
||||
#define X52_LED_E_GREEN 0x09
|
||||
#define X52_LED_T1_RED 0x0a
|
||||
#define X52_LED_T1_GREEN 0x0b
|
||||
#define X52_LED_T2_RED 0x0c
|
||||
#define X52_LED_T2_GREEN 0x0d
|
||||
#define X52_LED_T3_RED 0x0e
|
||||
#define X52_LED_T3_GREEN 0x0f
|
||||
#define X52_LED_POV_RED 0x10
|
||||
#define X52_LED_POV_GREEN 0x11
|
||||
#define X52_LED_I_RED 0x12
|
||||
#define X52_LED_I_GREEN 0x13
|
||||
#define X52_LED_THROTTLE 0x14
|
||||
|
||||
#endif /* !defined LIBX52_H */
|
||||
|
|
|
@ -15,47 +15,24 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <libusb.h>
|
||||
#include "libx52.h"
|
||||
|
||||
/*
|
||||
* The X52 MFD supports the following:
|
||||
* - 3 lines of 16 characters each
|
||||
* - Clock with HH:MM
|
||||
* - Base clock with HH:MM [AM/PM]
|
||||
* - Date with YYMMDD (IIRC)
|
||||
* - 2 additional clocks offset from base clock
|
||||
*/
|
||||
#define X52_MFD_LINE_SIZE 16
|
||||
#define X52_MFD_LINES 3
|
||||
#define X52_MFD_CLOCKS 3
|
||||
|
||||
struct x52_mfd_line {
|
||||
uint8_t text[X52_MFD_LINE_SIZE];
|
||||
uint8_t length;
|
||||
};
|
||||
|
||||
enum x52_mfd_date_format {
|
||||
x52_mfd_format_yymmdd, /* YY-MM-DD */
|
||||
x52_mfd_format_mmddyy, /* MM-DD-YY */
|
||||
x52_mfd_format_ddmmyy, /* DD-MM-YY */
|
||||
x52_mfd_format_max,
|
||||
};
|
||||
|
||||
struct x52_mfd_date {
|
||||
uint8_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t format; /* See format enum */
|
||||
};
|
||||
|
||||
struct x52_mfd_time {
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t h24; /* 24 hour format if 1 */
|
||||
};
|
||||
|
||||
struct x52_mfd_offs {
|
||||
uint16_t min_off; /* Minute offset from clock 0 */
|
||||
uint8_t neg_off; /* Negative offset if 1 */
|
||||
uint8_t h24; /* 24 hour format if 1 */
|
||||
};
|
||||
|
||||
struct libx52_device {
|
||||
libusb_context *ctx;
|
||||
libusb_device_handle *hdl;
|
||||
|
@ -70,9 +47,15 @@ struct libx52_device {
|
|||
uint16_t led_brightness;
|
||||
|
||||
struct x52_mfd_line line[X52_MFD_LINES];
|
||||
struct x52_mfd_date date;
|
||||
struct x52_mfd_time time;
|
||||
struct x52_mfd_offs offs[2];
|
||||
libx52_date_format date_format;
|
||||
int date_day;
|
||||
int date_month;
|
||||
int date_year;
|
||||
int time_hour;
|
||||
int time_minute;
|
||||
|
||||
int timezone[X52_MFD_CLOCKS];
|
||||
libx52_clock_format time_format[X52_MFD_CLOCKS];
|
||||
};
|
||||
|
||||
/** Indicator bits for update mask */
|
||||
|
@ -108,4 +91,19 @@ struct libx52_device {
|
|||
#define X52_BIT_MFD_OFFS1 29
|
||||
#define X52_BIT_MFD_OFFS2 30
|
||||
|
||||
static inline void set_bit(uint32_t *value, uint32_t bit)
|
||||
{
|
||||
*value |= (1UL << bit);
|
||||
}
|
||||
|
||||
static inline void clr_bit(uint32_t *value, uint32_t bit)
|
||||
{
|
||||
*value &= ~(1UL << bit);
|
||||
}
|
||||
|
||||
static inline uint32_t tst_bit(uint32_t *value, uint32_t bit)
|
||||
{
|
||||
return (*value & (1UL << bit));
|
||||
}
|
||||
|
||||
#endif /* !defined X52JOY_COMMON_H */
|
||||
|
|
|
@ -24,25 +24,10 @@
|
|||
static int libx52_control_transfer(libx52_device *x52, uint16_t index, uint16_t value)
|
||||
{
|
||||
return libusb_control_transfer(x52->hdl,
|
||||
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT,
|
||||
X52_VENDOR_REQUEST, value, index, NULL, 0, 1000);
|
||||
}
|
||||
|
||||
inline void set_bit(uint32_t *value, uint32_t bit)
|
||||
{
|
||||
*value |= (1UL << bit);
|
||||
}
|
||||
|
||||
inline void clr_bit(uint32_t *value, uint32_t bit)
|
||||
{
|
||||
*value &= ~(1UL << bit);
|
||||
}
|
||||
|
||||
inline uint32_t tst_bit(uint32_t *value, uint32_t bit)
|
||||
{
|
||||
return (*value & (1UL << bit));
|
||||
}
|
||||
|
||||
static int libx52_write_line(libx52_device *x52, uint8_t line_index)
|
||||
{
|
||||
uint8_t i;
|
||||
|
@ -118,33 +103,63 @@ int libx52_set_led(libx52_device *x52, uint8_t led, uint8_t state)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int libx52_set_date(libx52_device *x52, uint8_t date, uint8_t month, uint8_t year, uint8_t format)
|
||||
{
|
||||
if (!x52 || format >= x52_mfd_format_max) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
x52->date.day = date;
|
||||
x52->date.month = month;
|
||||
x52->date.year = year;
|
||||
x52->date.format = format;
|
||||
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_DATE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int libx52_set_time(libx52_device *x52, uint8_t hour, uint8_t minute, uint8_t format)
|
||||
int libx52_set_led_state(libx52_device *x52, libx52_led_id led, libx52_led_state state)
|
||||
{
|
||||
if (!x52) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
x52->time.hour = hour;
|
||||
x52->time.minute = minute;
|
||||
x52->time.h24 = !!format;
|
||||
switch (led) {
|
||||
case LIBX52_LED_FIRE:
|
||||
case LIBX52_LED_THROTTLE:
|
||||
if (state == LIBX52_LED_STATE_OFF) {
|
||||
clr_bit(&x52->led_mask, led);
|
||||
set_bit(&x52->update_mask, led);
|
||||
} else if (state == LIBX52_LED_STATE_ON) {
|
||||
set_bit(&x52->led_mask, led);
|
||||
set_bit(&x52->update_mask, led);
|
||||
} else {
|
||||
/* Colors not supported */
|
||||
return -ENOTSUP;
|
||||
}
|
||||
break;
|
||||
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_TIME);
|
||||
default:
|
||||
/* All other LEDs support OFF, RED, AMBER and GREEN states
|
||||
* However, they are composed of individual RED and GREEN LEDs which
|
||||
* must be turned on or off individually.
|
||||
*/
|
||||
switch (state) {
|
||||
case LIBX52_LED_STATE_OFF:
|
||||
clr_bit(&x52->led_mask, led + 0); // Red
|
||||
clr_bit(&x52->led_mask, led + 1); // Green
|
||||
break;
|
||||
|
||||
case LIBX52_LED_STATE_RED:
|
||||
set_bit(&x52->led_mask, led + 0); // Red
|
||||
clr_bit(&x52->led_mask, led + 1); // Green
|
||||
break;
|
||||
|
||||
case LIBX52_LED_STATE_AMBER:
|
||||
set_bit(&x52->led_mask, led + 0); // Red
|
||||
set_bit(&x52->led_mask, led + 1); // Green
|
||||
break;
|
||||
|
||||
case LIBX52_LED_STATE_GREEN:
|
||||
clr_bit(&x52->led_mask, led + 0); // Red
|
||||
set_bit(&x52->led_mask, led + 1); // Green
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Cannot set the LED to "ON" */
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Set the update mask bits */
|
||||
set_bit(&x52->update_mask, led + 0); // Red
|
||||
set_bit(&x52->update_mask, led + 1); // Green
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -155,23 +170,23 @@ static int libx52_write_date(libx52_device *x52)
|
|||
uint16_t value2; //yy
|
||||
int rc;
|
||||
|
||||
switch (x52->date.format) {
|
||||
case x52_mfd_format_yymmdd:
|
||||
value1 = x52->date.month << 8 |
|
||||
x52->date.year;
|
||||
value2 = x52->date.day;
|
||||
switch (x52->date_format) {
|
||||
case LIBX52_DATE_FORMAT_YYMMDD:
|
||||
value1 = x52->date_month << 8 |
|
||||
x52->date_year;
|
||||
value2 = x52->date_day;
|
||||
break;
|
||||
|
||||
case x52_mfd_format_mmddyy:
|
||||
value1 = x52->date.day << 8 |
|
||||
x52->date.month;
|
||||
value2 = x52->date.year;
|
||||
case LIBX52_DATE_FORMAT_MMDDYY:
|
||||
value1 = x52->date_day << 8 |
|
||||
x52->date_month;
|
||||
value2 = x52->date_year;
|
||||
break;
|
||||
|
||||
case x52_mfd_format_ddmmyy:
|
||||
value1 = x52->date.month << 8 |
|
||||
x52->date.day;
|
||||
value2 = x52->date.year;
|
||||
case LIBX52_DATE_FORMAT_DDMMYY:
|
||||
value1 = x52->date_month << 8 |
|
||||
x52->date_day;
|
||||
value2 = x52->date_year;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -244,18 +259,101 @@ int libx52_set_clock(libx52_device *x52, time_t time, int local)
|
|||
|
||||
if (local) {
|
||||
timeval = *localtime(&time);
|
||||
/* timezone from time.h presents the offset in seconds west of GMT.
|
||||
* Negate and divide by 60 to get the offset in minutes east of GMT.
|
||||
*/
|
||||
x52->timezone[LIBX52_CLOCK_1] = -timezone / 60;
|
||||
} else {
|
||||
timeval = *gmtime(&time);
|
||||
/* No offset from GMT */
|
||||
x52->timezone[LIBX52_CLOCK_1] = 0;
|
||||
}
|
||||
|
||||
x52->date.day = timeval.tm_mday;
|
||||
x52->date.month = timeval.tm_mon + 1;
|
||||
x52->date.year = timeval.tm_year % 100;
|
||||
x52->time.hour = timeval.tm_hour;
|
||||
x52->time.minute = timeval.tm_min;
|
||||
x52->date_day = timeval.tm_mday;
|
||||
x52->date_month = timeval.tm_mon + 1;
|
||||
x52->date_year = timeval.tm_year % 100;
|
||||
x52->time_hour = timeval.tm_hour;
|
||||
x52->time_minute = timeval.tm_min;
|
||||
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_DATE);
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_TIME);
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_OFFS1);
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_OFFS2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int libx52_set_clock_timezone(libx52_device *x52, libx52_clock_id clock, int offset)
|
||||
{
|
||||
if (!x52) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Limit offset to +/- 24 hours */
|
||||
if (offset < -1440 || offset > 1440) {
|
||||
return -EDOM;
|
||||
}
|
||||
|
||||
switch (clock) {
|
||||
case LIBX52_CLOCK_2:
|
||||
x52->timezone[clock] = offset;
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_OFFS1);
|
||||
break;
|
||||
|
||||
case LIBX52_CLOCK_3:
|
||||
x52->timezone[clock] = offset;
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_OFFS2);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int libx52_set_clock_format(libx52_device *x52,
|
||||
libx52_clock_id clock,
|
||||
libx52_clock_format format)
|
||||
{
|
||||
if (!x52) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((format != LIBX52_CLOCK_FORMAT_12HR) &&
|
||||
(format != LIBX52_CLOCK_FORMAT_24HR)) {
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (clock) {
|
||||
case LIBX52_CLOCK_1:
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_TIME);
|
||||
break;
|
||||
|
||||
case LIBX52_CLOCK_2:
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_OFFS1);
|
||||
break;
|
||||
|
||||
case LIBX52_CLOCK_3:
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_OFFS2);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
x52->time_format[clock] = format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int libx52_set_date_format(libx52_device *x52, libx52_date_format format)
|
||||
{
|
||||
if (!x52) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
x52->date_format = format;
|
||||
set_bit(&x52->update_mask, X52_BIT_MFD_DATE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -336,12 +434,6 @@ int libx52_update(libx52_device *x52)
|
|||
break;
|
||||
|
||||
case X52_BIT_MFD_TIME:
|
||||
value = x52->time.h24 << 15 |
|
||||
x52->time.hour << 8 |
|
||||
x52->time.minute;
|
||||
rc = libx52_control_transfer(x52, X52_TIME_CLOCK1, value);
|
||||
break;
|
||||
|
||||
case X52_BIT_MFD_OFFS1:
|
||||
case X52_BIT_MFD_OFFS2:
|
||||
default:
|
||||
|
|
|
@ -16,31 +16,17 @@ static void test_cleanup(libx52_device *dev)
|
|||
libx52_set_brightness(dev, 0, 127);
|
||||
|
||||
/* Set the default LED states */
|
||||
libx52_set_led(dev, X52_LED_FIRE, 1);
|
||||
|
||||
libx52_set_led(dev, X52_LED_A_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_A_GREEN, 1);
|
||||
libx52_set_led(dev, X52_LED_B_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_B_GREEN, 1);
|
||||
libx52_set_led(dev, X52_LED_D_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_D_GREEN, 1);
|
||||
libx52_set_led(dev, X52_LED_E_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_E_GREEN, 1);
|
||||
|
||||
libx52_set_led(dev, X52_LED_T1_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_T1_GREEN, 1);
|
||||
libx52_set_led(dev, X52_LED_T2_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_T2_GREEN, 1);
|
||||
libx52_set_led(dev, X52_LED_T3_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_T3_GREEN, 1);
|
||||
|
||||
libx52_set_led(dev, X52_LED_POV_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_POV_GREEN, 1);
|
||||
|
||||
libx52_set_led(dev, X52_LED_I_RED, 0);
|
||||
libx52_set_led(dev, X52_LED_I_GREEN, 1);
|
||||
|
||||
libx52_set_led(dev, X52_LED_THROTTLE, 1);
|
||||
libx52_set_led_state(dev, LIBX52_LED_FIRE, LIBX52_LED_STATE_ON);
|
||||
libx52_set_led_state(dev, LIBX52_LED_A, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_B, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_D, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_E, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_T1, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_T2, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_T3, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_POV, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_CLUTCH, LIBX52_LED_STATE_GREEN);
|
||||
libx52_set_led_state(dev, LIBX52_LED_THROTTLE, LIBX52_LED_STATE_ON);
|
||||
|
||||
/* Shift/Blink Off */
|
||||
libx52_set_shift(dev, 0);
|
||||
|
@ -97,28 +83,28 @@ static void test_leds(libx52_device *dev, int step)
|
|||
libx52_set_text(dev, 0, "LED Test", 8);
|
||||
libx52_set_text(dev, 1, "Fire", 4);
|
||||
libx52_set_text(dev, 2, "OFF", 3);
|
||||
libx52_set_led(dev, X52_LED_FIRE, 0);
|
||||
libx52_set_led_state(dev, LIBX52_LED_FIRE, LIBX52_LED_STATE_OFF);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
/* Turn on Fire LED */
|
||||
libx52_set_text(dev, 1, "Fire", 4);
|
||||
libx52_set_text(dev, 2, "ON", 2);
|
||||
libx52_set_led(dev, X52_LED_FIRE, 1);
|
||||
libx52_set_led_state(dev, LIBX52_LED_FIRE, LIBX52_LED_STATE_ON);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* Turn off Throttle LED */
|
||||
libx52_set_text(dev, 1, "Throttle", 8);
|
||||
libx52_set_text(dev, 2, "OFF", 3);
|
||||
libx52_set_led(dev, X52_LED_THROTTLE, 0);
|
||||
libx52_set_led_state(dev, LIBX52_LED_THROTTLE, LIBX52_LED_STATE_OFF);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/* Turn on Throttle LED */
|
||||
libx52_set_text(dev, 1, "Throttle", 8);
|
||||
libx52_set_text(dev, 2, "ON", 2);
|
||||
libx52_set_led(dev, X52_LED_THROTTLE, 1);
|
||||
libx52_set_led_state(dev, LIBX52_LED_THROTTLE, LIBX52_LED_STATE_ON);
|
||||
break;
|
||||
|
||||
default: {
|
||||
|
@ -129,23 +115,22 @@ static void test_leds(libx52_device *dev, int step)
|
|||
switch (step % 4) {
|
||||
case 0:
|
||||
libx52_set_text(dev, 2, "OFF", 3);
|
||||
libx52_set_led(dev, led, 0);
|
||||
libx52_set_led(dev, led + 1, 0);
|
||||
libx52_set_led_state(dev, led, LIBX52_LED_STATE_OFF);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
libx52_set_text(dev, 2, "RED", 3);
|
||||
libx52_set_led(dev, led, 1);
|
||||
libx52_set_led_state(dev, led, LIBX52_LED_STATE_RED);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
libx52_set_text(dev, 2, "AMBER", 5);
|
||||
libx52_set_led(dev, led + 1, 1);
|
||||
libx52_set_led_state(dev, led, LIBX52_LED_STATE_AMBER);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
libx52_set_text(dev, 2, "GREEN", 5);
|
||||
libx52_set_led(dev, led, 0);
|
||||
libx52_set_led_state(dev, led, LIBX52_LED_STATE_GREEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -206,10 +191,10 @@ struct test_case {
|
|||
};
|
||||
|
||||
static struct test_case cases[] = {
|
||||
{ test_brightness, 129 },
|
||||
{ test_mfd_display, 16 },
|
||||
{ test_leds, 40 },
|
||||
{ test_blinkenlichts, 4 },
|
||||
{ test_brightness, 129 },
|
||||
{ NULL, 0 } /* Must be the last entry */
|
||||
};
|
||||
|
||||
|
@ -232,7 +217,7 @@ int main()
|
|||
(*tc->test)(dev, i);
|
||||
}
|
||||
libx52_update(dev);
|
||||
usleep(250000);
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
tc++;
|
||||
|
|
Loading…
Reference in New Issue