Exemple #1
0
/*
 * LcdInit
 * Description: This initializes the LCD. This must be called before the LCD can
 *              be used.
 *              Thus this function has to be called before calling any other 
 *              LCD-interface functions.
 *              The LCD is set to the following specifications:
 *                8-bit mode, 4-line display, 5x8 font
 *                cursor INCs, display doesn't shift
 *                cursor visible, cursor blinking
 *
 * Argument:    None
 * Return:      None
 *
 * Input:       None
 * Output:      LCD
 *
 * Operation:   
 *   Really just follows standard initialization sequence. See sketch below
 *
 *   POWER ON
 *       |
 *       |  Wait time >40ms
 *      \|/
 *   FUNCTION SET (RS = 0, RW=0, DB = 0b0011NFXX) [BF cannot be checked b4 this]
 *       |
 *       |  Wait time >37us
 *      \|/
 *   FUNCTION SET (RS = 0, RW=0, DB = 0b0011NFXX) [BF cannot be checked b4 this]
 *       |
 *       |  Wait time >37us
 *      \|/
 *   DISPLAY ON/OFF control (RS = 0, RW=0, DB = 0b00001DCB)
 *       |
 *       |  Wait time >37us
 *      \|/
 *   DISPLAY Clear (RS=0, RW=0, DB=0b00000001)
 *       |
 *       |  Wait time >1.52ms
 *      \|/
 *   Entry Mode Set (RS=0, RW=0, DB=0b0000001{I/D}S)
 *       |
 *       |  Wait time >37us
 *      \|/
 *   Initialization End
 *
 * Revision History:
 *   Dec. 16, 2012      Nnoduka Eruchalu     Initial Revision
 */
void LcdInit(void)
{
  LCD_DATA_TRIS = 0x00;        /* setup LCD IO ports as outputs */
  LCD_E_TRIS = 0;
  LCD_RW_TRIS = 0;
  LCD_RS_TRIS = 0;
  
  LCD_DATA_LAT = 0;            /* clear IO lines*/
  CLEAR_RS(); CLEAR_RW(); CLEAR_E();
  
  __delay_ms(40);              
  
  LCD_DATA_LAT = LCD_FUNC_SET; /* FUNCTION SET, done manually to prevent a */
  LCD_STROBE();                /* BF check before next command */
  __delay_us(40);
  
  LcdCommand(LCD_FUNC_SET);    /* FUNCTION SET, again done manually */
  LCD_STROBE();
  __delay_us(40);
  
  LcdCommand(LCD_ON);          /* DISPLAY ON/OFF control: Turn display on */
  __delay_us(40);
  
  LcdCommand(LCD_CLEAR);        /* DISPLAY Clear */
  __delay_ms(2);
  
  LcdCommand(LCD_ENTRY_MD);     /* ENTRY mode set */
  
  GenSpecChars();               /* Now create some special characters */
}
Exemple #2
0
void LcdInit(void) {
	LCD_PORT.DIRSET	=	LCD_D4_bm|
						LCD_D5_bm|
						LCD_D6_bm|
						LCD_D7_bm|
						LCD_RS_bm|
						LCD_E_bm;
	_delay_ms(5); // oczekiwanie na ustalibizowanie si� napiecia zasilajacego
	LCD_PORT.OUTCLR = LCD_RS_bm | LCD_E_bm;

	for(uint8_t i = 0; i < 3; i++) { // trzykrotne powt�rzenie bloku instrukcji
		LCD_PORT.OUTSET = LCD_E_bm;
		_lcd_OutNibble(0x03); // tryb 8-bitowy
		LCD_PORT.OUTCLR = LCD_E_bm;
		_delay_ms(5); // czekaj 5ms
	}

	LCD_PORT.OUTSET = LCD_E_bm;
	_lcd_OutNibble(0x02); // tryb 4-bitowy
	LCD_PORT.OUTCLR = LCD_E_bm;

	_delay_ms(1); // czekaj 1ms 
	LcdCommand(HD44780_FUNCTION_SET | HD44780_FONT5x7 | HD44780_TWO_LINE | HD44780_4_BIT); // interfejs 4-bity, 2-linie, znak 5x7
	LcdCommand(HD44780_DISPLAY_ONOFF | HD44780_DISPLAY_OFF); // wy��czenie wyswietlacza
	LcdCommand(HD44780_CLEAR); // czyszczenie zawartos�i pamieci DDRAM
	_delay_ms(2);
	LcdCommand(HD44780_ENTRY_MODE | HD44780_EM_SHIFT_CURSOR | HD44780_EM_INCREMENT);// inkrementaja adresu i przesuwanie kursora
	LcdCommand(HD44780_DISPLAY_ONOFF | HD44780_DISPLAY_ON | HD44780_CURSOR_OFF | HD44780_CURSOR_NOBLINK); // w��cz lcd, bez kursora i mrugania
}
Exemple #3
0
/*
 * LcdWriteFill
 * Description: This function writes strings to all rows of display.
 * 
 * Arguments:   displaytable - a table of strings (one string per row).
 *                each string is of length (LCD_WIDTH+1). The +1 accounts for
 *                each string's NULL-terminator.
 * Return:      None
 *
 * Input:       None
 * Output:      LCD
 *
 * Operation:   Clear LCD. Return Cursor Home. Write strings in table, one row 
 *              at a time.
 *
 * Revision History:
 *   Apr. 21, 2013      Nnoduka Eruchalu     Initial Revision
 *   May  14, 2013      Nnoduka Eruchalu     Setting cursor per row
 */
