basic lcd control (must get improved!)
[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         int cnt;
27
28         /* system init */
29         pll_init();
30         pin_init();
31         ext_mem_init();
32         
33         /* uart init */
34         uart0_init();
35
36         /* display init */
37         display_bl_init();
38
39         /* button init */
40         button_init(&button);
41         button_set_retries(&button,100);
42
43         /* flash init */
44         flash_init();
45
46         /*
47          * start it ...
48          */
49
50         /* pause - seems to not work if running from flash! (?) */
51         pause(0xffffff);
52
53         /* display init */
54         display_bl_toggle();
55         display_init();
56         contrast=0x38;
57
58         /* pasue again */
59
60         /* announce */
61         uart0_send_string(announce);
62
63         
64         while(1) {
65                 pause(0x0fffff);
66
67                 /* button test! */
68                 if(button_get_event(&button)) {
69                         uart0_send_string(announce);
70                         switch(button.key[0]) {
71                                 case BUTTON_POWER:
72                                         display_load_logo(0);
73                                         break;
74                                 case BUTTON_DOWN:
75                                         if(contrast>0x00)
76                                                 contrast-=1;
77                                         DISPLAY_SET_CONTRAST(contrast);
78                                         break;
79                                 case BUTTON_UP:
80                                         if(contrast<0x3f)
81                                                 contrast+=1;
82                                         DISPLAY_SET_CONTRAST(contrast);
83                                         break;
84                                 default:
85                                         display_clear_screen();
86                                         break;
87                         }
88                 }
89         }
90
91         return 0;
92 }
93