aboutsummaryrefslogtreecommitdiff
path: root/drivers/oled/oled_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/oled/oled_driver.c')
-rw-r--r--drivers/oled/oled_driver.c36
1 files changed, 32 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 }