Add overlay_led_driver

This commit is contained in:
twinaphex 2018-01-05 13:27:52 +01:00
parent 751c0fe58c
commit a516a0a3a3
2 changed files with 38 additions and 25 deletions

View File

@ -498,6 +498,7 @@ INPUT
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
#include "../input/input_overlay.c" #include "../input/input_overlay.c"
#include "../led/overlay_led_driver.c"
#include "../tasks/task_overlay.c" #include "../tasks/task_overlay.c"
#endif #endif

View File

@ -10,8 +10,8 @@
typedef struct typedef struct
{ {
int setup[MAX_LEDS]; int setup[MAX_LEDS];
int map[MAX_LEDS]; int map[MAX_LEDS];
} overlayled_t; } overlayled_t;
static overlayled_t curins; static overlayled_t curins;
@ -19,19 +19,21 @@ static overlayled_t *cur = &curins;
static void overlay_init(void) static void overlay_init(void)
{ {
int i; int i;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
RARCH_LOG("[LED]: overlay LED driver init\n");
for(i=0;i<MAX_LEDS;i++) {
cur->setup[i] = 0;
cur->map[i] = settings->uints.led_map[i];
RARCH_LOG("[LED]: overlay map[%d]=%d\n",i,cur->map[i]);
if(cur->map[i] >= 0) RARCH_LOG("[LED]: overlay LED driver init\n");
{
input_overlay_set_visibility(cur->map[i],OVERLAY_VISIBILITY_HIDDEN); for (i = 0; i < MAX_LEDS; i++)
} {
} cur->setup[i] = 0;
cur->map[i] = settings->uints.led_map[i];
RARCH_LOG("[LED]: overlay map[%d]=%d\n",i,cur->map[i]);
if (cur->map[i] >= 0)
input_overlay_set_visibility(cur->map[i],
OVERLAY_VISIBILITY_HIDDEN);
}
} }
static void overlay_free(void) static void overlay_free(void)
@ -41,19 +43,29 @@ static void overlay_free(void)
static void overlay_set(int led,int state) static void overlay_set(int led,int state)
{ {
int gpio = 0; int gpio = 0;
if((led < 0) || (led >= MAX_LEDS)) if ((led < 0) || (led >= MAX_LEDS))
{ {
RARCH_WARN("[LED]: invalid led %d\n",led); RARCH_WARN("[LED]: invalid led %d\n",led);
return; return;
} }
gpio = cur->map[led]; gpio = cur->map[led];
if(gpio < 0) return; if (gpio < 0)
input_overlay_set_visibility(gpio,state?OVERLAY_VISIBILITY_VISIBLE:OVERLAY_VISIBILITY_HIDDEN); return;
RARCH_LOG("[LED]: set visibility %d %d\n",gpio,state);
input_overlay_set_visibility(gpio,
state ? OVERLAY_VISIBILITY_VISIBLE
: OVERLAY_VISIBILITY_HIDDEN);
RARCH_LOG("[LED]: set visibility %d %d\n",gpio,state);
} }
static led_driver_t overlay_led_driver_ins = { overlay_init, overlay_free, overlay_set }; static led_driver_t overlay_led_driver_ins = {
overlay_init,
overlay_free,
overlay_set
};
led_driver_t *overlay_led_driver = &overlay_led_driver_ins; led_driver_t *overlay_led_driver = &overlay_led_driver_ins;