Skip to content

Commit

Permalink
Jonavin mercutio - reduce mem footprint (qmk#17498)
Browse files Browse the repository at this point in the history
* Reduce mem footprint - remove sprintf

* remove stdio reference and use get_u8_str

Co-authored-by: Jonavin <=>
  • Loading branch information
Jonavin authored and nolanseaton committed Jan 23, 2023
1 parent 83782f0 commit 428581b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions keyboards/mechwild/mercutio/keymaps/jonavin/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


#include QMK_KEYBOARD_H
#include <stdio.h>
#include "jonavin.h"

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
Expand Down Expand Up @@ -54,7 +53,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
Defaults never changes if no encoder present to change it
*/
typedef struct {
char keydesc[6]; // this will be displayed on OLED
char keydesc[6]; // this will be displayed on OLED
uint16_t keycode; // this is the keycode that will be sent when activted
} keycodedescType;

Expand All @@ -69,7 +68,7 @@ static const keycodedescType PROGMEM keyselection[] = {
{"C-A-D", KC_CAD}, // Ctrl-Alt-Del
{"AltF4", KC_AF4},
{"PLAY", KC_MEDIA_PLAY_PAUSE},
{"RESET", RESET}, // firmware flash mode
{"FLASH", RESET}, // firmware flash mode
};

#define MAX_KEYSELECTION sizeof(keyselection)/sizeof(keyselection[0])
Expand Down Expand Up @@ -201,15 +200,13 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
}
render_logo();
oled_set_cursor(8,2);
char fn_str[12];
switch(get_selected_layer()){
case 0:
oled_write_P(PSTR("BASE"), false);
break;
case 1:
sprintf(fn_str, "FN %5s", selectedkey_rec.keydesc);
oled_write(fn_str, false);
//oled_write_P(PSTR("FN "), false);
oled_write_P(PSTR("FN "), false);
oled_write(selectedkey_rec.keydesc, false);
break;
case 2:
oled_write_P(PSTR("LOWER"), false);
Expand All @@ -230,8 +227,8 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
oled_write_P(PSTR("Temp BASE"), false);
break;
case 1:
sprintf(fn_str, "Temp FN %5s", selectedkey_rec.keydesc);
oled_write(fn_str, false);
oled_write_P(PSTR("Temp FN "), false);
oled_write(selectedkey_rec.keydesc, false);
break;
case 2:
oled_write_P(PSTR("Temp LOWER"), false);
Expand All @@ -246,12 +243,11 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
led_t led_state = host_keyboard_led_state();
oled_set_cursor(8,0);
uint8_t wpm_count;
char wpm_str[10];
wpm_count=get_current_wpm();

if (wpm_count > 020) { // how wpm when > 20
sprintf(wpm_str, " WPM: %03d", wpm_count);
oled_write(wpm_str, false);
oled_write_P(PSTR(" WPM: "), false);
oled_write(get_u8_str(wpm_count, ' '), false);
} else {
oled_write_P(PSTR(" JONAVIN "), false); // otherwise display keymap name
}
Expand Down

0 comments on commit 428581b

Please sign in to comment.