예제 #1
0
파일: lcd.c 프로젝트: bremy11/adar_ece477
/*********************************************************************
 * Function: bool LCD_Initialize(void);
 *
 * Overview: Initializes the LCD screen.  Can take several hundred
 *           milliseconds.
 *
 * PreCondition: none
 *
 * Input: None
 *
 * Output: true if initialized, false otherwise
 *
 ********************************************************************/
bool LCD_Initialize ( void )
{
    LCD_DATA_LAT &= 0xFF00 ;
    LCD_DATA_TRIS &= 0xFF00 ;

    // Control signal data pins
    LCD_RWSignal_Clear ( ) ; // LCD R/W signal
    LCD_RSSignal_Clear ( ) ; // LCD RS signal
    LCD_EnableSignal_Clear ( ) ;     // LCD E signal

    // Control signal pin direction
    LCD_RSSignal_Output ( )  ;
    LCD_RWSignal_Output ( )  ;
    LCD_EnableSignal_Output ( ) ;

    LCD_EnableSignal_Set ( )  ;
    LCD_Wait ( LCD_STARTUP ) ;
    LCD_Wait ( LCD_STARTUP ) ;

    LCD_SendCommand ( LCD_COMMAND_SET_MODE_8_BIT ,     LCD_F_INSTR + LCD_STARTUP ) ;
    LCD_SendCommand ( LCD_COMMAND_CURSOR_OFF ,         LCD_F_INSTR ) ;
    LCD_SendCommand ( LCD_COMMAND_ENTER_DATA_MODE ,    LCD_S_INSTR ) ;

    LCD_ClearScreen ( ) ;

    return true ;
}
예제 #2
0
파일: lcd.c 프로젝트: bremy11/adar_ece477
/*********************************************************************
 * Function: static void LCD_ShiftCursorLeft(void)
 *
 * Overview: Shifts cursor left one spot (wrapping if required)
 *
 * PreCondition: already initialized via LCD_Initialize()
 *
 * Input: None
 *
 * Output: None
 *
 ********************************************************************/
static void LCD_ShiftCursorLeft ( void )
{
    uint8_t i ;

    if (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 ;
        }

        //Now shift to the end of the row
        for (i = 0 ; i < ( LCD_MAX_COLUMN - 1 ) ; i++)
        {
            LCD_ShiftCursorRight ( ) ;
        }
    }
    else
    {
        column-- ;
        LCD_SendCommand ( LCD_COMMAND_MOVE_CURSOR_LEFT , LCD_F_INSTR ) ;
    }
}
예제 #3
0
파일: lcd.c 프로젝트: bremy11/adar_ece477
/*********************************************************************
 * Function: void LCD_ClearScreen(void);
 *
 * Overview: Clears the screen, if possible.
 *
 * PreCondition: already initialized via LCD_Initialize()
 *
 * Input: None
 *
 * Output: None
 *
 ********************************************************************/
void LCD_ClearScreen ( void )
{
    LCD_SendCommand ( LCD_COMMAND_CLEAR_SCREEN , LCD_S_INSTR ) ;
    LCD_SendCommand ( LCD_COMMAND_RETURN_HOME ,  LCD_S_INSTR ) ;

    row = 0 ;
    column = 0 ;
}
예제 #4
0
파일: lcd.c 프로젝트: bremy11/adar_ece477
/*********************************************************************
 * Function: void LCD_CursorEnable(bool enable)
 *
 * Overview: Enables/disables the cursor
 *
 * PreCondition: None
 *
 * Input: bool - specifies if the cursor should be on or off
 *
 * Output: None
 *
 ********************************************************************/
void LCD_CursorEnable ( bool enable )
{
    if (enable == true)
    {
        LCD_SendCommand ( LCD_COMMAND_CURSOR_ON , LCD_S_INSTR ) ;
    }
    else
    {
        LCD_SendCommand ( LCD_COMMAND_CURSOR_OFF , LCD_S_INSTR ) ;
    }
}
예제 #5
0
파일: lcd.c 프로젝트: bremy11/adar_ece477
/*********************************************************************
 * Function: static void LCD_CarriageReturn(void)
 *
 * Overview: Handles a carriage return
 *
 * PreCondition: already initialized via LCD_Initialize()
 *
 * Input: None
 *
 * Output: None
 *
 ********************************************************************/
