Skip to content

Commit

Permalink
OLED display update interval support (qmk#10388)
Browse files Browse the repository at this point in the history
* add OLED_UPDATE_INTERVAL_MS support

* update docs/feature_oled_driver.md

* Update docs/feature_oled_driver.md

Co-authored-by: Joel Challis <[email protected]>

* Update drivers/oled/oled_driver.c

* Update drivers/oled/oled_driver.c

Co-authored-by: Joel Challis <[email protected]>
  • Loading branch information
2 people authored and KarlK90 committed Nov 19, 2020
1 parent 9e32e9b commit 33e8a2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
6 changes: 0 additions & 6 deletions docs/feature_oled_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,6 @@ bool oled_off(void);
// not
bool is_oled_on(void);

// Sets the brightness level of the display
uint8_t oled_set_brightness(uint8_t level);

// Gets the current brightness level of the display
uint8_t oled_get_brightness(void);

// Basically it's oled_render, but with timeout management and oled_task_user calling!
void oled_task(void);

Expand Down
26 changes: 5 additions & 21 deletions drivers/oled/oled_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ bool oled_init(uint8_t rotation) {
}
}

static const uint8_t PROGMEM display_setup2[] = {I2C_CMD, COM_PINS, OLED_COM_PINS, CONTRAST, OLED_BRIGHTNESS, PRE_CHARGE_PERIOD, 0xF1, VCOM_DETECT, 0x20, DISPLAY_ALL_ON_RESUME, NORMAL_DISPLAY, DEACTIVATE_SCROLL, DISPLAY_ON};
static const uint8_t PROGMEM display_setup2[] = {I2C_CMD, COM_PINS, OLED_COM_PINS, CONTRAST, 0x8F, PRE_CHARGE_PERIOD, 0xF1, VCOM_DETECT, 0x40, DISPLAY_ALL_ON_RESUME, NORMAL_DISPLAY, DEACTIVATE_SCROLL, DISPLAY_ON};
if (I2C_TRANSMIT_P(display_setup2) != I2C_STATUS_SUCCESS) {
print("display_setup2 failed\n");
return false;
Expand Down Expand Up @@ -471,9 +471,8 @@ void oled_write_raw_byte(const char data, uint16_t index) {
}

void oled_write_raw(const char *data, uint16_t size) {
uint16_t cursor_start_index = oled_cursor - &oled_buffer[0];
if ((size + cursor_start_index) > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE - cursor_start_index;
for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) {
if (size > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE;
for (uint16_t i = 0; i < size; i++) {
if (oled_buffer[i] == data[i]) continue;
oled_buffer[i] = data[i];
oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE));
Expand Down Expand Up @@ -515,9 +514,8 @@ void oled_write_ln_P(const char *data, bool invert) {
}

void oled_write_raw_P(const char *data, uint16_t size) {
uint16_t cursor_start_index = oled_cursor - &oled_buffer[0];
if ((size + cursor_start_index) > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE - cursor_start_index;
for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) {
if (size > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE;
for (uint16_t i = 0; i < size; i++) {
uint8_t c = pgm_read_byte(data++);
if (oled_buffer[i] == c) continue;
oled_buffer[i] = c;
Expand Down Expand Up @@ -556,20 +554,6 @@ bool oled_off(void) {

bool is_oled_on(void) { return oled_active; }

uint8_t oled_set_brightness(uint8_t level) {
uint8_t set_contrast[] = {I2C_CMD, CONTRAST, level};
if (oled_brightness != level) {
if (I2C_TRANSMIT(set_contrast) != I2C_STATUS_SUCCESS) {
print("set_brightness cmd failed\n");
return oled_brightness;
}
oled_brightness = level;
}
return oled_brightness;
}

uint8_t oled_get_brightness(void) { return oled_brightness; }

// Set the specific 8 lines rows of the screen to scroll.
// 0 is the default for start, and 7 for end, which is the entire
// height of the screen. For 128x32 screens, rows 4-7 are not used.
Expand Down

0 comments on commit 33e8a2b

Please sign in to comment.