blob: 1537e76219d8ead0f76379c404b929419edd0b20 [file] [log] [blame]
Karl Kurbjun7b97fe22007-09-20 04:46:41 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Karl Kurbjunbebbac82007-09-22 15:43:38 +00008 * $Id$
Karl Kurbjun7b97fe22007-09-20 04:46:41 +00009 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "cpu.h"
24#include "system.h"
25#include "backlight-target.h"
26#include "backlight.h"
27#include "lcd.h"
28#include "power.h"
Catalin Patuleaf57ea9a2007-11-02 06:13:43 +000029#include "spi-target.h"
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000030
Jens Arnoldef12b3b2007-11-12 18:49:53 +000031void _backlight_on(void)
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000032{
Jens Arnoldef12b3b2007-11-12 18:49:53 +000033 _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000034}
35
Jens Arnoldef12b3b2007-11-12 18:49:53 +000036void _backlight_off(void)
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000037{
Jens Arnoldef12b3b2007-11-12 18:49:53 +000038 _backlight_set_brightness(0);
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000039}
40
41/* Assumes that the backlight has been initialized */
Jens Arnoldef12b3b2007-11-12 18:49:53 +000042void _backlight_set_brightness(int brightness)
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000043{
Catalin Patuleaf57ea9a2007-11-02 06:13:43 +000044 uint8_t bl_command[] = {0xa4, 0x00, brightness, 0xbb};
45 spi_block_transfer(SPI_target_BACKLIGHT, bl_command, 4, 0, 0);
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000046}
47
48void __backlight_dim(bool dim_now)
49{
Jens Arnoldef12b3b2007-11-12 18:49:53 +000050 _backlight_set_brightness(dim_now ?
Catalin Patuleaf57ea9a2007-11-02 06:13:43 +000051 DEFAULT_BRIGHTNESS_SETTING :
52 DEFAULT_DIMNESS_SETTING);
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000053}
54
Jens Arnoldef12b3b2007-11-12 18:49:53 +000055bool _backlight_init(void)
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000056{
Jens Arnoldef12b3b2007-11-12 18:49:53 +000057 _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
Karl Kurbjun7b97fe22007-09-20 04:46:41 +000058 return true;
59}