2008-04-23 21:15:07 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
|
|
|
|
* Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Vuong Minh Hiep (vmh)
|
|
|
|
* Copyright (C) 2008 Thomas Martitz (kugel.)
|
|
|
|
* Copyright (C) 2008 Alexander Papst
|
2008-05-07 21:59:45 +00:00
|
|
|
* Copyright (C) 2008 Peter D'Hoye
|
2008-04-23 21:15:07 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2008-04-23 21:15:07 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
2008-11-20 11:27:31 +00:00
|
|
|
#include "lib/helper.h"
|
2012-02-06 12:29:53 +00:00
|
|
|
#include "lib/pluginlib_actions.h"
|
|
|
|
|
|
|
|
/* this set the context to use with PLA */
|
|
|
|
static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
|
2008-04-23 21:15:07 +00:00
|
|
|
|
2010-11-06 13:40:09 +00:00
|
|
|
/* variable button definitions.
|
|
|
|
- only targets with a colour display
|
|
|
|
LAMP_LEFT / LAMP_RIGHT: change the color
|
|
|
|
LAMP_NEXT / LAMP_PREV: (optional) change the color
|
|
|
|
- only targets which can set brightness
|
|
|
|
LAMP_UP / LAMP_DOWN: change the brightness
|
|
|
|
*/
|
2009-04-07 23:41:44 +00:00
|
|
|
|
2012-02-06 12:29:53 +00:00
|
|
|
/* we use PLA */
|
|
|
|
#ifdef HAVE_SCROLLWHEEL
|
|
|
|
# define LAMP_LEFT PLA_LEFT
|
|
|
|
# define LAMP_RIGHT PLA_RIGHT
|
|
|
|
# define LAMP_UP PLA_SCROLL_FWD
|
|
|
|
# define LAMP_DOWN PLA_SCROLL_BACK
|
|
|
|
# define LAMP_UP_REPEAT PLA_SCROLL_FWD_REPEAT
|
|
|
|
# define LAMP_DOWN_REPEAT PLA_SCROLL_BACK_REPEAT
|
|
|
|
#else
|
|
|
|
# define LAMP_LEFT PLA_LEFT
|
|
|
|
# define LAMP_RIGHT PLA_RIGHT
|
|
|
|
# define LAMP_UP PLA_UP
|
|
|
|
# define LAMP_DOWN PLA_DOWN
|
|
|
|
# define LAMP_UP_REPEAT PLA_UP_REPEAT
|
|
|
|
# define LAMP_DOWN_REPEAT PLA_DOWN_REPEAT
|
|
|
|
#endif/* HAVE_SCROLLWHEEL */
|
2011-11-13 16:16:18 +00:00
|
|
|
|
2008-04-23 21:15:07 +00:00
|
|
|
|
2012-02-06 12:29:53 +00:00
|
|
|
#define LAMP_EXIT PLA_EXIT
|
|
|
|
#define LAMP_EXIT2 PLA_CANCEL
|
|
|
|
|
2008-04-27 15:30:19 +00:00
|
|
|
|
2008-04-23 21:15:07 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-04-24 00:06:45 +00:00
|
|
|
/* RGB color sets */
|
2013-01-29 07:45:14 +00:00
|
|
|
#define NUM_COLORSETS 9
|
2010-11-01 13:37:00 +00:00
|
|
|
static unsigned colorset[NUM_COLORSETS] = {
|
|
|
|
LCD_RGBPACK(255, 255, 255), /* white */
|
|
|
|
LCD_RGBPACK(255, 0, 0), /* red */
|
2013-01-29 07:45:14 +00:00
|
|
|
LCD_RGBPACK(255, 165, 0), /* orange */
|
|
|
|
LCD_RGBPACK(255, 255, 0), /* yellow */
|
|
|
|
LCD_RGBPACK( 0, 255, 0), /* green */
|
|
|
|
LCD_RGBPACK( 0, 0, 255), /* blue */
|
|
|
|
LCD_RGBPACK( 75, 0, 130), /* indigo */
|
|
|
|
LCD_RGBPACK(238, 130, 238), /* violet */
|
|
|
|
LCD_RGBPACK( 0, 0, 0), /* black */
|
2010-11-01 13:37:00 +00:00
|
|
|
};
|
2008-04-24 00:06:45 +00:00
|
|
|
#endif /* HAVE_LCD_COLOR */
|
2008-04-23 21:15:07 +00:00
|
|
|
|
|
|
|
/* this is the plugin entry point */
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2008-04-23 21:15:07 +00:00
|
|
|
{
|
2010-11-01 13:37:00 +00:00
|
|
|
enum plugin_status status = PLUGIN_OK;
|
2009-01-03 13:27:19 +00:00
|
|
|
long button;
|
2010-11-06 13:40:09 +00:00
|
|
|
bool quit = false;
|
2008-04-23 21:15:07 +00:00
|
|
|
(void)parameter;
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-04-24 00:06:45 +00:00
|
|
|
int cs = 0;
|
2010-11-06 13:40:09 +00:00
|
|
|
bool update = false;
|
2008-04-23 21:15:07 +00:00
|
|
|
#endif /* HAVE_LCD_COLOR */
|
|
|
|
|
|
|
|
#if LCD_DEPTH > 1
|
2010-11-01 13:37:00 +00:00
|
|
|
unsigned bg_color = rb->lcd_get_background();
|
2008-04-24 00:06:45 +00:00
|
|
|
rb->lcd_set_backdrop(NULL);
|
2008-04-23 21:15:07 +00:00
|
|
|
rb->lcd_set_background(LCD_WHITE);
|
|
|
|
#endif
|
2008-04-24 00:06:45 +00:00
|
|
|
|
2008-04-23 21:15:07 +00:00
|
|
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
2010-11-06 13:40:09 +00:00
|
|
|
int current_brightness = MAX_BRIGHTNESS_SETTING;
|
2010-11-01 13:37:00 +00:00
|
|
|
backlight_brightness_set(MAX_BRIGHTNESS_SETTING);
|
2008-04-23 21:15:07 +00:00
|
|
|
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
2008-05-08 21:23:31 +00:00
|
|
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
2010-11-01 13:37:00 +00:00
|
|
|
buttonlight_brightness_set(MAX_BRIGHTNESS_SETTING);
|
2008-05-08 21:23:31 +00:00
|
|
|
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
|
2008-04-23 21:15:07 +00:00
|
|
|
|
2008-04-24 00:06:45 +00:00
|
|
|
#ifdef HAVE_LCD_INVERT
|
2010-03-15 15:28:38 +00:00
|
|
|
#ifdef HAVE_NEGATIVE_LCD
|
2008-04-24 00:21:08 +00:00
|
|
|
rb->lcd_set_invert_display(true);
|
2008-04-24 00:06:45 +00:00
|
|
|
#else
|
2008-04-24 00:21:08 +00:00
|
|
|
rb->lcd_set_invert_display(false);
|
2010-03-15 15:28:38 +00:00
|
|
|
#endif /* HAVE_NEGATIVE_LCD */
|
2008-04-24 00:06:45 +00:00
|
|
|
#endif /* HAVE_LCD_INVERT */
|
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
backlight_force_on();
|
2008-05-08 21:23:31 +00:00
|
|
|
#ifdef HAVE_BUTTON_LIGHT
|
2009-01-16 10:34:40 +00:00
|
|
|
buttonlight_force_on();
|
2008-05-08 21:23:31 +00:00
|
|
|
#endif /* HAVE_BUTTON_LIGHT */
|
2008-04-23 21:15:07 +00:00
|
|
|
|
2010-11-06 13:40:09 +00:00
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
|
|
|
|
2008-05-08 21:23:31 +00:00
|
|
|
do
|
2008-04-23 21:15:07 +00:00
|
|
|
{
|
2010-11-06 13:40:09 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2010-11-01 13:37:00 +00:00
|
|
|
if(update)
|
|
|
|
{
|
|
|
|
if(cs < 0)
|
|
|
|
cs = NUM_COLORSETS-1;
|
|
|
|
if(cs >= NUM_COLORSETS)
|
|
|
|
cs = 0;
|
|
|
|
rb->lcd_set_background(colorset[cs]);
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
|
|
|
update = false;
|
|
|
|
}
|
2010-11-06 13:40:09 +00:00
|
|
|
#endif /* HAVE_LCD_COLOR */
|
2012-02-06 12:29:53 +00:00
|
|
|
button = pluginlib_getaction(HZ*30, plugin_contexts,
|
|
|
|
ARRAYLEN(plugin_contexts));
|
2010-11-01 13:37:00 +00:00
|
|
|
|
2012-02-06 12:29:53 +00:00
|
|
|
switch(button)
|
2008-04-23 21:15:07 +00:00
|
|
|
{
|
2010-11-06 13:40:09 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-05-07 21:59:45 +00:00
|
|
|
case LAMP_RIGHT:
|
|
|
|
#ifdef LAMP_NEXT
|
|
|
|
case LAMP_NEXT:
|
|
|
|
#endif /* LAMP_NEXT */
|
2008-04-24 00:06:45 +00:00
|
|
|
cs++;
|
2010-11-01 13:37:00 +00:00
|
|
|
update = true;
|
2008-04-23 21:15:07 +00:00
|
|
|
break;
|
2008-04-24 00:06:45 +00:00
|
|
|
|
2008-05-07 21:59:45 +00:00
|
|
|
case LAMP_LEFT:
|
|
|
|
#ifdef LAMP_PREV
|
|
|
|
case LAMP_PREV:
|
|
|
|
#endif /* LAMP_PREV */
|
2008-04-24 00:06:45 +00:00
|
|
|
cs--;
|
2010-11-01 13:37:00 +00:00
|
|
|
update = true;
|
2008-04-24 00:06:45 +00:00
|
|
|
break;
|
2010-11-06 13:40:09 +00:00
|
|
|
#endif /* HAVE_LCD_COLOR */
|
|
|
|
|
|
|
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
|
|
|
case LAMP_UP:
|
2012-02-06 12:29:53 +00:00
|
|
|
case (LAMP_UP_REPEAT):
|
2010-11-06 13:40:09 +00:00
|
|
|
if (current_brightness < MAX_BRIGHTNESS_SETTING)
|
|
|
|
backlight_brightness_set(++current_brightness);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAMP_DOWN:
|
2012-02-06 12:29:53 +00:00
|
|
|
case (LAMP_DOWN_REPEAT):
|
2010-11-06 13:40:09 +00:00
|
|
|
if (current_brightness > MIN_BRIGHTNESS_SETTING)
|
|
|
|
backlight_brightness_set(--current_brightness);
|
|
|
|
break;
|
|
|
|
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
2012-02-06 12:29:53 +00:00
|
|
|
case LAMP_EXIT:
|
|
|
|
case LAMP_EXIT2:
|
|
|
|
quit = true;
|
|
|
|
break;
|
2010-11-06 13:40:09 +00:00
|
|
|
case BUTTON_NONE:
|
|
|
|
/* time out */
|
|
|
|
break;
|
2008-04-23 21:15:07 +00:00
|
|
|
default:
|
2010-11-06 13:40:09 +00:00
|
|
|
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
2010-11-01 13:37:00 +00:00
|
|
|
{
|
2010-11-06 13:40:09 +00:00
|
|
|
status = PLUGIN_USB_CONNECTED;
|
|
|
|
quit = true;
|
2010-11-01 13:37:00 +00:00
|
|
|
}
|
2008-04-23 21:15:07 +00:00
|
|
|
}
|
2010-11-01 13:37:00 +00:00
|
|
|
rb->reset_poweroff_timer();
|
2008-04-23 21:15:07 +00:00
|
|
|
} while (!quit);
|
|
|
|
|
|
|
|
/* restore */
|
2009-01-16 10:34:40 +00:00
|
|
|
backlight_use_settings();
|
2008-05-08 21:23:31 +00:00
|
|
|
#ifdef HAVE_BUTTON_LIGHT
|
2009-01-16 10:34:40 +00:00
|
|
|
buttonlight_use_settings();
|
2008-05-08 21:23:31 +00:00
|
|
|
#endif /* HAVE_BUTTON_LIGHT */
|
2008-04-23 21:15:07 +00:00
|
|
|
|
2008-04-24 00:06:45 +00:00
|
|
|
#ifdef HAVE_LCD_INVERT
|
2008-04-24 00:21:08 +00:00
|
|
|
rb->lcd_set_invert_display(rb->global_settings->invert);
|
2008-04-24 00:06:45 +00:00
|
|
|
#endif /* HAVE_LCD_INVERT */
|
|
|
|
|
2008-04-23 21:15:07 +00:00
|
|
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
2010-11-01 13:37:00 +00:00
|
|
|
backlight_brightness_use_setting();
|
2008-04-23 21:15:07 +00:00
|
|
|
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
2008-05-08 21:23:31 +00:00
|
|
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
2010-11-01 13:37:00 +00:00
|
|
|
buttonlight_brightness_use_setting();
|
2008-05-08 21:23:31 +00:00
|
|
|
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
|
2008-04-23 21:15:07 +00:00
|
|
|
|
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
rb->lcd_set_background(bg_color);
|
|
|
|
#endif
|
2010-11-01 13:37:00 +00:00
|
|
|
return status;
|
2008-04-23 21:15:07 +00:00
|
|
|
}
|