stupid mistake fixed, display basically working now!
[my-code/arm.git] / betty / betty.c
1 /*
2  * betty.c - alternative firmware for the betty tv ;)
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  */
7
8 /* includes */
9 #include "betty.h"
10
11 /*
12  * functions
13  */
14
15 #define cc1100_init     spi1_init(8,SPI_MASTER,8)
16
17 /*
18  * main function
19  */
20
21 int main() {
22
23         char announce[]="betty - live from flash at 0x80000000! ;)\r\n";
24         t_button button;
25         u8 contrast;
26
27         /* system init */
28         pll_init();
29         pin_init();
30         ext_mem_init();
31         
32         /* uart init */
33         uart0_init();
34
35         /* display init */
36         display_bl_init();
37
38         /* button init */
39         button_init(&button);
40         button_set_retries(&button,100);
41
42         /* flash init */
43         flash_init();
44
45         /*
46          * start it ...
47          */
48
49         /* pause - seems to not work if running from flash! (?) */
50         pause(0xffffff);
51
52         /* display init */
53         display_bl_toggle();
54         display_init();
55         contrast=0x38;
56
57         /* pasue again */
58
59         /* announce */
60         uart0_send_string(announce);
61
62         
63         while(1) {
64                 pause(0x0fffff);
65
66                 /* button test! */
67                 if(button_get_event(&button)) {
68                         uart0_send_string(announce);
69                         switch(button.key[0]) {
70                                 case BUTTON_POWER:
71                                         display_load_logo(0);
72                                         break;
73                                 case BUTTON_DOWN:
74                                         if(contrast>0x00)
75                                                 contrast-=1;
76                                         DISPLAY_SET_CONTRAST(contrast);
77                                         break;
78                                 case BUTTON_UP:
79                                         if(contrast<0x3f)
80                                                 contrast+=1;
81                                         DISPLAY_SET_CONTRAST(contrast);
82                                         break;
83                                 case BUTTON_TV:
84                                         display_fill_screen(button.key[0]);
85                                         break;
86                                 default:
87                                         display_clear_screen();
88                                         break;
89                         }
90                 }
91         }
92
93         return 0;
94 }
95