//****************< globvar.h >*******************
extern void FindMenu(void);
extern void Tlacitka(void);
extern unsigned char TypSubMenu(void);

/************************************************************************************************
*                                 ---< Define barev >---                                        *
************************************************************************************************/
#define grey   0xd6ba
#define grey1  0x4a49
#define grey2  0x8cb3 
#define black  0x0000
#define white  0xffff
#define blue1  0x001f
#define blue2  0xd71f
#define blue3  0x8cbe 
#define blue5  0x0010
#define blue6  0x7db6
#define red1   0xb000  //d800
#define red2   0xfb4d
#define green1 0x0400
#define green2 0x04a3
#define green3 0x05e0
#define yellow 0xf81f

//----------< Glob. prom. pro projekt >-----------------
unsigned char Scope;  // Udava, ktera faze se ma zobrazovat
//---< Pole >---
float sigU0_RE [128],sigU1_RE [128],sigU2_RE [128],sigU3_RE [128];
float sigU0_IM [128],sigU1_IM [128],sigU2_IM [128],sigU3_IM [128];
float sigI0_RE [128],sigI1_RE [128],sigI2_RE [128],sigI3_RE [128];
float sigI0_IM [128],sigI1_IM [128],sigI2_IM [128],sigI3_IM [128];
float SumVal[150][4];
float ShowVal[150][4];
float MaxVal[10][4];
float MinVal[10][4];
float Kalibr_array[10];
volatile float P0_kalibr,P1_kalibr,P2_kalibr;
volatile unsigned int ColorPhase[8];
volatile signed int PoleScope[258][8]; // 4 napeti nebo proudy + osa X
volatile signed int ScopeOld[258][8];  // 4 napeti nebo proudy + osa X
volatile float PoleRozsahu[8];
volatile float PoleVector[8];
unsigned char cislo[15];  // Cislo pro zobrazeni
unsigned int TextX[6][2],TextY[6][2];
signed int dx[9][2],dy[9][2];

volatile unsigned char TypScope;
volatile float frekvence;
volatile unsigned char estep;

//------------< Edit pole >---------------------------------
volatile unsigned char ParamChar[20];
volatile unsigned int  ParamInt[20];
volatile float ParamFloat[20];
 
//---< Pocitadla >---
volatile unsigned int countVal,T_Cykl;

//---< Tlacitka >---
volatile unsigned char Key,OldKey,NewKey;

//---< Zoom a Scroll >---
volatile unsigned char menu_scroll;   // Kolikrat mohu scrolovast
volatile unsigned char max_scroll;    // Max pocet scroll
volatile unsigned char Screen_Zoom;   // Aktualni velikost zoomu  


//---< Konstanty pro kalendar >---
#define T_SEC_LEC 0
#define T_LEC_SEC 1
#define DEF_S_L 0x047f
#define DEF_L_S 0x055d
#define Adr_rok 0x10

//------------< Flagy >------------
typedef struct{
	unsigned ZoneTime     :1;
  unsigned Min          :1;  // Flag 1 sekundy pro nacteni aktualniho casu z pcf
	unsigned PulSec       :1;  // Pro blikani : pri zobrazeni casu 
  unsigned Change       :1;  // Priznak bylo stisknute tlacitko
	unsigned NewScreen    :1;  // Zmena obrazovky
  unsigned Show         :1;  // Zobraz namerene hodnoty
  unsigned TriFaze      :1;  // Urcuje kolik fazi se ma merit
	unsigned Scroll       :1;  // Priznak skrolovani
	unsigned Zoom         :1;  // Indikuje jestli je on/off zoom
	unsigned Scope        :1;  // Je Scope Obsluha scope je kvuli rychlosti v preruseni
	unsigned Param        :1;  // Je Param.
	unsigned ParamEnd     :1;  // Slozi k insikaci ze byla param.(Kdzy si nakreslim v param neco na dis. abych si to smazal)
  unsigned Repeat       :1;  // 1 - povolen repeat
	unsigned FastRepeat   :1;  // 1 - Povolen FastRepeat
  unsigned Kalibr       :1;  // 1 - je kalibrace
	unsigned Unlock       :1;  // 1 - Dobre zadane heslo
} flagy;

volatile flagy flag;

//------------< Priznaky >--------
typedef struct{
  unsigned Q4          :1;
	unsigned ChangeDate  :1;	
	
}priznaky;

volatile priznaky priznak;

//------------------------------------
// definice adres v eeprom pro jednotlive parametry
#define      ee_Frekvence    10
#define      ee_pro_TrSec    122
#define      ee_pro_TrPri    118
#define      ee_nap_TrSec    130
#define      ee_nap_TrPri    134
#define      EEadr_OVERTIME  138     // 2 x int  (4byty) - nastavitelne z PC
#define      ee_PSW          142     // heslo do parametrizace
#define      ee_kal_U0       144     // float
#define      ee_kal_U1       148     // float
#define      ee_kal_U2       152     // float
#define      ee_kal_U3       156     // float
#define      ee_kal_I0       160     // float
#define      ee_kal_I1       164     // float
#define      ee_kal_I2       168     // float
#define      ee_kal_I3       172
#define      ee_min_max      172     // 830 bytu pro min/max hodnoty	
//---------------------------------------------------------

#define KEY_SET  0x01
#define KEY_UP   0x02
#define KEY_DOWN 0x04
#define KEY_ESC  0x08
#define KEY_ZOOM 0x10

//---------------------------------------------------------
#define PrevodU 0.564971  // Prevod mezi LSB a hodnotou napeti
#define PrevodI 0.0044    // Prevod mezi LSB a hodnotou proudu
//-----------------< Mereni >------------------------------------
#define Typ_U 3
#define Typ_I 4 
//-----------------< Analyzator >--------------------------------
#define BRIGHT     8
#define STABRIGHT  9
#define STANDTIME  10