aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorbrickbots <rich@brickbots.com>2020-03-14 14:04:34 -0700
committerGitHub <noreply@github.com>2020-03-14 21:04:34 +0000
commitb5be96f8bb65d526a744795e8e3777d5ed47a034 (patch)
treed888e7c82e57b947407e26b1cf27ce565a9c4810 /drivers
parent7aa21cc287cd92cbfb8f3f7efce3a16058292349 (diff)
downloadqmk_firmware-b5be96f8bb65d526a744795e8e3777d5ed47a034.tar.gz
qmk_firmware-b5be96f8bb65d526a744795e8e3777d5ed47a034.zip
Adding OLED scroll setup functions (#8386)
* Adding scroll setup functions: * Clarifying values stored in oled_scroll_speed
Diffstat (limited to 'drivers')
-rw-r--r--drivers/oled/oled_driver.c36
-rw-r--r--drivers/oled/oled_driver.h12
2 files changed, 44 insertions, 4 deletions
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index 079f5688f..690efa4a6 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -108,6 +108,9 @@ bool oled_active = false;
108bool oled_scrolling = false; 108bool oled_scrolling = false;
109uint8_t oled_rotation = 0; 109uint8_t oled_rotation = 0;
110uint8_t oled_rotation_width = 0; 110uint8_t oled_rotation_width = 0;
111uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values
112uint8_t oled_scroll_start = 0;
113uint8_t oled_scroll_end = 7;
111#if OLED_TIMEOUT > 0 114#if OLED_TIMEOUT > 0
112uint32_t oled_timeout; 115uint32_t oled_timeout;
113#endif 116#endif
@@ -515,12 +518,37 @@ bool oled_off(void) {
515 return !oled_active; 518 return !oled_active;
516} 519}
517 520
521// Set the specific 8 lines rows of the screen to scroll.
522// 0 is the default for start, and 7 for end, which is the entire
523// height of the screen. For 128x32 screens, rows 4-7 are not used.
524void oled_scroll_set_area(uint8_t start_line, uint8_t end_line) {
525 oled_scroll_start = start_line;
526 oled_scroll_end = end_line;
527}
528
529void oled_scroll_set_speed(uint8_t speed) {
530 // Sets the speed for scrolling... does not take effect
531 // until scrolling is either started or restarted
532 // the ssd1306 supports 8 speeds
533 // FrameRate2 speed = 7
534 // FrameRate3 speed = 4
535 // FrameRate4 speed = 5
536 // FrameRate5 speed = 0
537 // FrameRate25 speed = 6
538 // FrameRate64 speed = 1
539 // FrameRate128 speed = 2
540 // FrameRate256 speed = 3
541 // for ease of use these are remaped here to be in order
542 static const uint8_t scroll_remap[8] = {7, 4, 5, 0, 6, 1, 2, 3};
543 oled_scroll_speed = scroll_remap[speed];
544}
545
518bool oled_scroll_right(void) { 546bool oled_scroll_right(void) {
519 // Dont enable scrolling if we need to update the display 547 // Dont enable scrolling if we need to update the display
520 // This prevents scrolling of bad data from starting the scroll too early after init 548 // This prevents scrolling of bad data from starting the scroll too early after init
521 if (!oled_dirty && !oled_scrolling) { 549 if (!oled_dirty && !oled_scrolling) {
522 static const uint8_t PROGMEM display_scroll_right[] = {I2C_CMD, SCROLL_RIGHT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL}; 550 uint8_t display_scroll_right[] = {I2C_CMD, SCROLL_RIGHT, 0x00, oled_scroll_start, oled_scroll_speed, oled_scroll_end, 0x00, 0xFF, ACTIVATE_SCROLL};
523 if (I2C_TRANSMIT_P(display_scroll_right) != I2C_STATUS_SUCCESS) { 551 if (I2C_TRANSMIT(display_scroll_right) != I2C_STATUS_SUCCESS) {
524 print("oled_scroll_right cmd failed\n"); 552 print("oled_scroll_right cmd failed\n");
525 return oled_scrolling; 553 return oled_scrolling;
526 } 554 }
@@ -533,8 +561,8 @@ bool oled_scroll_left(void) {
533 // Dont enable scrolling if we need to update the display 561 // Dont enable scrolling if we need to update the display
534 // This prevents scrolling of bad data from starting the scroll too early after init 562 // This prevents scrolling of bad data from starting the scroll too early after init
535 if (!oled_dirty && !oled_scrolling) { 563 if (!oled_dirty && !oled_scrolling) {
536 static const uint8_t PROGMEM display_scroll_left[] = {I2C_CMD, SCROLL_LEFT, 0x00, 0x00, 0x00, 0x0F, 0x00, 0xFF, ACTIVATE_SCROLL}; 564 uint8_t display_scroll_left[] = {I2C_CMD, SCROLL_LEFT, 0x00, oled_scroll_start, oled_scroll_speed, oled_scroll_end, 0x00, 0xFF, ACTIVATE_SCROLL};
537 if (I2C_TRANSMIT_P(display_scroll_left) != I2C_STATUS_SUCCESS) { 565 if (I2C_TRANSMIT(display_scroll_left) != I2C_STATUS_SUCCESS) {
538 print("oled_scroll_left cmd failed\n"); 566 print("oled_scroll_left cmd failed\n");
539 return oled_scrolling; 567 return oled_scrolling;
540 } 568 }
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 6d1cee9b7..3e5a5bcab 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -246,6 +246,18 @@ void oled_task(void);
246// Called at the start of oled_task, weak function overridable by the user 246// Called at the start of oled_task, weak function overridable by the user
247void oled_task_user(void); 247void oled_task_user(void);
248 248
249// Set the specific 8 lines rows of the screen to scroll.
250// 0 is the default for start, and 7 for end, which is the entire
251// height of the screen. For 128x32 screens, rows 4-7 are not used.
252void oled_scroll_set_area(uint8_t start_line, uint8_t end_line);
253
254// Sets scroll speed, 0-7, fastest to slowest. Default is three.
255// Does not take effect until scrolling is either started or restarted
256// the ssd1306 supports 8 speeds with the delay
257// listed below betwen each frame of the scrolling effect
258// 0=2, 1=3, 2=4, 3=5, 4=25, 5=64, 6=128, 7=256
259void oled_scroll_set_speed(uint8_t speed);
260
249// Scrolls the entire display right 261// Scrolls the entire display right
250// Returns true if the screen was scrolling or starts scrolling 262// Returns true if the screen was scrolling or starts scrolling
251// NOTE: display contents cannot be changed while scrolling 263// NOTE: display contents cannot be changed while scrolling