Subversion Repositories group.electronics

Rev

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

Rev 47 Rev 48
Line 66... Line 66...
66
void lcd_noDisplay() {
66
void lcd_noDisplay() {
67
	lcd.display &= ~LCD_DISPLAYON;
67
	lcd.display &= ~LCD_DISPLAYON;
68
	lcd_command(LCD_DISPLAYCONTROL | lcd.display);
68
	lcd_command(LCD_DISPLAYCONTROL | lcd.display);
69
}
69
}
70
 
70
 
-
 
71
void lcd_autoscroll() {
-
 
72
        lcd.display |= LCD_ENTRYSHIFTINCREMENT;
-
 
73
        lcd_command(LCD_ENTRYMODESET | lcd.display);
-
 
74
}
-
 
75
 
71
void lcd_setCursor(uint8_t col, uint8_t row) {
76
void lcd_setCursor(uint8_t col, uint8_t row) {
72
	uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
77
	uint8_t row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
73
	lcd_command(LCD_SETDDRAMADDR | (col+ row_offsets[row - 1]));
78
	lcd_command(LCD_SETDDRAMADDR | ((col - 1)+ row_offsets[row]));
-
 
79
}
-
 
80
 
-
 
81
void lcd_overprint(char * str, uint8_t len, uint8_t col, uint8_t row) {
-
 
82
	uint8_t i = 0;
-
 
83
	for (i=0; i<=len; i++)
-
 
84
		lcd_char(0x20);	
-
 
85
 
-
 
86
	lcd_setCursor(row, col);
-
 
87
 
-
 
88
	uint8_t size = lcd_print(str);
-
 
89
	for (i=size; i<=len; i++)
-
 
90
		lcd_char(0x20);	
74
}
91
}
75
 
92
 
76
/** End helpers **/
93
/** End helpers **/
77
 
94
 
78
 
95
 
Line 82... Line 99...
82
 
99
 
83
void lcd_char(uint8_t data) {
100
void lcd_char(uint8_t data) {
84
	lcd_send(data, LCD_MODE_RS);
101
	lcd_send(data, LCD_MODE_RS);
85
}
102
}
86
 
103
 
-
 
104
uint8_t lcd_print(char* str) {
-
 
105
	uint8_t c = 0;
-
 
106
	while (str[0] != 0x00) {
-
 
107
		lcd_char((uint8_t) str[0]);
-
 
108
		str++;
-
 
109
		c++;
-
 
110
	}
-
 
111
	return c;
-
 
112
}
-
 
113
 
87
void lcd_send(uint8_t value, uint8_t mode) {
114
void lcd_send(uint8_t value, uint8_t mode) {
88
	uint8_t high = value & 0xf0;
115
	uint8_t high = value & 0xf0;
89
	uint8_t low = (value << 4) & 0xf0;
116
	uint8_t low = (value << 4) & 0xf0;
90
	lcd_pulse((high)|mode);
117
	lcd_pulse((high)|mode);
91
	lcd_pulse((low)|mode);
118
	lcd_pulse((low)|mode);
Line 96... Line 123...
96
	i2c_writeByte((int) data | LCD_MODE_EN | lcd.backlight);
123
	i2c_writeByte((int) data | LCD_MODE_EN | lcd.backlight);
97
	i2c_writeByte((int) data | lcd.backlight);
124
	i2c_writeByte((int) data | lcd.backlight);
98
	i2c_endTransmission(1);
125
	i2c_endTransmission(1);
99
	_delay_us(5);
126
	_delay_us(5);
100
}
127
}
-
 
128
 
-
 
129
 
-
 
130
void lcd_createChar(uint8_t location, uint8_t charmap[]) {
-
 
131
        location &= 0x7; // we only have 8 locations 0-7
-
 
132
        lcd_command(LCD_SETCGRAMADDR | (location << 3));
-
 
133
	uint8_t i = 0;
-
 
134
        for (i=0; i<8; i++) {
-
 
135
                lcd_char(charmap[i]);
-
 
136
        }
-
 
137
}