#include <18F6722.h>
#device PASS_STRINGS=IN_RAM   // За да може да не пишем - sprintf(msg,"hello"); print(3,0,msg);   а да пишем : print(3,0,"hello")
//#device *=16 
#device adc=10
 #device HIGH_INTS=TRUE

//#include <math.h>
//#include <input.c>

#FUSES NOWDT                    //No Watch Dog Timer
// #FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOPUT 
#FUSES HS
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
//#FUSES BBSIZ1K                  //1K words Boot Block size

//#use delay(clock=20000000)
#use delay(clock=10M )
 
// #use rs232(baud=15625,parity=N,xmit=PIN_C6,   rcv=PIN_C7   ,bits=8,FORCE_SW /* INVERT*/,TIMEOUT=460/*360*/ )
 #use rs232(baud=15625,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8 /* INVERT*/ /*,TIMEOUT=860*/ /*360*/,ERRORS,DISABLE_INTS)
 //RS232_ERRORS 
#define XTAL_FREQUENCY  10000000//16000000
#define TIMER1_FREQUENCY (XTAL_FREQUENCY / 4)      //  10 000 000  = 1 clock tick = 1 instr. cycle = crystal frequency / 4

 

 
 
 
 
//***********************  DEFINE ***********************************/
//*******************************************************************/

//**************************************************
#byte pA   =0xF80   //port a   //
#byte pB   =0xF81   //b         // 
#byte pC   =0xF82   //c         // 
#byte pD   =0xF83   //d         // usb port 8 bits parallel
#byte pE   =0xF84   //port e   // 
#byte pF   =0xF85   //port e   // 
#byte pG   =0xF86   //port e   // 
// *********************************

//*********  Задаване на конфигурация на пиновете на портовете  ************ 
#Define  SetConfigPortA     9//100011  //33  100001
#Define  SetConfigPortB     240//255  11110010
#Define  SetConfigPortC     196//1000100 196//196//bx 11000100
#Define  SetConfigPortD     0
#Define  SetConfigPortE     0
#Define  SetConfigPortF     0
#Define  SetConfigPortG     0
//**************************************************
 
#bit UPButton=              pB.5
#bit DOWNButton=            pB.6 
#bit MENUButton=            pB.7 
 
 
#bit PowerSwitch=pF.0   // Ключ за изключване на захранването на LCD-то и периферията

#bit Led=pE.6
#bit LCD_Power=pG.3//pG.0   // Флаг за състоянието на подсветката и за хранването за дисплея
 
#ifndef Enable
#define Enable           1
#endif

#ifndef Disable
#define Disable          0
#endif

#ifndef ReadEP
#define ReadEP           0
#endif

#ifndef WriteEP
#define WriteEP          1
#endif


//..................................................................*/







 
// *******************  IMPORT FILES ********************************** 
 
#include "GLCD240x128 Driver.c"
//................................................................../
 






Void MAIN (){
      int8 prev_second;
 
     char Message[21];
     setup_timer_0(RTCC_OFF );
  
     set_tris_b(SetConfigPortB);
     set_tris_a(SetConfigPortA);//SetConfigPortA
     set_tris_c(SetConfigPortC); // SetConfigPortC Задава като изходи С = [0...7]
     set_tris_d(SetConfigPortD);
     set_tris_e(SetConfigPortE);
     set_tris_f(SetConfigPortF);
     set_tris_g(SetConfigPortG);
 
     
     While(MENUButton!=0){delayms(10);}
     
    output_high(int0);   
    init();
    
    
    
    
   
WHILE(true)
       { 
 
       
          display_address();
          display_black();
          Delay(60000);
          display_address();
          display_white();
          Delay(60000);
              display_address();
          text_dot(0xf0,0x0f);
          Delay(60000);
          text_dot(0x0f,0xf0);
          Delay(60000);
          text_dot(0xff,0x00);
          Delay(60000);
          text_dot(0x00,0xff);
          Delay(60000);
          text_dot(0xf0,0xf0);
          Delay(60000);
          text_dot(0x0f,0x0f);
          Delay(60000);
          display_address();

            //disppic(pic_data);
          Delay(60000);
         write_com(0xa7);
           Delay(60000);
          Delay(60000);
         write_com(0xa6);

          display_address();
          // disppic(pic_data1);
           Delay(60000);
         write_com(0xa7);
          Delay(60000);
          Delay(60000);
         write_com(0xa6);

          display_address();
           // disppic(pic_data2);
          Delay(60000);
         write_com(0xa7);
          Delay(60000);
          Delay(60000);
         write_com(0xa6);

           display_address();
            //disppic(pic_data3);
          Delay(60000);    
         write_com(0xa7);
          Delay(60000);
          Delay(60000);
         write_com(0xa6);

     
          
       }


 
 }
 
 
 
 
 
 
 
 
 
 
 //End******    While (true) 





