#ifndef LED_DISPLAY_H_
#define LED_DISPLAY_H_

/**** Includes ****/
#include <stdint.h>
#include "../utils/vcounter.h"
#include "../bsp/board.h"

namespace hw {

/**** Public definitions ****/
class LedDisplay
{
	public:
	typedef struct {
		bsp::DigitalOut* led0_dout_ch;
		bsp::DigitalOut* led1_dout_ch;
		bsp::DigitalOut* led2_dout_ch;
		bsp::DigitalOut* led3_dout_ch;
		bsp::DigitalOut* led4_dout_ch;
		bsp::DigitalOut* led5_dout_ch;
	} doutCfg_t;
	
	LedDisplay(void);
	~LedDisplay(void);
	
	uint16_t on_time;
	uint16_t period;
	uint8_t cycle_cnt;
	uint8_t cycle_limit;
	
	void init(doutCfg_t* dout_chs, uint8_t act_lvl, util::VCounter* timer, bsp::PwmOut* pwm_ch);
	void write(uint8_t image);
	void write(uint8_t image, uint16_t on_time, uint16_t period, uint8_t cycle_limit);
	void process(void);
	uint8_t is_cycle_end(void);
	void force(uint8_t image);
	
	void write_backlight(uint8_t percent);
	
	#ifdef TESTING
	protected:
	#endif
	bsp::DigitalOut* led0_dout_ch;
	bsp::DigitalOut* led1_dout_ch;
	bsp::DigitalOut* led2_dout_ch;
	bsp::DigitalOut* led3_dout_ch;
	bsp::DigitalOut* led4_dout_ch;
	bsp::DigitalOut* led5_dout_ch;
	uint8_t act_lvl;
	util::VCounter* timer;
	bsp::PwmOut* pwm_ch;
	uint16_t timestamp_start;
	uint8_t image;
	
	void set_single_led(uint8_t state, bsp::DigitalOut* led_ch);
};

/**** Public function declarations ****/

#ifdef TESTING
#endif

} //namespace

#endif /* LED_DISPLAY_H_ */