Exemplo n.º 1
0
/**
 * Возврат курсора
 *
 * Возврат курсора в левый верхний угол экрана (координаты
 * X: 0 и Y: 0)
 */
void lcd_creturn()
{
    while(lcd_bfstate()) {}
    write_max(DATA_IND_ADDR, 0x02);
    write_max(C_IND_ADDR, 0x01);
    write_max(C_IND_ADDR, 0x00);
    return;
}
Exemplo n.º 2
0
void lcd_setDdramAddress(const unsigned char addr) {
	//set ddram addr, nothing to say
	while(lcd_getBusyFlagState()) {}
	write_max(DATA_IND, addr | 0x80);
	write_max(C_IND, 0x01);
	write_max(C_IND, 0x00);
	return;
}
Exemplo n.º 3
0
/**
 * Установка адреса в DDRAM
 */
void lcd_set_ddram_addr(const unsigned char addr)
{
    while(lcd_bfstate()) {}
    write_max(DATA_IND_ADDR, addr | 0x80);
    write_max(C_IND_ADDR, 0x01); /* RS=0 RW=0 E=1 */
    write_max(C_IND_ADDR, 0x00);/* RS=0 RW=0 E=0 */
    return;
}
Exemplo n.º 4
0
unsigned char lcd_getDdramAddress(void) {
	unsigned char retval = 0x00;

	write_max(C_IND, 0x03); // RS=0 RW=1 E=1 
	retval = read_max(DATA_IND);
	write_max(C_IND, 0x02); // RS=0 RW=1 E=0 
	retval = retval & 0x7f;

	return retval;
}
Exemplo n.º 5
0
/**
 * Значение BF
 *
 * Функция возвращает значение флага занятости - BF
 */
unsigned char lcd_bfstate()
{
    unsigned char retval = 0x00;

    write_max(C_IND_ADDR, 0x03); /* RS=0 RW=1 E=1 */
    retval = read_max(DATA_IND_ADDR);
    write_max(C_IND_ADDR, 0x02); /* RS=0 RW=1 E=0 */
    retval = retval >> 7;

    return retval;
}
Exemplo n.º 6
0
void init_kb()
{
	set_vector(IE0_ADDRESS, (void*)kb_isr);
	write_max(ENA, 0x60); // enable keyboard interrupt as INT0
    EX0 = 1; // enable INT0
	write_max(KB, 0);
	TMOD |= 0x01;
	TCON |= 0x11;

    init_sound();
}
Exemplo n.º 7
0
unsigned char lcd_getBusyFlagState(void) {
	//get busy flag
	unsigned char retval = 0x00;

	write_max(C_IND, 0x03); // RS=0 RW=1 E=1 
	retval = read_max(DATA_IND);
	write_max(C_IND, 0x02); // RS=0 RW=1 E=0 
	retval = retval >> 7;

	return retval;
}
Exemplo n.º 8
0
/**
 * Вывод символа на дисплей
 */
void lcd_putchar(const char c)
{
    unsigned char ddram_addr = lcd_acstate();

    if ((ddram_addr > 0x0f) && (ddram_addr < 0x40))
    {
        lcd_set_ddram_addr(0x40);
    }
    while(lcd_bfstate()) {}
    write_max(DATA_IND_ADDR, c);
    write_max(C_IND_ADDR, 0x05);
    write_max(C_IND_ADDR, 0x04);
    return;
}
Exemplo n.º 9
0
void lcd_display(unsigned char buf[][])
{
    unsigned char i, j;

    for(i = 0; i < 2; i++)
    {
        for(j = 0; j < 16; j++)
        {
            lcd_set_ddram_addr(j + 0x40 * i);
            while(lcd_bfstate()) {}
            write_max(DATA_IND_ADDR, buf[i][j]);
            write_max(C_IND_ADDR, 0x05);
            write_max(C_IND_ADDR, 0x04);
        }
    }
}
Exemplo n.º 10
0
void lcd_putCharNow(const char charData) {
	unsigned char ddramAddress = lcd_getDdramAddress();	
	//if first string owerflows - write on second
	if ((ddramAddress > 0x0f) && (ddramAddress < 0x40)) {
		lcd_setDdramAddress(0x40);
	}
	if(_shouldBreakTheLine){
		_shouldBreakTheLine=0;
		lcd_clear();
	}
	if(charData=='\n'){
		_shouldBreakTheLine=1;
		return;
	}
	while(lcd_getBusyFlagState()) {}
	write_max(DATA_IND, charData);
	write_max(C_IND, 0x05);
	write_max(C_IND, 0x04);
	return;
}
Exemplo n.º 11
0
static void scan_col(uint8_t col)
{
    uint8_t row;
    uint8_t kb_reg;

    select_col(col);
    kb_reg = read_max(KB);
	write_max(KB, 0);

    for (row = 0; row < 4; row++)
	    update_key(col, row, kb_reg);
}
Exemplo n.º 12
0
/**
 * Функция для очистки экрана ЖКИ
 *
 * В данной функции происходит очистка экрана и
 * возврат курсора в начало строки.
 */
