/*
Diplomova prace : Palubni pocitac

definice konstant a maker

Atmega128A 10 MHz XTAL

Autor: Ondrej Lutera

2011/2012

*/
#ifndef DEFINE_H_INCLUDED
#define DEFINE_H_INCLUDED

//#define CAR_WDT_EN      /* zakomentovat v pripade problemu s watchdogem pri ladeni */
#define CAR_DEBUG
#define CAR_SHELL          /* zpristupni prochazeni SD karty pomoci seriove linky po odeslani dvou znaku '*' */
//#define MEAS_DEBUG          /* nahradi skutecne mereni hodnotami ziskanymi po seriove lince */

#define CAR_WDT_TIME    WDTO_2S
#define LCD_PWR_PIN     PC6
#define LCD_PWR_ON()    PORTC&=~(1<<LCD_PWR_PIN); \
                        DDRC|=1<<LCD_PWR_PIN
#define LCD_PWR_OFF()   DDRC&=~(1<<LCD_PWR_PIN)

//#define LANG_EN
#define LANG_CZ

#ifdef LANG_EN

#define TEXT_AVG        "Avg"
#define TEXT_TRIP       "Trip"
#define TEXT_ACT        "Act"
#define TEXT_RPM        "Rpm"
#define TEXT_TANK       "Tank"
#define TEXT_TIME       "Time"
#define TEXT_DISTANCE   "Dist"
#define TEXT_BAT        "Bat"
#define TEXT_CLEAR_TRIP "Clear trip data"
#define TEXT_SETTINGS   "Settings"
#define TEXT_TOTAL_KM   "Total km:"
#define TEXT_TOTAL_L    "Total liters:"
#define TEXT_USER_STAT  "User logs"
#define TEXT_CUSTOMIZE_SCR  "Customize screen"
#define TEXT_MENU       "Menu - user: "
#define TEXT_C_VALVE    "Number of injectors:"
#define TEXT_C_INJ      "Inj [ccm/min]:"
#define TEXT_C_KM       "Odo [imp/100m]:"
#define TEXT_C_L        "Tank volume [l]:"
#define TEXT_C_RPM      "Rpm [imp/100ot]:"
#define TEXT_C_TANK     "Tank calibration"
#define TEXT_FACTORY    "Reset factory settings"
#define TEXT_BACKLIGHT  "Customize backlight"
#define TEXT_CLOCK      "Set clock:"
#define TEXT_DATE       "Set date:"
#define TEXT_USER_NAME  "User name:"
#define TEXT_MANAGE_USERS "Manage users"
#define TEXT_CONST0_L   "Constant 0 [l]:"
#define TEXT_CONST0_MV  "Constant 0 [mV]:"
#define TEXT_CONST1_L   "Constant 1 [l]:"
#define TEXT_CONST1_MV  "Constant 1 [mV]:"
#define TEXT_CONST2_L   "Constant 2 [l]:"
#define TEXT_CONST2_MV  "Constant 2 [mV]:"
#define TEXT_CONST3_L   "Constant 3 [l]:"
#define TEXT_CONST3_MV  "Constant 3 [mV]:"
#define TEXT_CONST4_L   "Constant 4 [l]:"
#define TEXT_CONST4_MV  "Constant 4 [mV]:"
#define TEXT_MENU_TANK     "Tank %u l %u mV"
#define TEXT_TEMP_SENSORS  "Find temp. sensors"
#define TEXT_NEW_SENSOR    "New sensor [C]:"
#define TEXT_REG_SENSOR    "Reg. sensor [C]:"
#define TEXT_SENSOR_AS     "Sensor as:"
#define TEXT_REG_SENSOR_TEXT "Reg. sensor txt:"
#define TEXT_MANAGE_USER    "Manage user"
#define TEXT_USER_UID       "User uid:"
#define TEXT_USER_LAST_TIME   "Last time:"
#define TEXT_USER_LAST_DATE   "Last date:"
#define TEXT_USER_EXP_TIME    "Exp. time:"
#define TEXT_USER_EXP_DATE    "Exp. date:"
#define TEXT_USER_IBUTTON   "iButton set:"
#define TEXT_USER_ROOT      "Root group:"
#define TEXT_USER_READ      "Read group:"
#define TEXT_MANAGE_WHO     "Manage: %s"
#define TEXT_SYS_LOG        "System log"
#define TEXT_DATA_CLEARED   "Data cleared!"
#define TEXT_OPTO_0         "0. Intensity [%]:"
#define TEXT_PWM_0     "0. Backlight :"
#define TEXT_OPTO_1         "1. Intensity [%]:"
#define TEXT_PWM_1     "1. Backlight :"
#define TEXT_OPTO_2         "2. Intensity [%]:"
#define TEXT_PWM_2     "2. Backlight :"
#define TEXT_OPTO_3         "3. Intensity [%]:"
#define TEXT_PWM_3     "3. Backlight :"
#define TEXT_OPTO_4         "4. Intensity [%]:"
#define TEXT_PWM_4     "4. Backlight :"
#define TEXT_MENU_BCK   "Act. %u%% / %u"
#define TEXT_LOG_YEAR   "Data of year"
#define TEXT_LOG_MONTH  "Data of month"
#define TEXT_LOG_DAY    "Data of day"
#define TEXT_YEARS_WHO  "%s years"
#define TEXT_AVG_YEAR   "Avg. data of all years"
#define TEXT_AVG_MONTH  "Avg. data of all months"
#define TEXT_MONTHS_WHO "%s/"
#define TEXT_DAYS_WHO   "%s/%s/"
#define TEXT_AVG_DAY    "Avg. data of all days"
#define TEXT_AVG_ALL_MEAS "Avg. data of all meas"
#define TEXT_MEAS_WHO   "%s/%s/%s/"
#define TEXT_LOG_MEAS   "Start"
#define TEXT_WAIT       "    Wait..."
#define TEXT_INJ_TICKS  "Injector imp:"
#define TEXT_INJ_OVF    "Injector overflow:"
#define TEXT_IMP_TICKS  "Odo meters imp:"
#define TEXT_IMP_OVF    "Odo overflow:"
#define TEXT_RPM_TICKS  "Rpm imp:"
#define TEXT_RPM_OVF    "Rpm overflow:"
#define TEXT_TANK_INT   "Tank impulse:"
#define TEXT_C_KM_16    "16bit km counter:"
#define TEXT_INVALID_IBUTTON "Invalid key code"
#define TEXT_DELETED    "    Deleted!"
#define TEXT_REG_SENSOR_CLEAR       "Clear sensors"
#define TEXT_REG_ADMIN      "Register Admin"
#define TEXT_PRESS_OK       "Press OK please"
#define TEXT_ADMIN_CREATED  "Admin created"
#define TEXT_LOGIN          "Login please"
#define TEXT_EXP_USER       "User expired"
#define TEXT_USER_WHO_LOGGED "User %s logged"
#define TEXT_USER_SETTINGS   "User settings"
#define TEXT_USER_TRACK_DELAY "New track after [min]"
#define TEXT_USER_SUSPEND_MIN "Suspend after   [min]"

