more display testing
[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=0x32;
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                         uart0_send_byte(contrast);
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                                 case BUTTON_A:
85                                         display_fill_screen(DISPLAY_FILL_W);
86                                         break;
87                                 case BUTTON_B:
88                                         display_fill_screen(DISPLAY_FILL_LG);
89                                         break;
90                                 case BUTTON_C:
91                                         display_fill_screen(DISPLAY_FILL_DG);
92                                         break;
93                                 case BUTTON_D:
94                                         display_fill_screen(DISPLAY_FILL_B);
95                                         break;
96                                 case BUTTON_1:
97                                         display_draw_rectangle(20,20,40,40,
98                                                                DISPLAY_FILL_B,
99                                                                0);
100                                         break;
101                                 case BUTTON_2:
102                                         display_draw_rectangle(50,50,40,40,
103                                                                DISPLAY_FILL_LG,
104                                                                0);
105                                         break;
106                                 default:
107                                         display_clear_screen();
108                                         break;
109                         }
110                 }
111         }
112
113         return 0;
114 }
115