/*
Diplomova prace : Palubni pocitac

backlight.h

Atmega128A 10 MHz XTAL

Autor: Ondrej Lutera

2011/2012

*/

#ifndef BACKLIGHT_H_INCLUDED
#define BACKLIGHT_H_INCLUDED

#include <avr/io.h>
#include <avr/eeprom.h>
#include "define.h"
#include "adc.h"
#include "timer.h"
#include "i2clib/pca9530.h"

#ifdef CAR_DEBUG
#include "uart.h"
#include <avr/pgmspace.h>
#endif

#define OPTO        CH3
#define OPTO_CNT    5
#define OPTO_SET    'Y'
#define AVG_SAMPLES  10
#define OPTO_DELAY   60

typedef struct{

    uint8_t pwm;
    uint8_t opto;


}opto_t;

typedef struct{

    uint8_t isSet;
    opto_t data[OPTO_CNT];

}odat_t;

uint8_t initOpto(odat_t* opto); /* inicializace regulace jasu */
uint8_t optoPoll(uint8_t oldPwm, odat_t *opto); /* polling regulace jasu dle dat predanych strukturou opto */
uint8_t getActOptoPwm(void);        /* vraci aktualne nastavene PWM */
uint8_t getActOptoIx(void);         /* vraci aktualne pouzity index z tabulky opto */

#endif // BACKLIGHT_H_INCLUDED
