Jonavin mercutio - reduce mem footprint (#17498)

* Reduce mem footprint - remove sprintf

* remove stdio reference and use get_u8_str

Co-authored-by: Jonavin <=>
This commit is contained in:
jonavin 2022-07-21 08:44:51 -04:00 committed by GitHub
parent a6d70de96a
commit 7f0581cd35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,6 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
#include <stdio.h>
#include "jonavin.h" #include "jonavin.h"
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@ -54,7 +53,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
Defaults never changes if no encoder present to change it Defaults never changes if no encoder present to change it
*/ */
typedef struct { 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 uint16_t keycode; // this is the keycode that will be sent when activted
} keycodedescType; } keycodedescType;
@ -69,7 +68,7 @@ static const keycodedescType PROGMEM keyselection[] = {
{"C-A-D", KC_CAD}, // Ctrl-Alt-Del {"C-A-D", KC_CAD}, // Ctrl-Alt-Del
{"AltF4", KC_AF4}, {"AltF4", KC_AF4},
{"PLAY", KC_MEDIA_PLAY_PAUSE}, {"PLAY", KC_MEDIA_PLAY_PAUSE},
{"RESET", RESET}, // firmware flash mode {"FLASH", RESET}, // firmware flash mode
}; };
#define MAX_KEYSELECTION sizeof(keyselection)/sizeof(keyselection[0]) #define MAX_KEYSELECTION sizeof(keyselection)/sizeof(keyselection[0])
@ -201,15 +200,13 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
} }
render_logo(); render_logo();
oled_set_cursor(8,2); oled_set_cursor(8,2);
char fn_str[12];
switch(get_selected_layer()){ switch(get_selected_layer()){
case 0: case 0:
oled_write_P(PSTR("BASE"), false); oled_write_P(PSTR("BASE"), false);
break; break;
case 1: case 1:
sprintf(fn_str, "FN %5s", selectedkey_rec.keydesc); oled_write_P(PSTR("FN "), false);
oled_write(fn_str, false); oled_write(selectedkey_rec.keydesc, false);
//oled_write_P(PSTR("FN "), false);
break; break;
case 2: case 2:
oled_write_P(PSTR("LOWER"), false); oled_write_P(PSTR("LOWER"), false);
@ -230,8 +227,8 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
oled_write_P(PSTR("Temp BASE"), false); oled_write_P(PSTR("Temp BASE"), false);
break; break;
case 1: case 1:
sprintf(fn_str, "Temp FN %5s", selectedkey_rec.keydesc); oled_write_P(PSTR("Temp FN "), false);
oled_write(fn_str, false); oled_write(selectedkey_rec.keydesc, false);
break; break;
case 2: case 2:
oled_write_P(PSTR("Temp LOWER"), false); oled_write_P(PSTR("Temp LOWER"), false);
@ -246,12 +243,11 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
led_t led_state = host_keyboard_led_state(); led_t led_state = host_keyboard_led_state();
oled_set_cursor(8,0); oled_set_cursor(8,0);
uint8_t wpm_count; uint8_t wpm_count;
char wpm_str[10];
wpm_count=get_current_wpm(); wpm_count=get_current_wpm();
if (wpm_count > 020) { // how wpm when > 20 if (wpm_count > 020) { // how wpm when > 20
sprintf(wpm_str, " WPM: %03d", wpm_count); oled_write_P(PSTR(" WPM: "), false);
oled_write(wpm_str, false); oled_write(get_u8_str(wpm_count, ' '), false);
} else { } else {
oled_write_P(PSTR(" JONAVIN "), false); // otherwise display keymap name oled_write_P(PSTR(" JONAVIN "), false); // otherwise display keymap name
} }