2 * display.c - handling the display
4 * author: hackbard@hackdaworld.org
9 * some comments on alpha blending!
17 #include "default_logo.h"
24 void display_fill_screen(u8 fill) {
48 for(page=0;page<DISPLAY_PAGE_MAX;page++) {
49 DISPLAY_SET_C_ADDR(0);
50 DISPLAY_SET_PAGE_ADDR(page);
51 for(width=0;width<DISPLAY_DIMX;width++) {
58 void display_clear_screen(void) {
60 display_fill_screen(DISPLAY_FILL_W);
63 void display_init(void) {
65 /* oscillator, regulator, boost, opamp, contrast */
66 DISPLAY_START_OSCILLATOR;
67 DISPLAY_SET_REGULATOR(7);
68 DISPLAY_SET_CONTRAST(0x38);
69 DISPLAY_SET_CONV_FACTOR(0x01);
70 DISPLAY_SET_POWER(DISPLAY_V_BOOST|DISPLAY_REGULATOR|DISPLAY_OPAMP);
73 DISPLAY_SET_WHITE(0,0,0,0);
74 DISPLAY_SET_LGRAY(3,3,3,3);
75 DISPLAY_SET_DGRAY(6,6,6,6);
76 DISPLAY_SET_BLACK(9,9,9,9);
78 /* normal mode, display depending ram content */
79 DISPLAY_RAM_CONTENTS_ON;
80 display_clear_screen();
83 /* switch on the display */
87 void display_load_logo(u8 *src) {
96 for(page=0;page<DISPLAY_PAGE_MAX;page++) {
97 DISPLAY_SET_C_ADDR(0);
98 DISPLAY_SET_PAGE_ADDR(page);
99 for(width=0;width<DISPLAY_DIMX;width++) {
106 void display_draw_rectangle(int x,int y,int w,int h,u8 fill,u8 alpha) {
110 u8 b[2],a[2]; // c = a over b => c=alpha*a+(1-alpha)*b
115 case DISPLAY_FILL_LG:
118 case DISPLAY_FILL_DG:
129 spage=y>>3; // start page = y/8
130 epage=(y+h)>>3; // end page (y+h)/8
132 for(p=spage;p<=epage;p++) {
133 DISPLAY_SET_PAGE_ADDR(p);
135 DISPLAY_SET_C_ADDR(c);
136 b[0]=DISPLAY_DATA; // dummy read
139 rmax=y+8>y+h?y+h:y+8;
140 for(r=y;r<rmax;r++) {
146 DISPLAY_SET_C_ADDR(c);
154 void display_bl_init(void) {
157 IOSET0=(1<<4); // off by default
160 void display_bl_toggle(void) {
168 void display_bl_on(void) {
173 void display_bl_off(void) {