#pragma once
#include <stdint.h>
#include <stdbool.h>
#define OLED_IC_SSD1306 0
#define OLED_IC_SH1106 1
#if defined(OLED_DISPLAY_CUSTOM)
#elif defined(OLED_DISPLAY_128X64)
# ifndef OLED_DISPLAY_WIDTH
# define OLED_DISPLAY_WIDTH 128
# endif
# ifndef OLED_DISPLAY_HEIGHT
# define OLED_DISPLAY_HEIGHT 64
# endif
# ifndef OLED_MATRIX_SIZE
# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH)
# endif
# ifndef OLED_BLOCK_TYPE
# define OLED_BLOCK_TYPE uint16_t
# endif
# ifndef OLED_BLOCK_COUNT
# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8)
# endif
# ifndef OLED_BLOCK_SIZE
# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT)
# endif
# ifndef OLED_COM_PINS
# define OLED_COM_PINS COM_PINS_ALT
# endif
# ifndef OLED_SOURCE_MAP
# define OLED_SOURCE_MAP \
{ 0, 8, 16, 24, 32, 40, 48, 56 }
# endif
# ifndef OLED_TARGET_MAP
# define OLED_TARGET_MAP \
{ 56, 48, 40, 32, 24, 16, 8, 0 }
# endif
#else
# ifndef OLED_DISPLAY_WIDTH
# define OLED_DISPLAY_WIDTH 128
# endif
# ifndef OLED_DISPLAY_HEIGHT
# define OLED_DISPLAY_HEIGHT 32
# endif
# ifndef OLED_MATRIX_SIZE
# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH)
# endif
# ifndef OLED_BLOCK_TYPE
# define OLED_BLOCK_TYPE uint16_t
# endif
# ifndef OLED_BLOCK_COUNT
# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8)
# endif
# ifndef OLED_BLOCK_SIZE
# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT)
# endif
# ifndef OLED_COM_PINS
# define OLED_COM_PINS COM_PINS_SEQ
# endif
# ifndef OLED_SOURCE_MAP
# define OLED_SOURCE_MAP \
{ 0, 8, 16, 24 }
# endif
# ifndef OLED_TARGET_MAP
# define OLED_TARGET_MAP \
{ 24, 16, 8, 0 }
# endif
#endif
#if !defined(OLED_IC)
# define OLED_IC OLED_IC_SSD1306
#endif
#if !defined(OLED_COLUMN_OFFSET)
# define OLED_COLUMN_OFFSET 0
#endif
#if !defined(OLED_DISPLAY_ADDRESS)
# define OLED_DISPLAY_ADDRESS 0x3C
#endif
#if !defined(OLED_FONT_H)
# define OLED_FONT_H "glcdfont.c"
#endif
#if !defined(OLED_FONT_START)
# define OLED_FONT_START 0
#endif
#if !defined(OLED_FONT_END)
# define OLED_FONT_END 223
#endif
#if !defined(OLED_FONT_WIDTH)
# define OLED_FONT_WIDTH 6
#endif
#if !defined(OLED_FONT_HEIGHT)
# define OLED_FONT_HEIGHT 8
#endif
#if !defined(OLED_BRIGHTNESS)
# define OLED_BRIGHTNESS 255
#endif
#if !defined(OLED_TIMEOUT)
# if defined(OLED_DISABLE_TIMEOUT)
# define OLED_TIMEOUT 0
# else
# define OLED_TIMEOUT 60000
# endif
#endif
#if !defined(OLED_FADE_OUT_INTERVAL)
# define OLED_FADE_OUT_INTERVAL 0x00
#endif
#if OLED_FADE_OUT_INTERVAL > 0x0F || OLED_FADE_OUT_INTERVAL < 0x00
# error OLED_FADE_OUT_INTERVAL must be between 0x00 and 0x0F
#endif
#if !defined(OLED_I2C_TIMEOUT)
# define OLED_I2C_TIMEOUT 100
#endif
#if !defined(OLED_UPDATE_INTERVAL) && defined(SPLIT_KEYBOARD)
# define OLED_UPDATE_INTERVAL 50
#endif
typedef struct __attribute__((__packed__)) {
uint8_t *current_element;
uint16_t remaining_element_count;
} oled_buffer_reader_t;
typedef enum {
OLED_ROTATION_0 = 0,
OLED_ROTATION_90 = 1,
OLED_ROTATION_180 = 2,
OLED_ROTATION_270 = 3, } oled_rotation_t;
bool oled_init(oled_rotation_t rotation);
oled_rotation_t oled_init_user(oled_rotation_t rotation);
void oled_clear(void);
void oled_render(void);
void oled_set_cursor(uint8_t col, uint8_t line);
void oled_advance_page(bool clearPageRemainder);
void oled_advance_char(void);
void oled_write_char(const char data, bool invert);
void oled_write(const char *data, bool invert);
void oled_write_ln(const char *data, bool invert);
void oled_pan(bool left);
oled_buffer_reader_t oled_read_raw(uint16_t start_index);
void oled_write_raw(const char *data, uint16_t size);
void oled_write_raw_byte(const char data, uint16_t index);
void oled_write_pixel(uint8_t x, uint8_t y, bool on);
#if defined(__AVR__)
void oled_write_P(const char *data, bool invert);
void oled_write_ln_P(const char *data, bool invert);
void oled_write_raw_P(const char *data, uint16_t size);
#else
# define oled_write_P(data, invert) oled_write(data, invert)
# define oled_write_ln_P(data, invert) oled_write(data, invert)
# define oled_write_raw_P(data, size) oled_write_raw(data, size)
#endif
bool oled_on(void);
bool oled_off(void);
bool is_oled_on(void);
uint8_t oled_set_brightness(uint8_t level);
uint8_t oled_get_brightness(void);
void oled_task(void);
void oled_task_user(void);
void oled_scroll_set_area(uint8_t start_line, uint8_t end_line);
void oled_scroll_set_speed(uint8_t speed);
bool oled_scroll_right(void);
bool oled_scroll_left(void);
bool oled_scroll_off(void);
uint8_t oled_max_chars(void);
uint8_t oled_max_lines(void);