예제 #1
0
파일: lcd.c 프로젝트: h0nzZik/school
/*!
 * \brief Rewrite all LCD content
 *
 * \param *dta  Pointer to the memory
 *
 */
void LCD_write_all(uint8_t *dta)
{
	uint8_t i,j;
	for (i = 0; i < 4; i++) {
		/* Set line */
		switch (i) {
			case 0:	LCD_sendcmd(LCD_EN1 | 0x80); break;
			case 1: LCD_sendcmd(LCD_EN1 | 0xc0); break;
			case 2: LCD_sendcmd(LCD_EN2 | 0x80); break;
			case 3: LCD_sendcmd(LCD_EN2 | 0xc0); break;
				
		}
		for (j = 0; j < 40; j++) {
			/* ** Do you have some other data ? */
			if (!*dta) {
				j = 40;
				i = 5;
			}
			else {
				/* <N> ** Is it <ENTER> ? */
				if (*dta == '\n') {
					j = 40;
				}
				else {
					/* ** Is it first or second line ? */
					if (i <3)
						LCD_senddata(LCD_EN1 | *dta);           /* Send data to first or second line */
					else
						LCD_senddata(LCD_EN2 | *dta);           /* Send data to fird or fourht line */
				}
			}
			dta++;			
		}
	}
}		
예제 #2
0
파일: lcd.c 프로젝트: h0nzZik/school
/*!
 * \brief Initializing LCD by Instruction - 4-bit initialization
 */
void LCD_init(void)
{
	_delay_ms(30);        	                /* power on delay - wait more than 30 ms */
	LCD_write(0);      		        /* set RS, RW and EN low */

	LCD_write( P_LCD_EN1 | P_LCD_EN2 | 0x30 );  /* lcd enable high */
	LCD_write( 0x30 );                      /* lcd enable low */
	_delay_ms(5);			        /* wait 5 ms */

	LCD_write( P_LCD_EN1 | P_LCD_EN2 | 0x30 );  /* lcd enable high */
	LCD_write( 0x30 );                      /* lcd enable low */	
	_delay_us(100);                         /* wait more than 100us */

	LCD_write( P_LCD_EN1 | P_LCD_EN2 | 0x30 );  /* lcd enable high */
	LCD_write( 0x30 );                      /* lcd enable low */
	_delay_us(100);                         /* wait more than 100us */

	LCD_write( P_LCD_EN1 | P_LCD_EN2 | 0x20 );  /* lcd enable high */
	LCD_write( 0x20 );                      /* lcd enable low */
	_delay_us(100);                         /* wait more than 100us */

	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x28);                     /* 4 bit mode, 1/16 duty, 5x8 font */
	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x08);                     /* display off */
	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x01);                     /* display clear */
	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x06);                     /* entry mode */
	LCD_sendcmd(LCD_EN1| LCD_EN2 | 0x0f);                     /* display on, cursor off, blinking cursor off */

}
예제 #3
0
파일: lcd.c 프로젝트: h0nzZik/school
/*!
 * \brief Pre-set one CGRAM character
 *
 * \param char_val      Number of char. Only 0 - 7 are permitted.
 * \param *char_buf     Pointer to the memory on the first microline
 *
 */
void LCD_wr_cgram(uint8_t char_val, const uint8_t *char_buf )
{ uint8_t i = 8;

  char_val <<= 3;
  LCD_sendcmd(LCD_EN1 | LCD_EN2 | cmd_set_cgram_addr | char_val );

  while(i--) LCD_senddata( LCD_EN1 | LCD_EN2 | *char_buf++ );

  LCD_sendcmd(LCD_EN1 | LCD_EN2 | cmd_set_ddram_addr);
}
예제 #4
0
파일: czech.c 프로젝트: h0nzZik/school
/**
 * @brief Loads czech character into LCD slot.
 * @param czech_char_id - identification of czech character
 * @param lcd_slot_id - identification of lcd slot
 */
static void lcd_load_cz_char(uint8_t cz_char_id, uint8_t lcd_slot_id)
{

	LCD_sendcmd(LCD_EN1| cmd_set_cgram_addr | (lcd_slot_id << 3) );

	uint8_t i = 0;
	for (i=0; i < 8; i++)
	{
		LCD_senddata(LCD_EN1 | cz_char_cgrom[cz_char_id][i]);
	}
	LCD_sendcmd(LCD_EN1 | cmd_set_ddram_addr);
	LCD_cursor_yx(coord.y+1,coord.x);

}
예제 #5
0
파일: main.c 프로젝트: h0nzZik/school
/*!
 * \brief Putchar for fprintf
 * Send character c to the LCD display.  After a '\1' set cursor to first line, '\2' set cursor to secound line,
 * '\3' set cursor to third line, '\4' set cursor to fourth line, '\5' clear display.
 * the next character will first clear the display.
 * 
 * \param c input char
 * \param FILE * output FILE
 *
 * \return status output status
 *
 */
