Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Change OLED task function to be boolean #14864

Merged
merged 6 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/feature_oled_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Then in your `keymap.c` file, implement the OLED task call. This example assumes

```c
#ifdef OLED_ENABLE
void oled_task_user(void) {
bool oled_task_user(void) {
// Host Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);

Expand All @@ -62,6 +62,8 @@ void oled_task_user(void) {
oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);

return false;
}
#endif
```
Expand Down Expand Up @@ -133,13 +135,14 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return rotation;
}

void oled_task_user(void) {
bool oled_task_user(void) {
if (is_keyboard_master()) {
render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
} else {
render_logo(); // Renders a static logo
oled_scroll_left(); // Turns on scrolling
}
return false;
}
#endif
```
Expand Down Expand Up @@ -237,6 +240,7 @@ bool oled_init(oled_rotation_t rotation);
// Called at the start of oled_init, weak function overridable by the user
// rotation - the value passed into oled_init
// Return new oled_rotation_t if you want to override default rotation
oled_rotation_t oled_init_kb(oled_rotation_t rotation);
oled_rotation_t oled_init_user(oled_rotation_t rotation);

// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering
Expand Down Expand Up @@ -328,7 +332,8 @@ uint8_t oled_get_brightness(void);
void oled_task(void);

// Called at the start of oled_task, weak function overridable by the user
void oled_task_user(void);
bool oled_task_kb(void);
bool oled_task_user(void);

// 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
Expand Down
4 changes: 3 additions & 1 deletion drivers/oled/oled_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ bool oled_init(oled_rotation_t rotation);
// Called at the start of oled_init, weak function overridable by the user
// rotation - the value passed into oled_init
// Return new oled_rotation_t if you want to override default rotation
oled_rotation_t oled_init_kb(oled_rotation_t rotation);
oled_rotation_t oled_init_user(oled_rotation_t rotation);

// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering
Expand Down Expand Up @@ -285,7 +286,8 @@ uint8_t oled_get_brightness(void);
void oled_task(void);

// Called at the start of oled_task, weak function overridable by the user
void oled_task_user(void);
bool oled_task_kb(void);
bool oled_task_user(void);

// 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
Expand Down
10 changes: 6 additions & 4 deletions drivers/oled/ssd1306_sh1106.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ bool oled_init(oled_rotation_t rotation) {
}
#endif

oled_rotation = oled_init_user(rotation);
oled_rotation = oled_init_user(oled_init_kb(rotation));
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
oled_rotation_width = OLED_DISPLAY_WIDTH;
} else {
Expand Down Expand Up @@ -232,6 +232,7 @@ bool oled_init(oled_rotation_t rotation) {
return true;
}

__attribute__((weak)) oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return rotation; }
__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; }

void oled_clear(void) {
Expand Down Expand Up @@ -741,11 +742,11 @@ void oled_task(void) {
if (timer_elapsed(oled_update_timeout) >= OLED_UPDATE_INTERVAL) {
oled_update_timeout = timer_read();
oled_set_cursor(0, 0);
oled_task_user();
oled_task_kb();
}
#else
oled_set_cursor(0, 0);
oled_task_user();
oled_task_kb();
#endif

#if OLED_SCROLL_TIMEOUT > 0
Expand Down Expand Up @@ -776,4 +777,5 @@ void oled_task(void) {
#endif
}

__attribute__((weak)) void oled_task_user(void) {}
__attribute__((weak)) bool oled_task_kb(void) { return oled_task_user(); }
__attribute__((weak)) bool oled_task_user(void) { return true; }
3 changes: 2 additions & 1 deletion keyboards/0xcb/1337/keymaps/conor/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static void render_rgbled_status(bool) {
oled_write_ln_P(PSTR("\n"), false);
}
}
void oled_task_user(void) {
bool oled_task_user(void) {
static bool finished_timer = false;
if (!finished_timer && (timer_elapsed(startup_timer) < 1000)) {
render_logo();
Expand All @@ -181,5 +181,6 @@ void oled_task_user(void) {
render_rgbled_status(true);
render_logo_font();
}
return false;
}
#endif
3 changes: 2 additions & 1 deletion keyboards/0xcb/1337/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void render_rgbled_status(void) {
oled_write_ln_P(PSTR("\n"), false);
}
}
void oled_task_user(void) {
bool oled_task_user(void) {
static bool finished_timer = false;
if (!finished_timer && (timer_elapsed(startup_timer) < 1000)) {
render_logo();
Expand All @@ -172,5 +172,6 @@ void oled_task_user(void) {
render_rgbled_status();
render_logo_font();
}
return false;
}
#endif
3 changes: 2 additions & 1 deletion keyboards/0xcb/1337/keymaps/jakob/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static void render_rgbled_status(bool) {
oled_write_ln_P(PSTR("\n"), false);
}
}
void oled_task_user(void) {
bool oled_task_user(void) {
static bool finished_timer = false;
if (!finished_timer && (timer_elapsed(startup_timer) < 1000)) {
render_logo();
Expand All @@ -181,5 +181,6 @@ void oled_task_user(void) {
render_rgbled_status(true);
render_logo_font();
}
return false;
}
#endif
3 changes: 2 additions & 1 deletion keyboards/0xcb/1337/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static void render_rgbled_status(void) {
oled_write_ln_P(PSTR("\n"), false);
}
}
void oled_task_user(void) {
bool oled_task_user(void) {
static bool finished_timer = false;
if (!finished_timer && (timer_elapsed(startup_timer) < 1000)) {
render_logo();
Expand All @@ -181,5 +181,6 @@ void oled_task_user(void) {
render_rgbled_status();
render_logo_font();
}
return false;
}
#endif
3 changes: 2 additions & 1 deletion keyboards/0xcb/static/keymaps/bongocat/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static void render_cat(void) {
}
}

void oled_task_user(void) {
bool oled_task_user(void) {
static bool finished_timer = false;
if (!finished_timer && (timer_elapsed(startup_timer) < 3000)) {
render_logo();
Expand All @@ -286,6 +286,7 @@ void oled_task_user(void) {
render_layer();
}
}
return false;
}
#endif

Expand Down
3 changes: 2 additions & 1 deletion keyboards/0xcb/static/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static void render_layer(void) {
oled_write_P(logo[3][2], false);
}

void oled_task_user(void) {
bool oled_task_user(void) {
static bool finished_timer = false;
if (!finished_timer && (timer_elapsed(startup_timer) < 3000)) {
render_logo();
Expand All @@ -186,5 +186,6 @@ void oled_task_user(void) {
}
render_layer();
}
return false;
}
#endif
3 changes: 2 additions & 1 deletion keyboards/0xcb/static/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static void render_layer(void) {
oled_write_P(logo[3][2], false);
}

void oled_task_user(void) {
bool oled_task_user(void) {
static bool finished_timer = false;
if (!finished_timer && (timer_elapsed(startup_timer) < 3000)) {
render_logo();
Expand All @@ -186,6 +186,7 @@ void oled_task_user(void) {
}
render_layer();
}
return false;
}
#endif

Expand Down
5 changes: 4 additions & 1 deletion keyboards/10bleoledhub/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ static void render_logo(void) {
}

#ifdef OLED_ENABLE
void oled_task_user(void) { render_logo(); }
bool oled_task_user(void) {
render_logo();
return false;
}
#endif

bool encoder_update_user(uint8_t index, bool clockwise) {
Expand Down
5 changes: 4 additions & 1 deletion keyboards/10bleoledhub/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ static void render_logo(void) {
}

#ifdef OLED_ENABLE
void oled_task_user(void) { render_logo(); }
bool oled_task_user(void) {
render_logo();
return false;
}
#endif

bool encoder_update_user(uint8_t index, bool clockwise) {
Expand Down
3 changes: 2 additions & 1 deletion keyboards/aeboards/ext65/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ void render_mod_status(uint8_t modifiers) {
oled_write_ln(PSTR(" "), false);
}

void oled_task_user(void) {
bool oled_task_user(void) {
render_layer_state();
render_keylock_status(host_keyboard_led_state());
render_mod_status(get_mods()|get_oneshot_mods());
return false;
}

#endif
3 changes: 2 additions & 1 deletion keyboards/aeboards/ext65/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ void render_mod_status(uint8_t modifiers) {
oled_write_ln(PSTR(" "), false);
}

void oled_task_user(void) {
bool oled_task_user(void) {
render_layer_state();
render_keylock_status(host_keyboard_led_state());
render_mod_status(get_mods()|get_oneshot_mods());
return false;
}

#endif
2 changes: 1 addition & 1 deletion keyboards/aeboards/ext65/rev2/rev2.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void board_init(void) {
SYSCFG->CFGR1 &= ~(SYSCFG_CFGR1_SPI2_DMA_RMP);
}

oled_rotation_t oled_init_user(oled_rotation_t rotation) {
oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
return OLED_ROTATION_90; // rotates the display 90 degrees
}

Expand Down
3 changes: 2 additions & 1 deletion keyboards/aleblazer/zodiark/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return rotation;
}

void oled_task_user(void) {
bool oled_task_user(void) {
if (is_keyboard_master()) {
print_status_narrow();
} else {
render_logo();
}
return false;
}

#endif
Expand Down
3 changes: 2 additions & 1 deletion keyboards/aleblazer/zodiark/keymaps/slimoled/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return rotation;
}

void oled_task_user(void) {
bool oled_task_user(void) {
if (is_keyboard_master()) {
print_status_narrow();
} else {
render_logo();
}
return false;
}

#endif
Expand Down
3 changes: 2 additions & 1 deletion keyboards/aleblazer/zodiark/keymaps/via/oled.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return rotation;
}

void oled_task_user(void) {
bool oled_task_user(void) {
if (is_keyboard_master()) {
print_status_narrow();
} else {
render_logo();
}
return false;
}

#endif
3 changes: 2 additions & 1 deletion keyboards/anavi/macropad8/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
}

void oled_task_user(void) {
bool oled_task_user(void) {
// Host Keyboard Layer Status
oled_write_ln_P(PSTR("ANAVI Macro Pad 8"), false);
oled_write_P(PSTR("Active layer: "), false);
Expand Down Expand Up @@ -57,5 +57,6 @@ void oled_task_user(void) {
snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
oled_write_ln(rgbStatusLine2, false);
#endif
return false;
}
#endif
3 changes: 2 additions & 1 deletion keyboards/anavi/macropad8/keymaps/git/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
}

void oled_task_user(void) {
bool oled_task_user(void) {
// Host Keyboard Layer Status
oled_write_ln_P(PSTR("ANAVI Macro Pad 8"), false);
oled_write_P(PSTR("Active layer: "), false);
Expand Down Expand Up @@ -140,5 +140,6 @@ void oled_task_user(void) {
snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
oled_write_ln(rgbStatusLine2, false);
#endif
return false;
}
#endif
3 changes: 2 additions & 1 deletion keyboards/anavi/macropad8/keymaps/kicad/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
}

void oled_task_user(void) {
bool oled_task_user(void) {
// Host Keyboard Layer Status
oled_write_ln_P(PSTR("ANAVI Macro Pad 8"), false);
oled_write_P(PSTR("Layer: "), false);
Expand Down Expand Up @@ -113,5 +113,6 @@ void oled_task_user(void) {
snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
oled_write_ln(rgbStatusLine2, false);
#endif
return false;
}
#endif
3 changes: 2 additions & 1 deletion keyboards/anavi/macropad8/keymaps/kodi/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return OLED_ROTATION_180; // flips the display 180 degrees if offhand
}

void oled_task_user(void) {
bool oled_task_user(void) {
// Host Keyboard Layer Status
oled_write_ln_P(PSTR("ANAVI Macro Pad 8"), false);
oled_write_P(PSTR("Active layer: "), false);
Expand Down Expand Up @@ -76,5 +76,6 @@ void oled_task_user(void) {
snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
oled_write_ln(rgbStatusLine2, false);
#endif
return false;
}
#endif
Loading