Ejemplo n.º 1
0
void lcdData(unsigned char cmd)
{
    wait_ready();
    CMD_RS1(); // data
    lcdWriteData(cmd);
    pulse_e();
}
Ejemplo n.º 2
0
void lcdCmd(unsigned char cmd)
{
    wait_ready();
    CMD_RS0(); // controll command
    lcdWriteData(cmd);
    pulse_e();
}
Ejemplo n.º 3
0
void lcdInit(void)
{
    _lcd_init();

    lcdPrepareWrite();
    CMD_SLEEP_MS(16); // 16 ms

    lcdWriteData(3); // 8bit mode
    pulse_e();
    CMD_SLEEP_MS(5); // 4992 us

    pulse_e(); // Repeat 8bit mode
    CMD_SLEEP_MS(1); // 64 us

    pulse_e(); // Third repeat
    CMD_SLEEP_MS(1); // 64 us

    // lcdWriteData(2); // Change to 4bit mode (0x20)
    // pulse_e();

    lcdCmd(LCD_CMD_INIT8);
    /*
    lcdCmd(0x24);
    lcdCmd(0x09);
    lcdCmd(0x20);
    */

    lcdCmd(0x08);
    lcdCmd(0x01);
    lcdCmd(0x06);
    lcdCmd(0x0C);

    lcdCmd(0x80);
    /*
    lcdCmd(0x02);
    */
    /*
    lcdCmd(LCD_SET_DM | LCD_DM_DISPLAY_ON);
    lcdCmd(LCD_SET_INCREMENT_MODE);
    */

#ifdef WRAPEN
    cur_col = 0;
    cur_row = 0;
#endif
}
Ejemplo n.º 4
0
uint8_t read_register(bool register_sel) {

	uint8_t data = 0;
	uint8_t upper4 = 0;
	uint8_t lower4 = 0;

	if(register_sel) set_rs();
	else		 clear_rs();

	set_rw();
	config_bus_input();
	upper4 = pulse_e();
	lower4 = pulse_e();
	data |= upper4;
	data |= (lower4 >> 4);
	
	return data;
}
Ejemplo n.º 5
0
// Send one byte as command to display,
// split in two parts for 4bit interface
void lcd_send_cmd(int cmd_value) {
  GPIO_ResetBits(LCD_GPIO, LCD_RS | LCD_RW);
  GPIO_ResetBits(LCD_GPIO, LCD_D7 | LCD_D6 | LCD_D5 | LCD_D4);

  // Send first half
  if (cmd_value & (1<<7)) GPIO_SetBits(LCD_GPIO, LCD_D7);
  if (cmd_value & (1<<6)) GPIO_SetBits(LCD_GPIO, LCD_D6);
  if (cmd_value & (1<<5)) GPIO_SetBits(LCD_GPIO, LCD_D5);
  if (cmd_value & (1<<4)) GPIO_SetBits(LCD_GPIO, LCD_D4);
  pulse_e();

  // Send second half
  GPIO_ResetBits(LCD_GPIO, LCD_D7 | LCD_D6 | LCD_D5 | LCD_D4);
  if (cmd_value & (1<<3)) GPIO_SetBits(LCD_GPIO, LCD_D7);
  if (cmd_value & (1<<2)) GPIO_SetBits(LCD_GPIO, LCD_D6);
  if (cmd_value & (1<<1)) GPIO_SetBits(LCD_GPIO, LCD_D5);
  if (cmd_value & (1<<0)) GPIO_SetBits(LCD_GPIO, LCD_D4);
  pulse_e();

}
Ejemplo n.º 6
0
static void output_nibble(uint8_t data) {

	bool db7 = data & (1 << 7);
	bool db6 = data & (1 << 6);
	bool db5 = data & (1 << 5);
	bool db4 = data & (1 << 4);

	if(db7) set_db7();
	else	clear_db7();

	if(db6) set_db6();
	else	clear_db6();

	if(db5) set_db5();
	else	clear_db5();

	if(db4) set_db4();
	else	clear_db4();

	pulse_e();
}
Ejemplo n.º 7
0
// Init Routine
// http://sprut.de/electronic/lcd/
// Pinout:
// RS RW - D7 D6 D5 D5 (D3 D2 D1 D0)
void lcd_start() {
  // Wait 15ms
  wait_ms(15);

  // Set interface to 8 Bits
  GPIO_ResetBits(LCD_GPIO, LCD_RS | LCD_RW | LCD_D7 | LCD_D6);
  GPIO_SetBits(LCD_GPIO, LCD_D5 | LCD_D4);
  pulse_e(); // 00-0011

  // Wait 4.1ms
  wait_ms(5);

  // Pulse again (Set interface to 8 Bits)
  pulse_e();

  // Wait 100us and pulse again
  wait_ms(1);
  pulse_e();

  // Set interface to 4 Bits
  GPIO_ResetBits(LCD_GPIO, LCD_D4);
  pulse_e(); // 00-0010

  // From now on, send bytes in two parts
  // First:  7 6 5 4
  // Second: 3 2 1 0

  // 2 lines, 5x8
  pulse_e(); // 00-0010....
  GPIO_ResetBits(LCD_GPIO, LCD_D5);
  GPIO_SetBits(LCD_GPIO, LCD_D7);
  pulse_e(); // + ....1000

  // Display off
  GPIO_ResetBits(LCD_GPIO, LCD_D7);
  pulse_e();

  GPIO_SetBits(LCD_GPIO, LCD_D7);
  pulse_e();

  // Clear
  GPIO_ResetBits(LCD_GPIO, LCD_D7);
  pulse_e();

  GPIO_SetBits(LCD_GPIO, LCD_D4);
  pulse_e();

  // Cursor right, no display shift
  GPIO_ResetBits(LCD_GPIO, LCD_D4);
  pulse_e();

  GPIO_SetBits(LCD_GPIO, LCD_D6 | LCD_D5);
  pulse_e();

  // Display on
  GPIO_ResetBits(LCD_GPIO, LCD_D6 | LCD_D5);
  pulse_e();

  // To enable cursor: Add LCD_D5 | LCD_D4
  GPIO_SetBits(LCD_GPIO, LCD_D7 | LCD_D6);
  pulse_e();
}