diff options
author | Ryan <fauxpark@gmail.com> | 2021-06-19 18:51:35 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-19 18:51:35 +1000 |
commit | 37fba09021fe094ea4daf0813626b1b6a201c8c0 (patch) | |
tree | 7dc87da3d0852f521a63f8c6f665137821815d92 /drivers | |
parent | 0311c8036d693baf63ed4d3b7badf4257ffd5f46 (diff) | |
download | qmk_firmware-37fba09021fe094ea4daf0813626b1b6a201c8c0.tar.gz qmk_firmware-37fba09021fe094ea4daf0813626b1b6a201c8c0.zip |
ST7565 invert (#13237)
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/lcd/st7565.c | 16 | ||||
-rw-r--r-- | drivers/lcd/st7565.h | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c index ee2661a5e..49b13c00f 100644 --- a/drivers/lcd/st7565.c +++ b/drivers/lcd/st7565.c | |||
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
31 | #define DISPLAY_ALL_ON 0xA5 | 31 | #define DISPLAY_ALL_ON 0xA5 |
32 | #define DISPLAY_ALL_ON_RESUME 0xA4 | 32 | #define DISPLAY_ALL_ON_RESUME 0xA4 |
33 | #define NORMAL_DISPLAY 0xA6 | 33 | #define NORMAL_DISPLAY 0xA6 |
34 | #define INVERT_DISPLAY 0xA7 | ||
34 | #define DISPLAY_ON 0xAF | 35 | #define DISPLAY_ON 0xAF |
35 | #define DISPLAY_OFF 0xAE | 36 | #define DISPLAY_OFF 0xAE |
36 | #define NOP 0xE3 | 37 | #define NOP 0xE3 |
@@ -72,6 +73,7 @@ uint8_t * st7565_cursor; | |||
72 | ST7565_BLOCK_TYPE st7565_dirty = 0; | 73 | ST7565_BLOCK_TYPE st7565_dirty = 0; |
73 | bool st7565_initialized = false; | 74 | bool st7565_initialized = false; |
74 | bool st7565_active = false; | 75 | bool st7565_active = false; |
76 | bool st7565_inverted = false; | ||
75 | display_rotation_t st7565_rotation = DISPLAY_ROTATION_0; | 77 | display_rotation_t st7565_rotation = DISPLAY_ROTATION_0; |
76 | #if ST7565_TIMEOUT > 0 | 78 | #if ST7565_TIMEOUT > 0 |
77 | uint32_t st7565_timeout; | 79 | uint32_t st7565_timeout; |
@@ -429,6 +431,20 @@ __attribute__((weak)) void st7565_off_user(void) {} | |||
429 | 431 | ||
430 | bool st7565_is_on(void) { return st7565_active; } | 432 | bool st7565_is_on(void) { return st7565_active; } |
431 | 433 | ||
434 | bool st7565_invert(bool invert) { | ||
435 | if (!st7565_initialized) { | ||
436 | return st7565_inverted; | ||
437 | } | ||
438 | |||
439 | if (invert != st7565_inverted) { | ||
440 | spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR); | ||
441 | st7565_send_cmd(invert ? INVERT_DISPLAY : NORMAL_DISPLAY); | ||
442 | spi_stop(); | ||
443 | st7565_inverted = invert; | ||
444 | } | ||
445 | return st7565_inverted; | ||
446 | } | ||
447 | |||
432 | uint8_t st7565_max_chars(void) { return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; } | 448 | uint8_t st7565_max_chars(void) { return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; } |
433 | 449 | ||
434 | uint8_t st7565_max_lines(void) { return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; } | 450 | uint8_t st7565_max_lines(void) { return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; } |
diff --git a/drivers/lcd/st7565.h b/drivers/lcd/st7565.h index 53cfc9a81..d453dbe6d 100644 --- a/drivers/lcd/st7565.h +++ b/drivers/lcd/st7565.h | |||
@@ -202,6 +202,10 @@ void st7565_task(void); | |||
202 | // Called at the start of st7565_task, weak function overridable by the user | 202 | // Called at the start of st7565_task, weak function overridable by the user |
203 | void st7565_task_user(void); | 203 | void st7565_task_user(void); |
204 | 204 | ||
205 | // Inverts the display | ||
206 | // Returns true if the screen was or is inverted | ||
207 | bool st7565_invert(bool invert); | ||
208 | |||
205 | // Returns the maximum number of characters that will fit on a line | 209 | // Returns the maximum number of characters that will fit on a line |
206 | uint8_t st7565_max_chars(void); | 210 | uint8_t st7565_max_chars(void); |
207 | 211 | ||