void LcdWriteFill(const char (*displaytable)[LCD_WIDTH+1]) {
  size_t i;                       /* row counter             */
  LcdCommand(LCD_CLEAR);          /* clear LCD               */
  LcdCommand(LCD_RET_HOME);       /* return cursor home      */
  for (i=0; i<LCD_HEIGHT; i++) {  /* write strings in table, */
    LcdCursor(i,0);               /* one row at a time       */
    LcdWriteStr(displaytable[i]); 
  }
}
Exemple #4
0
/* GenSpecChars
 * Description: This procedure loads the CGRAM with custom characters.
 *              This procedure should be called after initializing the LCD.
 *
 * Arguments:   None
 * Return:      None
 *
 * Input:       None
 * Output:      LCD CGRAM
 * 
 * Operation:   For each custom character, call this ShapeX, the procedure sets 
 *                the CGRAM address to point to the corresponding base address 
 *                as defined in lcd.h.
 *              Then use the values in ShapeXTable to write the pixel data.
 *              After generating all the custom characters of interest, the 
 *                procedure returns the Cursor to a DDRAM location.
 *
 * Error Checking: None
 *
 * Revision History:
 *   Apr. 20, 2013      Nnoduka Eruchalu     Initial Revision
 */
static void GenSpecChars(void)
{
  size_t i; /* looping index */
  /* Generate Naira Character */
  LcdCommand(NAIRA_BASE);              /* point to Naira Char's CGRAM address */
  for(i=0; i < LCD_CHAR_HEIGHT; i++) { /* Loop through and write the bits in */
    LcdWrite(NairaTable[i]);           /* the pixel rows */
  }
  
  /* Done generating special Characters */
  LcdCommand(DDRAM_BASE);              /* return the Cursor to a DDRAM loc */
  
}
Exemple #5
0
/* LcdCursor
 * Description: This function moves the cursor to a specific position
 *              Below is a DDRAM address map by Row:
 *                Row 1:  0x00  -->  0x13
 *                Row 2:  0x40  -->  0x53
 *                Row 3:  0x14  -->  0x27
 *                Row 4:  0x54  -->  0x67
 *
 * Arguments:   row: 0-indexed row number
 *              col: 0-indexed column number
 * Return:      None
 *
 * Input:       None
 * Output:      LCD
 * 
 * Operation:   Choose the base register of the LCD then update the cursor 
 *              location
 * 
 * Error Checking: If row >= LCD_HEIGHT or col >= LCD_WIDTH, it is reset to 0.
 *
 * Revision History:
 *   Dec. 16, 2012      Nnoduka Eruchalu     Initial Revision
 *   Apr. 20, 2013      Nnoduka Eruchalu     Updated to actually compute loc 
 *                                           from row and col arguments.
 */
