/* display init */
display_bl_toggle();
display_init();
- contrast=0x38;
+ contrast=0x32;
/* pasue again */
/* 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);
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();
*
*/
+/*
+ * 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);
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);