summaryrefslogtreecommitdiff
path: root/bootloader/mrobe500.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/mrobe500.c')
-rwxr-xr-xbootloader/mrobe500.c79
1 files changed, 60 insertions, 19 deletions
diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c
index 1133fa6def..5f80d6d6c9 100755
--- a/bootloader/mrobe500.c
+++ b/bootloader/mrobe500.c
@@ -41,9 +41,59 @@
41#include "spi.h" 41#include "spi.h"
42#include "uart-target.h" 42#include "uart-target.h"
43#include "tsc2100.h" 43#include "tsc2100.h"
44#include "time.h"
44 45
45extern int line; 46extern int line;
46 47
48struct touch_calibration_point tl, br;
49
50void touchpad_get_one_point(struct touch_calibration_point *p)
51{
52 int data = 0;
53 int start = current_tick;
54 while (TIME_AFTER(start+(HZ/3), current_tick))
55 {
56 if (button_read_device()&BUTTON_TOUCHPAD)
57 {
58 data = button_get_last_touch();
59 p->val_x = data>>16;
60 p->val_y = data&0xffff;
61 start = current_tick;
62 }
63 else if (data == 0)
64 start = current_tick;
65 }
66}
67
68#define MARGIN 25
69#define LEN 7
70void touchpad_calibrate_screen(void)
71{
72 reset_screen();
73 printf("touch the center of the crosshairs to calibrate");
74 /* get the topleft value */
75 lcd_hline(MARGIN-LEN, MARGIN+LEN, MARGIN);
76 lcd_vline(MARGIN, MARGIN-LEN, MARGIN+LEN);
77 lcd_update();
78 tl.px_x = MARGIN; tl.px_y = MARGIN;
79 touchpad_get_one_point(&tl);
80 reset_screen();
81 printf("touch the center of the crosshairs to calibrate");
82 /* get the topright value */
83 lcd_hline(LCD_WIDTH-MARGIN-LEN, LCD_WIDTH-MARGIN+LEN, LCD_HEIGHT-MARGIN);
84 lcd_vline(LCD_WIDTH-MARGIN, LCD_HEIGHT-MARGIN-LEN, LCD_HEIGHT-MARGIN+LEN);
85 lcd_update();
86 br.px_x = LCD_WIDTH-MARGIN; br.px_y = LCD_HEIGHT-MARGIN;
87 touchpad_get_one_point(&br);
88 reset_screen();
89 line++;
90 printf("tl %d %d", tl.val_x, tl.val_y);
91 printf("br %d %d", br.val_x, br.val_y);
92 line++;
93 set_calibration_points(&tl, &br);
94}
95
96
47void main(void) 97void main(void)
48{ 98{
49 unsigned char* loadbuffer; 99 unsigned char* loadbuffer;
@@ -101,8 +151,14 @@ void main(void)
101 } 151 }
102#if 0 152#if 0
103 int button=0, *address=0x0, count=0; 153 int button=0, *address=0x0, count=0;
154 use_calibration(false);
155 touchpad_calibrate_screen();
156 use_calibration(true);
104 while(true) 157 while(true)
105 { 158 {
159 struct tm *t = get_time();
160 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);
161 printf("time: %d", mktime(t));
106 button = button_read_device(); 162 button = button_read_device();
107 if (button == BUTTON_POWER) 163 if (button == BUTTON_POWER)
108 { 164 {
@@ -119,26 +175,11 @@ void main(void)
119 address-=0x1000; 175 address-=0x1000;
120 if (button&BUTTON_TOUCHPAD) 176 if (button&BUTTON_TOUCHPAD)
121 { 177 {
122 int touch = button_get_last_touch(); 178 unsigned int data = button_get_last_touch();
123 printf("x: %d, y: %d", (touch>>16), touch&0xffff); 179 printf("x: %d, y: %d", data>>16, data&0xffff);
124 line--; 180 line-=3;
125 } 181 }
126// if ((IO_GIO_BITSET0&(1<<14) == 0) 182 else line -=2;
127// {
128// short x,y,z1,z2, reg;
129// extern int uart1count;
130// tsc2100_read_values(&x, &y, &z1, &z2);
131// printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2);
132// printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff);
133// printf("current tick: %04x", current_tick);
134// printf("Address: 0x%08x Data: 0x%08x", address, *address);
135// printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1));
136// printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2));
137// printf("uart1count: %d", uart1count);
138// printf("%x %x", IO_UART1_RFCR & 0x3f, IO_UART1_DTRR & 0xff);
139// tsc2100_keyclick(); /* doesnt work :( */
140// line -= 8;
141// }
142 } 183 }
143#endif 184#endif
144 printf("ATA"); 185 printf("ATA");