
	
#include <avr/io.h>
#include "lcd.h"
#include <avr/interrupt.h>


#include <util/delay.h>

void write_cmd(char val) {
	_delay_ms(5);
	PORTB=val;
	PORTA=0x00;
	PORTA=0x01;
	PORTA=0x00;
}

void disp_writeCh(char val) {
	_delay_ms(5);
	PORTB=val;
	PORTA=0x04;
	PORTA=0x05;
	PORTA=0x04;
}

void disp_clear() {
	_delay_ms(10);
	write_cmd(0x38); //function set
	_delay_ms(10);
	write_cmd(0x01); //clear display
	_delay_ms(10);
}


void disp_init() {

	disp_clear();
	_delay_ms(5);
	write_cmd(0x0f); //display on
	_delay_ms(5);
	write_cmd(0x06); //entry mode set
}


void disp_home(){
	write_cmd(0x03);
}

void disp_writePIN()
{
disp_clear();
_delay_ms(10);
disp_writeCh('E');
disp_writeCh('n');
disp_writeCh('t');
disp_writeCh('e');
disp_writeCh('r');
disp_writeCh(' ');
disp_writeCh('p');
disp_writeCh('i');
disp_writeCh('n');
disp_writeCh('c');
disp_writeCh('o');
disp_writeCh('d');
disp_writeCh('e');
disp_writeCh(':');

}

void disp_hello()
{
	disp_clear();
	_delay_ms(10);
	disp_writeCh('H');
	disp_writeCh('e');
	disp_writeCh('l');
	disp_writeCh('l');
	disp_writeCh('o');
	disp_writeCh('!');
	_delay_ms(10);
}

void disp_moveBotRow()
{
	disp_home();
	_delay_ms(10);
	for(int i = 0; i < 40; i++)
	{
	write_cmd(0x14);
	_delay_ms(10);
	}
	
}

void disp_Welcome()
{
	disp_clear();
	_delay_ms(10);
	disp_writeCh('W');
	disp_writeCh('e');
	disp_writeCh('l');
	disp_writeCh('c');
	disp_writeCh('o');
	disp_writeCh('m');
	disp_writeCh('e');
	disp_writeCh('!');
	_delay_ms(10);
}


void disp_wrongPIN()
{
	disp_clear();
	_delay_ms(10);
	disp_writeCh('W');
	disp_writeCh('r');
	disp_writeCh('o');
	disp_writeCh('n');
	disp_writeCh('g');
	disp_writeCh(' ');
	disp_writeCh('c');
	disp_writeCh('o');
	disp_writeCh('d');
	disp_writeCh('e');
	_delay_ms(10);
}


