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

zk3mod : added OLED #22303

Merged
merged 24 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d6d09c0
oled added.
coomstoolbox Oct 4, 2023
783fc2a
viaoled added.
coomstoolbox Oct 4, 2023
792a7a7
fix space.
coomstoolbox Oct 4, 2023
d43f1d3
fix un used.
coomstoolbox Oct 4, 2023
bba9fb6
mini fix.
coomstoolbox Oct 4, 2023
bfb4ae4
fix unused.
coomstoolbox Oct 7, 2023
ab96423
Merge origin keyboard
coomstoolbox Oct 20, 2023
9e907d1
Diode direction mistake
coomstoolbox Oct 21, 2023
2163a52
Use oled feature control in info.json.
coomstoolbox Oct 22, 2023
56afd3b
Use lto control in info.json.
coomstoolbox Oct 22, 2023
72b79e3
Rename ziyoulang_k3_mod_oled.c to ziyoulang_k3_mod.c
coomstoolbox Oct 22, 2023
c36c5c2
Apply suggestions from code review
coomstoolbox Oct 22, 2023
3af5857
Update keyboards/handwired/ziyoulang_k3_mod/readme.md
coomstoolbox Oct 22, 2023
a94d372
Merge branch 'qmk:master' into z-k3-mod-oled4
coomstoolbox Oct 22, 2023
66dfcec
matrix error fix.
coomstoolbox Oct 22, 2023
9532e56
Apply suggestions from code review
coomstoolbox Oct 22, 2023
3a32cda
matrix error fix.
coomstoolbox Oct 22, 2023
81893ea
Compile error fixed.
coomstoolbox Oct 22, 2023
724029a
Compile error fixed.
coomstoolbox Oct 22, 2023
2bdbfad
Update keyboards/handwired/ziyoulang_k3_mod/ziyoulang_k3_mod.c
coomstoolbox Oct 22, 2023
af987a4
Update keyboards/handwired/ziyoulang_k3_mod/ziyoulang_k3_mod.c
coomstoolbox Oct 22, 2023
55caf67
Delete keyboards/handwired/ziyoulang_k3_mod/ziyoulang_k3_mod.h
coomstoolbox Oct 22, 2023
342490d
Apply suggestions from code review
coomstoolbox Nov 18, 2023
b24d569
Merge branch 'develop' into z-k3-mod-oled4
coomstoolbox Dec 9, 2023
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
8 changes: 8 additions & 0 deletions keyboards/handwired/ziyoulang_k3_mod/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2023 Coom (@coomstoolbox)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#define I2C1_SCL_PIN B10
#define I2C1_SDA_PIN B11
#define I2C_DRIVER I2CD2
21 changes: 21 additions & 0 deletions keyboards/handwired/ziyoulang_k3_mod/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Copyright 2021 QMK
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#define HAL_USE_I2C TRUE

#include_next <halconf.h>
11 changes: 6 additions & 5 deletions keyboards/handwired/ziyoulang_k3_mod/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"keyboard_name": "ziyoulang k3 mod",
"development_board": "bluepill",
"usb": {
"device_version": "1.0.0",
"device_version": "1.1.0",
"pid": "0xE002",
"vid": "0x5006"
},
Expand All @@ -11,10 +11,11 @@
"command": false,
"console": false,
"extrakey": true,
"mousekey": true,
"nkro": false
"mousekey": false,
"nkro": false,
"lto": true
coomstoolbox marked this conversation as resolved.
Show resolved Hide resolved
},
coomstoolbox marked this conversation as resolved.
Show resolved Hide resolved
"diode_direction": "COL2ROW",
"diode_direction": "ROW2COL",
"dynamic_keymap": {
"layer_count": 3
},
Expand Down Expand Up @@ -139,4 +140,4 @@
"manufacturer": "Coom",
"maintainer": "coomstoolbox",
"url": ""
}
}
6 changes: 4 additions & 2 deletions keyboards/handwired/ziyoulang_k3_mod/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VIA_ENABLE = yes
MOUSEKEY_ENABLE = no
LTO_ENABLE = yes

OLED_ENABLE = yes

SRC += ziyoulang_k3_mod_oled.c
coomstoolbox marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 22 additions & 0 deletions keyboards/handwired/ziyoulang_k3_mod/mcuconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright 2021 QMK
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include_next <mcuconf.h>

#undef STM32_I2C_USE_I2C2
#define STM32_I2C_USE_I2C2 TRUE
2 changes: 1 addition & 1 deletion keyboards/handwired/ziyoulang_k3_mod/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_to