static void LCD_CarriageReturn ( void )
{
    if (row == 0)
    {
        LCD_SendCommand ( LCD_COMMAND_ROW_0_HOME , LCD_S_INSTR ) ;
    }
    else
    {
        LCD_SendCommand ( LCD_COMMAND_ROW_1_HOME , LCD_S_INSTR ) ;
    }
    column = 0 ;
}
예제 #6
0
//displays the results of the game on the screen
void Itog_Game(char all_nomber[100], char itog[13])
{
	uint8_t counter=0;

		delay(1000);
		LCD_SendCommand(0x01);
		delay(10);
		LCD_SendString(itog);
		delay(1000);
		LCD_SendCommand(0x01);
		while(all_nomber[counter]!=0)
		{
			all_nomber[counter]=0;
			counter++;
		}
}
예제 #7
0
파일: lcd.c 프로젝트: bremy11/adar_ece477
/*********************************************************************
 * 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 ;
    }
}
예제 #8
0
파일: lcd.c 프로젝트: bremy11/adar_ece477
/*********************************************************************
 * Function: static void LCD_ShiftCursorRight(void)
 *
 * Overview: Shifts cursor right one spot (wrapping if required)
 *
 * PreCondition: already initialized via LCD_Initialize()
 *
 * Input: None
 *
 * Output: None
 *
 ********************************************************************/
static void LCD_ShiftCursorRight ( void )
{
    LCD_SendCommand ( LCD_COMMAND_MOVE_CURSOR_RIGHT , LCD_F_INSTR ) ;
    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 ;
        }
    }
}
예제 #9
0
/**
 * Initialize the display.
 */
void LCD_Init() {
	// Initialize SysTick
	SysTickInit(1000);

	// Wait 50 ms for voltage to settle.
	_delay_ms(50);
	LCD_DataOut();
	RCC_AHBPeriphClockCmd(CLK(LCD_DATA_PORT),ENABLE);
	RCC_AHBPeriphClockCmd(CLK(LCD_CTRL_PORT),ENABLE);

	GPIO_InitTypeDef GPIO_InitStructure;
	GPIO_InitStructure.GPIO_Pin=(LCD_RS|LCD_RW|LCD_E);
	GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;
	GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;
	GPIO_Init(PORT(LCD_CTRL_PORT),&GPIO_InitStructure);

	//clear all control signals initially
	GPIO_ResetBits(PORT(LCD_CTRL_PORT),LCD_RW|LCD_RS|LCD_E);

	//initialization in 4-bit interface
	LCD_Write(0b0011);
	_delay_ms(5);

	LCD_Write(0b0011);
	_delay_ms(1);

	LCD_Write(0b0011);
	_delay_ms(1);

	LCD_Write(0b0010);
	_delay_ms(1);

	// 2 row display
	LCD_SendCommand(LCD_CMD_FUNCTION|LCD_2_ROWS_BIT);
	LCD_SendCommand(LCD_CMD_DISPLAY_ON_OFF|LCD_DISPLAY_ON_BIT|LCD_CURSOR_ON_BIT|LCD_BLINK_ON_BIT);
	LCD_Clear();

}
예제 #10
0
/*********************************************************************
* Function: bool LCD_Initialize(void);
*
* Overview: Initializes the LCD screen.  Can take several hundred
*           milliseconds.
*
* PreCondition: none
*
* Input: None
*
* Output: true if initialized, false otherwise
*
********************************************************************/
bool LCD_Initialize(void)
{
    LATC |= 0x00FF;
    TRISC &= 0x0F00;
    TRISB &= 0xFC7F;

    // Control signal data pins
    LATBbits.LATB8 = 0; // LCD R/W signal
    LATBbits.LATB9 = 0; // LCD RS signal
    LATBbits.LATB7  = 0;     // LCD E signal

    // Control signal pin direction
      TRISBbits.TRISB8 = 0;
    TRISBbits.TRISB9 = 0;
    TRISBbits.TRISB7 = 0;



    LATC |= 0x0038;

    LATBbits.LATB7  = 1;
    Nop();
    Nop();
    Nop();
    LATBbits.LATB7  = 0;

    LCD_Wait(LCD_STARTUP);
    LCD_Wait(LCD_STARTUP);

    LCD_SendCommand(LCD_COMMAND_SET_MODE_8_BIT,     LCD_F_INSTR + LCD_STARTUP);
    LCD_SendCommand(LCD_COMMAND_CURSOR_ON,         LCD_F_INSTR);
    LCD_SendCommand(LCD_COMMAND_ENTER_DATA_MODE,    LCD_S_INSTR);

    LCD_ClearScreen();

	return true;
}
예제 #11
0
/**
 * Clear the display.
 */
void LCD_Clear() {
	LCD_SendCommand(LCD_CMD_CLEAR_DISPLAY);
}
예제 #12
0
/**
 * Shifts the LCD display one position to the left
 */
void LCD_Shift() {
	LCD_SendCommand(LCD_CMD_CUR_DISP_SHIFT|LCD_SHIFT_DISPLAY_BIT);
}
예제 #13
0
/**
 * Position the LCD at a given memory location.
 */
void LCD_Position(uint8_t position) {
	LCD_SendCommand(LCD_CMD_SET_DDRAM | (position & 0x7f));
}
예제 #14
0
/**
 * Go to the beginning of the display.
 *
 */
void LCD_Home() {
	LCD_SendCommand(LCD_CMD_HOME);
}