Exemplo n.º 1
0
/***************************************************
 * Print String to LCD at current Cursor position 
*************************************************** */
void LCD_print( const unsigned char *string ) {
	char pi = 0, c;
	c = string[pi++]; 
    while( c )  {
        LCD_sendByte( c );  // Display on LCD
        c = string[pi++]; 
	}
}
Exemplo n.º 2
0
/**********************************
 * Clear Display                  *
 *   Clear Display   >=  1.64mS   *
 *   Cursor at home  >=  1.64mS   *
 *   Other commands  >=  40uS     *
 **********************************/
void LCD_Clear(void) {
	
    LCD_MODE = Mode_CMD;                    // Set LCD Command MODE
    LCD_sendByte(LCDClearDisplay);          // DD RAM address set 1st digit
    LCD_MODE = Mode_DATA;                   // ReSet LCD to Data MODE
    
    delay_ms(3); 
    
}
Exemplo n.º 3
0
/***************************************************
 * Print String to LCD at current Cursor position 
*************************************************** */
void LCD_print( const unsigned char *string ) {
	char pi = 0, c;
	LCD_MODE = Mode_DATA;          // Set LCD Data MODE
    while( 1 )  {
		c = string[pi++]; 
        if ( !c ) return;
        LCD_sendByte( c );  // Display on LCD
	}
}
Exemplo n.º 4
0
/**********************************
 * SET LCD Cursor Position        *
 *   Clear Display   >=  1.64mS   *
 *   Cursor at home  >=  1.64mS   *
 *   Other commands  >=  40uS     *
 **********************************/
void LCD_gotoRC( unsigned char LcdRow, unsigned char LcdColumn) {
	
    // LCD_sendByte(0x80 + LcdRow*0x40 + LcdColumn);     // TROPPI Bytes      
 
    LCD_MODE = Mode_CMD;           // Set LCD Command MODE
    if (LcdRow == 0)
        if (LcdColumn == 0)
            LCD_sendByte(0x02);             // goto Home
        else
            LCD_sendByte(0x80 + LcdColumn);
    else
        LCD_sendByte(0xC0 + LcdColumn);
    
    LCD_MODE = Mode_DATA;           // ReSet LCD to Data MODE
    
    delay_ms(3); 
    
}
Exemplo n.º 5
0
/***************************************************
 * Print ROM String[offset] to LCD at current Cursor position 
*************************************************** */
void LCD_printRom( rom unsigned char *string, unsigned int offset ) {
    unsigned int pi = offset;
    unsigned char c;
    c = string[pi++]; 
    while( c )  {
        LCD_sendByte( c );  // Display on LCD
        c = string[pi++]; 
	}
}
Exemplo n.º 6
0
/**********************************
 * Set Position on Display and... *
 * clean nBytes                   *
 **********************************/
void LCD_clean(unsigned char LcdRow, unsigned char LcdColumn, unsigned char nBytes) {
    
    LCD_gotoRC(LcdRow, LcdColumn);
    while (nBytes-- != 0) {
        LCD_sendByte(' ');
    }
      // Riposiziona cursore
    LCD_gotoRC(LcdRow, LcdColumn);
	
}
Exemplo n.º 7
0
/***************************************************
 * Print ROM String[x] to LCD at current Cursor position 
*************************************************** */
void LCD_printRom( rom unsigned char *string, unsigned int offset ) {
	unsigned int pi = offset;
	unsigned char c;
	LCD_MODE = Mode_DATA;          // Set LCD Data MODE
    while( 1 )  {
		c = string[pi++]; 
        if ( !c ) return;
        LCD_sendByte( c );  // Display on LCD
	}
}
Exemplo n.º 8
0
/*-------------------------------------------------------------------------*\
|* PUBLIC FUNCTION :: LCD_printStr
|*
|*    Print a string of characters to the screen.
|*
|* PARAMETERS
|*
|*    text - NULL terminated string of chars
|*
|* RETURN
|*
|*    void
|*
\*-------------------------------------------------------------------------*/
void LCD_printStr(char *text)
{
   char *c;
   c = text;

   while ((c != 0) && (*c != 0))
   {
      LCD_sendByte(*c, DATA);
      c++;
   }
}
Exemplo n.º 9
0
/***************************************************
 * Print ROM String[x] to LCD at RC position
*************************************************** */
void LCD_printRom(unsigned char LcdLine, unsigned char LcdColumn,  rom unsigned char *string, unsigned int offset ) {
    LCD_gotoRC( LcdLine, LcdColumn);
    // LCD_print(string, offset);
	unsigned int pi = offset;
	unsigned char c;
	LCD_MODE = Mode_DATA;          // Set LCD Data MODE
    while( 1 )  {
		c = string[pi++]; 
        if ( !c ) return;
        LCD_sendByte( c );  // Display on LCD
	}
}
Exemplo n.º 10
0
/**********************************
 * Initialisation by instructions *
 **********************************/
