Index: apps/plugins/lamp.c =================================================================== --- apps/plugins/lamp.c (revision 28737) +++ apps/plugins/lamp.c (working copy) @@ -134,6 +134,10 @@ # define LAMP_UP BUTTON_UP # define LAMP_DOWN BUTTON_DOWN +#elif CONFIG_KEYPAD == SANSA_CLIP_PAD +# define LAMP_UP BUTTON_UP +# define LAMP_DOWN BUTTON_DOWN + #else # error Missing key definitions for this keypad #endif Index: firmware/export/config/sansaclip.h =================================================================== --- firmware/export/config/sansaclip.h (revision 28737) +++ firmware/export/config/sansaclip.h (working copy) @@ -74,13 +74,6 @@ /* define this if you can invert the pixels */ #define HAVE_LCD_INVERT -/* Define this if your LCD can set contrast */ -#define HAVE_LCD_CONTRAST - -#define MIN_CONTRAST_SETTING 0 -#define MAX_CONTRAST_SETTING 50 -#define DEFAULT_CONTRAST_SETTING 30 - #define IRAM_LCDFRAMEBUFFER IBSS_ATTR /* put the lcd frame buffer in IRAM */ #define CONFIG_KEYPAD SANSA_CLIP_PAD @@ -121,6 +114,7 @@ /* Define this for LCD backlight available */ #define HAVE_BACKLIGHT +#define HAVE_BACKLIGHT_BRIGHTNESS /* define this if you have a flash memory storage */ #define HAVE_FLASH_STORAGE @@ -191,10 +185,13 @@ /** Port-specific settings **/ /* Main LCD backlight brightness range and defaults */ -#define MIN_BRIGHTNESS_SETTING 1 -#define MAX_BRIGHTNESS_SETTING 12 -#define DEFAULT_BRIGHTNESS_SETTING 6 +#define MIN_BRIGHTNESS_SETTING 0 +#define MAX_BRIGHTNESS_SETTING 10 +#define DEFAULT_BRIGHTNESS_SETTING 8 +/* "Backlight" fading */ +#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING + /* Default recording levels */ #define DEFAULT_REC_MIC_GAIN 23 #define DEFAULT_REC_LEFT_GAIN 23 Index: firmware/export/config/sansaclipplus.h =================================================================== --- firmware/export/config/sansaclipplus.h (revision 28737) +++ firmware/export/config/sansaclipplus.h (working copy) @@ -78,13 +78,6 @@ /* define this if you can invert the pixels */ #define HAVE_LCD_INVERT -/* Define this if your LCD can set contrast */ -#define HAVE_LCD_CONTRAST - -#define MIN_CONTRAST_SETTING 0 -#define MAX_CONTRAST_SETTING 50 -#define DEFAULT_CONTRAST_SETTING 30 - #define IRAM_LCDFRAMEBUFFER IDATA_ATTR /* put the lcd frame buffer in IRAM */ #define CONFIG_KEYPAD SANSA_CLIP_PAD @@ -128,6 +121,7 @@ /* Define this for LCD backlight available */ #define HAVE_BACKLIGHT +#define HAVE_BACKLIGHT_BRIGHTNESS /* define this if you have a flash memory storage */ #define HAVE_FLASH_STORAGE @@ -204,14 +198,17 @@ /** Port-specific settings **/ /* Main LCD backlight brightness range and defaults */ -#define MIN_BRIGHTNESS_SETTING 1 -#define MAX_BRIGHTNESS_SETTING 12 -#define DEFAULT_BRIGHTNESS_SETTING 6 +#define MIN_BRIGHTNESS_SETTING 0 +#define MAX_BRIGHTNESS_SETTING 10 +#define DEFAULT_BRIGHTNESS_SETTING 8 /* Default recording levels */ #define DEFAULT_REC_MIC_GAIN 23 #define DEFAULT_REC_LEFT_GAIN 23 #define DEFAULT_REC_RIGHT_GAIN 23 +/* "Backlight" fading */ +#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING + /* Define this if a programmable hotkey is mapped */ //#define HAVE_HOTKEY Index: firmware/export/config/sansaclipv2.h =================================================================== --- firmware/export/config/sansaclipv2.h (revision 28737) +++ firmware/export/config/sansaclipv2.h (working copy) @@ -74,13 +74,6 @@ /* define this if you can invert the pixels */ #define HAVE_LCD_INVERT -/* Define this if your LCD can set contrast */ -#define HAVE_LCD_CONTRAST - -#define MIN_CONTRAST_SETTING 0 -#define MAX_CONTRAST_SETTING 50 -#define DEFAULT_CONTRAST_SETTING 30 - #define IRAM_LCDFRAMEBUFFER IDATA_ATTR /* put the lcd frame buffer in IRAM */ #define CONFIG_KEYPAD SANSA_CLIP_PAD @@ -124,6 +117,7 @@ /* Define this for LCD backlight available */ #define HAVE_BACKLIGHT +#define HAVE_BACKLIGHT_BRIGHTNESS /* define this if you have a flash memory storage */ #define HAVE_FLASH_STORAGE @@ -199,10 +193,13 @@ /** Port-specific settings **/ /* Main LCD backlight brightness range and defaults */ -#define MIN_BRIGHTNESS_SETTING 1 -#define MAX_BRIGHTNESS_SETTING 12 -#define DEFAULT_BRIGHTNESS_SETTING 6 +#define MIN_BRIGHTNESS_SETTING 0 +#define MAX_BRIGHTNESS_SETTING 10 +#define DEFAULT_BRIGHTNESS_SETTING 8 +/* "Backlight" fading */ +#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING + /* Default recording levels */ #define DEFAULT_REC_MIC_GAIN 23 #define DEFAULT_REC_LEFT_GAIN 23 Index: firmware/SOURCES =================================================================== --- firmware/SOURCES (revision 28737) +++ firmware/SOURCES (working copy) @@ -1281,7 +1281,7 @@ target/arm/as3525/lcd-ssd1303.c target/arm/as3525/sansa-clipplus/lcd-clip-plus.c target/arm/as3525/sansa-clipplus/button-clip.c -target/arm/as3525/sansa-clipplus/backlight-clip.c +target/arm/as3525/backlight-clip.c #ifndef BOOTLOADER target/arm/powermgmt-ascodec.c target/arm/as3525/sansa-clipplus/powermgmt-clipplus.c @@ -1296,7 +1296,7 @@ target/arm/as3525/lcd-ssd1303.c target/arm/as3525/sansa-clipv2/lcd-clipv2.c target/arm/as3525/sansa-clipv2/button-clip.c -target/arm/as3525/sansa-clipv2/backlight-clipv2.c +target/arm/as3525/backlight-clip.c #ifndef BOOTLOADER target/arm/powermgmt-ascodec.c target/arm/as3525/sansa-clipv2/powermgmt-clipv2.c @@ -1310,6 +1310,7 @@ target/arm/as3525/lcd-ssd1303.c target/arm/as3525/sansa-clip/lcd-clip.c target/arm/as3525/sansa-clip/button-clip.c +target/arm/as3525/backlight-clip.c #ifndef BOOTLOADER target/arm/powermgmt-ascodec.c target/arm/as3525/sansa-clip/powermgmt-clip.c Index: firmware/target/arm/as3525/lcd-ssd1303.c =================================================================== --- firmware/target/arm/as3525/lcd-ssd1303.c (revision 28737) +++ firmware/target/arm/as3525/lcd-ssd1303.c (working copy) @@ -64,6 +64,9 @@ #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ +/* constants */ +#define DEFAULT_CONTRAST_SETTING 30 + /** globals **/ static bool display_on; /* used by lcd_enable */ Index: firmware/target/arm/as3525/sansa-clipplus/backlight-target.h =================================================================== --- firmware/target/arm/as3525/sansa-clipplus/backlight-target.h (revision 28737) +++ firmware/target/arm/as3525/sansa-clipplus/backlight-target.h (working copy) @@ -1,30 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright © 2009 Rafaël Carré - * - * 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. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef BACKLIGHT_TARGET_H -#define BACKLIGHT_TARGET_H - -#define _backlight_init() true - -void _backlight_on(void); -void _backlight_off(void); -#define _backlight_panic_on() _backlight_on() - -#endif Index: firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c =================================================================== --- firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c (revision 28737) +++ firmware/target/arm/as3525/sansa-clipplus/backlight-clip.c (working copy) @@ -1,37 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright © 2009 Rafaël Carré - * - * 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. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "backlight-target.h" -#include "lcd.h" -#include "as3525v2.h" -#include "ascodec-target.h" - -void _backlight_on(void) -{ - ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x90); - lcd_enable(true); -} - -void _backlight_off(void) -{ - lcd_enable(false); - ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x00); -} Index: firmware/target/arm/as3525/backlight-clip.c =================================================================== --- firmware/target/arm/as3525/backlight-clip.c (revision 0) +++ firmware/target/arm/as3525/backlight-clip.c (revision 0) @@ -0,0 +1,95 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Bertrik Sikken + * + * 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. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* + * "Backlight" code for the various Sansa Clip players (v1, v2, plus) + * + * These players use an OLED display, so they don't really have a backlight, + * but are treated as such to allow display fade-in and fade-out. + */ + +#include "config.h" +#include "lcd.h" +#include "lcd-clip.h" +#include "backlight.h" +#include "backlight-target.h" +#include "as3525v2.h" +#include "ascodec-target.h" + +bool _backlight_init(void) +{ +#if defined(SANSA_CLIP) + GPIOD_DIR |= (1<<7); /* for button light */ +#elif defined(SANSA_CLIPV2) + GPIOA_DIR |= (1<<5); /* for button light */ +#endif + return true; +} + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void _backlight_set_brightness(int brightness) +{ + static const int curve[] = {1, 2, 3, 4, 6, 8, 11, 16, 23, 32, 45}; + lcd_set_contrast(curve[brightness] - 1); +} +#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ + +void _backlight_panic_on(void) +{ + _backlight_on(); +} + +void _backlight_on(void) +{ +#if (CONFIG_CPU == AS3525v2) + ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x90); +#endif + lcd_enable(true); +} + +void _backlight_off(void) +{ + lcd_enable(false); +#if (CONFIG_CPU == AS3525v2) + ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x00); +#endif +} + +#ifdef HAVE_BUTTON_LIGHT +void _buttonlight_on(void) +{ +#if defined(SANSA_CLIP) + GPIOD_PIN(7) = (1<<7); +#elif defined(SANSA_CLIPV2) + GPIOA_PIN(5) = (1<<5); +#endif +} + +void _buttonlight_off(void) +{ +#if defined(SANSA_CLIP) + GPIOD_PIN(7) = 0; +#elif defined(SANSA_CLIPV2) + GPIOA_PIN(5) = 0; +#endif +} +#endif /* HAVE_BUTTON_LIGHT */ + Property changes on: firmware/target/arm/as3525/backlight-clip.c ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Index: firmware/target/arm/as3525/backlight-target.h =================================================================== --- firmware/target/arm/as3525/backlight-target.h (revision 0) +++ firmware/target/arm/as3525/backlight-target.h (revision 0) @@ -0,0 +1,39 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Bertrik Sikken + * + * 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. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include "config.h" + +bool _backlight_init(void); + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void _backlight_set_brightness(int brightness); +#endif + +void _backlight_panic_on(void); +void _backlight_on(void); +void _backlight_off(void); + +#ifdef HAVE_BUTTON_LIGHT +void _buttonlight_on(void); +void _buttonlight_off(void); +#endif + Property changes on: firmware/target/arm/as3525/backlight-target.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Index: firmware/target/arm/as3525/sansa-clipv2/backlight-target.h =================================================================== --- firmware/target/arm/as3525/sansa-clipv2/backlight-target.h (revision 28737) +++ firmware/target/arm/as3525/sansa-clipv2/backlight-target.h (working copy) @@ -1,48 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright © 2009 Rafaël Carré - * - * 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. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef BACKLIGHT_TARGET_H -#define BACKLIGHT_TARGET_H - -#include -#include "cpu.h" - -void _backlight_on(void); -void _backlight_off(void); -#define _backlight_panic_on() _backlight_on() - -static inline bool _backlight_init(void) -{ - GPIOA_DIR |= 1<<5; /* for button light */ - return true; -} - -static inline void _buttonlight_on(void) -{ - GPIOA_PIN(5) |= 1<<5; -} - -static inline void _buttonlight_off(void) -{ - GPIOA_PIN(5) &= ~(1<<5); -} - - -#endif Index: firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c =================================================================== --- firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c (revision 28737) +++ firmware/target/arm/as3525/sansa-clipv2/backlight-clipv2.c (working copy) @@ -1,37 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright © 2009 Rafaël Carré - * - * 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. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "backlight-target.h" -#include "lcd.h" -#include "as3525v2.h" -#include "ascodec-target.h" - -void _backlight_on(void) -{ - ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x90); - lcd_enable(true); -} - -void _backlight_off(void) -{ - lcd_enable(false); - ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x0); -} Index: firmware/target/arm/as3525/sansa-clip/backlight-target.h =================================================================== --- firmware/target/arm/as3525/sansa-clip/backlight-target.h (revision 28737) +++ firmware/target/arm/as3525/sansa-clip/backlight-target.h (working copy) @@ -1,56 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright © 2008 Rafaël Carré - * - * 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. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef BACKLIGHT_TARGET_H -#define BACKLIGHT_TARGET_H - -#include "stdbool.h" -#include "lcd.h" -#include "backlight.h" - -static inline void _backlight_on(void) -{ - lcd_enable(true); -} - -static inline void _backlight_off(void) -{ - lcd_enable(false); -} - -#define _backlight_panic_on() _backlight_on() - -static inline bool _backlight_init(void) -{ - GPIOD_DIR |= (1<<7); /* for button light */ - return true; -} - -static inline void _buttonlight_on(void) -{ - GPIOD_PIN(7) = (1<<7); -} - -static inline void _buttonlight_off(void) -{ - GPIOD_PIN(7) = 0; -} - -#endif