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(5,5,5,5); // obviously 3, but it's too bright!
75 DISPLAY_SET_DGRAY(7,7,7,7); // obviously 6, but again too bright!
76 DISPLAY_SET_BLACK(9,9,9,9);
78 /* normal mode, display depending ram content */
79 DISPLAY_RAM_CONTENTS_ON;
80 display_clear_screen();
81 DISPLAY_NORMAL; // 00 -> white, 11 -> black
82 DISPLAY_SET_COM_ODIR_REMAPPED; // start counting at the top
84 /* switch on the display */
88 void display_load_logo(u8 *src) {
97 for(page=0;page<DISPLAY_PAGE_MAX;page++) {
98 DISPLAY_SET_C_ADDR(0);
99 DISPLAY_SET_PAGE_ADDR(page);
100 for(width=0;width<DISPLAY_DIMX;width++) {
107 void display_draw_rectangle(int x,int y,int w,int h,u8 fill,u8 alpha) {
111 u8 b[2],a[2]; // c = a over b => c=alpha*a+(1-alpha)*b
116 case DISPLAY_FILL_LG:
119 case DISPLAY_FILL_DG:
130 spage=y>>3; // start page = y/8
131 epage=(y+h)>>3; // end page (y+h)/8
133 for(p=spage;p<=epage;p++) {
134 DISPLAY_SET_PAGE_ADDR(p);
136 DISPLAY_SET_C_ADDR(c);
137 b[0]=DISPLAY_DATA; // dummy read (p.16)
140 rmax=y+8>y+h?y+h:y+8;
141 for(r=y;r<rmax;r++) {
147 DISPLAY_SET_C_ADDR(c);
155 void display_bl_init(void) {
158 IOSET0=(1<<4); // off by default
161 void display_bl_toggle(void) {
169 void display_bl_on(void) {
174 void display_bl_off(void) {