summaryrefslogtreecommitdiffstats
path: root/keyboards/draculad/keymaps
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-08-04 11:30:49 -0700
committerGitHub <noreply@github.com>2021-08-04 11:30:49 -0700
commit3568eafd6564fe74264cfedd20cba47a4566eb26 (patch)
tree40940d76a408e6aa4eaf0ef13c7c8dc027f9643a /keyboards/draculad/keymaps
parent6525b82f5f8268ee0064d0f59cbc75dd295f8755 (diff)
[Keyboard] Switch Draculad to using WPM char hack (#13886)
Diffstat (limited to 'keyboards/draculad/keymaps')
-rw-r--r--keyboards/draculad/keymaps/default/keymap.c26
-rw-r--r--keyboards/draculad/keymaps/pimoroni/keymap.c25
2 files changed, 28 insertions, 23 deletions
diff --git a/keyboards/draculad/keymaps/default/keymap.c b/keyboards/draculad/keymaps/default/keymap.c
index 1d3591ce99..d19aa66257 100644
--- a/keyboards/draculad/keymaps/default/keymap.c
+++ b/keyboards/draculad/keymaps/default/keymap.c
@@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include QMK_KEYBOARD_H
-
enum layer_number {
_BASE,
_NUM,
@@ -26,9 +25,6 @@ enum layer_number {
_ADJ
};
-
-char wpm_as_str[8];
-
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE] = LAYOUT(
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,
@@ -155,14 +151,20 @@ static void render_logo(void) {
}
static void render_status(void) {
- oled_write_P(PSTR("This is\n~~~~~~~~~\nDracu\nLad\n~~~~~~~~~\nv1.0\n~~~~~~~~~\n"), false);
- sprintf(wpm_as_str, "WPM %03d", get_current_wpm());
- oled_write(wpm_as_str,false);
- led_t led_state = host_keyboard_led_state();
- oled_write_P(PSTR("\nCaps: "), false);
- oled_write_P(led_state.caps_lock ? PSTR("on ") : PSTR("off"), false);
- oled_write_P(PSTR("\n"),false);
- switch (get_highest_layer(layer_state)) {
+ oled_write_P(PSTR("This is\n~~~~~~~~~\nDracu\nLad\n~~~~~~~~~\nv1.0\n~~~~~~~~~\n"), false);
+ uint8_t n = get_current_wpm();
+ char wpm_counter[4];
+ wpm_counter[3] = '\0';
+ wpm_counter[2] = '0' + n % 10;
+ wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
+ wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
+ oled_write_P(PSTR("WPM:"), false);
+ oled_write(wpm_counter, false);
+ led_t led_state = host_keyboard_led_state();
+ oled_write_P(PSTR("\nCaps: "), false);
+ oled_write_P(led_state.caps_lock ? PSTR("on ") : PSTR("off"), false);
+ oled_write_P(PSTR("\n"), false);
+ switch (get_highest_layer(layer_state)) {
case _BASE:
oled_write_P(PSTR("Base "), false);
break;
diff --git a/keyboards/draculad/keymaps/pimoroni/keymap.c b/keyboards/draculad/keymaps/pimoroni/keymap.c
index 762ae26c70..9af6185768 100644
--- a/keyboards/draculad/keymaps/pimoroni/keymap.c
+++ b/keyboards/draculad/keymaps/pimoroni/keymap.c
@@ -38,9 +38,6 @@ enum custom_keycodes {
BALL_MCL,//middle click
};
-
-char wpm_as_str[8];
-
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE] = LAYOUT(
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,
@@ -168,14 +165,20 @@ static void render_logo(void) {
}
static void render_status(void) {
- oled_write_P(PSTR("This is\n~~~~~~~~~\nDracu\nLad\n~~~~~~~~~\nv1.0\n~~~~~~~~~\n"), false);
- sprintf(wpm_as_str, "WPM %03d", get_current_wpm());
- oled_write(wpm_as_str,false);
- led_t led_state = host_keyboard_led_state();
- oled_write_P(PSTR("\nCaps: "), false);
- oled_write_P(led_state.caps_lock ? PSTR("on ") : PSTR("off"), false);
- oled_write_P(PSTR("\n"),false);
- switch (get_highest_layer(layer_state)) {
+ oled_write_P(PSTR("This is\n~~~~~~~~~\nDracu\nLad\n~~~~~~~~~\nv1.0\n~~~~~~~~~\n"), false);
+ uint8_t n = get_current_wpm();
+ char wpm_counter[4];
+ wpm_counter[3] = '\0';
+ wpm_counter[2] = '0' + n % 10;
+ wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
+ wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
+ oled_write_P(PSTR("WPM:"), false);
+ oled_write(wpm_counter, false);
+ led_t led_state = host_keyboard_led_state();
+ oled_write_P(PSTR("\nCaps: "), false);
+ oled_write_P(led_state.caps_lock ? PSTR("on ") : PSTR("off"), false);
+ oled_write_P(PSTR("\n"), false);
+ switch (get_highest_layer(layer_state)) {
case _BASE:
oled_write_P(PSTR("Base "), false);
break;