moved pin/bank configuration to global init routines to system.c + added
[my-code/arm.git] / betty / display.c
1 /*
2  * display.c - handling the display
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  */
7
8 #include "display.h"
9 #include "system.h"
10 #include "default_logo.h"
11 #include "uart.h"
12
13 /*
14  * functions
15  */
16
17 void display_clear_screen(void) {
18
19         u32 cnt;
20
21         DISPLAY_SET_PAGE_ADDR(0);
22         DISPLAY_SET_C_ADDR(0);
23
24         for(cnt=0;cnt<DISPLAY_RAM_CONTENT;cnt++)
25                 DISPLAY_DATA=0x00;
26 }
27
28 void display_init(void) {
29
30         DISPLAY_EXIT_POWER_SAVE;
31
32         DISPLAY_SOFT_RESET;
33         pause(0xffffff);
34
35         DISPLAY_START_OSCILLATOR;
36
37         DISPLAY_SET_REGULATOR(7);
38
39         DISPLAY_SET_CONTRAST(0x38);
40
41         DISPLAY_SET_CONV_FACTOR(0x01);
42
43         DISPLAY_SET_UW_CORNER(0x1c,0x0a);
44         DISPLAY_SET_LW_CORNER(0x75,0x81);
45
46         DISPLAY_SET_PWM_FRC(0,0);
47
48         DISPLAY_SET_WHITE(0,0,0,0);
49         DISPLAY_SET_LGRAY(4,4,4,4);
50         DISPLAY_SET_DGRAY(6,6,6,6);
51         DISPLAY_SET_BLACK(9,9,9,9);
52
53         DISPLAY_SET_SEGMENT_REMAP_00H;
54         DISPLAY_SET_COM_ODIR_REMAPPED;
55
56         DISPLAY_SET_POWER(DISPLAY_REGULATOR|DISPLAY_OPAMP);
57         pause(0xffffff);
58         DISPLAY_SET_POWER(DISPLAY_V_BOOST|DISPLAY_REGULATOR|DISPLAY_OPAMP);
59         
60         DISPLAY_RAM_CONTENTS_ON;
61
62         DISPLAY_NORMAL;
63
64         display_clear_screen();
65
66         DISPLAY_SET_ON;
67 }
68
69 void display_load_logo(u8 *src) {
70
71         u32 cnt;
72         u8 *s;
73
74         s=src;
75         if(s==0)
76                 s=default_logo;
77
78         DISPLAY_SET_PAGE_ADDR(0);
79         DISPLAY_SET_C_ADDR(0);
80
81         for(cnt=0;cnt<DISPLAY_RAM_CONTENT;cnt++)
82                 DISPLAY_DATA=s[cnt];
83 }
84
85 void display_bl_init(void) {
86
87         IODIR0|=(1<<4);
88         IOSET0=(1<<4);  // off by default
89 }
90
91 void display_bl_toggle(void) {
92
93         if(IOPIN0&(1<<4))
94                 IOCLR0=(1<<4);
95         else
96                 IOSET0=(1<<4);
97 }
98
99 void display_bl_on(void) {
100
101         IOCLR0=(1<<4);
102 }
103
104 void display_bl_off(void) {
105
106         IOSET0=(1<<4);
107 }
108