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 ****************************************************************************/
34 #include "backlight.h"
35 #include "backlight-target.h"
41 #include "rbunicode.h"
44 #include "uart-target.h"
47 #include "system-arm.h"
55 struct touch_calibration_point tl
, br
;
57 void touchscreen_get_one_point(struct touch_calibration_point
*p
)
60 int start
= current_tick
;
61 while (TIME_AFTER(start
+(HZ
/3), current_tick
))
63 if (button_read_device()&BUTTON_TOUCHSCREEN
)
65 data
= button_get_last_touch();
67 p
->val_y
= data
&0xffff;
77 void touchscreen_calibrate_screen(void)
80 printf("touch the center of the crosshairs to calibrate");
81 /* get the topleft value */
82 lcd_hline(MARGIN
-LEN
, MARGIN
+LEN
, MARGIN
);
83 lcd_vline(MARGIN
, MARGIN
-LEN
, MARGIN
+LEN
);
85 tl
.px_x
= MARGIN
; tl
.px_y
= MARGIN
;
86 touchscreen_get_one_point(&tl
);
88 printf("touch the center of the crosshairs to calibrate");
89 /* get the topright value */
90 lcd_hline(LCD_WIDTH
-MARGIN
-LEN
, LCD_WIDTH
-MARGIN
+LEN
, LCD_HEIGHT
-MARGIN
);
91 lcd_vline(LCD_WIDTH
-MARGIN
, LCD_HEIGHT
-MARGIN
-LEN
, LCD_HEIGHT
-MARGIN
+LEN
);
93 br
.px_x
= LCD_WIDTH
-MARGIN
; br
.px_y
= LCD_HEIGHT
-MARGIN
;
94 touchscreen_get_one_point(&br
);
97 printf("tl %d %d", tl
.val_x
, tl
.val_y
);
98 printf("br %d %d", br
.val_x
, br
.val_y
);
100 set_calibration_points(&tl
, &br
);
103 static uint8_t bl_command
[] = {0xa4, 0x00, 0x00, 0xbb};
110 use_calibration(false);
111 touchscreen_calibrate_screen();
112 use_calibration(true);
118 struct tm
*t
= get_time();
119 printf("%d:%d:%d %d %d %d", t
->tm_hour
, t
->tm_min
, t
->tm_sec
, t
->tm_mday
, t
->tm_mon
, t
->tm_year
);
120 printf("time: %d", mktime(t
));
122 button
= button_get(false);
123 if (button
== BUTTON_POWER
)
126 IO_GIO_BITSET1
|=1<<10;
128 if (button
==BUTTON_RC_VOL_DOWN
)
130 brightness
= (brightness
- 5) & 0x7f;
131 bl_command
[2] = brightness
;
132 spi_block_transfer(SPI_target_BACKLIGHT
, bl_command
, 4, 0, 0);
134 else if (button
==BUTTON_RC_VOL_UP
)
136 brightness
= (brightness
+ 5) & 0x7f;
137 bl_command
[2] = brightness
;
138 spi_block_transfer(SPI_target_BACKLIGHT
, bl_command
, 4, 0, 0);
142 // tsc2100_read_values(&x, &y, &z1, &z2);
143 // printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2);
144 // printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff);
145 // // tsc2100_keyclick(); /* doesnt work :( */
148 else if (button
== BUTTON_RC_HEART
)
151 touchscreen_set_mode(TOUCHSCREEN_POINT
);
153 else if (button
== BUTTON_RC_MODE
)
156 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
159 else if (button
&BUTTON_TOUCHSCREEN
)
161 if (button
&BUTTON_REL
)
163 unsigned int data
= button_get_data();
164 int x
= (data
&0xffff0000)>>16, y
= data
&0x0000ffff;
167 printf("BB: %x %d %d", button
, x
,y
);
168 lcd_hline(x
-5, x
+5, y
);
169 lcd_vline(x
, y
-5, y
+5);
172 else if (button
== BUTTON_RC_PLAY
)
179 // if (button&BUTTON_REL)
181 printf("%08x %s\n", button
, (button
&BUTTON_REL
)?"yes":"no");
192 unsigned char* loadbuffer
;
195 int(*kernel_entry
)(void);
211 lcd_setfont(FONT_SYSFIXED
);
213 /* Show debug messages if button is pressed */
214 // if(button_read_device())
217 printf("Rockbox boot loader");
218 printf("Version %s", APPSVERSION
);
222 /* Enter USB mode without USB thread */
223 if(usb_detect() == USB_INSERTED
)
225 const char msg
[] = "Bootloader USB mode";
227 lcd_putsxy( (LCD_WIDTH
- (SYSFONT_WIDTH
* strlen(msg
))) / 2,
228 (LCD_HEIGHT
- SYSFONT_HEIGHT
) / 2, msg
);
231 ide_power_enable(true);
236 while (usb_detect() == USB_INSERTED
)
238 ata_spin(); /* Prevent the drive from spinning down */
262 rc
= disk_mount_all();
268 printf("Loading firmware");
270 loadbuffer
= (unsigned char*) 0x00900000;
271 buffer_size
= (unsigned char*)0x01900000 - loadbuffer
;
273 rc
= load_firmware(loadbuffer
, BOOTFILE
, buffer_size
);
275 error(EBOOTFILE
, rc
);
279 kernel_entry
= (void*) loadbuffer
;