void lcd_clear()
{
    while(lcd_bfstate()) {}
    write_max(DATA_IND_ADDR, 0x01);
    write_max(C_IND_ADDR, 0x01);
    write_max(C_IND_ADDR, 0x00);

    while(lcd_bfstate()) {}
    write_max(DATA_IND_ADDR, 0x06);
    write_max(C_IND_ADDR, 0x01);
    write_max(C_IND_ADDR, 0x00);

    while(lcd_bfstate()) {}
    write_max(DATA_IND_ADDR, 0x0f);
    write_max(C_IND_ADDR, 0x01);
    write_max(C_IND_ADDR, 0x00);
    return;
}
Exemplo n.º 13
0
static void select_col(uint8_t col)
{
    write_max(KB, ~(0x01 << col));
}
Exemplo n.º 14
0
void lcd_clear(void) {
	//clear
	while(lcd_getBusyFlagState()) {}
	write_max(DATA_IND, 0x01);
	write_max(C_IND, 0x01);
	write_max(C_IND, 0x00);

	//shift and direction
	while(lcd_getBusyFlagState()) {}
	write_max(DATA_IND, 0x06);
	write_max(C_IND, 0x01);
	write_max(C_IND, 0x00);

	//enable cursor, display, and blink
	while(lcd_getBusyFlagState()) {}
	write_max(DATA_IND, 0x0f);
	write_max(C_IND, 0x01);
	write_max(C_IND, 0x00);

	lcd_putCharNow('0');

	while(lcd_getBusyFlagState()) {}
	write_max(DATA_IND, 0x02);
	write_max(C_IND, 0x01);
	write_max(C_IND, 0x00);
}
Exemplo n.º 15
0
int recieve_string (void)
{
	unsigned char start, stop;
	unsigned char buff;
	unsigned int i = 0;
	unsigned short kol_vo_not;
	unsigned char good_or_bad;
	unsigned char num_page;
	
	start = read_max(2, 0x102);
	stop = read_max(2, 0x103);
	buff = SBUF;
	RI = 0;

	if (!if_ri())
		return 0;
	buff = SBUF;
	RI = 0;
	
	if (!(buff & 0x80))
	{
		good_or_bad = buff & 0x40;
		kol_vo_not = (buff & 0x3f) << 8;
		if (!if_ri())
			return 0;
		buff = SBUF;
		RI = 0;
		kol_vo_not += buff;
		
		while (kol_vo_not)
		{
			if (!if_ri())
				return 0;
			buff = SBUF;
			RI = 0;
			if ((buff != start) && (buff != stop))
			{
				write_max(4, 0x102+i, buff);
				i++;
				kol_vo_not--;
			}
		}
		write_max(4, 0x102+i, 0);

		
		if (good_or_bad)
		{
			num_page = 5;
			is_good_melody = 1;
		}
		else
		{
			num_page = 6;
			is_bad_melody = 1;
		}
		
		init_timer();
		str_to_notes (num_page);
		play_melody (num_page);
		init_uart();
	}
	else
	{
		init_timer();
		if (buff & 0x40)
		{
			write_sram(2, 0x00, "Оки-доки!                      ");
			read_sram_to_lsd(2);
			if (is_good_melody)
				play_melody (5);
			else
				delay(65535);
		}
		else
		{
			write_sram(2, 0x00, "Фигня какая-то...              ");
			read_sram_to_lsd(2);
			if (is_bad_melody)
				play_melody (6);	
			else
				delay(65535);
		}
		write_sram(2, 0x00, "Введите пароль:                 ");
		read_sram_to_lsd(2);
		goto_x(0x40);
		init_uart();
	}
	return 0;
}