void LCD_initialize(void) {
    
    
    
    #ifdef LCD_2W_MODE
        clear_HC164();
    #endif
    
    #ifdef LCD_3W_MODE
        LCD_ENA_LATCH_BIT = 0;                          // Prepariamo il bit per il pulse di LATCH (tranne per il LCD_2W
        clear_HC164();
    #endif
            
    #ifdef LCD_6W_MODE
        LCD_ENA_LATCH_BIT = 0;                          // Prepariamo il bit per il pulse di LATCH (tranne per il LCD_2W
    #endif
    
    LCD_MODE = Mode_CMD;                    // Set LCD Command MODE
    
    delay_ms(250);                          // WAIT for power-UP
    
    Initializing = true;
    LCD_sendByte(0x33);			            // esegue il comando 
    LCD_sendByte(0x32);			            // esegue il comando 
   
    LCD_sendByte(LCDInitFunc );             // Function Set: x-bits, n-line, 5X7 
    LCD_sendByte(LCDInitDCB );              // Display , cursor, blink 
    LCD_sendByte(LCDInitEntryMode );        // Entry mode: INC addr, NO SHIFT display 
    LCD_sendByte(LCDClearDisplay );         // Clear Display 
    
	Initializing = false;
    
    delay_ms(4);
    LCD_MODE = Mode_DATA;                   // ReSet LCD to Data MODE
}
Exemplo n.º 11
0
/**********************************
 * Set Position on Display and... *
 * clean nBytes                   *
 **********************************/
void LCD_gotoRC(unsigned char LcdLine, unsigned char LcdColumn, unsigned char nBytes) {
    LCD_gotoRC(LcdLine, LcdColumn);
			
    LCD_MODE = Mode_DATA;           // Set LCD Data MODE
    while (nBytes != 0) {
        LCD_sendByte(' ');
            // Riposiziona cursore
        LCD_gotoRC(LcdLine, LcdColumn);
    }
    
    
    
    if (nBytes != 0) {
        LCD_MODE = Mode_DATA;           // Set LCD Data MODE
        for (; nBytes != 0; nBytes--)
            LCD_sendByte(' ');
    
        // Riposiziona cursore
        LCD_MODE = Mode_CMD;           // Set LCD Command MODE
        LCD_sendByte(0x80 + LcdLine*0x40 + LcdColumn);           
    }
	
}
Exemplo n.º 12
0
void LCD_printMio(const unsigned char *text ) {
    LCD_MODE = Mode_DATA;          // Set LCD Data MODE
    // char i;
    char *ptr = text;
    for (; *ptr != '\0'; ptr++) {
                // move to start second line
        if ( *ptr == '\n' ) {
			LCD_gotoRC(1,0);
			LCD_MODE = Mode_DATA;          // Set LCD Data MODE
		}
        else
            LCD_sendByte( *ptr );
    }
}
Exemplo n.º 13
0
void LCD_printMio( rom unsigned char *string ) {
	char pi = 0, c;
	LCD_MODE = Mode_DATA;          // Set LCD Data MODE
    while( 1 ) {
		c = string[pi++]; if ( !c ) return;
            // move to start second line
		if ( c == '\n' ) {
			LCD_gotoRC( 1, 0); 
			LCD_MODE = Mode_DATA;          // Set LCD Data MODE
		}
		else
            LCD_sendByte( c );  // Display on LCD
	}
}
Exemplo n.º 14
0
/**********************************
 * Initialisation by instructions *
 **********************************/
