#ifndef OLED_CONTROL_H_
#define OLED_CONTROL_H_

#include <stdbool.h>

#define OLED_I2C_ADDR		(0x98u) // For use with UNSHIFTED address type, 0b1001.100W, where W is the read/write bit

#define OLED_PPS_REG_ADDR	(0x70u)
#define OLED_PPS_LEN		(44)

#define OLED_POST_INIT_DELAY	(20) // 20ms after display on, the post-init function should be called

typedef enum _panelsel {
	OLED_LEFT,
	OLED_RIGHT
} OLED_Panel_T;

typedef enum _vidsel {
	Vid_Unknown,
	Vid_H2544_V2544_75Hz,
	Vid_H2544_V2544_72Hz,
//	Vid_H2544_V2184_90Hz,
	Vid_H1920_V1920_90Hz,
	Vid_H1920_V1920_60Hz,
	Vid_H2560_V2560_30Hz,
	Vid_H2544_V2544_60Hz,
	Vid_Colorbar_Test
} Video_Selection_T;

uint8_t OLED_send_cmd(OLED_Panel_T panel_sel, uint8_t reg_addr, uint8_t datalen, const uint8_t* data);
uint8_t OLED_send_tc_cmd(OLED_Panel_T panel_sel, uint8_t reg_addr, uint8_t reg_start_offset, uint8_t datalen, uint8_t* data);
uint8_t OLED_sleep_in_out(OLED_Panel_T panel_sel, bool sleep_in);
uint8_t OLED_display_on_off(OLED_Panel_T panel_sel, bool display_on);
uint8_t OLED_dimming_post_init(OLED_Panel_T panel_sel);
uint8_t OLED_flip(OLED_Panel_T panel_sel, bool flip);
uint8_t OLED_set_brightness(OLED_Panel_T panel_sel, uint16_t new_brightness, bool pulse_emission);
uint8_t OLED_temperature(OLED_Panel_T panel_sel);
uint8_t OLED_read_ID(OLED_Panel_T panel_sel, uint8_t* id_buffer);
uint8_t OLED_set_pps(OLED_Panel_T panel_sel, uint8_t* pps_data);
uint8_t OLED_Startup(OLED_Panel_T panel_sel, Video_Selection_T vidsel);
uint8_t OLED_Colorbar_Test(OLED_Panel_T panel_sel);

#endif /* OLED_CONTROL_H_ */
