LCD Baseshield GSOE GSOF

Dependents:   WebserverGSOE_Schnaiter HC05__TI4_RP5_Schnaiter

Committer:
jack1930
Date:
Wed Aug 18 14:00:05 2021 +0000
Revision:
12:05f13250c22d
Parent:
7:c3d157395c16
Anschluesse geaendert

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jack1930 0:0eebf803661c 1 #include "LCD.h"
jack1930 0:0eebf803661c 2
jack1930 0:0eebf803661c 3 lcd::lcd(void)
jack1930 0:0eebf803661c 4 {
jack1930 12:05f13250c22d 5 i2c=new SoftwareI2C(PB_9,PB_8);
jack1930 0:0eebf803661c 6 //po=new PortOut(PortC,0xFF);
jack1930 0:0eebf803661c 7 //t=new DigitalIn(PA_1,PullDown);
jack1930 0:0eebf803661c 8 init();
jack1930 0:0eebf803661c 9
jack1930 0:0eebf803661c 10 };
jack1930 0:0eebf803661c 11
jack1930 0:0eebf803661c 12 void lcd::clear(void)
jack1930 0:0eebf803661c 13 {
jack1930 7:c3d157395c16 14
jack1930 0:0eebf803661c 15 sendeByte(0x01,0,0);
jack1930 0:0eebf803661c 16 cursorpos(0);
jack1930 0:0eebf803661c 17 //sleep_for(20);
jack1930 7:c3d157395c16 18
jack1930 0:0eebf803661c 19 };
jack1930 0:0eebf803661c 20
jack1930 0:0eebf803661c 21 void lcd::warte(void)
jack1930 0:0eebf803661c 22 {/*
jack1930 0:0eebf803661c 23 *po=wert;
jack1930 0:0eebf803661c 24 while(*t==0);
jack1930 0:0eebf803661c 25 wait_ms(20);
jack1930 0:0eebf803661c 26 while(*t==1);
jack1930 0:0eebf803661c 27 wait_ms(20);*/
jack1930 0:0eebf803661c 28 };
jack1930 0:0eebf803661c 29 void lcd::sendeByte(char b,uint8_t rw, uint8_t rs )
jack1930 0:0eebf803661c 30 {
jack1930 0:0eebf803661c 31
jack1930 0:0eebf803661c 32 wert=(b&0xF0)+0x08+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 33 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 34 warte();
jack1930 0:0eebf803661c 35 wert=(b&0xF0)+0xC+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 36 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 37 warte();
jack1930 0:0eebf803661c 38 wert=(b&0xF0)+0x8+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 39 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 40 warte();
jack1930 0:0eebf803661c 41 wert=((b&0xF)<<4)+0x8+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 42 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 43 warte();
jack1930 0:0eebf803661c 44 wert=((b&0xF)<<4)+0xC+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 45 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 46 warte();
jack1930 0:0eebf803661c 47 wert=((b&0xF)<<4)+0x8+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 48 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 49 warte();
jack1930 0:0eebf803661c 50 }
jack1930 0:0eebf803661c 51
jack1930 0:0eebf803661c 52 void lcd::sendeNippel(char b,uint8_t rw, uint8_t rs )
jack1930 0:0eebf803661c 53 {
jack1930 0:0eebf803661c 54 wert=((b&0xF)<<4)+0x0+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 55 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 56 warte();
jack1930 0:0eebf803661c 57 wert=((b&0xF)<<4)+0x4+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 58 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 59 warte();
jack1930 0:0eebf803661c 60 wert=((b&0xF)<<4)+0x0+((rw&0x01)<<1)+(rs&0x01);
jack1930 0:0eebf803661c 61 i2c->write(Adresse,wert);
jack1930 0:0eebf803661c 62 warte();
jack1930 0:0eebf803661c 63 }
jack1930 0:0eebf803661c 64 void lcd::cursorpos(uint8_t pos)
jack1930 0:0eebf803661c 65 {
jack1930 0:0eebf803661c 66 sendeByte(0x80+pos,0,0);
jack1930 0:0eebf803661c 67 }
jack1930 0:0eebf803661c 68 void lcd::init(void)
jack1930 0:0eebf803661c 69 {
jack1930 0:0eebf803661c 70 //Adresse=pAdresse<<1;
jack1930 0:0eebf803661c 71 uint8_t data[1];
jack1930 1:d6c8b9840a53 72 for (Adresse=0;Adresse<255&&data[0]!=0x55;Adresse++)
jack1930 0:0eebf803661c 73 {
jack1930 0:0eebf803661c 74 i2c->write(Adresse,0x55);
jack1930 0:0eebf803661c 75 i2c->read(Adresse,data,1);
jack1930 0:0eebf803661c 76 }
jack1930 0:0eebf803661c 77
jack1930 1:d6c8b9840a53 78 wait_us(20000);
jack1930 0:0eebf803661c 79 sendeNippel(0b0011,0,0);
jack1930 1:d6c8b9840a53 80 wait_us(5000);
jack1930 0:0eebf803661c 81 sendeNippel(0b0011,0,0);
jack1930 1:d6c8b9840a53 82 wait_us(1000);
jack1930 0:0eebf803661c 83 sendeNippel(0b0011,0,0);
jack1930 0:0eebf803661c 84
jack1930 0:0eebf803661c 85 sendeNippel(0b0010,0,0);
jack1930 0:0eebf803661c 86
jack1930 0:0eebf803661c 87 sendeByte(0b00101000,0,0); //4Bit 2 Zeilen
jack1930 0:0eebf803661c 88
jack1930 0:0eebf803661c 89
jack1930 0:0eebf803661c 90 sendeByte(0b00000001,0,0); //display clear
jack1930 0:0eebf803661c 91
jack1930 0:0eebf803661c 92 sendeByte(0b00000110,0,0); //Increment Cursor*/
jack1930 0:0eebf803661c 93
jack1930 0:0eebf803661c 94 sendeByte(0b10000000,0,0); //Home
jack1930 0:0eebf803661c 95
jack1930 0:0eebf803661c 96 sendeByte(0b00001110,0,0); //Display On
jack1930 0:0eebf803661c 97
jack1930 0:0eebf803661c 98
jack1930 0:0eebf803661c 99 cursorpos(0x0);
jack1930 0:0eebf803661c 100
jack1930 0:0eebf803661c 101 printf("GSOE V%0.1f",1.1);
jack1930 0:0eebf803661c 102
jack1930 0:0eebf803661c 103
jack1930 0:0eebf803661c 104
jack1930 0:0eebf803661c 105 }
jack1930 0:0eebf803661c 106 int lcd::printf(const char *format, ...)
jack1930 0:0eebf803661c 107 {
jack1930 2:96140687b227 108 char buf[20];
jack1930 0:0eebf803661c 109 va_list args;
jack1930 0:0eebf803661c 110 va_start(args, format);
jack1930 0:0eebf803661c 111 vsprintf(buf,format,args);
jack1930 0:0eebf803661c 112 va_end(args);
jack1930 0:0eebf803661c 113 //LCD_i2c_textaus(buf);
jack1930 0:0eebf803661c 114 for (int i=0;i<16 && buf[i]!=0;i++)
jack1930 0:0eebf803661c 115 sendeByte(buf[i],0,1);
jack1930 0:0eebf803661c 116 return 0;
jack1930 0:0eebf803661c 117 }