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"
30 #include "lcd-target.h"
32 short read_brightness
= 0x0;
34 static void _backlight_write_brightness(int brightness
)
36 uint8_t bl_command
[] = {0xA4, 0x00, brightness
, 0xA4};
38 uint8_t bl_read
[] = {0xA8, 0x00};
40 spi_block_transfer(SPI_target_BACKLIGHT
, bl_read
, 2, (char*)&read_brightness
, 2);
42 spi_block_transfer(SPI_target_BACKLIGHT
, bl_command
, 4, 0, 0);
45 void _backlight_on(void)
47 lcd_awake(); /* power on lcd + visible display */
49 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_NO_FADING)
50 _backlight_write_brightness(backlight_brightness
);
54 void _backlight_off(void)
56 _backlight_write_brightness(0);
59 /* Assumes that the backlight has been initialized */
60 void _backlight_set_brightness(int brightness
)
62 _backlight_write_brightness(brightness
);
65 void __backlight_dim(bool dim_now
)
67 _backlight_set_brightness(dim_now
?
68 DEFAULT_BRIGHTNESS_SETTING
:
69 DEFAULT_DIMNESS_SETTING
);
72 bool _backlight_init(void)
74 _backlight_set_brightness(backlight_brightness
);