void LcdCursor(uint8_t row, uint8_t col)
{
  uint8_t loc;
  
  if (row >LCD_HEIGHT) row = 0;      /* error checking of indices */
  if (col >= LCD_WIDTH) col = 0;
  
  switch(row) {  /* get LCD's relative DDRAM location */
  case 0:
    loc = 0x00;
    break;
  case 1:
    loc = 0x40;
    break;
  case 2:
    loc = 0x14;
    break;
  case 3:
    loc = 0x54;
    break;
  default:
    break;
  }
  
  loc += col;  /* offset relative DDRAM location by column */
  
  LcdCommand(DDRAM_BASE+loc); /* have to write to absolute DDRAM location */
}
/*****************************************************
* INITIALIZE DISPLAY
* DESCRIPTION: Setup all ports and initialize the LCD
* for usage.
*****************************************************/
void InitializeNokia5110(void)
{
   P2DIR |= 0x10;                           //Set LCD power port
   P2OUT |= 0x10;                           //Power up LCD
   P2DIR |= PIN_SCE;
   P2DIR |= PIN_RESET;
   P1DIR |= PIN_DC;
   P1DIR |= PIN_LED;
   P1OUT&= ~PIN_LED;                         //Enable the backlight by default
   P1SEL = BIT1 + BIT2 + BIT4;
   P1SEL2 = BIT1 + BIT2 + BIT4;
   UCA0CTL0 |= UCCKPL + UCMSB + UCMST + UCSYNC;  // 3-pin, 8-bit SPI master
   UCA0CTL1 |= UCSSEL_2;                     // SMCLK
   UCA0BR0 |= 2;                          // /2
   UCA0BR1 = 0;                              //
   UCA0MCTL = 0;                             // No modulation
   UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
   digitalWrite(PIN_RESET, 0);
   digitalWrite(PIN_RESET, 1);

   //Send LCD init instructions
   LcdCommand(0x21 );  // LCD Extended Commands.
   LcdCommand(0xB6 );  // Set LCD Vop (Contrast).0xB0
   LcdCommand(0x04 );  // Set Temp coefficent. //0x04
   LcdCommand(0x15 );  // LCD bias mode 1:48. //0x13
   LcdCommand(0x0C );  // LCD in normal mode.
   LcdCommand(0x20 );
   LcdCommand(0x0C );
   LcdClear();
}
/*************************************************
* SET POSITION
* DESCRIPTION: Sets the X and Y cursor of the LCD
*************************************************/
void set_LCD_Cursor(char inputX, char inputY)
{
   CURSOR = 0x80;

   if (inputX > 83)
   {
      inputX = 83;
   }

   CURSOR = CURSOR | inputX;
   LcdCommand(CURSOR);

   CURSOR = 0x40;

   if (inputY > 5)
   {
      inputY = 5;
   }

   CURSOR = CURSOR | inputY;
   LcdCommand(CURSOR);
}
Exemple #8
0
void LcdClear(void) {
	LcdCommand(HD44780_CLEAR);
	_delay_ms(2);
}
Exemple #9
0
void LcdGoto(unsigned char x, unsigned char y) {
	LcdCommand(HD44780_DDRAM_SET | (x + (0x40 * y)));
}
	LcdCommand LcdApplication::construct_command(std::shared_ptr<DataProvider> provider, std::shared_ptr<DataVisualizer> visualizer,
			const std::chrono::milliseconds &interval) const
	{
		return LcdCommand(device_, provider, visualizer, interval);
	}
Exemple #11
0
/*
 * LcdClear
 * Description: This function clears the LCD and return the cursor to the 
 *              starting position
 *              This function doesnt return until the LCD's BF is cleared.
 *
 * Arguments:   None
 * Return:      None
 *
 * Input:       None
 * Output:      LCD
 *
 * Operation:   Write the clear command to the instruction register of the LCD.
 *
 * Revision History:
 *   Dec. 16, 2012      Nnoduka Eruchalu     Initial Revision
 */
void LcdClear(void)
{
  LcdCommand(0x01);
}