Index: embios/trunk/target/ipodnano2g/backlight.c |
— | — | @@ -0,0 +1,42 @@ |
| 2 | +// |
| 3 | +// |
| 4 | +// Copyright 2010 TheSeven |
| 5 | +// |
| 6 | +// |
| 7 | +// This file is part of emBIOS. |
| 8 | +// |
| 9 | +// emBIOS is free software: you can redistribute it and/or |
| 10 | +// modify it under the terms of the GNU General Public License as |
| 11 | +// published by the Free Software Foundation, either version 2 of the |
| 12 | +// License, or (at your option) any later version. |
| 13 | +// |
| 14 | +// emBIOS is distributed in the hope that it will be useful, |
| 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 17 | +// See the GNU General Public License for more details. |
| 18 | +// |
| 19 | +// You should have received a copy of the GNU General Public License along |
| 20 | +// with emBIOS. If not, see <http://www.gnu.org/licenses/>. |
| 21 | +// |
| 22 | +// |
| 23 | + |
| 24 | + |
| 25 | +#include "global.h" |
| 26 | +#include "i2c.h" |
| 27 | +#include "backlight.h" |
| 28 | + |
| 29 | + |
| 30 | +void backlight_on(bool on) |
| 31 | +{ |
| 32 | + i2c_sendbyte(0, 0xe6, 0x29, on ? 1 : 0);
|
| 33 | +} |
| 34 | + |
| 35 | +void backlight_set_fade(uint8_t fade) |
| 36 | +{ |
| 37 | + i2c_sendbyte(0, 0xe6, 0x2b, fade);
|
| 38 | +} |
| 39 | + |
| 40 | +void backlight_set_brightness(uint8_t brightness) |
| 41 | +{ |
| 42 | + i2c_sendbyte(0, 0xe6, 0x28, (46 * (brightness & 0xff)) >> 8);
|
| 43 | +} |
Index: embios/trunk/target/ipodnano2g/target.h |
— | — | @@ -46,6 +46,8 @@ |
47 | 47 | #define LCD_FORMAT rgb565
|
48 | 48 | #define LCD_BYTESPERPIXEL 2
|
49 | 49 |
|
| 50 | +#define HAVE_BACKLIGHT
|
| 51 | +
|
50 | 52 | #define HAVE_I2C
|
51 | 53 |
|
52 | 54 | #define HAVE_BOOTFLASH
|
Index: embios/trunk/target/ipodnano4g/backlight.h |
— | — | @@ -1,34 +0,0 @@ |
2 | | -// |
3 | | -// |
4 | | -// Copyright 2010 TheSeven |
5 | | -// |
6 | | -// |
7 | | -// This file is part of emBIOS. |
8 | | -// |
9 | | -// emBIOS is free software: you can redistribute it and/or |
10 | | -// modify it under the terms of the GNU General Public License as |
11 | | -// published by the Free Software Foundation, either version 2 of the |
12 | | -// License, or (at your option) any later version. |
13 | | -// |
14 | | -// emBIOS is distributed in the hope that it will be useful, |
15 | | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | | -// See the GNU General Public License for more details. |
18 | | -// |
19 | | -// You should have received a copy of the GNU General Public License along |
20 | | -// with emBIOS. If not, see <http://www.gnu.org/licenses/>. |
21 | | -// |
22 | | -// |
23 | | - |
24 | | - |
25 | | -#ifndef __BACKLIGHT_H__ |
26 | | -#define __BACKLIGHT_H__ |
27 | | - |
28 | | -#include "global.h" |
29 | | - |
30 | | -// fade is only used on the 2G but keep it here for a common API (use anything) |
31 | | -void backlight_set(double brightness, uint8_t fade); |
32 | | -void backlight_on(uint8_t fade); |
33 | | -void backlight_off(uint8_t fade); |
34 | | - |
35 | | -#endif |
Index: embios/trunk/target/ipodnano4g/backlight.c |
— | — | @@ -23,19 +23,23 @@ |
24 | 24 | |
25 | 25 | #include "global.h" |
26 | 26 | #include "i2c.h" |
| 27 | +#include "backlight.h" |
27 | 28 | |
28 | | -void backlight_set(uint8_t brightness, uint8_t fade) |
| 29 | + |
| 30 | +static bool backlight_fade; |
| 31 | + |
| 32 | + |
| 33 | +void backlight_on(bool on) |
29 | 34 | { |
30 | | - i2csendbyte(0xe6, 0x30, brightness); |
31 | | - i2csendbyte(0xe6, 0x31, 3); |
| 35 | + i2c_sendbyte(0, 0xe6, 0x31, (backlight_fade ? 2 : 0) + (on ? 1 : 0));
|
32 | 36 | } |
33 | 37 | |
34 | | -void backlight_on(uint8_t fade) |
| 38 | +void backlight_set_fade(uint8_t fade) |
35 | 39 | { |
36 | | - backlight_set(255, 32); |
| 40 | + backlight_fade = fade;
|
37 | 41 | } |
38 | 42 | |
39 | | -void backlight_off(uint8_t fade) |
| 43 | +void backlight_set_brightness(uint8_t brightness) |
40 | 44 | { |
41 | | - i2csendbyte(0xe6, 0x31, 2); |
| 45 | + i2c_sendbyte(0, 0xe6, 0x30, (250 * (brightness & 0xff)) >> 8);
|
42 | 46 | } |
Index: embios/trunk/target/ipodnano4g/target.h |
— | — | @@ -46,6 +46,8 @@ |
47 | 47 | #define LCD_FORMAT rgb565
|
48 | 48 | #define LCD_BYTESPERPIXEL 2
|
49 | 49 |
|
| 50 | +#define HAVE_BACKLIGHT
|
| 51 | +
|
50 | 52 | #define HAVE_I2C
|
51 | 53 |
|
52 | 54 | //#define HAVE_STORAGE
|
Index: embios/trunk/export/syscallwrappers.h |
— | — | @@ -152,6 +152,9 @@ |
153 | 153 | #define strrchr(args...) __embios_syscall->strrchr(args)
|
154 | 154 | #define strstr(args...) __embios_syscall->strstr(args)
|
155 | 155 | #define strtok_r(args...) __embios_syscall->strtok_r(args)
|
| 156 | +#define backlight_on(args...) __embios_syscall->backlight_on(args) |
| 157 | +#define backlight_set_fade(args...) __embios_syscall->backlight_set_fade(args) |
| 158 | +#define backlight_set_brightness(args...) __embios_syscall->backlight_set_brightness(args)
|
156 | 159 |
|
157 | 160 |
|
158 | 161 | #endif
|
Index: embios/trunk/export/syscallapi.h |
— | — | @@ -45,6 +45,7 @@ |
46 | 46 | #include "../nand.h"
|
47 | 47 | #include "../power.h"
|
48 | 48 | #include "../execimage.h"
|
| 49 | +#include "../backlight.h"
|
49 | 50 | #include "../libc/include/string.h"
|
50 | 51 | #include "../libc/include/stdlib.h"
|
51 | 52 | #include "../libc/include/stdio.h"
|
— | — | @@ -183,6 +184,9 @@ |
184 | 185 | typeof(strrchr) *strrchr;
|
185 | 186 | typeof(strstr) *strstr;
|
186 | 187 | typeof(strtok_r) *strtok_r;
|
| 188 | + typeof(backlight_on) *backlight_on;
|
| 189 | + typeof(backlight_set_fade) *backlight_set_fade;
|
| 190 | + typeof(backlight_set_brightness) *backlight_set_brightness;
|
187 | 191 | };
|
188 | 192 |
|
189 | 193 |
|
Index: embios/trunk/backlight.h |
— | — | @@ -0,0 +1,33 @@ |
| 2 | +// |
| 3 | +// |
| 4 | +// Copyright 2010 TheSeven |
| 5 | +// |
| 6 | +// |
| 7 | +// This file is part of emBIOS. |
| 8 | +// |
| 9 | +// emBIOS is free software: you can redistribute it and/or |
| 10 | +// modify it under the terms of the GNU General Public License as |
| 11 | +// published by the Free Software Foundation, either version 2 of the |
| 12 | +// License, or (at your option) any later version. |
| 13 | +// |
| 14 | +// emBIOS is distributed in the hope that it will be useful, |
| 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 17 | +// See the GNU General Public License for more details. |
| 18 | +// |
| 19 | +// You should have received a copy of the GNU General Public License along |
| 20 | +// with emBIOS. If not, see <http://www.gnu.org/licenses/>. |
| 21 | +// |
| 22 | +// |
| 23 | + |
| 24 | + |
| 25 | +#ifndef __BACKLIGHT_H__ |
| 26 | +#define __BACKLIGHT_H__ |
| 27 | + |
| 28 | +#include "global.h" |
| 29 | + |
| 30 | +void backlight_on(bool on); |
| 31 | +void backlight_set_fade(uint8_t fade); |
| 32 | +void backlight_set_brightness(uint8_t brightness); |
| 33 | + |
| 34 | +#endif |
Index: embios/trunk/SOURCES |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | target/ipodnano2g/storage_nand.c
|
15 | 15 | target/ipodnano2g/clockgates.c
|
16 | 16 | target/ipodnano2g/bootflash.c
|
| 17 | +target/ipodnano2g/backlight.c
|
17 | 18 | usb/synopsysotg.c
|
18 | 19 | #endif
|
19 | 20 |
|
Index: embios/trunk/syscallapi.c |
— | — | @@ -42,6 +42,7 @@ |
43 | 43 | #include "nand.h"
|
44 | 44 | #include "power.h"
|
45 | 45 | #include "execimage.h"
|
| 46 | +#include "backlight.h"
|
46 | 47 | #include "libc/include/string.h"
|
47 | 48 | #include "libc/include/stdlib.h"
|
48 | 49 | #include "libc/include/stdio.h"
|
— | — | @@ -158,6 +159,11 @@ |
159 | 160 | .lcd_get_height = lcd_get_height,
|
160 | 161 | .lcd_get_bytes_per_pixel = lcd_get_bytes_per_pixel,
|
161 | 162 | #endif
|
| 163 | +#ifdef HAVE_BACKLIGHT
|
| 164 | + .backlight_on = backlight_on,
|
| 165 | + .backlight_set_fade = backlight_set_fade,
|
| 166 | + .backlight_set_brightness = backlight_set_brightness,
|
| 167 | +#endif
|
162 | 168 | #ifdef HAVE_BOOTFLASH
|
163 | 169 | .bootflash_filesize = bootflash_filesize,
|
164 | 170 | .bootflash_attributes = bootflash_attributes,
|