Esempio n. 1
0
void MI0283QT9::begin(uint_least8_t clock_div)
{
  //init pins
#if defined(RST_PIN)
  pinMode(RST_PIN, OUTPUT);
  RST_ENABLE();
#endif
  pinMode(LED_PIN, OUTPUT);
  pinMode(CS_PIN, OUTPUT);
#if defined(LCD_8BIT_SPI)
  pinMode(RS_PIN, OUTPUT);
  RS_HIGH();
#endif
  pinMode(SCK_PIN, OUTPUT);
  pinMode(MOSI_PIN, OUTPUT);
  pinMode(MISO_PIN, INPUT);
  LED_DISABLE();
  CS_DISABLE();
#if defined(ADS7846)
  pinMode(ADSCS_PIN, OUTPUT);
  ADSCS_DISABLE();
#endif

#if !defined(SOFTWARE_SPI)
  lcd_clock_div = clock_div;
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  //SPI.setClockDivider(clock_div);
  SPI.begin();
#endif

  //SPI speed-down
#if !defined(SOFTWARE_SPI)
# if F_CPU >= 128000000UL
  SPI.setClockDivider(SPI_CLOCK_DIV64);
# elif F_CPU >= 64000000UL
  SPI.setClockDivider(SPI_CLOCK_DIV32);
# elif F_CPU >= 32000000UL
  SPI.setClockDivider(SPI_CLOCK_DIV16);
# elif F_CPU >= 16000000UL
  SPI.setClockDivider(SPI_CLOCK_DIV8);
# else //elif F_CPU >= 8000000UL
  SPI.setClockDivider(SPI_CLOCK_DIV4);
# endif
#endif

  //reset display
  reset();

  //SPI speed-up
#if !defined(SOFTWARE_SPI)
  SPI.setClockDivider(clock_div);
#endif

  //enable backlight
  led(50);

  return;
}
Esempio n. 2
0
static void lcd_Write (
	uint8_t reg,	/*	b0:command(0)/data(1), b2-b1:E1(2)/E2(1)/both(0)(don't care on single controller),
						b3:write high nibble only(don't care on 8-bit I/F) */
	uint8_t data	/*	Byte to be written */
)
{
	if (reg & 1)	/* Select register */
		RS_HIGH();
	else
		RS_LOW();
	IF_DLY60nS();

#if IF_BUS == 4
	if (!(reg & 8)) { // write both nibbles
		OUT_DATA(data);
#if LCD_IF_DUAL
		if (!(reg & 2)) E1_HIGH();
		if (!(reg & 4)) E2_HIGH();
		IF_DLY450nS();
		E1_LOW();
		E2_LOW();
#else
		E1_HIGH();
		IF_DLY450nS();
		E1_LOW();
#endif
		data <<= 4;
	}
#endif

	OUT_DATA(data);

#if LCD_IF_DUAL
	if (!(reg & 2)) E1_HIGH();
	if (!(reg & 4)) E2_HIGH();
	IF_DLY450nS();
	E1_LOW();
	E2_LOW();
#else
	E1_HIGH();
	IF_DLY450nS();
	E1_LOW();
#endif

	_delay_us(LCD_DT2);	/* Always use timer */

	OUT_DATA(0xF0);
}
static
void lcd_write (
	uint8_t reg,	/* b0:command(0)/data(1), b2..1:E1(2)/E2(1)/both(0)(don't care on single controller), b3:write high nibble only(don't care on 8-bit bus) */
	uint8_t dat		/* Byte to be written */
)
{
	if (reg & 1)	/* Select register */
		RS_HIGH();
	else
		RS_LOW();
	IF_DLY60();

#if IF_BUS == 4
	if (!(reg & 8)) {
		OUT_DATA(dat);
#if LCD_IF_DUAL
		if (!(reg & 2)) E1_HIGH();
		if (!(reg & 4)) E2_HIGH();
		IF_DLY450();
		E1_LOW();
		E2_LOW();
#else
		E1_HIGH();
		IF_DLY450();
		E1_LOW();
#endif
		IF_DLY450();
		dat <<= 4;
	}
#endif

	OUT_DATA(dat);
#if LCD_IF_DUAL
	if (!(reg & 2)) E1_HIGH();
	if (!(reg & 4)) E2_HIGH();
	IF_DLY450();
	E1_LOW();
	E2_LOW();
#else
	E1_HIGH();
	IF_DLY450();
	E1_LOW();
#endif

	DELAY_US(LCD_DT2);	/* Always use timer */
}
Esempio n. 4
0
void MI0283QT9::begin(uint_least8_t clock_div)
{
  //init pins
#if defined(RST_PIN)
  pinMode(RST_PIN, OUTPUT);
  RST_ENABLE();
#endif
  pinMode(LED_PIN, OUTPUT);
  pinMode(CS_PIN, OUTPUT);
#if defined(USE_8BIT_SPI)
  pinMode(RS_PIN, OUTPUT);
  RS_HIGH();
#endif
  pinMode(CLK_PIN, OUTPUT);
  pinMode(MOSI_PIN, OUTPUT);
  pinMode(MISO_PIN, INPUT);
  LED_DISABLE();
  CS_DISABLE();
#if defined(ADS7846)
  pinMode(ADSCS_PIN, OUTPUT);
  ADSCS_DISABLE();
#endif

#if !defined(SOFTWARE_SPI)
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(clock_div);
  SPI.begin();
#endif

  //reset display
  reset(clock_div);

  //enable backlight
  led(50);

  return;
}