/* menu v zobrazovanych prumerech */

#define TEXT_AVG_FCONS  "Avg [l/100km]"
#define TEXT_AVG_LIT    "Fuel [l]"
#define TEXT_AVG_KMH    "speed [km/h]"
#define TEXT_AVG_KM     "Distance [km]"
#define TEXT_AVG_TIME   "Time"
#define TEXT_AVG_RPM    "Avg Rpm"

#define UNIT_KM         "km"
#define UNIT_KMH        "km/h"
#define UNIT_LKM        "l/100"
#define UNIT_L          "l"
#define UNIT_RPM        "/min"
#define UNIT_V          "V"
#define UNIT_C          "C"

#define TEXT_OK         "Ok"
#define TEXT___         "--"
#define TEXT_YES        "Yes"
#define TEXT_NO         "No"

#endif

#ifdef LANG_CZ

#define TEXT_AVG        "Prum"
#define TEXT_TRIP       "Trat"
#define TEXT_ACT        "Akt"
#define TEXT_RPM        "Ot"
#define TEXT_TANK       "Nadrz"
#define TEXT_TIME       "Cas"
#define TEXT_DISTANCE   "Dojezd"
#define TEXT_BAT        "Bat"
#define TEXT_CLEAR_TRIP "Reset trate"
#define TEXT_SETTINGS   "Nastaveni systemu"
#define TEXT_TOTAL_KM   "Celkove [km]"
#define TEXT_TOTAL_L    "Celkove [l]"
#define TEXT_USER_STAT  "Zaznamy jizd"
#define TEXT_CUSTOMIZE_SCR  "Editace obrazovky"
#define TEXT_MENU       "Uzivatel: "
#define TEXT_C_VALVE    "Pocet vstrikovacu:"
#define TEXT_C_INJ      "Vstrik [ccm/min]:"
#define TEXT_C_KM       "Km    [imp/100m]:"
#define TEXT_C_L        "Objem nadrze [l]:"
#define TEXT_C_RPM      "Otacky  [imp/ot]:"
#define TEXT_C_TANK     "Kalibrace nadrze"
#define TEXT_FACTORY    "Kompletni reset"
#define TEXT_BACKLIGHT  "Podsviceni"
#define TEXT_CLOCK      "Cas:"
#define TEXT_DATE       "Datum:"
#define TEXT_USER_NAME  "Jmeno uziv.:"
#define TEXT_MANAGE_USERS "Sprava uzivatelu"
#define TEXT_CONST0_L   "Stav   0 [l]:"
#define TEXT_CONST0_MV  "Napeti 0 [mV]:"
#define TEXT_CONST1_L   "Stav   1 [l]:"
#define TEXT_CONST1_MV  "Napeti 1 [mV]:"
#define TEXT_CONST2_L   "Stav   2 [l]:"
#define TEXT_CONST2_MV  "Napeti 2 [mV]:"
#define TEXT_CONST3_L   "Stav   3 [l]:"
#define TEXT_CONST3_MV  "Napeti 3 [mV]:"
#define TEXT_CONST4_L   "Stav   4 [l]:"
#define TEXT_CONST4_MV  "Napeti 4 [mV]:"
#define TEXT_MENU_TANK     "Nadrz %u l %u mV"
#define TEXT_TEMP_SENSORS  "Senzory teploty"
#define TEXT_NEW_SENSOR    "Nalezeny senzor [C]:"
#define TEXT_REG_SENSOR    "Reg. senzor [C]:"
#define TEXT_SENSOR_AS     "Senzor jako:"
#define TEXT_REG_SENSOR_TEXT "Text senzoru:"
#define TEXT_MANAGE_USER    "Uzivatel"
#define TEXT_USER_UID       "UID:"
#define TEXT_USER_LAST_TIME   "Prihlasil:"
#define TEXT_USER_LAST_DATE   "Prihlasil:"
#define TEXT_USER_EXP_TIME    "Vyprsi casu:"
#define TEXT_USER_EXP_DATE    "Vyprsi data:"
#define TEXT_USER_IBUTTON   "iButton klic:"
#define TEXT_USER_ROOT      "Prava Admin:"
#define TEXT_USER_READ      "Pristup pro cteni:"
#define TEXT_MANAGE_WHO     "Editace: %s"
#define TEXT_SYS_LOG        "Systemove informace"
#define TEXT_DATA_CLEARED   "  Data smazana!"
#define TEXT_OPTO_0         "0. Intenzita [%]:"
#define TEXT_PWM_0     "0. Podsviceni :"
#define TEXT_OPTO_1         "1. Intenzita [%]:"
#define TEXT_PWM_1     "1. Podsviceni :"
#define TEXT_OPTO_2         "2. Intenzita [%]:"
#define TEXT_PWM_2     "2. Podsviceni :"
#define TEXT_OPTO_3         "3. Intenzita [%]:"
#define TEXT_PWM_3     "3. Podsviceni :"
#define TEXT_OPTO_4         "4. Intenzita [%]:"
#define TEXT_PWM_4     "4. Podsviceni :"
#define TEXT_MENU_BCK   "Cidlo %u%% / %u"
#define TEXT_LOG_YEAR   "Data roku"
#define TEXT_LOG_MONTH  "Data mesice"
#define TEXT_LOG_DAY    "Data dne"
#define TEXT_YEARS_WHO  "%s zaznamy"
#define TEXT_AVG_YEAR   "Prumery vsech let"
#define TEXT_AVG_MONTH  "Prumery mesicu v roce"
#define TEXT_MONTHS_WHO "%s/"
#define TEXT_DAYS_WHO   "%s/%s/"
#define TEXT_AVG_DAY    "Prumery dni v mesici"
#define TEXT_AVG_ALL_MEAS "Prumery jizd v dni"
#define TEXT_MEAS_WHO   "%s/%s/%s/"
#define TEXT_LOG_MEAS   "Start"
#define TEXT_WAIT       "   Cekejte..."
#define TEXT_INJ_TICKS  "Vstrik. impulzy:"
#define TEXT_INJ_OVF    "Vstrik. preteceni:"
#define TEXT_IMP_TICKS  "Cidlo km impulzy:"
#define TEXT_IMP_OVF    "Cidlo km preteceni:"
#define TEXT_RPM_TICKS  "Otacky impulzy:"
#define TEXT_RPM_OVF    "Otacky preteceni:"
#define TEXT_TANK_INT   "Nadrz impulzy:"
#define TEXT_C_KM_16    "16bit citac km:"
#define TEXT_INVALID_IBUTTON "Chyba:registrovany klic"
#define TEXT_DELETED    "    Smazano!"
#define TEXT_REG_SENSOR_CLEAR       "Smaz senzory"
#define TEXT_REG_ADMIN      "Registrujte Admina"
#define TEXT_PRESS_OK       "Stisknete OK prosim"
#define TEXT_ADMIN_CREATED  "  Admin vytvoren"
#define TEXT_LOGIN          "Prihlaste se prosim"
#define TEXT_EXP_USER       "Ucet vyrpsel!"
#define TEXT_USER_WHO_LOGGED "%s prihlasen"
#define TEXT_USER_SETTINGS   "Osobni nastaveni"
#define TEXT_USER_TRACK_DELAY "Nova trat [min]:"
#define TEXT_USER_SUSPEND_MIN "Uspat PP  [min]:"

