#include "asuro.h"
gehe zum Quellcode dieser Datei
Makrodefinitionen | |
#define | LCD_INIT {(LCD_4BIT | LCD_2LINE | LCD_5X7), 0} |
#define | LCD_DEV 0x40 |
#define | LCD_LINES 2 |
#define | LCD_CHARS 8 |
#define | LCD_LINE1 0x00 |
#define | LCD_LINE2 0x40 |
#define | LCD_LINE3 0x10 |
#define | LCD_LINE4 0x50 |
#define | LD4 0 |
#define | LD5 1 |
#define | LD6 2 |
#define | LD7 3 |
#define | LRS 4 |
#define | LRW 5 |
#define | LEN 7 |
#define | LBL 6 |
#define | LCD_D0 (1 << LD4) |
#define | LCD_D1 (1 << LD5) |
#define | LCD_D2 (1 << LD6) |
#define | LCD_D3 (1 << LD7) |
#define | LCD_D4 (1 << LD4) |
#define | LCD_D5 (1 << LD5) |
#define | LCD_D6 (1 << LD6) |
#define | LCD_D7 (1 << LD7) |
#define | LCD_RS (1 << LRS) |
#define | LCD_RW (1 << LRW) |
#define | LCD_EN (1 << LEN) |
#define | LCD_BL (1 << LBL) |
#define | LCD_CLEAR 0x01 |
#define | LCD_HOME 0x02 |
#define | LCD_ENTRYMODE 0x04 |
#define | LCD_INCREASE (LCD_ENTRYMODE | 0x02) |
#define | LCD_DECREASE (LCD_ENTRYMODE | 0x00) |
#define | LCD_DISPLAYSHIFTON (LCD_ENTRYMODE | 0x01) |
#define | LCD_DISPLAYSHIFTOFF (LCD_ENTRYMODE | 0x00) |
#define | LCD_DISPLAYMODE 0x08 |
#define | LCD_DISPLAYON (LCD_DISPLAYMODE | 0x04) |
#define | LCD_DISPLAYOFF (LCD_DISPLAYMODE | 0x00) |
#define | LCD_CURSORON (LCD_DISPLAYMODE | 0x02) |
#define | LCD_CURSOROFF (LCD_DISPLAYMODE | 0x00) |
#define | LCD_BLINKINGON (LCD_DISPLAYMODE | 0x01) |
#define | LCD_BLINKINGOFF (LCD_DISPLAYMODE | 0x00) |
#define | LCD_SHIFTMODE 0x10 |
#define | LCD_DISPLAYSHIFT (LCD_SHIFTMODE | 0x08) |
#define | LCD_CURSORMOVE (LCD_SHIFTMODE | 0x00) |
#define | LCD_RIGHT (LCD_SHIFTMODE | 0x04) |
#define | LCD_LEFT (LCD_SHIFTMODE | 0x00) |
#define | LCD_CONFIGURATION 0x20 |
#define | LCD_8BIT (LCD_CONFIGURATION | 0x10) |
#define | LCD_4BIT (LCD_CONFIGURATION | 0x00) |
#define | LCD_2LINE (LCD_CONFIGURATION | 0x08) |
#define | LCD_1LINE (LCD_CONFIGURATION | 0x00) |
#define | LCD_5X10 (LCD_CONFIGURATION | 0x04) |
#define | LCD_5X7 (LCD_CONFIGURATION | 0x00) |
#define | LCD_CGRAM 0x40 |
#define | LCD_DDRAM 0x80 |
Funktionen | |
void | InitLCD (void) |
LCD Initialisierung. | |
void | BacklightLCD (unsigned char state) |
LCD Backlight an oder ausschalten. | |
void | SetIOLCD (unsigned char setCommand, unsigned char bits) |
LCD IO Ports schreiben. | |
unsigned char | GetIOLCD (void) |
LCD IO Ports lesen. | |
void | SetCursorLCD (unsigned char cursor, unsigned char line) |
LCD Cursor setzen. | |
void | ClearLCD (void) |
LCD loeschen und Cursor auf 1 Postion der ersten Zeile. | |
void | SetDataLCD (unsigned char data) |
LCD Daten schreiben. | |
void | CommandLCD (unsigned char command) |
LCD Kommando ausgeben. | |
void | WriteLCD (unsigned char data) |
LCD Daten schreiben. | |
void | PrintLCD (char *string, unsigned char wrap) |
LCD String ausgeben optional mit Zeilenumbruch. | |
void | PrintSetLCD (unsigned char cursor, unsigned char line, char *string) |
LCD String ausgeben an bestimmter Position. | |
void | PrintIntLCD (int value) |
LCD Integer Wert ausgeben. | |
void | PrintAlignLCD (unsigned char line, unsigned char alignment, char *string) |
LCD Stringausgabe mit Ausrichtung (links, mitte, rechts). | |
Variablen | |
unsigned char | portLCD |
unsigned char | lineLCD |
unsigned char | cursorLCD |
void BacklightLCD | ( | unsigned char | state | ) |
void ClearLCD | ( | void | ) |
LCD loeschen und Cursor auf 1 Postion der ersten Zeile.
Definiert in Zeile 225 der Datei lcd.c.
00226 { 00227 CommandLCD(LCD_CLEAR); 00228 CommandLCD(LCD_HOME); 00229 }
void CommandLCD | ( | unsigned char | command | ) |
unsigned char GetIOLCD | ( | void | ) |
void InitLCD | ( | void | ) |
LCD Initialisierung.
Definiert in Zeile 62 der Datei lcd.c.
00063 { 00064 unsigned char init[] = LCD_INIT; 00065 unsigned char i = 0; 00066 00067 SetIOLCD(OFF, LCD_EN); // Start LCD Control, EN=0 00068 Msleep(1); // Wait LCD Ready 00069 00070 // Initialize LCD 00071 CommandLCD( LCD_8BIT | (LCD_8BIT >> 4) ); 00072 CommandLCD( LCD_8BIT | (LCD_4BIT >> 4) ); 00073 00074 while (init[i] != 0x00) 00075 { 00076 CommandLCD(init[i]); 00077 i++; 00078 } 00079 00080 CommandLCD( LCD_DISPLAYON ); // Display on/off Control (Entry Display,Cursor off,Cursor not Blink) 00081 CommandLCD( LCD_INCREASE ); // Entry Mode Set (I/D=1 Increment,S=0 Cursor Shift) 00082 CommandLCD( LCD_CLEAR ); // Clear Display 00083 CommandLCD( LCD_HOME ); // Home Cursor 00084 Msleep(1); // Wait Initial Complete 00085 }
void PrintAlignLCD | ( | unsigned char | alignment, | |
unsigned char | line, | |||
char * | string | |||
) |
LCD Stringausgabe mit Ausrichtung (links, mitte, rechts).
alignment | Ausrichtung (links, mitte, rechts) | |
line | Zeilennummer | |
string | auszugebender String |
Definiert in Zeile 307 der Datei lcd.c.
00308 { 00309 unsigned char i = 0; 00310 while (string[i] != 0x00) 00311 i++; 00312 if (alignment == RIGHT) 00313 PrintSetLCD(LCD_CHARS-i, line, string); 00314 else if (alignment == CENTER) 00315 PrintSetLCD((LCD_CHARS-i)/2, line, string); 00316 else 00317 PrintSetLCD(0, line, string); 00318 }
void PrintIntLCD | ( | int | value | ) |
void PrintLCD | ( | char * | string, | |
unsigned char | wrap | |||
) |
LCD String ausgeben optional mit Zeilenumbruch.
string | auszugebender String | |
wrap | Zeilenumbruch ja oder nein |
Definiert in Zeile 252 der Datei lcd.c.
00253 { 00254 unsigned char i = 0; 00255 while (string[i] != 0x00) 00256 { 00257 if (cursorLCD >= LCD_CHARS) 00258 { 00259 if (wrap) 00260 SetCursorLCD(0, lineLCD+1); 00261 else 00262 break; 00263 } 00264 WriteLCD(string[i]); 00265 i++; 00266 } 00267 }
void PrintSetLCD | ( | unsigned char | cursor, | |
unsigned char | line, | |||
char * | string | |||
) |
LCD String ausgeben an bestimmter Position.
cursor | Cursor Position | |
line | Zeilen Nummer | |
string | auszugebender String |
Definiert in Zeile 277 der Datei lcd.c.
00278 { 00279 SetCursorLCD(cursor, line); 00280 PrintLCD(string, OFF); 00281 }
void SetCursorLCD | ( | unsigned char | cursor, | |
unsigned char | line | |||
) |
LCD Cursor setzen.
cursor | Cursor Position | |
line | Zeilen Nummer |
Definiert in Zeile 181 der Datei lcd.c.
00182 { 00183 cursorLCD = cursor; 00184 lineLCD = line; 00185 00186 if (line == 0) 00187 line = LCD_LINE1; 00188 #if LCD_LINES>=2 00189 else if (line == 1) 00190 line = LCD_LINE2; 00191 #endif 00192 #if LCD_LINES>=3 00193 else if (line == 2) 00194 line = LCD_LINE3; 00195 #endif 00196 #if LCD_LINES>=4 00197 else if (line == 3) 00198 line = LCD_LINE4; 00199 #endif 00200 else 00201 line = LCD_LINE1; 00202 00203 CommandLCD(LCD_DDRAM | (line+cursor)); 00204 }
void SetDataLCD | ( | unsigned char | data | ) |
LCD Daten schreiben.
data | auszugebende Date |
Definiert in Zeile 108 der Datei lcd.c.
00109 { 00110 unsigned char dataPins; // Pin Compatibility 00111 00112 // Set First Nibble Data to DataPins on PCF8574 00113 dataPins &= 0x00; 00114 dataPins |= ((data & 0x80) >> 7) << LD7; 00115 dataPins |= ((data & 0x40) >> 6) << LD6; 00116 dataPins |= ((data & 0x20) >> 5) << LD5; 00117 dataPins |= ((data & 0x10) >> 4) << LD4; 00118 00119 SetIOLCD(OFF, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7); // Clear old LCD Data (Bit[7..4]) 00120 SetIOLCD(ON, dataPins); // Strobe High Nibble Command 00121 SetIOLCD(ON, LCD_EN); // Enable ON 00122 Msleep(1); 00123 SetIOLCD(OFF, LCD_EN); // Enable OFF 00124 00125 // Set Second Nibble Data to DataPins on PCF8574 00126 dataPins &= 0x00; 00127 dataPins |= ((data & 0x08) >> 3) << LD7; 00128 dataPins |= ((data & 0x04) >> 2) << LD6; 00129 dataPins |= ((data & 0x02) >> 1) << LD5; 00130 dataPins |= ((data & 0x01) >> 0) << LD4; 00131 00132 SetIOLCD(OFF, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7); // Clear old LCD Data (Bit[7..4]) 00133 SetIOLCD(ON, dataPins); // Strobe Low Nibble Command 00134 SetIOLCD(ON, LCD_EN); // Enable ON 00135 Msleep(1); 00136 SetIOLCD(OFF, LCD_EN); // Enable OFF 00137 00138 Msleep(1); // Wait LCD Busy 00139 }
void SetIOLCD | ( | unsigned char | setCommand, | |
unsigned char | bits | |||
) |
void WriteLCD | ( | unsigned char | data | ) |