diff options
Diffstat (limited to 'drivers/oled')
| -rw-r--r-- | drivers/oled/oled_driver.c | 29 | ||||
| -rw-r--r-- | drivers/oled/oled_driver.h | 12 |
2 files changed, 39 insertions, 2 deletions
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 92c64399e..082115d53 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c | |||
| @@ -24,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | 24 | ||
| 25 | #include "progmem.h" | 25 | #include "progmem.h" |
| 26 | 26 | ||
| 27 | #include "keyboard.h" | ||
| 28 | |||
| 27 | // Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf | 29 | // Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf |
| 28 | // for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf | 30 | // for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf |
| 29 | 31 | ||
| @@ -71,6 +73,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 71 | #define PRE_CHARGE_PERIOD 0xD9 | 73 | #define PRE_CHARGE_PERIOD 0xD9 |
| 72 | #define VCOM_DETECT 0xDB | 74 | #define VCOM_DETECT 0xDB |
| 73 | 75 | ||
| 76 | // Advance Graphic Commands | ||
| 77 | #define FADE_BLINK 0x23 | ||
| 78 | #define ENABLE_FADE 0x20 | ||
| 79 | #define ENABLE_BLINK 0x30 | ||
| 80 | |||
| 74 | // Charge Pump Commands | 81 | // Charge Pump Commands |
| 75 | #define CHARGE_PUMP 0x8D | 82 | #define CHARGE_PUMP 0x8D |
| 76 | 83 | ||
| @@ -152,6 +159,12 @@ static void InvertCharacter(uint8_t *cursor) { | |||
| 152 | } | 159 | } |
| 153 | 160 | ||
| 154 | bool oled_init(uint8_t rotation) { | 161 | bool oled_init(uint8_t rotation) { |
| 162 | #if defined(USE_I2C) && defined(SPLIT_KEYBOARD) | ||
| 163 | if (!is_keyboard_master()) { | ||
| 164 | return true; | ||
| 165 | } | ||
| 166 | #endif | ||
| 167 | |||
| 155 | oled_rotation = oled_init_user(rotation); | 168 | oled_rotation = oled_init_user(rotation); |
| 156 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | 169 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { |
| 157 | oled_rotation_width = OLED_DISPLAY_WIDTH; | 170 | oled_rotation_width = OLED_DISPLAY_WIDTH; |
| @@ -539,7 +552,13 @@ bool oled_on(void) { | |||
| 539 | oled_timeout = timer_read32() + OLED_TIMEOUT; | 552 | oled_timeout = timer_read32() + OLED_TIMEOUT; |
| 540 | #endif | 553 | #endif |
| 541 | 554 | ||
| 542 | static const uint8_t PROGMEM display_on[] = {I2C_CMD, DISPLAY_ON}; | 555 | static const uint8_t PROGMEM display_on[] = |
| 556 | #ifdef OLED_FADE_OUT | ||
| 557 | {I2C_CMD, FADE_BLINK, 0x00}; | ||
| 558 | #else | ||
| 559 | {I2C_CMD, DISPLAY_ON}; | ||
| 560 | #endif | ||
| 561 | |||
| 543 | if (!oled_active) { | 562 | if (!oled_active) { |
| 544 | if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) { | 563 | if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) { |
| 545 | print("oled_on cmd failed\n"); | 564 | print("oled_on cmd failed\n"); |
| @@ -555,7 +574,13 @@ bool oled_off(void) { | |||
| 555 | return !oled_active; | 574 | return !oled_active; |
| 556 | } | 575 | } |
| 557 | 576 | ||
| 558 | static const uint8_t PROGMEM display_off[] = {I2C_CMD, DISPLAY_OFF}; | 577 | static const uint8_t PROGMEM display_off[] = |
| 578 | #ifdef OLED_FADE_OUT | ||
| 579 | {I2C_CMD, FADE_BLINK, ENABLE_FADE | OLED_FADE_OUT_INTERVAL}; | ||
| 580 | #else | ||
| 581 | {I2C_CMD, DISPLAY_OFF}; | ||
| 582 | #endif | ||
| 583 | |||
| 559 | if (oled_active) { | 584 | if (oled_active) { |
| 560 | if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) { | 585 | if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) { |
| 561 | print("oled_off cmd failed\n"); | 586 | print("oled_off cmd failed\n"); |
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index 72ab21247..cbf5380ee 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h | |||
| @@ -154,10 +154,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 154 | # endif | 154 | # endif |
| 155 | #endif | 155 | #endif |
| 156 | 156 | ||
| 157 | #if !defined(OLED_FADE_OUT_INTERVAL) | ||
| 158 | # define OLED_FADE_OUT_INTERVAL 0x00 | ||
| 159 | #endif | ||
| 160 | |||
| 161 | #if OLED_FADE_OUT_INTERVAL > 0x0F || OLED_FADE_OUT_INTERVAL < 0x00 | ||
| 162 | # error OLED_FADE_OUT_INTERVAL must be between 0x00 and 0x0F | ||
| 163 | #endif | ||
| 164 | |||
| 157 | #if !defined(OLED_I2C_TIMEOUT) | 165 | #if !defined(OLED_I2C_TIMEOUT) |
| 158 | # define OLED_I2C_TIMEOUT 100 | 166 | # define OLED_I2C_TIMEOUT 100 |
| 159 | #endif | 167 | #endif |
| 160 | 168 | ||
| 169 | #if !defined(OLED_UPDATE_INTERVAL) && defined(SPLIT_KEYBOARD) | ||
| 170 | # define OLED_UPDATE_INTERVAL 50 | ||
| 171 | #endif | ||
| 172 | |||
| 161 | typedef struct __attribute__((__packed__)) { | 173 | typedef struct __attribute__((__packed__)) { |
| 162 | uint8_t *current_element; | 174 | uint8_t *current_element; |
| 163 | uint16_t remaining_element_count; | 175 | uint16_t remaining_element_count; |