/* menu v zobrazovanych prumerech */

#define TEXT_AVG_FCONS  "Prum [l/100km]"
#define TEXT_AVG_LIT    "Paliva [l]"
#define TEXT_AVG_KMH    "Rychlost [km/h]"
#define TEXT_AVG_KM     "Ujeto [km]"
#define TEXT_AVG_TIME   "Cas"
#define TEXT_AVG_RPM    "Prum [ot./min]"

#define UNIT_KM         "km"
#define UNIT_KMH        "km/h"
#define UNIT_LKM        "l/100"
#define UNIT_LH         "l/h"
#define UNIT_L          "l"
#define UNIT_RPM        "/min"
#define UNIT_V          "V"
#define UNIT_C          "C"

#define TEXT_OK         "Ok"
#define TEXT___         "--"
#define TEXT_YES        "Ano"
#define TEXT_NO         "Ne"

#endif


#define UNIT_FONT       font_5x8
#define TEXT_FONT       font_5x8
#define VAL_FONT        font_6x12
#define BIG_VAL_FONT    font_12x24
#define MENU_TITLE_FONT font_6x12
#define MENU_LIST_FONT  font_5x8

#define FUEL_CONS_PREC  1
#define KM_CONS_PREC    1
#define V12_PREC        1

#define MAX_SCREENS 4


