pause values somehow reasonable for flash and ram usage
[my-code/arm.git] / betty / betty.c
index 31bc5a2..427d32b 100644 (file)
 
 int main() {
 
-       char buf[]="betty - live from flash at 0x80000000! ;)\r\n";
+       char announce[]="betty - live from flash at 0x80000000! ;)\r\n";
        t_button button;
+       u8 contrast;
 
        /* system init */
        pll_init();
-
+       pin_init();
+       ext_mem_init();
+       
        /* uart init */
        uart0_init();
 
        /* display init */
-       bl_init();
+       display_bl_init();
 
        /* button init */
        button_init(&button);
        button_set_retries(&button,100);
 
+       /* flash init */
+       flash_init();
+
        /*
         * start it ...
         */
 
-       pause(0xffffff);
-       bl_toggle();
+       /* display init */
+       display_bl_toggle();
+       display_init();
+       contrast=0x38;
+
+       /* pasue again */
+
+       /* announce */
+       uart0_send_string(announce);
 
+       
        while(1) {
-               pause(0x0fffff);
+               pause(0x05ffff);
 
                /* button test! */
                if(button_get_event(&button)) {
-                       uart0_send_string(buf);
-                       if(button.key[0]==BUTTON_POWER)
-                               bl_toggle();
+                       uart0_send_string(announce);
+                       switch(button.key[0]) {
+                               case BUTTON_POWER:
+                                       display_logo((u8 *)default_logo);
+                                       break;
+                               case BUTTON_DOWN:
+                                       if(contrast>0x00)
+                                               contrast-=1;
+                                       DISPLAY_SET_CONTRAST(contrast);
+                                       break;
+                               case BUTTON_UP:
+                                       if(contrast<0x3f)
+                                               contrast+=1;
+                                       DISPLAY_SET_CONTRAST(contrast);
+                                       break;
+                               case BUTTON_A:
+                                       display_fill_screen(DISPLAY_FILL_W);
+                                       break;
+                               case BUTTON_B:
+                                       display_fill_screen(DISPLAY_FILL_LG);
+                                       break;
+                               case BUTTON_C:
+                                       display_fill_screen(DISPLAY_FILL_DG);
+                                       break;
+                               case BUTTON_D:
+                                       display_fill_screen(DISPLAY_FILL_B);
+                                       break;
+                               case BUTTON_1:
+                                       display_draw_rectangle(20,20,40,40,
+                                                              DISPLAY_FILL_B,
+                                                              0xff);
+                                       break;
+                               case BUTTON_2:
+                                       display_draw_rectangle(50,50,40,40,
+                                                              DISPLAY_FILL_LG,
+                                                              0x7f);
+                                       break;
+                               case BUTTON_3:
+                                       display_draw_font(70,70,
+                                                         (u8 *)default_font+(0x33>>3),
+                                                              DISPLAY_FILL_LG,
+                                                              0xff);
+                                       break;
+                               default:
+                                       display_clear_screen();
+                                       break;
+                       }
                }
        }