*
*/
+/*
+ * 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;
}
}
}
+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);