[KiCAD wiring diagram](https://github.com/coomstoolbox/ZK3-BP-MOD-wiring-diagram)

![explanation](https://i.imgur.com/yvhvhoBh.png)
![explanation](https://i.imgur.com/thGIdOt.png)
coomstoolbox marked this conversation as resolved.
Show resolved Hide resolved

## Bootloader

Expand Down
4 changes: 3 additions & 1 deletion keyboards/handwired/ziyoulang_k3_mod/rules.mk
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# This file intentionally left blank
OLED_ENABLE = yes

SRC += ziyoulang_k3_mod_oled.c
coomstoolbox marked this conversation as resolved.
Show resolved Hide resolved
120 changes: 120 additions & 0 deletions keyboards/handwired/ziyoulang_k3_mod/ziyoulang_k3_mod_oled.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be renamed to ziyoulang_k3_mod.c.

Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright 2023 Coom (@coomstoolbox)
// SPDX-License-Identifier: GPL-2.0-or-later

#include <stdio.h>

#include QMK_KEYBOARD_H

drashna marked this conversation as resolved.
Show resolved Hide resolved
#ifdef CONSOLE_ENABLE
#include <print.h>
#endif

void keyboard_post_init_user(void) {

// Customise these values to desired behaviour
#ifdef CONSOLE_ENABLE
debug_enable=true;
debug_matrix=true;
#endif
//debug_keyboard=true;
//debug_mouse=true;

}
drashna marked this conversation as resolved.
Show resolved Hide resolved

static uint16_t last_keycode = KC_NO;
static uint16_t last_col = 0;
static uint16_t last_row = 0;

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// コンソールが有効化されている場合、マトリックス上の位置とキー押下状態を出力します
drashna marked this conversation as resolved.
Show resolved Hide resolved
#ifdef CONSOLE_ENABLE
uprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
#endif
if (record->event.pressed) {
if (last_keycode != keycode) {
last_keycode = keycode;
last_col = record->event.key.col;
last_row = record->event.key.row;
}
}
return true;
}

oled_rotation_t oled_init_user(oled_rotation_t rotation) {
drashna marked this conversation as resolved.
Show resolved Hide resolved
return OLED_ROTATION_180;
}

static void render_logo(void) {
static const char PROGMEM qmk_logo[] = {
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
};
oled_write_P(qmk_logo, false);
#ifdef CONSOLE_ENABLE
uprintf("Ziyoulang K3 Mod\n");
oled_set_cursor(3, 0);
oled_write_P(PSTR("Ziyoulang K3 Mod"), false);
#endif
}

bool oled_task_user(void) {
drashna marked this conversation as resolved.
Show resolved Hide resolved
int uptime_seconds = (int)(timer_read32() / 1000);
if (uptime_seconds < 5) {
render_logo();
return false;
}

// Host Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);

switch (get_highest_layer(layer_state | default_layer_state)) {
case 0:
oled_write_P(PSTR("Default\n"), false);
break;
case 1:
oled_write_P(PSTR("2\n"), false);
break;
case 2:
oled_write_P(PSTR("3\n"), false);
break;
default:
// Or use the write_ln shortcut over adding '\n' to the end of your string
oled_write_ln_P(PSTR("Undefined"), false);
}

// Host Keyboard LED Status
led_t led_state = host_keyboard_led_state();
if (led_state.num_lock) {
oled_write_P(PSTR("NUM"), true);
oled_write_P(PSTR(" "), false);
} else {
oled_write_P(PSTR(" "), false);
}
if (led_state.caps_lock) {
oled_write_P(PSTR("CAP"), true);
oled_write_P(PSTR(" "), false);
} else {
oled_write_P(PSTR(" "), false);
}
if (led_state.scroll_lock) {
oled_write_P(PSTR("SCR"), true);
oled_write_ln_P(PSTR(" "), false);
} else {
oled_write_ln_P(PSTR(" "), false);
}

// Last Key pressed info
oled_write_P(PSTR("kc : "), false);
if (last_keycode > 21000) {
oled_write_ln_P(PSTR(" Fn"), false);
} else {
oled_write_ln_P(get_u16_str(last_keycode, ' '), false);
}
oled_write_P(PSTR("col: "), false);
oled_write_P(get_u16_str(last_col, ' '), false);
oled_write_P(PSTR(",row: "), false);
oled_write_P(get_u16_str(last_row, ' '), false);

return false;
}