void LCD_initialize(void) {
    
    #ifdef LCD_2W_MODE
        clear_HC164();
    #endif
    
    LCD_MODE = Mode_CMD;           // Set LCD Command MODE
    
    delay_ms(30);
    InitFlag = true;
    LCD_sendByte(0x33);			// esegue il comando 
    LCD_sendByte(0x32);			// esegue il comando 
   
    LCD_sendByte(LCDInitFunc );            //  Function Set: x-bits, n-line, 5X7 
    LCD_sendByte(LCDInitDCB );            // Display , cursor, blink 
    LCD_sendByte(LCDInitEM );            // Entry mode: INC addr, NO SHIFT display 
    LCD_sendByte(LCDClearDisplay );            // Clear Display 
    
	InitFlag = false;
    delay_ms(4); 
}
Exemplo n.º 15
0
/**********************************
 * Initialisation by instructions *
 **********************************/
void LCD_initialize(void) {

    #if LCD_NUM_WIRES == LCD_3_WIRES
		#warning "LCD_3_WIRES"
        LCD_TRIS.LCD_ENA_LATCH_PIN_NUM = 0;         // Set port BIT as OUTPUT 
        HC164_TRIS.HC164_DATA_PIN_NUM  = 0;          // Set port BIT as OUTPUT 
        HC164_TRIS.HC164_CLOCK_PIN_NUM = 0;         // Set port BIT as OUTPUT 
        clear_HC164();
    #endif
    
    #if LCD_NUM_WIRES == LCD_2_WIRES
		#warning "LCD_2_WIRES"
        HC164_TRIS.HC164_DATA_PIN_NUM  = 0;          // Set port BIT as OUTPUT 
        HC164_TRIS.HC164_CLOCK_PIN_NUM = 0;         // Set port BIT as OUTPUT 
        clear_HC164();
    #endif
    
    #ifndef  LCD_NUM_WIRES
        #error "Display non definito"
    #endif    
    
            
    LCD_MODE = Mode_CMD;                    // Set LCD Command MODE
    
    LnDelayMS(250);                          // WAIT for a while... power-UP
    
    Initializing = true;
    LCD_sendByte(0x33);                                    // esegue il comando 
    LCD_sendByte(0x32);                                    // esegue il comando 
   
    LCD_sendByte(LCDInitFunc );             // Function Set: x-bits, n-line, 5X7 
    LCD_sendByte(LCDInitDCB );              // Display , cursor, blink 
    LCD_sendByte(LCDInitEntryMode );        // Entry mode: INC addr, NO SHIFT display 
    LCD_sendByte(LCDClearDisplay );         // Clear Display 
    
    Initializing = false;
    
    LnDelayMS(4);
    LCD_MODE = Mode_DATA;                   // ReSet LCD to Data MODE
}                                
Exemplo n.º 16
0
void My_LCD_printf( const unsigned char *lcdString, unsigned int val ) {
	unsigned char pi = 0, buffLen, c, fill, baseOrBits, sign, mask;
	unsigned char buff[ 10 ]; // max length allow is 9
	bit pad;
	
	LCD_MODE = Mode_DATA;          // Set LCD Data MODE come default
    while( 1 ) {
    
		c = lcdString[pi++]; if ( !c ) return;
		
		switch( c ) {
    		
            case '\n':
    			LCD_MODE = Mode_CMD;           // Set LCD Command MODE
    			// move to start second line
    			LCD_gotoRC(1, 0);
    			LCD_MODE = Mode_DATA;          // Set LCD Data MODE
    			break;
                
    		case '%':
					// get next char
				c = lcdString[pi++]; if ( !c ) return;
				
				
                    //Handle escape sequence that prints '%'
    			if ( c == '%' ) {	// è un % allora scivilo 
    				LCD_sendByte( c );// Display on LCD
    				break;
    			}
    			
					// Next character if zero indicates that we should zero fill output
    			if ( c == '0' ) {
    				fill = '0';
    				c = lcdString[pi++]; if ( !c ) return;
    			}
    			else
    				fill = ' ';

                    // Next character if valid digit indicates field width
    			if( c > '0' && c <= '9' ) {
    				pad = 1;
    				buffLen = c - 48;;				
    				c = lcdString[pi++]; if ( !c ) return;
    			}
    			else {
    				pad = 0;
    				buffLen = sizeof( buff ) - 1;
    			}
    				
    			
    			// Next character indicates the radix (number base)
    			sign = 0;
    			switch( c ) {
        			
					case 'd':
        				if( val & 0x8000 )	{ // Negative values must be adjusted to be positive // JS
        					sign = '-';
        					val ^= 0xFFFF; // 2s complement negate	// JS
        					val++;
        				}
						
        			case 'u':
        				baseOrBits = 10; // base ten, divide by ten per digit
        				break;			
        			
					case 'X':
        				baseOrBits = 4; // base 16, requires a 4 bit shift per digit
        				mask = 0x0F;
        				break;
        			
					case 'b':
        				baseOrBits = 1; // base 16, requires a 1 bit shift per digit
        				mask = 0x01;
        				break;
        			
					default:
        				return; // no radix
    			}
    				
    			// null terminate, then reverse fill string
    			buff[ buffLen ] = '\0';
    			
    			bit first = true;				
    			while( buffLen ) {
    				buffLen--;
    				
					if( val || first ) {
    					first = false;

    					if( baseOrBits == 10 ) {
    						c = (unsigned char)(val % 10);	// JS - Optimization, use absolute of 10
    						val /= 10;	// JS - Optimization, use absolute of 10
    					}
    					else {
    						c = val & mask;
    						val = ((unsigned int)val) >> baseOrBits;						
    					}
    					
    					if( c > 9 )
    						c += 55; // convert to hex digits character A-F
    					else
    						c += 48; // convert to digit character 0-9

    				}
    				else {
    					if( sign && (buffLen == 0 || fill != '0') ) {
    						c = sign;
    						sign = 0;
    					}
    					else
    						c = fill;
    				}
    				
    				buff[ buffLen ] = c;
    				
    				if( pad == 0 && val == 0 && sign == 0 )
    					break;
    			}
    			
				// output string to display
    			while( 1 ) {
    				c = buff[ buffLen ];
    				if( !c ) break;
    				LCD_sendByte( c );      // Display on LCD
    				buffLen++;
    			}
    			break;
                
    		default:	// char al di fuori di %xxx
    			LCD_sendByte( c );// Display on LCD
    			break;
		}
Exemplo n.º 17
0
/*-------------------------------------------------------------------------*\
|* PUBLIC FUNCTION :: LCD_sendCommand
|*
|*    Send a command to the LCD on the data bus in 4 bit mode.
|*
|* PARAMETERS
|*
|*    command - command to send
|*
|* RETURN
|*
|*    void
|*
\*-------------------------------------------------------------------------*/
void LCD_sendCommand(char command) {
   LCD_sendByte(command, COMMAND);
}
Exemplo n.º 18
0
/*-------------------------------------------------------------------------*\
|* PUBLIC FUNCTION :: LCD_printChar
|*
|*    Print a character to the screen.
|*
|* PARAMETERS
|*
|*    character - character to be printed
|*
|* RETURN
|*
|*    void
|*
\*-------------------------------------------------------------------------*/
void LCD_printChar(char character)
{
   LCD_sendByte(character, DATA);
}
Exemplo n.º 19
0
/***************************************************
 * Print char to LCD at current Cursor position 
*************************************************** */
void LCD_print(unsigned char chr ) {
    LCD_sendByte( chr );
}
Exemplo n.º 20
0
/***************************************************
 * Print char to LCD at current Cursor position 
*************************************************** */
void LCD_print(unsigned char chr ) {
    LCD_MODE = Mode_DATA;          // Set LCD Data MODE
    LCD_sendByte( chr );
}
Exemplo n.º 21
0
/***************************************************
 * Print String to LCD at current Cursor position 
*************************************************** */
void LCD_printStr( unsigned char *string ) {
    while( *string ) 
        LCD_sendByte( *string++ );  // Display on LCD
}
Exemplo n.º 22
0
/**********************************
 * Clear Display                  *
 **********************************/
void LCD_Clear() {
	LCD_MODE = Mode_CMD;                               // Set LCD Command MODE
    LCD_sendByte(LCDClearDisplay);                         // DD RAM address set 1st digit
    delay_ms(4); 
}
Exemplo n.º 23
0
/**********************************
 * SET LCD Cursor Position        *
 **********************************/
void LCD_gotoRC( unsigned char LcdLine, unsigned char LcdColumn) {
	LCD_MODE = Mode_CMD;           // Set LCD Command MODE
	LCD_sendByte(0x80 + LcdLine*0x40 + LcdColumn);

}