Ejemplo n.º 1
0
void keyPressed(char key)
{
	//the clear button
	if (key == 'C')
	{
		clear();
		_log("lcd cleared\r\0");
		return;
	}
	//
	switch (state)
	{
	case 0:

		if ((value=getDigit(key)) != -1) //digit
		{_log("number\r\0")
			//check stack, if full show errer
			if (! stack_isfull(sd1))
			{
				stack_push(sd1,value);
				LCD_SendData(key);
			}
			else
			{
				showError();
				_log(" stack full\r\0");
			}
		}
		else if(getOperator(key) != -1) //operator
Ejemplo n.º 2
0
//==========================================================================================
//   print a string on LCD.
//==========================================================================================
void LCD_SendText(char *text)
{
 while(*text)
 {
  LCD_SendData(*text);
  text++;
 }
}
Ejemplo n.º 3
0
/*
 * the string must be ended with a null char
 */
void LCD_SendStr(char * ptr)				       // send string function
{
	int i=0;
	while(ptr[i]!='\0')
	{
		LCD_SendData(ptr[i]);

		i++;
	}
}
Ejemplo n.º 4
0
//==========================================================================================
//   Initialize the LCD.
//==========================================================================================
void LCD_Initialization(void)
{
 uint8_t i;
 char const *p;

 GPIO_InitTypeDef GPIO_InitStructure;
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
 GPIO_InitStructure.GPIO_Pin = (LCD_D7 | LCD_D6 | LCD_D5 | LCD_D4 | LCD_EN | LCD_RS);
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_Init(LCD_PORT, &GPIO_InitStructure);

 delay_ms(15);
 GPIO_ResetBits(LCD_PORT, LCD_RS);
 GPIO_ResetBits(LCD_PORT, LCD_EN);

 for(i = 0; i<3; i++)
 {

  GPIO_SetBits(LCD_PORT, LCD_D4 | LCD_D5);
  GPIO_ResetBits(LCD_PORT, LCD_D6 | LCD_D7);
                GPIO_SetBits(LCD_PORT, LCD_EN);
                delay_us(50);
  GPIO_ResetBits(LCD_PORT, LCD_EN);
                delay_ms(10);
 }

 delay_ms(50);
 GPIO_SetBits(LCD_PORT, LCD_D5);
 GPIO_ResetBits(LCD_PORT,LCD_D4 | LCD_D6 | LCD_D7);
        GPIO_SetBits(LCD_PORT, LCD_EN);
 delay_ms(50);
 GPIO_ResetBits(LCD_PORT, LCD_EN);
 LCD_SendCmd(0x28);
 LCD_SendCmd(0x08);
 LCD_SendCmd(0x01);
 LCD_SendCmd(0x06);
 LCD_SendCmd(0x0C);
 delay_ms(5);

 /* Load user-specific characters into CGRAM                               */
 LCD_SendCmd(0x40);                  /* Set CGRAM address counter to 0     */
 p = &UserFont[0][0];
 for (i = 0; i < sizeof(UserFont); i++, p++)
  LCD_SendData (*p);
 LCD_SendCmd(0x80);                 /* Set DDRAM address counter to 0     */
}
Ejemplo n.º 5
0
/*********************************************************************
 * Function: void LCD_PutChar(char);
 *
 * Overview: Puts a character on the LCD screen.  Unsupported characters will be
 *           discarded.  May block or throw away characters is LCD is not ready
 *           or buffer space is not available.
 *
 * PreCondition: already initialized via LCD_Initialize()
 *
 * Input: char - character to print
 *
 * Output: None
 *
 ********************************************************************/
void LCD_PutChar ( char inputCharacter )
{
    switch (inputCharacter)
    {
    case '\r':
        LCD_CarriageReturn ( ) ;
        break ;

    case '\n':
        if (row == 0)
        {
            LCD_ShiftCursorDown ( ) ;
        }
        else
        {
            LCD_ShiftCursorUp ( ) ;
        }
        break ;

    case '\b':
        LCD_ShiftCursorLeft ( ) ;
        LCD_PutChar ( ' ' ) ;
        LCD_ShiftCursorLeft ( ) ;
        break ;

    default:
        LCD_SendData ( inputCharacter ) ;
        column++ ;

        if (column == LCD_MAX_COLUMN)
        {
            column = 0 ;
            if (row == 0)
            {
                LCD_SendCommand ( LCD_COMMAND_ROW_1_HOME , LCD_S_INSTR ) ;
                row = 1 ;
            }
            else
            {
                LCD_SendCommand ( LCD_COMMAND_ROW_0_HOME , LCD_S_INSTR ) ;
                row = 0 ;
            }
        }
        break ;
    }
}
Ejemplo n.º 6
0
/**
 * Print a character.
 */
void LCD_Putc(char c) {
	LCD_SendData(c);
}