*
*/
+/*
+ * some comments on alpha blending!
+ *
+ * ...
+ *
+ */
+
#include "display.h"
#include "system.h"
#include "default_logo.h"
* functions
*/
-void display_clear_screen(void) {
-
- u32 cnt;
+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=buf[0];
+ DISPLAY_DATA=buf[1];
+ }
+ }
+}
- DISPLAY_SET_PAGE_ADDR(0);
- DISPLAY_SET_C_ADDR(0);
+void display_clear_screen(void) {
- for(cnt=0;cnt<DISPLAY_RAM_CONTENT;cnt++)
- DISPLAY_DATA=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_POWER(DISPLAY_V_BOOST|DISPLAY_REGULATOR|DISPLAY_OPAMP);
- DISPLAY_SET_UW_CORNER(0x1c,0x0a);
- DISPLAY_SET_LW_CORNER(0x75,0x81);
-
- DISPLAY_SET_PWM_FRC(0,0);
-
+ // gray scale palette
DISPLAY_SET_WHITE(0,0,0,0);
- DISPLAY_SET_LGRAY(4,4,4,4);
+ DISPLAY_SET_LGRAY(3,3,3,3);
DISPLAY_SET_DGRAY(6,6,6,6);
DISPLAY_SET_BLACK(9,9,9,9);
- DISPLAY_SET_SEGMENT_REMAP_00H;
- DISPLAY_SET_COM_ODIR_REMAPPED;
-
- 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_load_logo(u8 *src) {
- u32 cnt;
u8 *s;
+ u8 page,width;
s=src;
if(s==0)
s=default_logo;
- DISPLAY_SET_PAGE_ADDR(0);
- DISPLAY_SET_C_ADDR(0);
+ 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=*s++;
+ DISPLAY_DATA=*s++;
+ }
+ }
+}
- for(cnt=0;cnt<DISPLAY_RAM_CONTENT;cnt++)
- DISPLAY_DATA=s[cnt];
+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) {