X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=betty%2Fdisplay.c;h=a439fcdff09b4483953574e30d2a8d920300583e;hb=dbbb7d4ca12c21c84af2f72f7c75ce7a3559dcad;hp=e102141d2a562ce4d7a87cea7c902fac3dbf832d;hpb=b02acd993d27fd99503d9c9c53e10b19ec1c207c;p=my-code%2Farm.git diff --git a/betty/display.c b/betty/display.c index e102141..a439fcd 100644 --- a/betty/display.c +++ b/betty/display.c @@ -5,6 +5,17 @@ * */ +/* + * some comments on alpha blending! + * ################################ + * + * if c is the result of layer a over layer b with opacity alpha: + * + * c=alpha*a+(1-alpha)*b and if alpha is a byte (0-255) + * => c=alpha*a+(255-alpha)*b + * + */ + #include "display.h" #include "system.h" #include "default_logo.h" @@ -14,53 +25,67 @@ * functions */ -void display_clear_screen(void) { +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 white, 11 -> black + DISPLAY_SET_COM_ODIR_REMAPPED; // start counting at the top + /* switch on the display */ DISPLAY_SET_ON; } @@ -68,20 +93,135 @@ void display_load_logo(u8 *src) { u8 *s; u8 page,width; - u32 cnt; s=src; if(s==0) s=default_logo; - cnt=0; for(page=0;page>r)&1)<<1)|(((m)[1]>>r)&1)) + +void display_draw_rectangle(u8 x,u8 y,u8 w,u8 h,u8 fill,u8 alpha) { + + u8 page,col,row,rmax,cnt; + u8 d[2]; + int ca,cb; + u8 a,b,c; // c = a over b + + a=fill&0x03; + ca=0; + for(cnt=0;cnt>3);page<=((y+h)>>3);page++) { // page = y/8 + DISPLAY_SET_PAGE_ADDR(page); + rmax=(page+1)<<3; // row max + if(rmax>y+h) + rmax=y+h; + for(col=x;col>8; + d[0]&=~(1<>1)&1)<>3);page<=((y+8)>>3);page++) { // page = y/8 + DISPLAY_SET_PAGE_ADDR(page); + rmax=(page+1)<<3; // row max + if(rmax>y+left) + rmax=y+left; + cf=0; + for(col=x;col>row)&1) { + c=(ca+cb)>>8; + d[0]&=~(1<>1)&1)<>3);page<=((y+h)>>3);page++) { + DISPLAY_SET_PAGE_ADDR(page); + for(col=x;col