basic lcd control (must get improved!)
[my-code/arm.git] / betty / betty.c
index 859860a..e5923e9 100644 (file)
@@ -22,11 +22,14 @@ int main() {
 
        char announce[]="betty - live from flash at 0x80000000! ;)\r\n";
        t_button button;
-       u32 addr;
+       u8 contrast;
+       int cnt;
 
        /* system init */
        pll_init();
-
+       pin_init();
+       ext_mem_init();
+       
        /* uart init */
        uart0_init();
 
@@ -47,26 +50,40 @@ int main() {
        /* pause - seems to not work if running from flash! (?) */
        pause(0xffffff);
 
-       /* announce */
-       uart0_send_string(announce);
-
-       /* toggle backlight */
+       /* display init */
        display_bl_toggle();
+       display_init();
+       contrast=0x38;
+
+       /* pasue again */
 
-       //addr=0x82000000;
-       flash_sector_erase(BANK2,0);
-       addr=FLASH_BANK2;
+       /* announce */
+       uart0_send_string(announce);
 
+       
        while(1) {
                pause(0x0fffff);
 
                /* button test! */
                if(button_get_event(&button)) {
                        uart0_send_string(announce);
-                       if(button.key[0]==BUTTON_POWER) {
-                               display_bl_toggle();
-                               flash_write_buf(addr,(u16 *)announce,42);
-                               addr+=64;
+                       switch(button.key[0]) {
+                               case BUTTON_POWER:
+                                       display_load_logo(0);
+                                       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;
+                               default:
+                                       display_clear_screen();
+                                       break;
                        }
                }
        }