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"
50 char version
[] = APPSVERSION
;
51 #define LONG_DELAY 200000
52 #define SHORT_DELAY 50000
53 #define PAUSE_DELAY 50000
55 static inline void delay(int duration
)
58 for(i
=0;i
<duration
;i
++);
62 void bl_debug(bool bit
)
66 PDAT0
^= (1 << 2); //Toggle backlight
68 PDAT0
^= (1 << 2); //Toggle backlight
73 PDAT0
^= (1 << 2); //Toggle backlight
75 PDAT0
^= (1 << 2); //Toggle backlight
80 void bl_debug_count(unsigned int input
)
84 for (i
= 0; i
< input
; i
++)
86 PDAT0
^= (1 << 2); //Toggle backlight
88 PDAT0
^= (1 << 2); //Toggle backlight
92 void bl_debug_int(unsigned int input
,unsigned int count
)
95 for (i
= 0; i
< count
; i
++)
97 bl_debug(input
>>i
& 1);
102 /* These functions are supposed to be static in lcd-m6sl.c, but
103 we use them here for testing */
104 void init_lcd_spi(void);
105 unsigned int lcd_read_id(void);
109 //Set backlight pin to output and enable
112 PCON0
= ((oldval
& ~(3 << 4)) | (1 << 4));
117 PCON1
= ((oldval
& ~(0xf << 16)) | (0 << 16));
121 // Wait for play to be pressed
122 while(!(PDAT1
& (1 << 4)));
123 // Wait for play to be released
124 while((PDAT1
& (1 << 4)));
125 PDAT0
^= (1 << 2); //Toggle backlight
130 bl_debug_count((model
&0xf000)>>12);
131 bl_debug_count((model
&0xf00)>>8);
132 bl_debug_count((model
&0xf0)>>4);
133 bl_debug_count(model
&0xf);
135 /* Calibrate the lot */
136 qt1106_io(QT1106_MODE_FREE
| QT1106_MOD_INF
| QT1106_DI \
137 | QT1106_SLD_SLIDER
| QT1106_CAL_WHEEL
| QT1106_CAL_KEYS
| QT1106_RES_4
);
139 /* Set to maximum sensitivity */
140 qt1106_io(QT1106_CT
| (0x00 << 8) );
146 int slider
= qt1106_io(QT1106_MODE_FREE
| QT1106_MOD_INF \
147 | QT1106_DI
| QT1106_SLD_SLIDER
| QT1106_RES_4
);
148 if(slider
& 0x008000)
149 bl_debug_count(((slider
&0xff)) + 1);