void TFT_ILI9163C::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { #if defined(__MK20DX128__) || defined(__MK20DX256__) SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); _setAddrWindow(x0,y0,x1,y1); SPI.endTransaction(); #else writecommand(CMD_CLMADRS); // Column if (rotation == 0 || rotation > 1){ writedata16(x0); writedata16(x1); } else { writedata16(x0 + __OFFSET); writedata16(x1 + __OFFSET); } writecommand(CMD_PGEADRS); // Page if (rotation == 0){ writedata16(y0 + __OFFSET); writedata16(y1 + __OFFSET); } else { writedata16(y0); writedata16(y1); } writecommand(CMD_RAMWR); //Into RAM #endif }
void TFT_ILI9163C::pushData(uint16_t color) { #if defined(__MK20DX128__) || defined(__MK20DX256__) writedata16_cont(color); #else writedata16(color); #endif }
void TFT_ILI9163C::pushColor(uint16_t color) { #if defined(__MK20DX128__) || defined(__MK20DX256__) SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); writedata16_last(color); endProc(); #else writedata16(color); #endif }
void TFT_ILI9163C::defineScrollArea(uint16_t tfa, uint16_t bfa){ tfa += __OFFSET; int16_t vsa = _GRAMHEIGH - tfa - bfa; if (vsa >= 0) { #if defined(__MK20DX128__) || defined(__MK20DX256__) SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); writecommand_cont(CMD_VSCLLDEF); writedata16_cont(tfa); writedata16_cont(vsa); writedata16_last(bfa); endProc(); #else writecommand(CMD_VSCLLDEF); writedata16(tfa); writedata16(vsa); writedata16(bfa); #endif } }
void TFT_ILI9163C::scroll(uint16_t adrs) { #if defined(__MK20DX128__) || defined(__MK20DX256__) SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); writecommand_cont(CMD_VSSTADRS); writedata16_last(adrs); endProc(); #else writecommand(CMD_VSSTADRS); writedata16(adrs); #endif }
void TFT_ILI9163C::drawPixel(int16_t x, int16_t y, uint16_t color) { if (boundaryCheck(x,y)) return; if ((x < 0) || (y < 0)) return; setAddr(x,y,x+1,y+1); #if defined(__MK20DX128__) || defined(__MK20DX256__) writedata16_last(color); endProc(); #else writedata16(color); #endif }
void TFT_ILI9163C::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) { // Rudimentary clipping if (boundaryCheck(x,y)) return; if (((x+w) - 1) >= _width) w = _width-x; setAddr(x,y,(x+w)-1,y); while (w-- > 1) { #if defined(__MK20DX128__) || defined(__MK20DX256__) if (w == 0){ writedata16_last(color); } else { writedata16_cont(color); } #else writedata16(color); #endif } endProc(); }
void TFT_ILI9163C::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) { // Rudimentary clipping if (boundaryCheck(x,y)) return; if (((y + h) - 1) >= _height) h = _height-y; setAddr(x,y,x,(y+h)-1); while (h-- > 1) { #if defined(__MK20DX128__) || defined(__MK20DX256__) if (h == 0){ writedata16_last(color); } else { writedata16_cont(color); } #else writedata16(color); #endif } endProc(); }
// fill a rectangle void TFT_ILI9163C::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { if (boundaryCheck(x,y)) return; if (((x + w) - 1) >= _width) w = _width - x; if (((y + h) - 1) >= _height) h = _height - y; setAddr(x,y,(x+w)-1,(y+h)-1); for (y = h;y > 0;y--) { for (x = w;x > 1;x--) { #if defined(__MK20DX128__) || defined(__MK20DX256__) writedata16_cont(color); #else writedata16(color); #endif } #if defined(__MK20DX128__) || defined(__MK20DX256__) writedata16_last(color); #endif } endProc(); }
void TFT_ILI9163C::writeScreen24(const uint32_t *bitmap,uint16_t size) { uint16_t color; int px; #if defined(__MK20DX128__) || defined(__MK20DX256__) writecommand_cont(CMD_RAMWR); for (px = 0;px < size; px++){//16384 color = Color24To565(bitmap[px]); writedata16_cont(color); } _setAddrWindow(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH);//home endProc(); #else writecommand(CMD_RAMWR); for (px = 0;px < size; px++){ color = Color24To565(bitmap[px]); writedata16(color); } homeAddress(); #endif }
//corrected! void TFT_ILI9163C::clearScreen(uint16_t color) { int px; #if defined(__MK20DX128__) || defined(__MK20DX256__) //SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); setAddr(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH);//go home //writecommand_cont(CMD_RAMWR);//this was missed! for (px = 0;px < _GRAMSIZE; px++){ writedata16_cont(color); } _setAddrWindow(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH);//go home writecommand_last(CMD_NOP); endProc(); #else setAddr(0x00,0x00,_GRAMWIDTH,_GRAMHEIGH);//go home //writecommand(CMD_RAMWR); for (px = 0;px < _GRAMSIZE; px++){ writedata16(color); } #endif }
void Adafruit_ST7735::drawPixel(int x, int y, USBDM::Color color) { if((x < 0) ||(x >= fWidth) || (y < 0) || (y >= fHeight)) return; setAddrWindow(x,y,x+1,y+1); writedata16(color); }
void Adafruit_ST7735::pushColor(uint16_t color) { writedata16(color); }
void TFT_ILI9163C::chipInit() { uint8_t i; #if defined(__GAMMASET1) const uint8_t pGammaSet[15]= {0x36,0x29,0x12,0x22,0x1C,0x15,0x42,0xB7,0x2F,0x13,0x12,0x0A,0x11,0x0B,0x06}; const uint8_t nGammaSet[15]= {0x09,0x16,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x34,0x39}; #elif defined(__GAMMASET2) const uint8_t pGammaSet[15]= {0x3F,0x21,0x12,0x22,0x1C,0x15,0x42,0xB7,0x2F,0x13,0x02,0x0A,0x01,0x00,0x00}; const uint8_t nGammaSet[15]= {0x09,0x18,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x24,0x29}; #elif defined(__GAMMASET3) const uint8_t pGammaSet[15]= {0x3F,0x26,0x23,0x30,0x28,0x10,0x55,0xB7,0x40,0x19,0x10,0x1E,0x02,0x01,0x00}; //&const uint8_t nGammaSet[15]= {0x00,0x19,0x1C,0x0F,0x14,0x0F,0x2A,0x48,0x3F,0x06,0x1D,0x21,0x3D,0x3F,0x3F}; const uint8_t nGammaSet[15]= {0x09,0x18,0x2D,0x0D,0x13,0x15,0x40,0x48,0x53,0x0C,0x1D,0x25,0x2E,0x24,0x29}; #else const uint8_t pGammaSet[15]= {0x3F,0x25,0x1C,0x1E,0x20,0x12,0x2A,0x90,0x24,0x11,0x00,0x00,0x00,0x00,0x00}; const uint8_t nGammaSet[15]= {0x20,0x20,0x20,0x20,0x05,0x15,0x00,0xA7,0x3D,0x18,0x25,0x2A,0x2B,0x2B,0x3A}; #endif #if defined(__MK20DX128__) || defined(__MK20DX256__) SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); writecommand_cont(CMD_SWRESET);//software reset delay(500); writecommand_cont(CMD_SLPOUT);//exit sleep delay(5); writecommand_cont(CMD_PIXFMT);//Set Color Format 16bit writedata8_cont(0x05); delay(5); writecommand_cont(CMD_GAMMASET);//default gamma curve 3 writedata8_cont(0x08);//0x04 delay(1); writecommand_cont(CMD_GAMRSEL);//Enable Gamma adj writedata8_cont(0x01); delay(1); writecommand_cont(CMD_NORML); writecommand_cont(CMD_DFUNCTR); writedata8_cont(0b11111111);// writedata8_cont(0b00000110);// writecommand_cont(CMD_PGAMMAC);//Positive Gamma Correction Setting for (i=0;i<15;i++){ writedata8_cont(pGammaSet[i]); } writecommand_cont(CMD_NGAMMAC);//Negative Gamma Correction Setting for (i=0;i<15;i++){ writedata8_cont(nGammaSet[i]); } writecommand_cont(CMD_FRMCTR1);//Frame Rate Control (In normal mode/Full colors) writedata8_cont(0x08);//0x0C//0x08 writedata8_cont(0x02);//0x14//0x08 delay(1); writecommand_cont(CMD_DINVCTR);//display inversion writedata8_cont(0x07); delay(1); writecommand_cont(CMD_PWCTR1);//Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD writedata8_cont(0x0A);//4.30 - 0x0A writedata8_cont(0x02);//0x05 delay(1); writecommand_cont(CMD_PWCTR2);//Set BT[2:0] for AVDD & VCL & VGH & VGL writedata8_cont(0x02); delay(1); writecommand_cont(CMD_VCOMCTR1);//Set VMH[6:0] & VML[6:0] for VOMH & VCOML writedata8_cont(0x50);//0x50 writedata8_cont(99);//0x5b delay(1); writecommand_cont(CMD_VCOMOFFS); writedata8_cont(0);//0x40 delay(1); writecommand_cont(CMD_CLMADRS);//Set Column Address /* writedata8_cont(0x00); writedata8_cont(0X00); writedata8_cont(0X00); writedata8_cont(_GRAMWIDTH); */ writedata16_cont(0x00); writedata16_cont(_GRAMWIDTH); writecommand_cont(CMD_PGEADRS);//Set Page Address /* writedata8_cont(0x00); writedata8_cont(0X00); writedata8_cont(0X00); writedata8_last(_GRAMHEIGH); */ writedata16_cont(0x00); writedata16_last(_GRAMHEIGH); endProc(); colorSpace(_colorspaceData); setRotation(0); SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0)); writecommand_cont(CMD_DISPON);//display ON delay(1); writecommand_last(CMD_RAMWR);//Memory Write SPI.endTransaction(); delay(1); #else writecommand(CMD_SWRESET);//software reset delay(500); writecommand(CMD_SLPOUT);//exit sleep delay(5); writecommand(CMD_PIXFMT);//Set Color Format 16bit writedata(0x05); delay(5); writecommand(CMD_GAMMASET);//default gamma curve 3 writedata(0x04);//0x04 delay(1); writecommand(CMD_GAMRSEL);//Enable Gamma adj writedata(0x01); delay(1); writecommand(CMD_NORML); writecommand(CMD_DFUNCTR); writedata(0b11111111);// writedata(0b00000110);// writecommand(CMD_PGAMMAC);//Positive Gamma Correction Setting for (i=0;i<15;i++){ writedata(pGammaSet[i]); } writecommand(CMD_NGAMMAC);//Negative Gamma Correction Setting for (i=0;i<15;i++){ writedata(nGammaSet[i]); } writecommand(CMD_FRMCTR1);//Frame Rate Control (In normal mode/Full colors) writedata(0x08);//0x0C//0x08 writedata(0x02);//0x14//0x08 delay(1); writecommand(CMD_DINVCTR);//display inversion writedata(0x07); delay(1); writecommand(CMD_PWCTR1);//Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD writedata(0x0A);//4.30 - 0x0A writedata(0x02);//0x05 delay(1); writecommand(CMD_PWCTR2);//Set BT[2:0] for AVDD & VCL & VGH & VGL writedata(0x02); delay(1); writecommand(CMD_VCOMCTR1);//Set VMH[6:0] & VML[6:0] for VOMH & VCOML writedata(0x50);//0x50 writedata(99);//0x5b delay(1); writecommand(CMD_VCOMOFFS); writedata(0);//0x40 delay(1); writecommand(CMD_CLMADRS);//Set Column Address //writedata(0x00); //writedata(0X00); //writedata(0X00); //writedata(_GRAMWIDTH); writedata16(0x00); writedata16(_GRAMWIDTH); writecommand(CMD_PGEADRS);//Set Page Address //writedata(0x00); //writedata(0X00); //writedata(0X00); //writedata(_GRAMHEIGH); writedata16(0X00); writedata16(_GRAMHEIGH); colorSpace(_colorspaceData); setRotation(0); writecommand(CMD_DISPON);//display ON delay(1); writecommand(CMD_RAMWR);//Memory Write delay(1); #endif fillScreen(BLACK); }