Subversion Repositories group.electronics

Rev

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

Rev 52 Rev 53
Line 1... Line 1...
1
#include <avr/io.h>
1
#include <avr/io.h>
-
 
2
#include <stdlib.h>
2
#include "wire.h"
3
#include "wire.h"
3
#include "lcd.h"
4
#include "lcd.h"
4
#include "petelib.h"
5
#include "petelib.h"
5
#include <util/delay.h>
6
#include <util/delay.h>
6
 
7
 
Line 60... Line 61...
60
/** Character Printing **/
61
/** Character Printing **/
61
/************************/
62
/************************/
62
 
63
 
63
uint8_t lcd_print_right(char *str) {
64
uint8_t lcd_print_right(char *str) {
64
	uint8_t c = 0;
65
	uint8_t c = 0;
65
	char* oldp = str;
66
	char* oldstr = str;
-
 
67
 
-
 
68
	// Find the null terminator
66
	while (str[0] != 0x00) 
69
	while ((++str)[0] != 0x00)
67
		c++;
70
		c++;
-
 
71
 
-
 
72
	// Print backwards to start 
68
	lcd_autoscroll();
73
	lcd_autocursorRight();
69
	while (str != oldp) {
74
	while (--str != oldstr -1)
70
		lcd_char((uint8_t) str[0]);
75
		lcd_char((uint8_t) str[0]);
71
		str--;
76
	lcd_autocursorLeft();
72
	}
77
 
73
	lcd_noAutoscroll();
-
 
74
	return c;
78
	return c;
75
}
79
}
76
 
80
 
77
uint8_t lcd_print(char* str) {
81
uint8_t lcd_print(char* str) {
78
        uint8_t c = 0;
82
        uint8_t c = 0;
79
        while (str[0] != 0x00) {
83
        while ((str++)[0] != 0x00) {
80
                lcd_char((uint8_t) str[0]);
84
                lcd_char((uint8_t) (str-1)[0]);
81
                str++;
85
                //str++;
82
                c++;
86
                c++;
83
        }
87
        }
84
        return c;
88
        return c;
85
}
89
}
86
 
90
 
87
void lcd_overprint(char * str, uint8_t len, uint8_t col, uint8_t row) {
91
void lcd_overprint(char * str, uint8_t len, uint8_t col, uint8_t row) {
88
        uint8_t i = 0;
92
        uint8_t i = 0;
89
        lcd_setCursor(row, col);
93
        lcd_setCursor(col, row);
90
 
94
 
91
        uint8_t size = lcd_print(str);
95
        uint8_t size = lcd_print(str);
92
        for (i=size; i<=len; i++)
96
        for (i=size; i<=len; i++)
93
                lcd_char(0x20);
97
                lcd_char(0x20);
94
}
98
}
Line 122... Line 126...
122
void lcd_noDisplay() {
126
void lcd_noDisplay() {
123
	lcd.display &= ~LCD_DISPLAYON;
127
	lcd.display &= ~LCD_DISPLAYON;
124
	lcd_command(LCD_DISPLAYCONTROL | lcd.display);
128
	lcd_command(LCD_DISPLAYCONTROL | lcd.display);
125
}
129
}
126
 
130
 
-
 
131
void lcd_autocursorLeft(void) {
-
 
132
        lcd.display |= LCD_ENTRYLEFT;
-
 
133
        lcd_command(LCD_ENTRYMODESET | lcd.display);
-
 
134
}
-
 
135
 
-
 
136
void lcd_autocursorRight(void) {
-
 
137
        lcd.display &= ~LCD_ENTRYLEFT;
-
 
138
        lcd_command(LCD_ENTRYMODESET | lcd.display);
-
 
139
}
-
 
140
 
127
void lcd_autoscroll() {
141
void lcd_autoscroll() {
128
        lcd.display |= LCD_ENTRYSHIFTINCREMENT;
142
        lcd.display |= LCD_ENTRYSHIFTINCREMENT;
129
        lcd_command(LCD_ENTRYMODESET | lcd.display);
143
        lcd_command(LCD_ENTRYMODESET | lcd.display);
130
}
144
}
131
 
145