コード例 #1
0
void init_lcd()
{
    DDRD &= ~((1<<PD4)|(1<<PD5)|(1<<PD6)|(1<<PD7));//clear register D
    DDRD |= ((1<<PD4)|(1<<PD5)|(1<<PD6)|(1<<PD7));//sets D4-D7 as output; used for sending bits
    DDRB &= ~((1<<PB0)|(1<<PB1));//clear register B
    DDRB |= ((1<<PB0)|(1<<PB1));//sets D8 & D9 as output; PB0/D8 used for Register Select(RS), PB1/D9 used for Enable
    _delay_ms(15);
    PORTB &= ~(1<<PB0);              // Delay at least 15ms
    writenibble(0b00110000);
    // Use writenibble to send 0011
    _delay_ms(5);               // Delay at least 4msec
    writenibble(0b00110000);
    // Use writenibble to send 0011
    _delay_us(100);             // Delay at least 100usec
    writenibble(0b00110000);
    // Use writenibble to send 0011, no delay needed
    writenibble(0b00100000);
    // Use writenibble to send 0010    // Function Set: 4-bit interface
    _delay_ms(2);
    
    writecommand(0x28);         // Function Set: 4-bit interface, 2 lines

    writecommand(0x0f);         // Display and cursor on
    _delay_ms(2);

}
コード例 #2
0
ファイル: GL_ST7735.cpp プロジェクト: vaj4088/LCD_Experiments
void GL_ST7735::setInverted(boolean b) {
	if (b) {
		writecommand(ST7735_INVON);
	} else {
		writecommand(ST7735_INVOFF);
	}
}
コード例 #3
0
void TFT_ILI9163C::sleepMode(boolean mode) {
	if (mode){
		if (sleep == 1) return;//already sleeping
		sleep = 1;
		#if defined(__MK20DX128__) || defined(__MK20DX256__)
			SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
			writecommand_last(CMD_SLPIN);
			endProc();
		#else
			writecommand(CMD_SLPIN);
		#endif
		delay(5);//needed
	} else {
		if (sleep == 0) return; //Already awake
		sleep = 0;
		#if defined(__MK20DX128__) || defined(__MK20DX256__)
			SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
			writecommand_last(CMD_SLPOUT);
			endProc();
		#else
			writecommand(CMD_SLPOUT);
		#endif
		delay(120);//needed
	}
}
コード例 #4
0
ファイル: SED1531.cpp プロジェクト: Duality4Y/SED1531
void SED1531::setMarker(byte marker, boolean on){
	byte highNibble, lowNibble;
	byte markerLCD;
	switch(marker){
		case 1:
			markerLCD = 20;			// arrows on the left
			break;
		case 2:
			markerLCD = 31;			// 2 hor. dashes
			break;
		case 3:
			markerLCD = 32;			// barcode
			break;
		case 4:
			markerLCD = 57;			// battery low
			break;
		case 5:
			markerLCD = 69;			// ?
			break;
		case 6:
			markerLCD = 78;			// arrow up
			break;
		}
	lowNibble = markerLCD&0xf;
	highNibble = markerLCD;
	highNibble = highNibble >> 4;
	bitSet(highNibble, 4);
	writecommand(0xb6);
	writecommand(highNibble);
	writecommand(lowNibble);
	writePixData(on);
	}
