123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- #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_I2C_TIMEOUT)
- # define OLED_I2C_TIMEOUT 100
- #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);
|