/* ---------------------------------------------
*ad0x0, 2020
* ----------------------------------------------
*/


#ifndef __SSD1306_H
#define __SSD1306_H
#include "stdint.h"
#include "../i2c/ad0x0_i2c.h"
#ifdef __cplusplus
extern "C" {
#endif

#define SSD1306_I2C_ADDRESS		     ( 0x78 ) 
	/* size */
#define SSD1306_LCDWIDTH                     128
#define SSD1306_LCDHEIGHT                    32
#define SSD1306_DEFAULT_SPACE                5
	/* Commands */
#define SSD1306_SETCONTRAST                  0x81
#define SSD1306_DISPLAYALLON_RESUME          0xA4
#define SSD1306_DISPLAYALLON                 0xA5
#define SSD1306_NORMALDISPLAY                0xA6
#define SSD1306_INVERTDISPLAY                0xA7
#define SSD1306_DISPLAYOFF                   0xAE
#define SSD1306_DISPLAYON                    0xAF
#define SSD1306_SETDISPLAYOFFSET             0xD3
#define SSD1306_SETCOMPINS                   0xDA
#define SSD1306_SETVCOMDETECT                0xDB
#define SSD1306_SETDISPLAYCLOCKDIV           0xD5
#define SSD1306_SETPRECHARGE                 0xD9
#define SSD1306_SETMULTIPLEX                 0xA8
#define SSD1306_SETLOWCOLUMN                 0x00
#define SSD1306_SETHIGHCOLUMN                0x10
#define SSD1306_SETSTARTLINE                 0x40
#define SSD1306_MEMORYMODE                   0x20
#define SSD1306_COLUMNADDR                   0x21
#define SSD1306_PAGEADDR                     0x22
#define SSD1306_COMSCANINC                   0xC0
#define SSD1306_COMSCANDEC                   0xC8
#define SSD1306_SEGREMAP                     0xA0
#define SSD1306_CHARGEPUMP                   0x8D
#define SSD1306_EXTERNALVCC                  0x1
#define SSD1306_SWITCHCAPVCC                 0x2
	/* Scrolling #defines */
#define SSD1306_ACTIVATE_SCROLL              0x2F
#define SSD1306_DEACTIVATE_SCROLL            0x2E
#define SSD1306_SET_VERTICAL_SCROLL_AREA     0xA3
#define SSD1306_RIGHT_HORIZONTAL_SCROLL      0x26
#define SSD1306_LEFT_HORIZONTAL_SCROLL       0x27
#define SSD1306_VERT_AND_RIGHT_HORIZ_SCROLL  0x29
#define SSD1306_VERT_AND_LEFT_HORIZ_SCROLL   0x2A

#define COMAND		                     0x00
#define DATA		                     0x40

typedef struct{
	unsigned int out;
	float t;
	uint8_t i2cbuf[2];
	char buff[40];  //буфер дисплея
	uint8_t OLED_X,OLED_Y;
	void (*clear)(void);
	void (*print_at)(unsigned char x, unsigned char y,unsigned char* buf, unsigned char size);
	void    (*ad0x0_i2c_push)(ADQ_t _ctype,uint8_t _cbyte);
	uint8_t (*ad0x0_i2c_get_ext_async2)(uint8_t *_p_out_handle,void **_p_out_i2c_ext_t);
	void 		(*commmand)(unsigned char ControByte, unsigned char DataByte);
	void 		(*OLED_test)(void);
}oled_desc_s;

	/* --- Прототипы функций -------------------------------- */
//        void delay_ms( unsigned int ms );
          


//	void OLED_CharBig(unsigned int c);  /* вывод крупных символов */
//	void OLED_Printf(unsigned char* buf, unsigned char size);  /* печатает строку с размерами - 0 самый мелкий 2 - увеличиный - 3 самый большой(только для цифр) */
//	void OLED_DrawImage(unsigned char num_image);  /* выводит картинку из флеш */
//	void OLED_Bat(unsigned char y,unsigned char x, unsigned char z);  /* рисует батарейку по координатам z - от 0 до 10 делений */
//	void OLED_Mode(char set_mode);  /* 1 - inverted / 0 - normal */
//	void OLED_Sleep(char set);  /* 1 - on sleep / 0 - off sleep */
void	OLED_Init2(I2C_TypeDef * _I2C_BASE, oled_desc_s *p_desc);
		unsigned char * i16_2s(int16_t value, unsigned char *buffer);
		unsigned char * i32_2s(int32_t value, unsigned char *buffer);
        
#ifdef __cplusplus
}
#endif

#endif /* __SSD1306_H */
