Ejemplo n.º 1
0
/* -----------------------------------------------------------------------------------------------------------*/ 
void HD44780_TWI_enable( void )
{
	if ( TWI_SendAddress( HD44780_TWI_ADDR , TWI_WRITE ) == TRUE )
	{
		HD44780_TWI_Byte &= ~( 1 << HD44780_TWI_E_PIN );
		TWI_Write( HD44780_TWI_Byte );
		_delay_us( 100 );
		HD44780_TWI_Byte |= ( 1 << HD44780_TWI_E_PIN );
		TWI_Write( HD44780_TWI_Byte );
		_delay_us( 90 );
		HD44780_TWI_Byte &= ~( 1 << HD44780_TWI_E_PIN );
		TWI_Write( HD44780_TWI_Byte );
		TWI_SendStop();
		_delay_us( 90 );
	}
}
Ejemplo n.º 2
0
int TWI_Scan( void )
{
	unsigned char i;
	int Devices=0;

	for ( i = 0; i < 128 ; i++ )
	{
		if ( TWI_SendAddress( i , TWI_WRITE ) == TRUE )
		{
			TWI_SendStop();
			Devices++;
		}			
	}

	return( Devices );
}
Ejemplo n.º 3
0
/* -----------------------------------------------------------------------------------------------------------*/ 
void HD44780_TWI_Backlight( unsigned char value )
{
	if ( TWI_SendAddress( HD44780_TWI_ADDR , TWI_WRITE ) == TRUE )
	{
		if ( value != 0 )
		{
			HD44780_TWI_Byte |= ( 1 << HD44780_TWI_BL_PIN );        //  Backlight off
		}
		else
		{
			HD44780_TWI_Byte &= ~( 1 << HD44780_TWI_BL_PIN );        //  Backlight off
		}
		TWI_Write( HD44780_TWI_Byte );
		TWI_SendStop();        
	}
}
Ejemplo n.º 4
0
/* -----------------------------------------------------------------------------------------------------------*/ 
void KS0073_TWI_enable( void )
{
	if ( TWI_SendAddress( KS0073_TWI_ADDR , TWI_WRITE ) == TRUE )
	{
		KS0073_TWI_Byte &= ~( 1 << KS0073_TWI_E_PIN );
		TWI_Write( KS0073_TWI_Byte );
		_delay_us( 100 );
		KS0073_TWI_Byte |= ( 1 << KS0073_TWI_E_PIN );
		TWI_Write( KS0073_TWI_Byte );
		_delay_us( 90 );
		KS0073_TWI_Byte &= ~( 1 << KS0073_TWI_E_PIN );
		TWI_Write( KS0073_TWI_Byte );
		TWI_SendStop();
		_delay_us( 90 );
	}
}
Ejemplo n.º 5
0
/* -----------------------------------------------------------------------------------------------------------*/ 
void KS0073_TWI_Backlight( unsigned char value )
{
	if ( TWI_SendAddress( KS0073_TWI_ADDR , TWI_WRITE ) == TRUE )
	{
		if ( LCD_CMD != LCD_BL_OFF )
		{
			KS0073_TWI_Byte |= ( 1 << KS0073_TWI_BL_PIN );        //  Backlight off
		}
		else
		{
			KS0073_TWI_Byte &= ~( 1 << KS0073_TWI_BL_PIN );        //  Backlight off
		}
		TWI_Write( KS0073_TWI_Byte );
		TWI_SendStop();        
	}
}
Ejemplo n.º 6
0
/* -----------------------------------------------------------------------------------------------------------*/ 
void HD44780_TWI_init( void )
{
	unsigned char i;
	int y;
	
	HD44780_TWI_Byte = 0;
	// erster Reset in den 8-Bit Modus
	HD44780_TWI_out(HD44780_CMD_SOFT_RESET);
	CLOCK_delay( HD44780_DELAY_SOFT_RESET1 );

	// zweiter Reset in den 8-Bit Modus
	HD44780_TWI_enable();
	CLOCK_delay( HD44780_DELAY_SOFT_RESET2 );

	// dritter Reset in den 8-Bit Modus
	HD44780_TWI_enable();
	CLOCK_delay( HD44780_DELAY_SOFT_RESET3 );

	// und jetzt endlich in den 4-Bit Modus
	HD44780_TWI_out(	HD44780_CMD_SET_FUNCTION |
	            	HD44780_SF_4BIT );
	
	CLOCK_delay( HD44780_DELAY_SET_4BITMODE );
	
	// Display einstellen, 4Bit, 2 Lines und Zeichensatz 5x8 Pixel
	HD44780_TWI_sendCMD( 	HD44780_CMD_SET_FUNCTION |
			 	 		HD44780_SF_4BIT | 			// 4 Bit mode
				 		HD44780_SF_2LINES | 		// 2 lines
				 		HD44780_SF_5x10 ); 		// 5x10

	// clear screen
	HD44780_TWI_sendCMD( HD44780_CMD_CLEAR );
	// Cursor auf Homeposition setzen
	HD44780_TWI_sendCMD( HD44780_CMD_CURSOR_HOME );
	// Display einschalten
	HD44780_TWI_sendCMD( HD44780_CMD_SET_DISPLAY |    
	             HD44780_SD_DISPLAY_ON /* |		// display on
				 HD44780_SD_CURSOR_ON |			// show cursor
				 HD44780_SD_BLINKING_ON */ );	// cursor blinking

	HD44780_TWI_row = 0;
	HD44780_TWI_column = 0;

	// fade in LCD-Backlight
	if ( TWI_SendAddress( HD44780_TWI_ADDR , TWI_WRITE ) == TRUE )
	{
		for( y = 0 ; y < 128 ; y++ )// Backlight auf 100% dimmen
		{
			for ( i = 0 ; i < 128 ; i++ )
			{
				if( i <= y)
					HD44780_TWI_Byte &= ~( 1 << HD44780_TWI_BL_PIN );
				else
					HD44780_TWI_Byte |= ( 1 << HD44780_TWI_BL_PIN );

				TWI_Write( HD44780_TWI_Byte );
			}
		}
		TWI_SendStop();
	}
	HD44780_TWI_Byte &= ~( 1 << HD44780_TWI_BL_PIN );
}
Ejemplo n.º 7
0
/* -----------------------------------------------------------------------------------------------------------*/ 
void KS0073_TWI_init( void )
{
	unsigned char i;
	int y;
	
	KS0073_TWI_Byte = 0;
	// erster Reset in den 8-Bit Modus
	KS0073_TWI_out(HD44780_CMD_SOFT_RESET);
	CLOCK_delay( HD44780_DELAY_SOFT_RESET1 );

	// zweiter Reset in den 8-Bit Modus
	KS0073_TWI_enable();
	CLOCK_delay( HD44780_DELAY_SOFT_RESET2 );

	// dritter Reset in den 8-Bit Modus
	KS0073_TWI_enable();
	CLOCK_delay( HD44780_DELAY_SOFT_RESET3 );

	// und jetzt endlich in den 4-Bit Modus und 'RE-Bit ein b00101100  
	KS0073_TWI_out(HD44780_CMD_SET_FUNCTION |
	            	HD44780_SF_4BIT);							// RE:1
	CLOCK_delay( HD44780_DELAY_SET_4BITMODE );
	KS0073_TWI_sendCMD(HD44780_CMD_SET_FUNCTION |
						HD44780_SF_4BIT |
						HD44780_SF_2LINES |
						KS0073_RE_ON);
						
	// Display für KS0073 einstellen b00001001
	KS0073_TWI_sendCMD(KS0073_CMD_EXT_FUNCTION |
						HD44780_SF_5x7 |					// 5-dot-Font
						KS0073_4LINES);						// 4-line display

	// RE:Bit wieder auf 0 setzen b00101000
	KS0073_TWI_sendCMD(HD44780_CMD_SET_FUNCTION |
						HD44780_SF_4BIT |
						HD44780_SF_2LINES|
						KS0073_RE_OFF);

	// clear screen
	KS0073_TWI_sendCMD( HD44780_CMD_CLEAR );
	
	//Display ausschalten
	KS0073_TWI_sendCMD(HD44780_CMD_SET_DISPLAY |
						HD44780_SD_DISPLAY_OFF);
						
	// Entry Mode
	KS0073_TWI_sendCMD(HD44780_CMD_SET_ENTRY |
						HD44780_SE_INCREASE);
						
	// Display clear cursor home
	KS0073_TWI_sendCMD( HD44780_CMD_CLEAR );
	
	// Cursor auf Homeposition setzen
	KS0073_TWI_sendCMD( HD44780_CMD_CURSOR_HOME );
	
	
	// Display einschalten
	KS0073_TWI_sendCMD( HD44780_CMD_SET_DISPLAY |    
			 	             HD44780_SD_DISPLAY_ON /* |		// display on
							 HD44780_SD_CURSOR_ON |			// show cursor
							 HD44780_SD_BLINKING_ON */ );	// cursor blinking

	KS0073_TWI_row = 0;
	KS0073_TWI_column = 0;

	// fade in LCD-Backlight
	if ( TWI_SendAddress( KS0073_TWI_ADDR , TWI_WRITE ) == TRUE )
	{
		for( y = 0 ; y < 128 ; y++ )// Backlight auf 100% dimmen
		{
			for ( i = 0 ; i < 128 ; i++ )
			{
				if( i <= y)
					KS0073_TWI_Byte &= ~( 1 << KS0073_TWI_BL_PIN );
				else
					KS0073_TWI_Byte |= ( 1 << KS0073_TWI_BL_PIN );

				TWI_Write( KS0073_TWI_Byte );
			}
		}
		TWI_SendStop();
	}
	KS0073_TWI_Byte &= ~( 1 << KS0073_TWI_BL_PIN );
}