#define SCR0        0
#define SCR1        1
#define SCR2        2
#define SCR3        3

#define MENU_SCREEN             1000000
#define MENU_CLR_DATA           1100000
#define MENU_USER_SETTINGS      1200000
#define MENU_CUST_BCK           1204000
#define MENU_CUST_SCR           1205000
#define MENU_USR_STAT           1300000
#define MENU_USR_STAT_Y_AVG     1301000
#define MENU_USR_STAT_M         1302000
#define MENU_USR_STAT_M_AVG     1302100
#define MENU_USR_STAT_D         1302200
#define MENU_USR_STAT_D_AVG     1302210
#define MENU_USR_STAT_MEAS      1302220
#define MENU_USR_STAT_MEAS_AVG  1302221
#define MENU_USR_STAT_MEAS_TRAC 1302222
#define MENU_SETTINGS           1400000
#define MENU_SYSLOG             1500000
#define MENU_TANK_CALIB         1409000
#define MENU_MANAGE_USR         1410000
#define MENU_FIND_TEMP          1411000
#define MENU_RESET_SET          1412000
#define MENU_USR_EDIT           1410100

#define MENU_MAX_ITEMS  50
#define DTEXT_MAX   30

#define MAX_FS_LIST 50       // urcuje priblizne maximalni pocet zobrazovanych polozek - hlavne jizd, kde format je HH:MM+\0
#define FS_TXT_SIZE (6*MAX_FS_LIST)

#define ACT_PATH_SIZE   40

#define BAUD_SPEED  UART_BAUD_SELECT_DOUBLE_SPEED(115200,F_CPU)+1       /* +1, makro knihovny neresi zaokrouhleni! */

#define MAX_VAL 18
#define BLINK_EDIT 16
#define DELAY5S     (32*5)      //5s



#endif // DEFINE_H_INCLUDED
