Пример #1
0
//non-core stuff --------------------------------------
//move the cursor to the given absolute position.  line numbers start at 1.
//if this is not a 2-line LCD4Bit_mod instance, will always position on first line.
void cursorTo(int line_num, int x){
  //if we are on a 1-line display, set line_num to 1st line, regardless of given
  //offset 40 chars in if second line requested
  x += 0x40*(((g_num_lines>line_num)?line_num:g_num_lines)-1);

  commandWrite(CMD_DDADDR(x));
  cursor_pos=x;
}
Пример #2
0
void set_char_at(char c, int line_num, int  x)
{
	uint8_t orig_cursor=cursor_pos;
	//move cursor
	cursorTo(line_num, x);
	//write
	dataWrite(c);
	//restore cursor
	commandWrite(CMD_DDADDR(orig_cursor));
	cursor_pos=orig_cursor;
}
Пример #3
0
/*
 * function to redirect stdout to lcd by FDEV_SETUP_STREAM() macro
 * Sends a character to the LCD display.
 * '\n' clears the display after the *next* character
 * '\r' sets the cursor address to begin of 2nd line
 */
int lcd_putchar(char c, FILE *unused)
{
  static char nl_seen;
  if (nl_seen && c != '\n') {
      // first character after newline, clear display and home cursor.
      clear();
      nl_seen = 0;
  }
  if (c == '\n') {
      nl_seen = 1;
  }
  else if (c != '\r') {
      dataWrite(c);
  } else {	
      commandWrite(CMD_DDADDR(64));
  }
  return 0;
}
Пример #4
0
extern void lcd_cursor_addr(int pos){
  commandWrite(CMD_DDADDR(pos));
  _delay_us(1000);
}