From c27d9424ed6c3a14e2cf8a8e98da3af5c0f6db54 Mon Sep 17 00:00:00 2001 From: Barabas Raffai Date: Sun, 3 Jan 2021 22:10:25 +0000 Subject: [PATCH 1/3] Added OLED fade out support Uses register 23h for a smooth fade out instead of turning off instantly. --- docs/feature_oled_driver.md | 32 +++++++++++++++++--------------- drivers/oled/oled_driver.c | 19 +++++++++++++++++-- drivers/oled/oled_driver.h | 8 ++++++++ 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md index 44202487f15e..e5750460da7a 100644 --- a/docs/feature_oled_driver.md +++ b/docs/feature_oled_driver.md @@ -136,21 +136,23 @@ void oled_task_user(void) { ## Basic Configuration -|Define |Default |Description | -|---------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------| -|`OLED_DISPLAY_ADDRESS` |`0x3C` |The i2c address of the OLED Display | -|`OLED_FONT_H` |`"glcdfont.c"` |The font code file to use for custom fonts | -|`OLED_FONT_START` |`0` |The starting character index for custom fonts | -|`OLED_FONT_END` |`223` |The ending character index for custom fonts | -|`OLED_FONT_WIDTH` |`6` |The font width | -|`OLED_FONT_HEIGHT` |`8` |The font height (untested) | -|`OLED_TIMEOUT` |`60000` |Turns off the OLED screen after 60000ms of keyboard inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | -|`OLED_SCROLL_TIMEOUT` |`0` |Scrolls the OLED screen after 0ms of OLED inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | -|`OLED_SCROLL_TIMEOUT_RIGHT`|*Not defined* |Scroll timeout direction is right when defined, left when undefined. | -|`OLED_IC` |`OLED_IC_SSD1306`|Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. | -|`OLED_COLUMN_OFFSET` |`0` |(SH1106 only.) Shift output to the right this many pixels.
Useful for 128x64 displays centered on a 132x64 SH1106 IC.| -|`OLED_BRIGHTNESS` |`255` |The default brightness level of the OLED, from 0 to 255. | -|`OLED_UPDATE_INTERVAL` |`0` |Set the time interval for updating the OLED display in ms. This will improve the matrix scan rate. | +|Define |Default |Description | +|-----------------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------| +|`OLED_DISPLAY_ADDRESS` |`0x3C` |The i2c address of the OLED Display | +|`OLED_FONT_H` |`"glcdfont.c"` |The font code file to use for custom fonts | +|`OLED_FONT_START` |`0` |The starting character index for custom fonts | +|`OLED_FONT_END` |`223` |The ending character index for custom fonts | +|`OLED_FONT_WIDTH` |`6` |The font width | +|`OLED_FONT_HEIGHT` |`8` |The font height (untested) | +|`OLED_TIMEOUT` |`60000` |Turns off the OLED screen after 60000ms of keyboard inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | +|`OLED_DRIVER_DISPLAY_FADE` |*Not defined* |Enables fade out animation. Use together with `OLED_TIMEOUT`. | +|`OLED_DRIVER_DISPLAY_FADE_INTERVAL`|`0` |The speed of fade out animation, from 0 to 15. Larger values are slower. | +|`OLED_SCROLL_TIMEOUT` |`0` |Scrolls the OLED screen after 0ms of OLED inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | +|`OLED_SCROLL_TIMEOUT_RIGHT` |*Not defined* |Scroll timeout direction is right when defined, left when undefined. | +|`OLED_IC` |`OLED_IC_SSD1306`|Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. | +|`OLED_COLUMN_OFFSET` |`0` |(SH1106 only.) Shift output to the right this many pixels.
Useful for 128x64 displays centered on a 132x64 SH1106 IC.| +|`OLED_BRIGHTNESS` |`255` |The default brightness level of the OLED, from 0 to 255. | +|`OLED_UPDATE_INTERVAL` |`0` |Set the time interval for updating the OLED display in ms. This will improve the matrix scan rate. | ## 128x64 & Custom sized OLED Displays diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 6c1238cd6f16..fa57df9f454d 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c @@ -73,6 +73,9 @@ along with this program. If not, see . #define PRE_CHARGE_PERIOD 0xD9 #define VCOM_DETECT 0xDB +// Advance Graphic Commands +#define FADE_BLINK 0x23 + // Charge Pump Commands #define CHARGE_PUMP 0x8D @@ -547,7 +550,13 @@ bool oled_on(void) { oled_timeout = timer_read32() + OLED_TIMEOUT; #endif - static const uint8_t PROGMEM display_on[] = {I2C_CMD, DISPLAY_ON}; + static const uint8_t PROGMEM display_on[] = +#ifdef OLED_DRIVER_DISPLAY_FADE + {I2C_CMD, FADE_BLINK, 0x00}; +#else + {I2C_CMD, DISPLAY_ON}; +#endif + if (!oled_active) { if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) { print("oled_on cmd failed\n"); @@ -563,7 +572,13 @@ bool oled_off(void) { return !oled_active; } - static const uint8_t PROGMEM display_off[] = {I2C_CMD, DISPLAY_OFF}; + static const uint8_t PROGMEM display_off[] = +#ifdef OLED_DRIVER_DISPLAY_FADE + {I2C_CMD, FADE_BLINK, 0x20 | OLED_DRIVER_DISPLAY_FADE_INTERVAL}; +#else + {I2C_CMD, DISPLAY_OFF}; +#endif + if (oled_active) { if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) { print("oled_off cmd failed\n"); diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index 00896f01c2b5..1070ebc07117 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h @@ -154,6 +154,14 @@ along with this program. If not, see . # endif #endif +#if !defined(OLED_DRIVER_DISPLAY_FADE_INTERVAL) +# define OLED_DRIVER_DISPLAY_FADE_INTERVAL 0x00 +#endif + +#if OLED_DRIVER_DISPLAY_FADE_INTERVAL > 0x0F || OLED_DRIVER_DISPLAY_FADE_INTERVAL < 0x00 +# error OLED_DRIVER_DISPLAY_FADE_INTERVAL must be between 0x00 and 0x0F +#endif + #if !defined(OLED_I2C_TIMEOUT) # define OLED_I2C_TIMEOUT 100 #endif From ad46312e01a1ce456fb1f345512c24ab57b3aeea Mon Sep 17 00:00:00 2001 From: Barabas Raffai Date: Sun, 14 Mar 2021 09:57:33 +0000 Subject: [PATCH 2/3] Add definitions for values of the OLED FADE_BLINK register --- drivers/oled/oled_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index fa57df9f454d..335a5108d663 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c @@ -75,6 +75,8 @@ along with this program. If not, see . // Advance Graphic Commands #define FADE_BLINK 0x23 +#define ENABLE_FADE 0x20 +#define ENABLE_BLINK 0x30 // Charge Pump Commands #define CHARGE_PUMP 0x8D @@ -574,7 +576,7 @@ bool oled_off(void) { static const uint8_t PROGMEM display_off[] = #ifdef OLED_DRIVER_DISPLAY_FADE - {I2C_CMD, FADE_BLINK, 0x20 | OLED_DRIVER_DISPLAY_FADE_INTERVAL}; + {I2C_CMD, FADE_BLINK, ENABLE_FADE | OLED_DRIVER_DISPLAY_FADE_INTERVAL}; #else {I2C_CMD, DISPLAY_OFF}; #endif From 18b29b26423e58ddb06a4fce24fefe8e83942e9d Mon Sep 17 00:00:00 2001 From: Barabas Raffai Date: Wed, 28 Apr 2021 18:31:32 +0100 Subject: [PATCH 3/3] Update OLED fade define names --- docs/feature_oled_driver.md | 34 +++++++++++++++++----------------- drivers/oled/oled_driver.c | 6 +++--- drivers/oled/oled_driver.h | 8 ++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md index e5750460da7a..d2dc6103a687 100644 --- a/docs/feature_oled_driver.md +++ b/docs/feature_oled_driver.md @@ -136,23 +136,23 @@ void oled_task_user(void) { ## Basic Configuration -|Define |Default |Description | -|-----------------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------| -|`OLED_DISPLAY_ADDRESS` |`0x3C` |The i2c address of the OLED Display | -|`OLED_FONT_H` |`"glcdfont.c"` |The font code file to use for custom fonts | -|`OLED_FONT_START` |`0` |The starting character index for custom fonts | -|`OLED_FONT_END` |`223` |The ending character index for custom fonts | -|`OLED_FONT_WIDTH` |`6` |The font width | -|`OLED_FONT_HEIGHT` |`8` |The font height (untested) | -|`OLED_TIMEOUT` |`60000` |Turns off the OLED screen after 60000ms of keyboard inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | -|`OLED_DRIVER_DISPLAY_FADE` |*Not defined* |Enables fade out animation. Use together with `OLED_TIMEOUT`. | -|`OLED_DRIVER_DISPLAY_FADE_INTERVAL`|`0` |The speed of fade out animation, from 0 to 15. Larger values are slower. | -|`OLED_SCROLL_TIMEOUT` |`0` |Scrolls the OLED screen after 0ms of OLED inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | -|`OLED_SCROLL_TIMEOUT_RIGHT` |*Not defined* |Scroll timeout direction is right when defined, left when undefined. | -|`OLED_IC` |`OLED_IC_SSD1306`|Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. | -|`OLED_COLUMN_OFFSET` |`0` |(SH1106 only.) Shift output to the right this many pixels.
Useful for 128x64 displays centered on a 132x64 SH1106 IC.| -|`OLED_BRIGHTNESS` |`255` |The default brightness level of the OLED, from 0 to 255. | -|`OLED_UPDATE_INTERVAL` |`0` |Set the time interval for updating the OLED display in ms. This will improve the matrix scan rate. | +|Define |Default |Description | +|---------------------------|-----------------|--------------------------------------------------------------------------------------------------------------------------| +|`OLED_DISPLAY_ADDRESS` |`0x3C` |The i2c address of the OLED Display | +|`OLED_FONT_H` |`"glcdfont.c"` |The font code file to use for custom fonts | +|`OLED_FONT_START` |`0` |The starting character index for custom fonts | +|`OLED_FONT_END` |`223` |The ending character index for custom fonts | +|`OLED_FONT_WIDTH` |`6` |The font width | +|`OLED_FONT_HEIGHT` |`8` |The font height (untested) | +|`OLED_TIMEOUT` |`60000` |Turns off the OLED screen after 60000ms of keyboard inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | +|`OLED_FADE_OUT` |*Not defined* |Enables fade out animation. Use together with `OLED_TIMEOUT`. | +|`OLED_FADE_OUT_INTERVAL` |`0` |The speed of fade out animation, from 0 to 15. Larger values are slower. | +|`OLED_SCROLL_TIMEOUT` |`0` |Scrolls the OLED screen after 0ms of OLED inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. | +|`OLED_SCROLL_TIMEOUT_RIGHT`|*Not defined* |Scroll timeout direction is right when defined, left when undefined. | +|`OLED_IC` |`OLED_IC_SSD1306`|Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. | +|`OLED_COLUMN_OFFSET` |`0` |(SH1106 only.) Shift output to the right this many pixels.
Useful for 128x64 displays centered on a 132x64 SH1106 IC.| +|`OLED_BRIGHTNESS` |`255` |The default brightness level of the OLED, from 0 to 255. | +|`OLED_UPDATE_INTERVAL` |`0` |Set the time interval for updating the OLED display in ms. This will improve the matrix scan rate. | ## 128x64 & Custom sized OLED Displays diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 335a5108d663..082115d53434 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c @@ -553,7 +553,7 @@ bool oled_on(void) { #endif static const uint8_t PROGMEM display_on[] = -#ifdef OLED_DRIVER_DISPLAY_FADE +#ifdef OLED_FADE_OUT {I2C_CMD, FADE_BLINK, 0x00}; #else {I2C_CMD, DISPLAY_ON}; @@ -575,8 +575,8 @@ bool oled_off(void) { } static const uint8_t PROGMEM display_off[] = -#ifdef OLED_DRIVER_DISPLAY_FADE - {I2C_CMD, FADE_BLINK, ENABLE_FADE | OLED_DRIVER_DISPLAY_FADE_INTERVAL}; +#ifdef OLED_FADE_OUT + {I2C_CMD, FADE_BLINK, ENABLE_FADE | OLED_FADE_OUT_INTERVAL}; #else {I2C_CMD, DISPLAY_OFF}; #endif diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index 1070ebc07117..cbf5380ee089 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h @@ -154,12 +154,12 @@ along with this program. If not, see . # endif #endif -#if !defined(OLED_DRIVER_DISPLAY_FADE_INTERVAL) -# define OLED_DRIVER_DISPLAY_FADE_INTERVAL 0x00 +#if !defined(OLED_FADE_OUT_INTERVAL) +# define OLED_FADE_OUT_INTERVAL 0x00 #endif -#if OLED_DRIVER_DISPLAY_FADE_INTERVAL > 0x0F || OLED_DRIVER_DISPLAY_FADE_INTERVAL < 0x00 -# error OLED_DRIVER_DISPLAY_FADE_INTERVAL must be between 0x00 and 0x0F +#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)