コード例 #1
0
void TFT_ILI9163C::setRotation(uint8_t m) {
	rotation = m % 4; // can't be higher than 3
	switch (rotation) {
	case 0:
		_Mactrl_Data = 0b00001000;
		_width  = _TFTWIDTH;
		_height = _TFTHEIGHT;//-__OFFSET;
		break;
	case 1:
		_Mactrl_Data = 0b01101000;
		_width  = _TFTHEIGHT;//-__OFFSET;
		_height = _TFTWIDTH;
		break;
	case 2:
		_Mactrl_Data = 0b11001000;
		_width  = _TFTWIDTH;
		_height = _TFTHEIGHT;//-__OFFSET;
		break;
	case 3:
		_Mactrl_Data = 0b10101000;
		_width  = _TFTWIDTH;
		_height = _TFTHEIGHT;//-__OFFSET;
		break;
	}
	colorSpace(_colorspaceData);
	#if defined(__MK20DX128__) || defined(__MK20DX256__)
		SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
		writecommand_cont(CMD_MADCTL);
		writedata8_last(_Mactrl_Data);
		endProc();
	#else
		writecommand(CMD_MADCTL);
		writedata(_Mactrl_Data);
	#endif
}
コード例 #2
0
void TFT_ILI9163C::_setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
	writecommand_cont(CMD_CLMADRS); // Column
	if (rotation == 0 || rotation > 1){
		writedata16_cont(x0);
		writedata16_cont(x1);
	} else {
		writedata16_cont(x0 + __OFFSET);
		writedata16_cont(x1 + __OFFSET);
	}
	writecommand_cont(CMD_PGEADRS); // Page
	if (rotation == 0){
		writedata16_cont(y0 + __OFFSET);
		writedata16_cont(y1 + __OFFSET);
	} else {
		writedata16_cont(y0);
		writedata16_cont(y1);
	}
	writecommand_cont(CMD_RAMWR); //Into RAM
}
コード例 #3
0
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
}
コード例 #4
0
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
    }
}
コード例 #5
0
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
}
コード例 #6
0
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);
}
コード例 #7
0
ファイル: lcd_basic.c プロジェクト: RGassmann/FRDM
/*! \brief Initialize the LCD.
 *
 *  The LCD is reset and initialized with all predefined settings.
 */
void lcd_init(void)
{

lcd_spi_init();

    lcd_reset_on();
	//R_ESET=1;
	//for(i=120; i > 0; i--);
	delay_ms(1);
	lcd_reset_off();
	delay_ms(10);
	//for(i=1200; i > 0; i--);
	lcd_reset_on();
	delay_ms(1000);
	//for(i=12000; i > 0; i--);

static const uint8_t init_commands[] = {
	4, 0xEF, 0x03, 0x80, 0x02,
	4, 0xCF, 0x00, 0XC1, 0X30,
	5, 0xED, 0x64, 0x03, 0X12, 0X81,
	4, 0xE8, 0x85, 0x00, 0x78,
	6, 0xCB, 0x39, 0x2C, 0x00, 0x34, 0x02,
	2, 0xF7, 0x20,
	3, 0xEA, 0x00, 0x00,
	2, ILI9341_PWCTR1, 0x23, // Power control
	2, ILI9341_PWCTR2, 0x10, // Power control
	3, ILI9341_VMCTR1, 0x3e, 0x28, // VCM control
	2, ILI9341_VMCTR2, 0x86, // VCM control2
	2, ILI9341_MADCTL, 0x48, // Memory Access Control
	2, ILI9341_PIXFMT, 0x55,
	3, ILI9341_FRMCTR1, 0x00, 0x18,
	4, ILI9341_DFUNCTR, 0x08, 0x82, 0x27, // Display Function Control
	2, 0xF2, 0x00, // Gamma Function Disable
	2, ILI9341_GAMMASET, 0x01, // Gamma curve selected
	16, ILI9341_GMCTRP1, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08,
		0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00, // Set Gamma
	16, ILI9341_GMCTRN1, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07,
		0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, // Set Gamma
	0
};


const uint8_t *addr = init_commands;
	while (1) {
		uint8_t count = *addr++;
		if (count-- == 0) break;
		writecommand_cont(*addr++);
		while (count-- > 0) {
			writedata8_cont(*addr++);
		}
	}
	writecommand_last(ILI9341_SLPOUT);    // Exit Sleep

	writecommand_last(ILI9341_DISPON); // Display on


    /*lcd_send_cmd(ILI9341_PWCTRA);
        lcd_send_data(0x39);
        lcd_send_data(0x2C);
        lcd_send_data(0x00);
        lcd_send_data(0x34);
        lcd_send_data(0x02);

    lcd_send_cmd(ILI9341_PWCTRB);
        lcd_send_data(0x00);
        lcd_send_data(0X81);
        lcd_send_data(0X30);

    lcd_send_cmd(ILI9341_DRVTCTRA);
        lcd_send_data(0x85);
        lcd_send_data(0x00);
        lcd_send_data(0x78);

    lcd_send_cmd(ILI9341_DRVTCTRB);
        lcd_send_data(0x66);
        lcd_send_data(0x00);

    lcd_send_cmd(ILI9341_PWRONCTR);
        lcd_send_data(0x55);
        lcd_send_data(0x01);
        lcd_send_data(0X23);
        lcd_send_data(0X01);

    lcd_send_cmd(ILI9341_PMPRTCTR);
        lcd_send_data(0x10);

    lcd_send_cmd(ILI9341_PWCTR1);    //Power control
        lcd_send_data(0x21);   //VRH[5:0]

    lcd_send_cmd(ILI9341_PWCTR2);    //Power control
        lcd_send_data(0x10);   //SAP[2:0];BT[3:0]

    lcd_send_cmd(ILI9341_VMCTR1);    //VCM control
        lcd_send_data(0x31);
        lcd_send_data(0x3C);

    lcd_send_cmd(ILI9341_VMCTR2);    //VCM control2
        lcd_send_data(0xC0);  //--0x86

    lcd_set_Orientation(rot0);


    lcd_send_cmd(ILI9341_PIXFMT);
        lcd_send_data(0x55);

    lcd_send_cmd(ILI9341_FRMCTR1);
        lcd_send_data(0x00);
        lcd_send_data(0x11);

    lcd_send_cmd(ILI9341_FRMCTR2);
        lcd_send_data(0x00);
        lcd_send_data(0x11);

    lcd_send_cmd(ILI9341_FRMCTR3);
        lcd_send_data(0x00);
        lcd_send_data(0x11);

    lcd_send_cmd(ILI9341_DFUNCTR);    // Display Function Control
        lcd_send_data(0x08);
        lcd_send_data(0x82);
        lcd_send_data(0x27);

    lcd_send_cmd(0xF2);    // 3Gamma Function Disable
        lcd_send_data(0x02);

    lcd_send_cmd(ILI9341_GAMMASET);    //Gamma curve selected
        lcd_send_data(0x01);

    lcd_send_cmd(ILI9341_SLPOUT);    //Exit Sleep*/

        delay_ms(100);

   // lcd_send_cmd(ILI9341_DISPON);    //Display on
  //  lcd_send_cmd(ILI9341_RAMWR);
}