uint16_t lcd_putchar(uint8_t c, FILE *unused)
{
        static uint8_t line = 1;
        if (c == 1) {
                LCD_cursor_yx(1,1);                             /* Set cursor to first line */
                line = 1;
        }
        else if (c == 2) {
                LCD_cursor_yx(2,1);                             /* Set cursor to second line */
                line = 2;
        }
        else if (c == 3) {                                      
                LCD_cursor_yx(3,1);                             /* Set cursor to third line */
                line = 3;
        }
        else if (c == 4) {
                LCD_cursor_yx(4,1);                             /* Set cursor to fourth line */
                line = 4;
        }
        else if (c == 5) {
                LCD_sendcmd(LCD_EN1 | LCD_EN2 | 0x1);           /* Clear both displays */
                line = 1;
        }
        else if (c == '\n') {                                   /* Set cursor to next line */ 
                LCD_cursor_yx(((++line < 5) ? line : (line = 1)),1);   
        }
        else    LCD_senddata(((line <3) ? LCD_EN1 : LCD_EN2) | c); /* Send data to LCD */
        return 0;
}
예제 #6
0
파일: main.c 프로젝트: h0nzZik/school
/*!
 *      M       A       I       N
 *
 */
int main(void) {
    uint16_t poc = 0;
    uint8_t i,j;
    uint8_t dir;
    uint8_t tmp;

        LCD_init();                                     /* Initialize display */

        LCD_wr_cgram(0,&cgrom_p[0]);                    /* Program first char in CG-RAM */
        LCD_sendcmd(LCD_EN1 | LCD_EN2 | 0xc);           /* Disable cursors */

        for (i = 1; i < 5; i++)                         /* Fill display with pattern */
                for (j = 1; j < 41; j++) {
                        LCD_cursor_yx(i,j);
                        LCD_senddata(((i <3) ? LCD_EN1 : LCD_EN2)| 0);
                        _delay_ms(100);                 
                }
        LCD_sendcmd(LCD_EN1 | LCD_EN2 | 0x1);           /* Clear display */
                 
        i = 1; j = 1;
        dir = 0;
        do{
                LCD_cursor_yx(i,j);                                     /* Display figure */
                LCD_senddata(((i <3) ? LCD_EN1 : LCD_EN2)| 0);
                for (tmp = 0; tmp < 20; tmp++)
                        _delay_ms(10);                                  /* Wait for while */

                LCD_cursor_yx(i,j);
                LCD_senddata(((i <3) ? LCD_EN1 : LCD_EN2)| ' ');        /* Clear figure */
                switch(dir) {                                           /* State machine - direction control */
                        case 0: j++;                                    
                                if (j == 40) dir = 1;                   /* Right */
                                break;

                        case 1: i++;                                            
                                if (i == 4) dir = 2;                    /* Down */
                                break;
                        case 2: j--;
                                if (j == 1) dir = 3;                    /* Left */
                                break;
                        case 3: i--;
                                if (i == 1) dir =0;                     /* Up */
                                break;  
                }
        } while(1);
}
예제 #7
0
파일: lcd.c 프로젝트: h0nzZik/school
/*!
 * \brief Send one digit to LCD
 *
 * \param pos   start position
 * \param val   value (only number)
 * 
 */
void LCD_write_big_num(uint8_t pos, uint8_t val)
{
	uint8_t i,j;
	for (i = 0; i <4; i++) {
		switch (i) {
			case 0:	LCD_sendcmd(LCD_EN1 | (0x80 + pos)); break;
			case 1: LCD_sendcmd(LCD_EN1 | (0xc0 + pos)); break;
			case 2: LCD_sendcmd(LCD_EN2 | (0x80 + pos)); break;
			case 3: LCD_sendcmd(LCD_EN2 | (0xc0 + pos)); break;
		}
		for (j = 0; j < 4; j++) {
			if (i <2)
				LCD_senddata(LCD_EN1 | big_number[val][4*i+j]);
			else
				LCD_senddata(LCD_EN2 | big_number[val][4*i+j]);
		}		
	}
}
예제 #8
0
파일: lcd.c 프로젝트: h0nzZik/school
/*!
 * \brief Set cursor on LCD
 *
 * \param row           Row (1-4)
 * \param column        Column (1-40)
 *
 */
void LCD_cursor_yx(uint8_t row, uint8_t column ) {
uint16_t i;
        column--;
	switch( row ) {
		case 1 : i = (0x80 + column) | LCD_EN1; break;
		case 2 : i = (0xc0 + column) | LCD_EN1; break;
		case 3 : i = (0x80 + column) | LCD_EN2; break;
		case 4 : i = (0xc0 + column) | LCD_EN2; break;
		default: i = (0x80 + column) | LCD_EN1 | LCD_EN2; break;
	}
	LCD_sendcmd( i );
}
예제 #9
0
파일: main.c 프로젝트: h0nzZik/school
/*!
 *      M       A       I       N
 *
 */
int main(void) {
    uint16_t poc = 0;
    uint8_t i;
        LCD_init();                                     /* Initialize display */
        LCD_sendcmd(LCD_EN1 | LCD_EN2 | 0xc);           /* Switch off cursor */

        stderr = &lcd_str;                              /* Set FILE stderr */
        while (1) {
                fprintf(stderr, "\1 First line -> Cnt %d .\n",poc++);
                fprintf(stderr, "\2 Second line\n");
                fprintf(stderr, " Next line");
                fprintf(stderr, "\4 Fourth line");
                for (i = 0; i < 10; i++)
                    _delay_ms(50);
                if (!(poc % 10))
                        fprintf(stderr, "\5 Clear disp.");
        }
        return(0);
}
예제 #10
0
파일: max_LCD.cpp 프로젝트: 12019/libraries
inline void Max_LCD::command(uint8_t value) {
  LCD_sendcmd(value);
  delayMicroseconds(100);
}