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: 120_robot_H_Bridge8835_UserButton_DIR_PWM_I2C_LCD 140_robot_H_Bridge8835_DIR_PWM_US_LCD xxx_Uhr_I2C_LCD_Delay_Bua xxx_Uhr_I2C_LCD_Delay_BuaV ... more
LCD.cpp
00001 #include "LCD.h" 00002 00003 lcd::lcd(void) 00004 { 00005 i2c=new SoftwareI2C(PB_9, PB_8); //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::warte(void) 00022 {/* 00023 *po=wert; 00024 while(*t==0); 00025 wait_ms(20); 00026 while(*t==1); 00027 wait_ms(20);*/ 00028 }; 00029 void lcd::sendeByte(char b,uint8_t rw, uint8_t rs ) 00030 { 00031 00032 wert=(b&0xF0)+0x08+((rw&0x01)<<1)+(rs&0x01); 00033 i2c->write(Adresse,wert); 00034 warte(); 00035 wert=(b&0xF0)+0xC+((rw&0x01)<<1)+(rs&0x01); 00036 i2c->write(Adresse,wert); 00037 warte(); 00038 wert=(b&0xF0)+0x8+((rw&0x01)<<1)+(rs&0x01); 00039 i2c->write(Adresse,wert); 00040 warte(); 00041 wert=((b&0xF)<<4)+0x8+((rw&0x01)<<1)+(rs&0x01); 00042 i2c->write(Adresse,wert); 00043 warte(); 00044 wert=((b&0xF)<<4)+0xC+((rw&0x01)<<1)+(rs&0x01); 00045 i2c->write(Adresse,wert); 00046 warte(); 00047 wert=((b&0xF)<<4)+0x8+((rw&0x01)<<1)+(rs&0x01); 00048 i2c->write(Adresse,wert); 00049 warte(); 00050 } 00051 00052 void lcd::sendeNippel(char b,uint8_t rw, uint8_t rs ) 00053 { 00054 wert=((b&0xF)<<4)+0x0+((rw&0x01)<<1)+(rs&0x01); 00055 i2c->write(Adresse,wert); 00056 warte(); 00057 wert=((b&0xF)<<4)+0x4+((rw&0x01)<<1)+(rs&0x01); 00058 i2c->write(Adresse,wert); 00059 warte(); 00060 wert=((b&0xF)<<4)+0x0+((rw&0x01)<<1)+(rs&0x01); 00061 i2c->write(Adresse,wert); 00062 warte(); 00063 } 00064 void lcd::cursorpos(uint8_t pos) 00065 { 00066 sendeByte(0x80+pos,0,0); 00067 } 00068 void lcd::init(void) 00069 { 00070 //Adresse=pAdresse<<1; 00071 uint8_t data[1]; 00072 for (Adresse=0;Adresse<255&&data[0]!=0x55;Adresse++) 00073 { 00074 i2c->write(Adresse,0x55); 00075 i2c->read(Adresse,data,1); 00076 } 00077 00078 wait_us(20000); 00079 sendeNippel(0b0011,0,0); 00080 wait_us(5000); 00081 sendeNippel(0b0011,0,0); 00082 wait_us(1000); 00083 sendeNippel(0b0011,0,0); 00084 00085 sendeNippel(0b0010,0,0); 00086 00087 sendeByte(0b00101000,0,0); //4Bit 2 Zeilen 00088 00089 00090 sendeByte(0b00000001,0,0); //display clear 00091 00092 sendeByte(0b00000110,0,0); //Increment Cursor*/ 00093 00094 sendeByte(0b10000000,0,0); //Home 00095 00096 sendeByte(0b00001110,0,0); //Display On 00097 00098 00099 cursorpos(0x0); 00100 00101 printf("GSOE V%0.1f",1.1); 00102 00103 00104 00105 } 00106 int lcd::printf(const char *format, ...) 00107 { 00108 char buf[20]; 00109 va_list args; 00110 va_start(args, format); 00111 vsprintf(buf,format,args); 00112 va_end(args); 00113 //LCD_i2c_textaus(buf); 00114 for (int i=0;i<16 && buf[i]!=0;i++) 00115 sendeByte(buf[i],0,1); 00116 return 0; 00117 }
Generated on Tue Jul 26 2022 02:31:18 by
