Subversion Repositories group.electronics

Rev

Rev 46 | Rev 48 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 46 Rev 47
Line 14... Line 14...
14
	lcd.backlight = LCD_BACKLIGHT;
14
	lcd.backlight = LCD_BACKLIGHT;
15
	lcd.display = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
15
	lcd.display = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
16
	lcd.function = LCD_2LINE;
16
	lcd.function = LCD_2LINE;
17
 
17
 
18
	lcd_pulse(0x30);	
18
	lcd_pulse(0x30);	
19
	_delay_ms(150);
19
	_delay_ms(50);
20
 
20
 
21
	lcd_pulse(0x30);	
21
	lcd_pulse(0x30);	
22
	_delay_ms(150);
22
	_delay_ms(50);
23
 
23
 
24
	lcd_pulse(0x30);	
24
	lcd_pulse(0x30);	
25
	_delay_ms(50);
25
	_delay_ms(50);
26
 
26
 
27
	lcd_pulse(0x20);	
27
	lcd_pulse(0x20);	
28
	_delay_ms(50);
28
	_delay_ms(10);
29
 
29
 
30
	lcd_command(LCD_FUNCTIONSET | lcd.function);
30
	lcd_command(LCD_FUNCTIONSET | lcd.function);
31
	_delay_ms(50);
31
	_delay_ms(10);
32
 
32
 
33
	lcd_command(LCD_DISPLAYCONTROL | lcd.display);
33
	lcd_command(LCD_DISPLAYCONTROL | lcd.display);
34
	_delay_ms(50);
34
	_delay_ms(10);
35
 
35
 
36
	lcd_clear();	
36
	lcd_clear();	
37
	_delay_ms(50);
37
	_delay_ms(10);
38
 
38
 
39
	lcd_home();
39
	lcd_home();
40
	_delay_ms(50);
40
	_delay_ms(10);
41
}
41
}
42
 
42
 
43
/** Helper functions **/
43
/** Helper functions **/
44
 
44
 
45
inline void lcd_clear() {
45
inline void lcd_clear() {
Line 89... Line 89...
89
	uint8_t low = (value << 4) & 0xf0;
89
	uint8_t low = (value << 4) & 0xf0;
90
	lcd_pulse((high)|mode);
90
	lcd_pulse((high)|mode);
91
	lcd_pulse((low)|mode);
91
	lcd_pulse((low)|mode);
92
}
92
}
93
 
93
 
94
void lcd_write(uint8_t data) {
94
void lcd_pulse(uint8_t data) {
95
	i2c_beginTransmission(LCD_ADDR);
95
	i2c_beginTransmission(LCD_ADDR);
-
 
96
	i2c_writeByte((int) data | LCD_MODE_EN | lcd.backlight);
96
	i2c_writeByte((int) data | lcd.backlight);
97
	i2c_writeByte((int) data | lcd.backlight);
97
	i2c_endTransmission(1);
98
	i2c_endTransmission(1);
98
}
-
 
99
 
-
 
100
void lcd_pulse(uint8_t data) {
-
 
101
	lcd_write(data | LCD_MODE_EN);
-
 
102
	_delay_us(40);
99
	_delay_us(5);
103
 
-
 
104
	//lcd_write(data & ~LCD_MODE_EN);
-
 
105
	lcd_write(data);
-
 
106
	_delay_us(40);
-
 
107
}
100
}