コード例 #5
0
ファイル: lcd.c プロジェクト: NikTRSK/EE109
/*
  init_lcd - Do various things to initialize the LCD display
*/
void init_lcd()
{
    DDRD |= (1 << PD7) | (1 << PD6) | (1 << PD5) | (1 << PD4);  // initialize data lines
    DDRB |= (1 << PB1) | (1 << PB0);                            // initialize Reg select & Enable

    _delay_ms(15);              // Delay at least 15ms

    // Use writenibble to send 0011
    writenibble(0x30);
    _delay_ms(5);               // Delay at least 4msec

    // Use writenibble to send 0011
    writenibble(0x30);
    _delay_us(120);             // Delay at least 100usec

    // Use writenibble to send 0011, no delay needed
    writenibble(0x30);

    // Use writenibble to send 0010    // Function Set: 4-bit interface
    writenibble(0x20);
    _delay_ms(2);

    writecommand(0x28);         // Function Set: 4-bit interface, 2 lines
    _delay_ms(2);

    writecommand(0x0F);         // Display and cursor on
    _delay_ms(2);

}
コード例 #6
0
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
}
コード例 #7
0
ファイル: Zpu_ILI9340.cpp プロジェクト: yukiyahakase/sample
void Zpu_ILI9340::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
{
  writecommand(ILI9340_CASET); // Column addr set
  writedata(x0 >> 8);
  writedata(x0 & 0xFF);     // XSTART 
  writedata(x1 >> 8);
  writedata(x1 & 0xFF);     // XEND

  writecommand(ILI9340_PASET); // Row addr set
  writedata(y0>>8);
  writedata(y0);     // YSTART
  writedata(y1>>8);
  writedata(y1);     // YEND

  writecommand(ILI9340_RAMWR); // write to RAM
}
コード例 #8
0
void Adafruit_ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) {

   writecommand(ST7735_CASET); // Column addr set
   writedata8(0x00);
   writedata8(x0+xstart);     // XSTART
   writedata8(0x00);
   writedata8(x1+xstart);     // XEND

   writecommand(ST7735_RASET); // Row addr set
   writedata8(0x00);
   writedata8(y0+ystart);     // YSTART
   writedata8(0x00);
   writedata8(y1+ystart);     // YEND

   writecommand(ST7735_RAMWR); // write to RAM
}
コード例 #9
0
ファイル: GL_ST7735.cpp プロジェクト: vaj4088/LCD_Experiments
void GL_ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)
{
  writecommand(ST7735_CASET);  // column addr set
  writedata(0x00);
  writedata(x0+0);   // XSTART 
  writedata(0x00);
  writedata(x1+0);   // XEND

  writecommand(ST7735_RASET);  // row addr set
  writedata(0x00);
  writedata(y0+0);    // YSTART
  writedata(0x00);
  writedata(y1+0);    // YEND

  writecommand(ST7735_RAMWR);  // write to RAM
}
コード例 #10
0
ファイル: lcd.cpp プロジェクト: Williangalvani/er9x_ili9340
void setRotation(uint8_t m) {

  writecommand(ILI9340_MADCTL);
  rotation = m % 4; // can't be higher than 3
  switch (rotation) {
   case 0:
     writedata(ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);
     _width  = ILI9340_TFTWIDTH;
     _height = ILI9340_TFTHEIGHT;
     break;
   case 1:
     writedata(ILI9340_MADCTL_MV | ILI9340_MADCTL_BGR);
     _width  = ILI9340_TFTHEIGHT;
     _height = ILI9340_TFTWIDTH;
     break;
  case 2:
    writedata(ILI9340_MADCTL_MY | ILI9340_MADCTL_BGR);
     _width  = ILI9340_TFTWIDTH;
     _height = ILI9340_TFTHEIGHT;
    break;
   case 3:
     writedata(ILI9340_MADCTL_MV | ILI9340_MADCTL_MY | ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);
     _width  = ILI9340_TFTHEIGHT;
     _height = ILI9340_TFTWIDTH;
     break;
  }
}
コード例 #11
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
}
コード例 #12
0
/**
 * Initialization for ST7735R screens (green or red tabs)
 */
