]> hackdaworld.org Git - my-code/arm.git/commitdiff
more display testing
authorhackbard <hackbard@staubsauger.localdomain>
Thu, 13 Sep 2007 23:19:24 +0000 (01:19 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Thu, 13 Sep 2007 23:19:24 +0000 (01:19 +0200)
betty/betty.c
betty/display.c
betty/display.h

index 163a8e23281eb97d2a5c71e1be8bd8bc8c9830c7..c2aaa386b291d9421a8890295a26f757a5423b16 100644 (file)
@@ -52,7 +52,7 @@ int main() {
        /* display init */
        display_bl_toggle();
        display_init();
-       contrast=0x38;
+       contrast=0x32;
 
        /* pasue again */
 
@@ -65,7 +65,8 @@ int main() {
 
                /* button test! */
                if(button_get_event(&button)) {
-                       uart0_send_string(announce);
+                       //uart0_send_string(announce);
+                       uart0_send_byte(contrast);
                        switch(button.key[0]) {
                                case BUTTON_POWER:
                                        display_load_logo(0);
@@ -80,8 +81,27 @@ int main() {
                                                contrast+=1;
                                        DISPLAY_SET_CONTRAST(contrast);
                                        break;
-                               case BUTTON_TV:
-                                       display_fill_screen(button.key[0]);
+                               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,
+                                                              0);
+                                       break;
+                               case BUTTON_2:
+                                       display_draw_rectangle(50,50,40,40,
+                                                              DISPLAY_FILL_LG,
+                                                              0);
                                        break;
                                default:
                                        display_clear_screen();
index 4d4e1e1a292498939fc9cc8ecd31cbbde1c199f8..1248279740118943e249be6c22c505a6e4946963 100644 (file)
@@ -5,6 +5,13 @@
  *
  */
 
+/*
+ * some comments on alpha blending!
+ *
+ * ...
+ *
+ */
+
 #include "display.h"
 #include "system.h"
 #include "default_logo.h"
 void display_fill_screen(u8 fill) {
 
        u8 page,width;
+       u8 buf[2];
+
+       buf[0]=0;
+       buf[1]=0;
+
+       switch(fill) {
+               case DISPLAY_FILL_LG:
+                       buf[1]=0xff;
+                       break;
+               case DISPLAY_FILL_DG:
+                       buf[0]=0xff;
+                       break;
+               case DISPLAY_FILL_B:
+                       buf[0]=0xff;
+                       buf[1]=0xff;
+                       break;
+               case DISPLAY_FILL_W:
+               default:
+                       break;
+       }
 
        for(page=0;page<DISPLAY_PAGE_MAX;page++) {
                DISPLAY_SET_C_ADDR(0);
                DISPLAY_SET_PAGE_ADDR(page);
                for(width=0;width<DISPLAY_DIMX;width++) {
-                       DISPLAY_DATA=fill;
-                       DISPLAY_DATA=fill;
+                       DISPLAY_DATA=buf[0];
+                       DISPLAY_DATA=buf[1];
                }
        }
 }
 
 void display_clear_screen(void) {
 
-       display_fill_screen(0x00);
+       display_fill_screen(DISPLAY_FILL_W);
 }
 
 void display_init(void) {
 
-       DISPLAY_EXIT_POWER_SAVE;
-
-       DISPLAY_SOFT_RESET;
-       pause(0xffffff);
-
+       /* oscillator, regulator, boost, opamp, contrast */
        DISPLAY_START_OSCILLATOR;
-
        DISPLAY_SET_REGULATOR(7);
-
        DISPLAY_SET_CONTRAST(0x38);
-
        DISPLAY_SET_CONV_FACTOR(0x01);
-
-       DISPLAY_SET_PWM_FRC(0,0);
+       DISPLAY_SET_POWER(DISPLAY_V_BOOST|DISPLAY_REGULATOR|DISPLAY_OPAMP);
 
        // gray scale palette
        DISPLAY_SET_WHITE(0,0,0,0);
-       DISPLAY_SET_LGRAY(2,2,2,2);
+       DISPLAY_SET_LGRAY(3,3,3,3);
        DISPLAY_SET_DGRAY(6,6,6,6);
        DISPLAY_SET_BLACK(9,9,9,9);
 
-       DISPLAY_SET_POWER(DISPLAY_REGULATOR|DISPLAY_OPAMP);
-       pause(0xffffff);
-       DISPLAY_SET_POWER(DISPLAY_V_BOOST|DISPLAY_REGULATOR|DISPLAY_OPAMP);
-       
+       /* normal mode, display depending ram content */
        DISPLAY_RAM_CONTENTS_ON;
-
-       DISPLAY_NORMAL;
-
        display_clear_screen();
+       DISPLAY_NORMAL;
 
+       /* switch on the display */
        DISPLAY_SET_ON;
 }
 
@@ -88,6 +103,54 @@ void display_load_logo(u8 *src) {
        }
 }
 
+void display_draw_rectangle(int x,int y,int w,int h,u8 fill,u8 alpha) {
+
+       int c,r,rmax;
+       u8 p,spage,epage;
+       u8 b[2],a[2];           // c = a over b => c=alpha*a+(1-alpha)*b
+
+       a[0]=0;
+       a[1]=0;
+       switch(fill) {
+               case DISPLAY_FILL_LG:
+                       a[1]=1;
+                       break;
+               case DISPLAY_FILL_DG:
+                       a[0]=1;
+                       break;
+               case DISPLAY_FILL_B:
+                       a[0]=1;
+                       a[1]=1;
+               case DISPLAY_FILL_W:
+               default:
+                       break;
+       }
+
+       spage=y>>3;                                     // start page = y/8
+       epage=(y+h)>>3;                                 // end page (y+h)/8
+
+       for(p=spage;p<=epage;p++) {
+               DISPLAY_SET_PAGE_ADDR(p);
+               for(c=x;c<x+w;c++) {
+                       DISPLAY_SET_C_ADDR(c);
+                       b[0]=DISPLAY_DATA;              // dummy read
+                       b[0]=DISPLAY_DATA;
+                       b[1]=DISPLAY_DATA;
+                       rmax=y+8>y+h?y+h:y+8;
+                       for(r=y;r<rmax;r++) {
+                               b[0]&=~(1<<r);
+                               b[1]&=~(1<<r);
+                               b[0]|=a[0]<<r;
+                               b[1]|=a[1]<<r;
+                       }
+                       DISPLAY_SET_C_ADDR(c);
+                       DISPLAY_DATA=b[0];
+                       DISPLAY_DATA=b[1];
+               }
+               y+=8;
+       }
+}
+
 void display_bl_init(void) {
 
        IODIR0|=(1<<4);
index bed4b7012de8a4126ae05805738a269d082bbae1..df371ac4eb67efa361a948e3f49381e7cf466732 100644 (file)
                                        DISPLAY_CMD=(c)
 #define DISPLAY_EXTENDED_FEATURES      DISPLAY_CMD=0xf0
 
+/* display api specific defines */
+#define DISPLAY_FILL_W                 0x00
+#define DISPLAY_FILL_LG                        0x01
+#define DISPLAY_FILL_DG                        0x02
+#define DISPLAY_FILL_B                 0x03
+
+
 /* function prototypes */
 void display_fill_screen(u8 fill);
 void display_clear_screen(void);
 void display_init(void);
 void display_load_logo(u8 *src);
+void display_draw_rectangle(int x,int y,int w,int h,u8 fill,u8 alpha);
 void display_bl_init(void);
 void display_bl_toggle(void);
 void display_bl_on(void);