Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DigitaleingabeBluetooth_TI4 Temperatursever_TI4 BelueftungMitDS1820 ZustandCodeschloss ... more
LCD.cpp
00001 #include "LCD.h" 00002 00003 lcd::lcd(void) 00004 { 00005 i2c=new SoftwareI2C(PA_12,PA_11); 00006 //po=new PortOut(PortC,0xFF); 00007 //t=new DigitalIn(PA_1,PullDown); 00008 init(); 00009 00010 }; 00011 00012 void lcd::clear(void) 00013 { 00014 00015 sendeByte(0x01,0,0); 00016 cursorpos(0); 00017 //sleep_for(20); 00018 00019 }; 00020 00021 void lcd::locate(int column, int row) 00022 { 00023 cursorpos(column+row*0x40); 00024 } 00025 00026 void lcd::putc(int c) 00027 { 00028 sendeByte(c,0,1); 00029 } 00030 00031 void lcd::cls() 00032 { 00033 clear(); 00034 } 00035 00036 /* 00037 void lcd::warte(void) 00038 { 00039 *po=wert; 00040 while(*t==0); 00041 wait_ms(20); 00042 while(*t==1); 00043 wait_ms(20); 00044 };*/ 00045 00046 void lcd::warte() 00047 { 00048 asm("push {R0,R1} \n" 00049 "ldr R0,=32000000/5/1000 \n" 00050 "mov R1,#1 \n" 00051 "1: \n" 00052 "subs R0,R1 \n" 00053 "bne 1b \n" 00054 "pop {R0,R1} \n" 00055 ); 00056 } 00057 void lcd::sendeByte(char b,uint8_t rw, uint8_t rs ) 00058 { 00059 00060 wert=(b&0xF0)+0x08+((rw&0x01)<<1)+(rs&0x01); 00061 i2c->write(Adresse,wert); 00062 warte(); 00063 wert=(b&0xF0)+0xC+((rw&0x01)<<1)+(rs&0x01); 00064 i2c->write(Adresse,wert); 00065 warte(); 00066 wert=(b&0xF0)+0x8+((rw&0x01)<<1)+(rs&0x01); 00067 i2c->write(Adresse,wert); 00068 warte(); 00069 wert=((b&0xF)<<4)+0x8+((rw&0x01)<<1)+(rs&0x01); 00070 i2c->write(Adresse,wert); 00071 warte(); 00072 wert=((b&0xF)<<4)+0xC+((rw&0x01)<<1)+(rs&0x01); 00073 i2c->write(Adresse,wert); 00074 warte(); 00075 wert=((b&0xF)<<4)+0x8+((rw&0x01)<<1)+(rs&0x01); 00076 i2c->write(Adresse,wert); 00077 warte(); 00078 } 00079 00080 void lcd::sendeNippel(char b,uint8_t rw, uint8_t rs ) 00081 { 00082 wert=((b&0xF)<<4)+0x0+((rw&0x01)<<1)+(rs&0x01); 00083 i2c->write(Adresse,wert); 00084 warte(); 00085 wert=((b&0xF)<<4)+0x4+((rw&0x01)<<1)+(rs&0x01); 00086 i2c->write(Adresse,wert); 00087 warte(); 00088 wert=((b&0xF)<<4)+0x0+((rw&0x01)<<1)+(rs&0x01); 00089 i2c->write(Adresse,wert); 00090 warte(); 00091 } 00092 void lcd::cursorpos(uint8_t pos) 00093 { 00094 sendeByte(0x80+pos,0,0); 00095 } 00096 void lcd::init(void) 00097 { 00098 //Adresse=pAdresse<<1; 00099 uint8_t data[1]; 00100 for (Adresse=0;Adresse<255&&data[0]!=0x55;Adresse++) 00101 { 00102 i2c->write(Adresse,0x55); 00103 i2c->read(Adresse,data,1); 00104 } 00105 00106 wait_us(20000); 00107 sendeNippel(0b0011,0,0); 00108 wait_us(5000); 00109 sendeNippel(0b0011,0,0); 00110 wait_us(1000); 00111 sendeNippel(0b0011,0,0); 00112 00113 sendeNippel(0b0010,0,0); 00114 00115 sendeByte(0b00101000,0,0); //4Bit 2 Zeilen 00116 00117 00118 sendeByte(0b00000001,0,0); //display clear 00119 00120 sendeByte(0b00000110,0,0); //Increment Cursor*/ 00121 00122 sendeByte(0b10000000,0,0); //Home 00123 00124 sendeByte(0b00001110,0,0); //Display On 00125 00126 00127 cursorpos(0x0); 00128 00129 printf("GSOE V%0.1f",1.1); 00130 00131 00132 00133 } 00134 int lcd::printf(const char *format, ...) 00135 { 00136 char buf[20]; 00137 va_list args; 00138 va_start(args, format); 00139 vsprintf(buf,format,args); 00140 va_end(args); 00141 //LCD_i2c_textaus(buf); 00142 for (int i=0;i<16 && buf[i]!=0;i++) 00143 sendeByte(buf[i],0,1); 00144 return 0; 00145 }
Generated on Mon Jul 18 2022 14:47:38 by
1.7.2