mirror of https://github.com/nirenjan/libx52.git
Add LED state and brightness functionality
parent
88955418b8
commit
bd682cd5c7
|
@ -11,7 +11,7 @@ bin_PROGRAMS = x52d
|
|||
# Service daemon that manages the X52 device
|
||||
x52d_SOURCES = \
|
||||
x52d_main.c x52d_config_parser.c x52d_config.c \
|
||||
x52d_device.c x52d_clock.c
|
||||
x52d_device.c x52d_clock.c x52d_led.c
|
||||
|
||||
x52d_CFLAGS = \
|
||||
-I $(top_srcdir) \
|
||||
|
|
|
@ -43,19 +43,6 @@ void x52d_config_load(const char *cfg_file)
|
|||
/* Callback stubs
|
||||
* TODO: Remove the ones below when their implementation is complete
|
||||
*/
|
||||
void x52d_cfg_set_LED_Fire(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_Throttle(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_A(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_B(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_D(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_E(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_T1(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_T2(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_T3(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_POV(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_LED_Clutch(libx52_led_state param) { (void)param; }
|
||||
void x52d_cfg_set_Brightness_MFD(uint16_t param) { (void)param; }
|
||||
void x52d_cfg_set_Brightness_LED(uint16_t param) { (void)param; }
|
||||
void x52d_cfg_set_Profiles_Directory(char* param) { (void)param; }
|
||||
void x52d_cfg_set_Profiles_ClutchEnabled(bool param) { (void)param; }
|
||||
void x52d_cfg_set_Profiles_ClutchLatched(bool param) { (void)param; }
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Saitek X52 Pro MFD & LED driver - Clock manager
|
||||
*
|
||||
* Copyright (C) 2021 Nirenjan Krishnan (nirenjan@nirenjan.org)
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pinelog.h"
|
||||
#include "x52d_config.h"
|
||||
#include "x52d_const.h"
|
||||
#include "x52d_device.h"
|
||||
|
||||
static const char *TRACE_led_states[] = {
|
||||
"off", "on", "red", "amber", "green"
|
||||
};
|
||||
|
||||
#define SET_LED_STATE(led, state) \
|
||||
PINELOG_TRACE("Setting LED " #led " state to %s", TRACE_led_states[state]); \
|
||||
x52d_dev_set_led_state(LIBX52_LED_ ## led, state);
|
||||
|
||||
void x52d_cfg_set_LED_Fire(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(FIRE, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_Throttle(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(THROTTLE, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_A(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(A, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_B(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(B, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_D(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(D, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_E(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(E, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_T1(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(T1, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_T2(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(T2, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_T3(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(T3, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_POV(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(POV, state);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_LED_Clutch(libx52_led_state state)
|
||||
{
|
||||
SET_LED_STATE(CLUTCH, state);
|
||||
}
|
||||
|
||||
#define SET_BRIGHTNESS(mfd, brightness) \
|
||||
PINELOG_TRACE("Setting %s brightness to %u", mfd ? "MFD" : "LED", brightness); \
|
||||
x52d_dev_set_brightness(mfd, brightness);
|
||||
|
||||
void x52d_cfg_set_Brightness_MFD(uint16_t brightness)
|
||||
{
|
||||
SET_BRIGHTNESS(1, brightness);
|
||||
}
|
||||
|
||||
void x52d_cfg_set_Brightness_LED(uint16_t brightness)
|
||||
{
|
||||
SET_BRIGHTNESS(0, brightness);
|
||||
}
|
Loading…
Reference in New Issue