Ejemplo n.º 1
0
/*
 * Send character c to the LCD display.  After a '\n' has been seen,
 * the next character will first clear the display.
 */
int
lcd_putchar(char c, FILE *unused)
{
  static bool nl_seen;

  if (nl_seen && c != '\n')
    {
      /*
       * First character after newline, clear display and home cursor.
       */
      hd44780_wait_ready();
      hd44780_outcmd(HD44780_CLR);
      hd44780_wait_ready();
      hd44780_outcmd(HD44780_HOME);
      hd44780_wait_ready();
      hd44780_outcmd(HD44780_DDADDR(0));

      nl_seen = false;
    }
  if (c == '\n')
    {
      nl_seen = true;
    }
  else
    {
      hd44780_wait_ready();
      hd44780_outdata(c);
    }

  return 0;
}
Ejemplo n.º 2
0
/*
 * Setup the LCD controller.  First, call the hardware initialization
 * function, then adjust the display attributes we want.
 */
void
lcd_init(void)
{

  hd44780_init();

  /*
   * Clear the display.
   */
  hd44780_outcmd(HD44780_CLR);
  hd44780_wait_ready();

  /*
   * Entry mode: auto-increment address counter, no display shift in
   * effect.
   */
  hd44780_outcmd(HD44780_ENTMODE(1, 0));
  hd44780_wait_ready();

  /*
   * Enable display, activate non-blinking cursor.
   */
  hd44780_outcmd(HD44780_DISPCTL(1, 1, 0));
  hd44780_wait_ready();
}
Ejemplo n.º 3
0
/*
 * Initialize the LCD controller.
 *
 * The initialization sequence has a mandatory timing so the
 * controller can safely recognize the type of interface desired.
 * This is the only area where timed waits are really needed as
 * the busy flag cannot be probed initially.
 */
void
hd44780_init(void)
{

  DDRB = 0xFF; // Data port out
  DDRD = 0xF2; // (comment was obsolete)
  _delay_ms(15);		/* 40 ms needed for Vcc = 2.7 V */
  hd44780_outcmd(HD44780_FNSET(1, 0, 0));
  _delay_ms(4.1);
  hd44780_outcmd(HD44780_FNSET(1, 0, 0));
  _delay_ms(0.1);
  hd44780_outcmd(HD44780_FNSET(1, 0, 0));

  hd44780_outcmd(HD44780_FNSET(1, 1, 0));
  hd44780_wait_ready();
  hd44780_outcmd(HD44780_FNSET(1, 1, 0));
  hd44780_wait_ready();
  hd44780_outcmd(HD44780_DISPCTL(0, 0, 0));
  hd44780_wait_ready();
}
Ejemplo n.º 4
0
/*
 * Initialize the LCD controller.
 *
 * The initialization sequence has a mandatory timing so the
 * controller can safely recognize the type of interface desired.
 * This is the only area where timed waits are really needed as
 * the busy flag cannot be probed initially.
 */
void
hd44780_init(void)
{
  SET(DDR, HD44780_RS);
  SET(DDR, HD44780_RW);
  SET(DDR, HD44780_E);
  ASSIGN(DDR, HD44780_D8, 0xFF);

  _delay_ms(150);		/* 40 ms needed for Vcc = 2.7 V */
  hd44780_outbyte(HD44780_FNSET(1, 0, 0), 0);
  _delay_ms(41);
  hd44780_outbyte(HD44780_FNSET(1, 0, 0), 0);
  _delay_ms(1);
  hd44780_outbyte(HD44780_FNSET(1, 0, 0), 0);
  _delay_us(370);

  hd44780_outcmd(HD44780_FNSET(1, 1, 0));
  hd44780_wait_ready(false);
  hd44780_outcmd(HD44780_DISPCTL(0, 0, 0));
  hd44780_wait_ready(false);
}
Ejemplo n.º 5
0
/** Inicjalizacja urządzeń wejścia / wyjścia.
*/
void ioinit(void)
{
	uint8_t i;
	hd44780_init();
	hd44780_outcmd(HD44780_CLR);
	hd44780_wait_ready();
	hd44780_outcmd(HD44780_ENTMODE(1, 0));
	hd44780_wait_ready();
	hd44780_outcmd(HD44780_DISPCTL(1, 1, 1));
	hd44780_wait_ready();
	hd44780_outcmd(HD44780_CGADDR(0));
	for(i=0; i<64; i++) {
		hd44780_outdata(pgm_read_byte(&extraChar[i]));
	}

	TCCR1B = _BV(WGM12) | _BV(CS11);                        // licznik / 8 - wyzerwoanie na porownanie
	TIMSK = _BV(OCIE1A);                                    // przerwanie na porownanie wartosci
	OCR1A = TAU1;                                           // warto licznika porownania

	usart_init(UBRR_VALUE);

	onewire_init();

	twi_init();

	outputs_init();

	top_off_init();

	qbuttons_init();

	ui_init();

	BUZZER_DDR |= _BV(BUZZER_SWITCH);
	buzzer_off();

	wdt_enable(WDTO_2S);
}
Ejemplo n.º 6
0
int main()
{
  hd44780_init();
  /*
   * Clear the display.
   */
  hd44780_outcmd(HD44780_CLR);
  hd44780_wait_ready(1);   // long wait

  /*
   * Entry mode: auto-increment address counter, no display shift in effect.
   */
  hd44780_outcmd(HD44780_ENTMODE(1, 0));
  hd44780_wait_ready(0);

  /*
   * Enable display, activate non-blinking cursor.
   */
  hd44780_outcmd(HD44780_DISPCTL(1, 1, 0));
  hd44780_wait_ready(0);

  EICRA = (1 << ISC00);
  EIMSK = (1 << INT0);

  sei();

  while (1) {
    while (!update_needed)
      sleep_mode();
    update_needed = 0;
    char buffer[16];

    hd44780_outcmd(HD44780_CLR);
    hd44780_wait_ready(1);   // long wait
    hd44780_outcmd(HD44780_DDADDR(4));
    hd44780_wait_ready(0);
    sprintf(buffer, "%2d:%02d:%02d", hour, minute, second);

    char *s = buffer;
    while (*s) {
      hd44780_outdata(*s++);
      hd44780_wait_ready(0);
    }
  }
}
Ejemplo n.º 7
0
void lcd_clear()
{
  hd44780_outcmd(HD44780_CLR);
  hd44780_wait_ready();
}