1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Karl Kurbjun
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 #include "backlight-target.h"
26 #include "backlight.h"
29 #include "spi-target.h"
31 int _backlight_brightness
=DEFAULT_BRIGHTNESS_SETTING
;
33 static void _backlight_write_brightness(int brightness
)
35 uint8_t bl_command
[] = {0xa4, 0x00, brightness
, 0xbb};
36 spi_block_transfer(SPI_target_BACKLIGHT
, bl_command
, 4, 0, 0);
39 void _backlight_on(void)
41 #if defined(HAVE_LCD_SLEEP) && !defined(BOOTLOADER)
42 backlight_lcd_sleep_countdown(false); /* stop counter */
44 #ifdef HAVE_LCD_ENABLE
45 lcd_enable(true); /* power on lcd + visible display */
47 _backlight_write_brightness(_backlight_brightness
);
50 void _backlight_off(void)
52 _backlight_write_brightness(0);
53 #if defined(HAVE_LCD_SLEEP) && !defined(BOOTLOADER)
54 /* Disable lcd after fade completes (when lcd_sleep timeout expires) */
55 backlight_lcd_sleep_countdown(true); /* start countdown */
59 /* Assumes that the backlight has been initialized */
60 void _backlight_set_brightness(int brightness
)
62 _backlight_brightness
=brightness
;
63 _backlight_write_brightness(brightness
);
66 void __backlight_dim(bool dim_now
)
68 _backlight_set_brightness(dim_now
?
69 DEFAULT_BRIGHTNESS_SETTING
:
70 DEFAULT_DIMNESS_SETTING
);
73 bool _backlight_init(void)
75 _backlight_set_brightness(_backlight_brightness
);