#include "marh.h"
void init_port (void);
void outcontrol (char);
void outdata (char);
void delay1 (int);
void lcd_control_write (void);
void init_lcd (void);
void write_data (char);
void write_string(char);

void setup() {
  init_port();
  init_lcd();
  write_string("Francis Otieno                             mark");
}
void write_string(char *ptr)
{
    while(*ptr != '\0')
      {
        write_data(*ptr);
        ptr++;
      }
}

void delay1(int count)
{
   volatile long i;
   while(count)
   {
    for(i=0;i<100000;i++);
     count--;
   }
  
}
void lcd_control_write(void)
{
   outcontrol(0x00);
   //delay1(1);
   outcontrol(0x01);
   //delay1(1);
}
void init_lcd(void) 
{
  outdata(0x01);
  lcd_control_write();
  outdata(0x06); // auto increament
  lcd_control_write();
  outdata(0x38); // 8 bit 2 line
  lcd_control_write();
  outdata(0x0f);  // cursor
  lcd_control_write();
  //outdata(0x1c);// shifting all the display to right
  //lcd_control_write();
}

void write_data(char wr_data)
{
   outdata(wr_data);
   outcontrol(0x02);
   delay1(1);
   outcontrol(0x03);
   delay1(1);
   outcontrol(0x02);
   delay1(1);
}
void loop() {
 // write_string("Francis Otieno\n");
}