Skip to content

Commit

Permalink
[Keymap] Fix build error helix:five_rows (qmk#16847)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtei authored and Vino Rodrigues committed May 17, 2022
1 parent 4a2d033 commit e3c5cc7
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 283 deletions.
279 changes: 0 additions & 279 deletions keyboards/helix/rev2/keymaps/five_rows/oled_display.c

This file was deleted.

3 changes: 2 additions & 1 deletion keyboards/helix/rev2/keymaps/five_rows/rules.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SPLIT_KEYBOARD = yes
USER_NAME := mtei
SPLIT_KEYBOARD = yes

CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
Expand Down
2 changes: 2 additions & 0 deletions keyboards/helix/rev3_5rows/keymaps/five_rows/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define OLED_UPDATE_INTERVAL 50
#endif

#define PSEUDO_SPRINTF_DEFINED

// place overrides here

// If you need more program area, try select and reduce rgblight modes to use.
Expand Down
2 changes: 2 additions & 0 deletions keyboards/helix/rev3_5rows/keymaps/five_rows/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
USER_NAME := mtei

CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
# CONSOLE_ENABLE and COMMAND_ENABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
#include <string.h>
#include "layer_number.h"

char *sprints(char *buf, char *src);
char *sprintd(char *buf, char *leadstr, int data);
char *sprint2d(char *buf, char *leadstr, int data);
#include "pseudo_sprintf.h"

extern int current_default_layer;

Expand Down Expand Up @@ -68,6 +66,10 @@ void matrix_update(struct CharacterMatrix *dest,
}
# endif

#ifndef PSEUDO_SPRINTF_DEFINED
#include "pseudo_sprintf.c"
#endif

# ifdef SSD1306OLED
static void render_logo(struct CharacterMatrix *matrix) {
# else
Expand All @@ -80,8 +82,10 @@ static void render_logo(void) {
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
0};
oled_write_P(helix_logo, false);
# if defined(RGBLIGHT_ENABLE) || defined(DEBUG_MATRIX_SCAN_RATE)
char buf[30];
char *bufp;
# endif
# ifdef RGBLIGHT_ENABLE
if (RGBLIGHT_MODES > 1 && rgblight_is_enabled()) {
bufp = sprint2d(buf, " LED ", rgblight_get_mode());
Expand Down
53 changes: 53 additions & 0 deletions users/mtei/pseudo_sprintf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2022 Takeshi Ishii (@mtei)
// SPDX-License-Identifier: GPL-2.0-or-later

#include "pseudo_sprintf.h"

static char *sprint_decimal(char *buf, int data) {
if (data > 9) {
buf = sprint_decimal(buf, data/10);
}
*buf++ = "0123456789"[data%10];
*buf = '\0';
return buf;
}

static char *sprint_hex(char *buf, uint32_t data) {
if (data > 0xf) {
buf = sprint_hex(buf, data/0x10);
}
*buf++ = "0123456789abcdef"[data & 0xf];
*buf = '\0';
return buf;
}

char *sprints(char *buf, char *src) {
while (*src) {
*buf++ = *src++;
}
*buf = '\0';
return buf;
}

char *sprintx(char *buf, char *leadstr, uint32_t data) {
buf = sprints(buf, leadstr);
buf = sprint_hex(buf, data);
return buf;
}

char *sprintd(char *buf, char *leadstr, int data) {
buf = sprints(buf, leadstr);
buf = sprint_decimal(buf, data);
return buf;
}

char *sprint2d(char *buf, char *leadstr, int data) {
buf = sprints(buf, leadstr);
if (data > 99) {
return sprint_decimal(buf, data);
}
if (data < 10) {
*buf++ = ' ';
}
return sprint_decimal(buf, data);
}
8 changes: 8 additions & 0 deletions users/mtei/pseudo_sprintf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2022 Takeshi Ishii (@mtei)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

char *sprints(char *buf, char *src);
char *sprintd(char *buf, char *leadstr, int data);
char *sprint2d(char *buf, char *leadstr, int data);

0 comments on commit e3c5cc7

Please sign in to comment.