![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
output
Fork of display by
Diff: ili9163lcd.cpp
- Revision:
- 3:7d97b4f535c6
- Parent:
- 2:e7a5b9bc75b4
diff -r e7a5b9bc75b4 -r 7d97b4f535c6 ili9163lcd.cpp --- a/ili9163lcd.cpp Wed Jun 13 11:34:37 2018 +0000 +++ b/ili9163lcd.cpp Thu Oct 04 11:19:42 2018 +0000 @@ -35,8 +35,8 @@ //-------------------------------------------------------------------------- // Construktor Objekt initialisieren // -ILI9163::ILI9163(PinName SCK, PinName SDA, PinName A0, PinName RESET, PinName CS) - : SCK_(SCK), SDA_(SDA), A0_(A0), RESET_(RESET), CS_(CS) +ILI9163::ILI9163(PinName SCK, PinName SDA, PinName RESET, PinName CS) + : SCK_(SCK), SDA_(SDA), RESET_(RESET), CS_(CS) { tm=10; R=0,G=0,B=0; @@ -57,7 +57,7 @@ wait_ms(50); RESET_ = 1; - wait_ms(120); + wait_ms(150); } void ILI9163::lcdWriteCommand(uint8_t address) @@ -65,55 +65,88 @@ uint8_t i; CS_ = 0; - A0_ = 0; + SDA_ = 0; + + SCK_ = 1; + wait_us(1); + SCK_ = 0; + wait_us(0.5); + + for(i=0;i<8;i++){ if(address & 128)SDA_= 1; else SDA_ = 0; - SCK_ = 1; + SCK_ = 1;wait_us(1); address <<= 1; - SCK_ = 0; + SCK_ = 0;wait_us(1); } wait_us(1); CS_ = 1; -} +for(int i=0;i<10;i++) +{ SCK_ = 1; + wait_us(1/1000); + SCK_ = 0; + wait_us(1/1000); + } + } void ILI9163::lcdWriteParameter(uint8_t parameter) { uint8_t i; CS_ = 0; - A0_ = 1; + SDA_ = 1; + SCK_ = 1; + wait_us(1); + SCK_ = 0; + wait_us(1); + for(i=0;i<8;i++){ if(parameter & 128)SDA_= 1; else SDA_ = 0; - SCK_ = 1; + SCK_ = 1; wait_us(1); parameter <<= 1; - SCK_ = 0; + SCK_ = 0; wait_us(1); } wait_us(1); CS_ = 1; -} +for(int i=0;i<10;i++) +{ SCK_ = 1; wait_us(1/1000); + SCK_ = 0; + wait_us(1/1000); + } + } void ILI9163::lcdWriteData(uint8_t dataByte1, uint8_t dataByte2) { uint8_t i; CS_ = 0; - //A0_ = 1; + SDA_ = 1; + SCK_ = 1; + wait_us(1); + SCK_ = 0; + wait_us(1); + for(i=0;i<8;i++){ if(dataByte1 & 128)SDA_= 1; else SDA_ = 0; - SCK_ = 1; + SCK_ = 1; wait_us(1); dataByte1 <<= 1; - SCK_ = 0; + SCK_ = 0; wait_us(1); } - wait_us(1); + for(i=0;i<8;i++){ if(dataByte2 & 128)SDA_= 1; else SDA_ = 0; - SCK_ = 1; + SCK_ = 1; wait_us(1); dataByte2 <<= 1; - SCK_ = 0; + SCK_ = 0; wait_us(1); } wait_us(1); CS_ = 1; -} +for(int i=0;i<10;i++) +{ SCK_ = 1; wait_us(1/1000); + SCK_ = 0; + wait_us(1/1000); + } + } // Initialise the display with the require screen orientation void ILI9163::lcdInitialise(uint8_t orientation) @@ -211,6 +244,8 @@ // Set the display to on lcdWriteCommand(SET_DISPLAY_ON); lcdWriteCommand(WRITE_MEMORY_START); + // END + } // LCD graphics functions ----------------------------------------------------------------------------------- @@ -219,23 +254,23 @@ { uint16_t pixel; - // Set the column address to 0-127 + // Set the column address to 0-160 lcdWriteCommand(SET_COLUMN_ADDRESS); lcdWriteParameter(0x00); lcdWriteParameter(0x00); lcdWriteParameter(0x00); - lcdWriteParameter(0x7f); + lcdWriteParameter(0xA0); // Set the page address to 0-127 lcdWriteCommand(SET_PAGE_ADDRESS); lcdWriteParameter(0x00); lcdWriteParameter(0x00); lcdWriteParameter(0x00); - lcdWriteParameter(0x7f); + lcdWriteParameter(0xA0); // Plot the pixels lcdWriteCommand(WRITE_MEMORY_START); - for(pixel = 0; pixel < 16385; pixel++) lcdWriteData(colour >> 8, colour); + for(pixel = 0; pixel < 50000; pixel++) lcdWriteData(colour >> 8, colour); } void ILI9163::lcdPlot(uint8_t x, uint8_t y, uint16_t colour) @@ -245,14 +280,14 @@ lcdWriteParameter(0x00); lcdWriteParameter(x); lcdWriteParameter(0x00); - lcdWriteParameter(0x7f); + lcdWriteParameter(0x00); // Vertical Address end Position lcdWriteCommand(SET_PAGE_ADDRESS); lcdWriteParameter(0x00); lcdWriteParameter(y); + lcdWriteParameter(0xA0); lcdWriteParameter(0x00); - lcdWriteParameter(0x7f); // Plot the point lcdWriteCommand(WRITE_MEMORY_START); @@ -468,7 +503,7 @@ } // If we move past the bottom of the screen just exit - if (y > (127 - font_hor)) break; + if (y > (159 - font_hor)) break; // Plot the current character lcdPutCh(string[characterNumber], x, y, fgColour, bgColour);