blob: a65576979f258c4aec9f828f2a6d63d2e3afce98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "display_dogm.h"
void display_dogm_init()
{
//DDRA |= (1<<PA7); // activate portA for display
//DDRC |= (1<<PC7); // activate portC for display
DDRD |= (1<<PD7) | (1<<PD6);
PORTD |= (1<<PD7) | (1<<PD6);
// Wait time >40mS after VDD stable
_delay_ms(50); // 10ms for safty
display_dogm_exec(CMD_FUNCTION_SET);
display_dogm_exec(CMD_FUNCTION_SET);
display_dogm_exec(CMD_CONTRAST_SET);
display_dogm_exec(CMD_POWER_CONTROL);
display_dogm_exec(CMD_FOLLOWER_CONTROL);
display_dogm_exec(CMD_DISPLAY_ONOFF);
display_dogm_exec(CMD_ENTRY_MODE_SET);
display_dogm_exec(CMD_DISPLAY_CLEAR);
}
void display_dogm_putc(char c)
{
PORTD &= ~(1<<PD7); // chip select: activate display
PORTD |= (1<<PD6); // L=Commandmode, H=Datamode
spi_putc(c);
_delay_us(40); // try and error value (you get chinese chars? increase!)
PORTD |= (1<<PD7); // chip select: deactivate display
}
void display_dogm_exec(char c)
{
PORTD &= ~(1<<PD7); // chip select: activate display
PORTD &= ~(1<<PD6); // L=Commandmode, H=Datamode
spi_putc(c);
_delay_ms(4); // time the longest command takes on display
PORTD |= (1<<PD7); // chip select: deactivate display
}
|