void Adafruit_ST7735::initR(DisplayType options) {
   commandList(Rcmd1);

   if(options == INITR_GREENTAB) {
      commandList(Rcmd2green);
      colstart = 2;
      rowstart = 1;
   } else if(options == INITR_144GREENTAB) {
      fHeight = ST7735_TFTHEIGHT_128;
      fWidth  = ST7735_TFTWIDTH_128;
      commandList(Rcmd2green144);
      colstart = 2;
      rowstart = 3;
   } else if(options == INITR_MINI160x80) {
      fHeight = ST7735_TFTHEIGHT_160;
      fWidth  = ST7735_TFTWIDTH_80;
      commandList(Rcmd2green160x80);
      colstart = 24;
      rowstart = 0;
   } else {
      // colstart, rowstart left at default '0' values
      commandList(Rcmd2red);
   }
   commandList(Rcmd3);

   // if black, change MADCTL color filter
   if ((options == INITR_BLACKTAB) || (options == INITR_MINI160x80)) {
      writecommand(ST7735_MADCTL);
      writedata8(0xC0);
   }

   tabcolor = options;

   setRotation(0);
}
コード例 #13
0
ファイル: ST7735.c プロジェクト: howlanjo/Project-2
// Set the region of the screen RAM to be modified
// Pixel colors are sent left to right, top to bottom
// (same as Font table is encoded; different from regular bitmap)
// Requires 11 bytes of transmission
void static setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) {

  writecommand(ST7735_CASET); // Column addr set
  writedata(0x00);
  writedata(x0+ColStart);     // XSTART
  writedata(0x00);
  writedata(x1+ColStart);     // XEND

  writecommand(ST7735_RASET); // Row addr set
  writedata(0x00);
  writedata(y0+RowStart);     // YSTART
  writedata(0x00);
  writedata(y1+RowStart);     // YEND

  writecommand(ST7735_RAMWR); // write to RAM
}
コード例 #14
0
void Adafruit_HX8357::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1,
                                    uint16_t y1) {

    writecommand(HX8357_CASET); // Column addr set
    writedata(x0 >> 8);
    writedata(x0 & 0xFF);     // XSTART
    writedata(x1 >> 8);
    writedata(x1 & 0xFF);     // XEND

    writecommand(HX8357_PASET); // Row addr set
    writedata(y0>>8);
    writedata(y0);     // YSTART
    writedata(y1>>8);
    writedata(y1);     // YEND

    writecommand(HX8357_RAMWR); // write to RAM
}
コード例 #15
0
void TFT_ILI9163C::invertDisplay(boolean i) {
	#if defined(__MK20DX128__) || defined(__MK20DX256__)
		SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
		writecommand_last(i ? CMD_DINVON : CMD_DINVOF);
		SPI.endTransaction();
	#else
		writecommand(i ? CMD_DINVON : CMD_DINVOF);
	#endif
}
コード例 #16
0
void TFT_ILI9163C::display(boolean onOff) {
	if (onOff){
		#if defined(__MK20DX128__) || defined(__MK20DX256__)
			SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
			writecommand_last(CMD_DISPON);
			endProc();
		#else
			writecommand(CMD_DISPON);
		#endif
	} else {
		#if defined(__MK20DX128__) || defined(__MK20DX256__)
			SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
			writecommand_last(CMD_DISPOFF);
			endProc();
		#else
			writecommand(CMD_DISPOFF);
		#endif
	}
}
コード例 #17
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
}
コード例 #18
0
ファイル: lcd.c プロジェクト: arjunn11/Thermostat
/*
  init_lcd - Do various things to initialize the LCD display
*/
void init_lcd()
{
    DDRD |= (1 << PD7);//configure port as output
    DDRD |= (1 << PD6);
    DDRD |= (1 << PD5);
    DDRD |= (1 << PD4);
    DDRB |= (1 << PB0);
    DDRB |= (1 << PB1);
    _delay_ms(15);              // Delay at least 15ms
    writenibble(0x30); // Use writenibble to 78send 0011
    _delay_ms(5);               // Delay at least 4msec
    writenibble(0x30); // Use writenibble to send 0011
    _delay_us(120);             // Delay at least 100usec
    writenibble(0x30); // Use writenibble to send 0011, no delay needed
    writenibble(0x20); // Use writenibble to send 0010  // Function Set: 4-bit interface
    _delay_ms(2);
    writecommand(0x28);         // Function Set: 4-bit interface, 2 lines
    _delay_ms(2);
    writecommand(0xf0);         // Display and cursor on
    _delay_ms(2);
}
コード例 #19
0
ファイル: lab8.c プロジェクト: NikTRSK/EE109
int main(void)
{

  // Initialize the ADC registers
  init_adc();

  init_lcd(); // initialize the display

  writecommand(0x01); // clear display

  welcomemessage();   // print welcome message

  writecommand(0x01); // clear display

  init_count();

  init_timer(25000);  // initializes the timer with the count of 0.1s

  sei();  // start the ISR

  unsigned char old_value = 0;
  unsigned char conv_result = 0;

  while (1)    // Loop forever
  {
    ADCSRA |= ( 1 << ADSC );  // Start the conversion
    while ( (ADCSRA & ( 1 << ADSC)) != 0 ) {}

    conv_result = ADCH;

    if (old_value != conv_result)
    {
      checkState(conv_result);
      old_value = conv_result;
      _delay_ms(200);
    }
  }

    return 0;   /* never reached */
}
コード例 #20
0
ファイル: lcd.c プロジェクト: monolli/ee109
/*
  init_lcd - Do various things to initialize the LCD display
*/
void init_lcd()
{
    _delay_ms(15);              // Delay at least 15ms
    writenibble(0b00110000);
    // Use writenibble to send 0011
    _delay_ms(5);               // Delay at least 4msec
    writenibble(0b00110000);
    // Use writenibble to send 0011
    _delay_us(120);             // Delay at least 100usec
    writenibble(0b00110000);
    // Use writenibble to send 0011, no delay needed
    writenibble(0b00100000);
    // Use writenibble to send 0010    // Function Set: 4-bit interface
    _delay_ms(2);

    writecommand(0x28);         // Function Set: 4-bit interface, 2 lines

    writecommand(0x0f);         // Display and cursor on

    writecommand(1);

}
コード例 #21
0
ファイル: lcd.c プロジェクト: NikTRSK/EE109
/*
  moveto - Move the cursor to the postion "pos"
*/
void moveto(unsigned char row, unsigned char column)
{
  char pos;
  // subtract -1 from the result so that the doesn't need to enter 0 for pos 1

  if (row == 1)
  {
    pos = 0x80 + (column - 1);
  }
  else if (row == 2)
  {
    pos = 0xC0 + (column - 1);
  }
  writecommand(pos);
}
コード例 #22
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
    }
}
コード例 #23
0
void moduleinit() {
	DDRD = 0xf0;
	DDRB = 0x03;
	// initialize lcd
	init_lcd();
	writecommand(0x01);

	// leds 					(blue wire)
	DDRD |= (1 << PD2) | (1 << PD3);
	// rotary encoder (yellow wire)
	DDRC &=	~(1 << PC1) | ~(1 << PC2);
	PORTC |= (1 << PC1) |  (1 << PC2);
	// buttons 				(green wire)
	DDRB &= ~(1 << PB3) | ~(1 << PB4);
	PORTB |= (1 << PB3) |  (1 << PB4);
	
	//enable interrupts
	sei();
	PCICR |= (1 << PCIE0) | (1 << PCIE1);	
	PCMSK0 |= (1 << PB3) | (1 << PB4);
	PCMSK1 |= (1 << PC1) | (1 << PC2);
	
	//serial interface
	UBRR0 = 103; // Set baud rate
	UCSR0B |= (1 << TXEN0 | 1 << RXEN0); 	// Enable RX and TX
	UCSR0C = (3 << UCSZ00); 							// Async., no parity,
 	// 1 stop bit, 8 data bits
	DDRC |= (1 << PC3);
	PORTC &= ~(1 << PC3);

	//initialize thermometer
	ds1631_init();
	ds1631_conv();

	// template
	stringout("Temp:");
	moveto(8);
	stringout("Rmt :");
	moveto(0x40);
	stringout("Low :");
	moveto(0x48);
	stringout("High:");
}
コード例 #24
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
}
コード例 #25
0
// Companion code to the above tables.  Reads and issues
// a series of LCD commands stored in PROGMEM byte array.
void Adafruit_ST7735::commandList(const uint8_t *addr) {

  uint8_t  numCommands, numArgs;
  uint16_t ms;

  numCommands = pgm_read_byte(addr++);   // Number of commands to follow
  while(numCommands--) {                 // For each command...
    writecommand(pgm_read_byte(addr++)); //   Read, issue command
    numArgs  = pgm_read_byte(addr++);    //   Number of args to follow
    ms       = numArgs & DELAY;          //   If hibit set, delay follows args
    numArgs &= ~DELAY;                   //   Mask out delay bit
    while(numArgs--) {                   //   For each argument...
      writedata(pgm_read_byte(addr++));  //     Read, issue argument
    }

    if(ms) {
      ms = pgm_read_byte(addr++); // Read post-command delay time (ms)
      if(ms == 255) ms = 500;     // If 255, delay for 500 ms
      delay(ms);
    }
  }
}
コード例 #26
0
ファイル: ST7735.c プロジェクト: howlanjo/Project-2
//------------ST7735_InitR------------
// Initialization for ST7735R screens (green or red tabs).
// Input: option one of the enumerated options depending on tabs
// Output: none
void ST7735_InitR(enum initRFlags option) {
  commonInit(Rcmd1);
  if(option == INITR_GREENTAB) {
    commandList(Rcmd2green);
    ColStart = 2;
    RowStart = 1;
  } else {
    // colstart, rowstart left at default '0' values
    commandList(Rcmd2red);
  }
  commandList(Rcmd3);

  // if black, change MADCTL color filter
  if (option == INITR_BLACKTAB) {
    writecommand(ST7735_MADCTL);
    writedata(0xC0);
  }
  TabColor = option;
  ST7735_SetCursor(0,0);
  StTextColor = ST7735_YELLOW;
  ST7735_FillScreen(0);                 // set screen to black
}
コード例 #27
0
ファイル: Graphic2.c プロジェクト: smhuang426/Keil
void drawline(uchar hang,uchar lie,uchar length,uchar way,uchar foc)
{
	uchar i;
	writecommand(0xb2); //退出自动写模式
	address=hang*30+lie/8;
	writeadd();
	if(way==1)
	{
		if(length<(9-lie%8))
		{
			for(i=lie%8;i<length+lie%8;i++)
				writecommand(foc==1?0xf8-i+7:0xf0-i+7);
		}
		else
		{
			for(i=lie%8+1;i<=8;i++)
				writecommand(foc==1?0xf8-i+8:0xf0-i+7);
			address++; writeadd();
			writecommand(0xb0);
			for(i=0;i<(length+lie%8-8)/8;i++)
				writedata(foc==1?0xff:0x00);
			writecommand(0xb2);
			for(i=1;i<=(length+lie%8-8)%8;i++)
				writecommand(foc==1?0xf8-i+8:0xf0-i+8);
		}
	}
	else if(way==2)
	{
		for(i=0;i<length;i++)
		{
			writecommand(foc==1?0xff-lie%8:0xf8-lie%8);
			address+=30;
			writeadd();
		}
	}
}
コード例 #28
0
ファイル: Zpu_ILI9340.cpp プロジェクト: yukiyahakase/sample
void Zpu_ILI9340::begin(void) 
{
//  SPI.begin(WISHBONESLOT(_slot));
//  SPI.begin(MOSI(_mosi), MISO(_miso), SCK(_sclk));
//  SPI.setClockDivider(SPI_CLOCK_DIV4); // 8 MHz (full! speed!)
//  SPI.setBitOrder(MSBFIRST);
//  SPI.setDataMode(SPI_MODE0);

  USPICTL=BIT(SPICP1)|BIT(SPICPOL)|BIT(SPISRE)|BIT(SPIEN)|BIT(SPIBLOCK);

  pinModePPS(_mosi,HIGH);
  pinMode(_mosi, OUTPUT);
  outputPinForFunction(_mosi, IOPIN_USPI_MOSI );

  pinModePPS(_sclk,HIGH);
  pinMode(_sclk, OUTPUT);
  outputPinForFunction(_sclk, IOPIN_USPI_SCK);

  pinMode(_miso, INPUT);
  inputPinForFunction(_miso, IOPIN_USPI_MISO );

  pinModePPS(_cs, LOW);
  pinMode(_cs, OUTPUT);

  pinModePPS(_dc, LOW);
  pinMode(_dc, OUTPUT);

  pinModePPS(_rst, LOW);
  pinMode(_rst, OUTPUT);

  digitalWrite(_rst, LOW);
  digitalWrite(_sclk, LOW);
  digitalWrite(_mosi, LOW);

  // toggle RST low to reset
  digitalWrite(_rst, HIGH);
  delay(5);
  digitalWrite(_rst, LOW);
  delay(20);
  digitalWrite(_rst, HIGH);
  delay(150);

  writecommand(0xEF);
  writedata(0x03);
  writedata(0x80);
  writedata(0x02);

  writecommand(0xCF);  
  writedata(0x00); 
  writedata(0xC1); 
  writedata(0x30); 

  writecommand(0xED);  
  writedata(0x64); 
  writedata(0x03); 
  writedata(0x12); 
  writedata(0x81); 
 
  writecommand(0xE8);  
  writedata(0x85); 
  writedata(0x00); 
  writedata(0x78); 

  writecommand(0xCB);  
  writedata(0x39); 
  writedata(0x2C); 
  writedata(0x00); 
  writedata(0x34); 
  writedata(0x02); 
 
  writecommand(0xF7);  
  writedata(0x20); 

  writecommand(0xEA);  
  writedata(0x00); 
  writedata(0x00); 
 
  writecommand(ILI9340_PWCTR1);    //Power control 
  writedata(0x23);   //VRH[5:0] 
 
  writecommand(ILI9340_PWCTR2);    //Power control 
  writedata(0x10);   //SAP[2:0];BT[3:0] 
 
  writecommand(ILI9340_VMCTR1);    //VCM control 
  writedata(0x3e); //�Աȶȵ���
  writedata(0x28); 
  
  writecommand(ILI9340_VMCTR2);    //VCM control2 
  writedata(0x86);  //--
 
  writecommand(ILI9340_MADCTL);    // Memory Access Control 
  writedata(ILI9340_MADCTL_MX | ILI9340_MADCTL_BGR);

  writecommand(ILI9340_PIXFMT);    
  writedata(0x55); 
  
  writecommand(ILI9340_FRMCTR1);    
  writedata(0x00);  
  writedata(0x18); 
 
  writecommand(ILI9340_DFUNCTR);    // Display Function Control 
  writedata(0x08); 
  writedata(0x82);
  writedata(0x27);  
 
  writecommand(0xF2);    // 3Gamma Function Disable 
  writedata(0x00); 
 
  writecommand(ILI9340_GAMMASET);    //Gamma curve selected 
  writedata(0x01); 
 
  writecommand(ILI9340_GMCTRP1);    //Set Gamma 
  writedata(0x0F); 
  writedata(0x31); 
  writedata(0x2B); 
  writedata(0x0C); 
  writedata(0x0E); 
  writedata(0x08); 
  writedata(0x4E); 
  writedata(0xF1); 
  writedata(0x37); 
  writedata(0x07); 
  writedata(0x10); 
  writedata(0x03); 
  writedata(0x0E); 
  writedata(0x09); 
  writedata(0x00); 
  
  writecommand(ILI9340_GMCTRN1);    //Set Gamma 
  writedata(0x00); 
  writedata(0x0E); 
  writedata(0x14); 
  writedata(0x03); 
  writedata(0x11); 
  writedata(0x07); 
  writedata(0x31); 
  writedata(0xC1); 
  writedata(0x48); 
  writedata(0x08); 
  writedata(0x0F); 
  writedata(0x0C); 
  writedata(0x31); 
  writedata(0x36); 
  writedata(0x0F); 

  writecommand(ILI9340_SLPOUT);    //Exit Sleep 
  delay(120); 
  writecommand(ILI9340_DISPON);    //Display on 
}
コード例 #29
0
/*
  moveto - Move the cursor to the postion "pos"
*/
void moveto(unsigned char pos)
{
  cursor = pos;
  writecommand((0x80+pos));
}
コード例 #30
0
void Adafruit_ST7735::invertDisplay(bool i) {
   writecommand(i ? ST7735_INVON : ST7735_INVOFF);
}