1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Greg White
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 ****************************************************************************/
37 #include "backlight.h"
38 #include "backlight-target.h"
44 #include "rbunicode.h"
47 #include "rockboxlogo.h"
52 char version
[] = APPSVERSION
;
53 #define LONG_DELAY 200000
54 #define SHORT_DELAY 50000
55 #define PAUSE_DELAY 50000
57 static inline void delay(int duration
)
60 for(i
=0;i
<duration
;i
++);
64 void bl_debug(bool bit
)
68 PDAT0
^= (1 << 2); //Toggle backlight
70 PDAT0
^= (1 << 2); //Toggle backlight
75 PDAT0
^= (1 << 2); //Toggle backlight
77 PDAT0
^= (1 << 2); //Toggle backlight
82 void bl_debug_count(unsigned int input
)
86 for (i
= 0; i
< input
; i
++)
88 PDAT0
^= (1 << 2); //Toggle backlight
90 PDAT0
^= (1 << 2); //Toggle backlight
94 void bl_debug_int(unsigned int input
,unsigned int count
)
97 for (i
= 0; i
< count
; i
++)
99 bl_debug(input
>>i
& 1);
101 delay(SHORT_DELAY
*6);
108 //Set backlight pin to output and enable
110 PCON0
= ((oldval
& ~(3 << 4)) | (1 << 4));
115 // PCON1 = ((oldval & ~(0xf << 12)) | (1 << 12));
120 PCON1
= ((oldval
& ~(0xf << 16)) | (2 << 16));
124 PCON1
= (oldval
& ~(0xf)) | 2;
126 // enable external interrupts
130 asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts
137 /* Calibrate the lot */
138 qt1106_io(QT1106_MODE_FREE
| QT1106_MOD_INF
| QT1106_DI \
139 | QT1106_SLD_SLIDER
| QT1106_CAL_WHEEL
| QT1106_CAL_KEYS
| QT1106_RES_256
);
142 lcd_bitmap(rockboxlogo
, 0, 30, BMPWIDTH_rockboxlogo
, BMPHEIGHT_rockboxlogo
);
145 /* Set to maximum sensitivity */
146 qt1106_io(QT1106_CT
| (0x00 << 8) );
152 int slider
= qt1106_io(QT1106_MODE_FREE
| QT1106_MOD_INF \
153 | QT1106_DI
| QT1106_SLD_SLIDER
| QT1106_RES_256
);
154 snprintf(mystring
, 64, "%x %2.2x",(slider
& 0x008000)>>15, slider
&0xff);
155 lcd_puts(0,1,mystring
);
158 if(slider & 0x008000)
159 bl_debug_count(((slider&0xff)) + 1);