aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlin Marin Elena <alin@elena.space>2022-01-10 20:15:28 +0000
committerGitHub <noreply@github.com>2022-01-10 12:15:28 -0800
commitf423837ed25b7a2c48d59aefaf95a0cf6f2c90b9 (patch)
treea89cd4c1c2effe3353f110e822804324d6f6afe9
parent23ba884fa08e0a7cb16486ba1d31ea2c74cf33c9 (diff)
downloadqmk_firmware-f423837ed25b7a2c48d59aefaf95a0cf6f2c90b9.tar.gz
qmk_firmware-f423837ed25b7a2c48d59aefaf95a0cf6f2c90b9.zip
[Keyboard] M48 12x4 lego ortholinear keyboard (#15536)
-rw-r--r--keyboards/mlego/m48/config.h37
-rw-r--r--keyboards/mlego/m48/info.json11
-rw-r--r--keyboards/mlego/m48/keymaps/default/config.h21
-rw-r--r--keyboards/mlego/m48/keymaps/default/keymap.c182
-rw-r--r--keyboards/mlego/m48/keymaps/via/config.h20
-rw-r--r--keyboards/mlego/m48/keymaps/via/keymap.c137
-rw-r--r--keyboards/mlego/m48/keymaps/via/rules.mk1
-rw-r--r--keyboards/mlego/m48/m48.c30
-rw-r--r--keyboards/mlego/m48/m48.h80
-rw-r--r--keyboards/mlego/m48/readme.md50
-rw-r--r--keyboards/mlego/m48/rev1/config.h58
-rw-r--r--keyboards/mlego/m48/rev1/halconf.h30
-rw-r--r--keyboards/mlego/m48/rev1/mcuconf.h30
-rw-r--r--keyboards/mlego/m48/rev1/rules.mk21
14 files changed, 708 insertions, 0 deletions
diff --git a/keyboards/mlego/m48/config.h b/keyboards/mlego/m48/config.h
new file mode 100644
index 000000000..6be2373d8
--- /dev/null
+++ b/keyboards/mlego/m48/config.h
@@ -0,0 +1,37 @@
1/* Copyright 2021-2022 alin m elena <alinm.elena@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include "config_common.h"
19
20/* USB Device descriptor parameter */
21#define VENDOR_ID 0xBABA
22#define MANUFACTURER alin elena
23#define PRODUCT m48
24
25#define MATRIX_ROWS 4 // Rows are doubled-up
26#define MATRIX_COLS 12
27
28#define DEBOUNCE 5
29
30/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
31#define LOCKING_SUPPORT_ENABLE
32/* Locking resynchronize hack */
33#define LOCKING_RESYNC_ENABLE
34
35/* disable these deprecated features by default */
36#define NO_ACTION_MACRO
37#define NO_ACTION_FUNCTION
diff --git a/keyboards/mlego/m48/info.json b/keyboards/mlego/m48/info.json
new file mode 100644
index 000000000..cc6b273f0
--- /dev/null
+++ b/keyboards/mlego/m48/info.json
@@ -0,0 +1,11 @@
1{
2 "keyboard_name": "mlego/m48",
3 "keyboard_folder": "mlego/m48",
4 "url": "https://gitlab.com/m-lego/m48",
5 "maintainer": "alin elena",
6 "layouts": {
7 "LAYOUT_ortho_4x12": {
8 "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":4, "y":0}, {"x":5, "y":0}, {"x":6, "y":0}, {"x":7, "y":0}, {"x":8, "y":0}, {"x":9, "y":0}, {"x":10, "y":0}, {"x":11, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":4, "y":1}, {"x":5, "y":1}, {"x":6, "y":1}, {"x":7, "y":1}, {"x":8, "y":1}, {"x":9, "y":1}, {"x":10, "y":1}, {"x":11, "y":1}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":3, "y":2}, {"x":4, "y":2}, {"x":5, "y":2}, {"x":6, "y":2}, {"x":7, "y":2}, {"x":8, "y":2}, {"x":9, "y":2}, {"x":10, "y":2}, {"x":11, "y":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":3, "y":3}, {"x":4, "y":3}, {"x":5, "y":3}, {"x":6, "y":3}, {"x":7, "y":3}, {"x":8, "y":3}, {"x":9, "y":3}, {"x":10, "y":3}, {"x":11, "y":3}]
9 }
10 }
11}
diff --git a/keyboards/mlego/m48/keymaps/default/config.h b/keyboards/mlego/m48/keymaps/default/config.h
new file mode 100644
index 000000000..b1aed18a1
--- /dev/null
+++ b/keyboards/mlego/m48/keymaps/default/config.h
@@ -0,0 +1,21 @@
1/*
2Copyright 2021-2022 Alin M Elena <alinm.elena@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#define TAPPING_TOGGLE 2
21#define UNICODE_SELECTED_MODES UC_LNX, UC_MAC, UC_WINC
diff --git a/keyboards/mlego/m48/keymaps/default/keymap.c b/keyboards/mlego/m48/keymaps/default/keymap.c
new file mode 100644
index 000000000..8a76993c0
--- /dev/null
+++ b/keyboards/mlego/m48/keymaps/default/keymap.c
@@ -0,0 +1,182 @@
1/*
2Copyright 2021-2022 Alin M Elena <alinm.elena@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include QMK_KEYBOARD_H
19
20#ifdef RGBLIGHT_ENABLE
21
22const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE});
23const rgblight_segment_t PROGMEM my_lwr_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_CYAN});
24const rgblight_segment_t PROGMEM my_rse_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_RED});
25const rgblight_segment_t PROGMEM my_adj_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_GREEN});
26
27const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(my_qwerty_layer, my_lwr_layer, my_rse_layer, my_adj_layer);
28#endif
29
30#define LOWER TT(_LWR)
31#define RAISE TT(_RSE)
32
33// clang-format off
34const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
35/* Qwerty
36 * ,-----------------------------------------------------------------------------------.
37 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
38 * |------+------+------+------+------+------+------+------+------+------+------+------|
39 * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
40 * |------+------+------+------+------+------+------+------+------+------+------+------|
41 * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
42 * |------+------+------+------+------+------+------+------+------+------+------+------|
43 * | | Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
44 * `-----------------------------------------------------------------------------------'
45 */
46[_QW] = LAYOUT_ortho_4x12(
47 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
48 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
49 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT ,
50 KC_TRNS,KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
51),
52
53/* Lower
54 * ,-----------------------------------------------------------------------------------.
55 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
56 * |------+------+------+------+------+------+------+------+------+------+------+------|
57 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
58 * |------+------+------+------+------+------+------+------+------+------+------+------|
59 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | Home | End | |
60 * |------+------+------+------+------+------+------+------+------+------+------+------|
61 * | | | | | | | | Next | Vol- | Vol+ | Play |
62 * `-----------------------------------------------------------------------------------'
63 */
64[_LWR] = LAYOUT_ortho_4x12(
65 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
66 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
67 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS), S(KC_NUBS), KC_HOME, KC_END, _______,
68 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
69),
70
71/* Raise
72 * ,-----------------------------------------------------------------------------------.
73 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
74 * |------+------+------+------+------+------+------+------+------+------+------+------|
75 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
76 * |------+------+------+------+------+------+------+------+------+------+------+------|
77 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / |Pg Up |Pg Dn | |
78 * |------+------+------+------+------+------+------+------+------+------+------+------|
79 * | | | | | | | | Next | Vol- | Vol+ | Play |
80 * `-----------------------------------------------------------------------------------'
81 */
82[_RSE] = LAYOUT_ortho_4x12(
83 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
84 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
85 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______,
86 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
87),
88
89/* Adjust (Lower + Raise)
90 * v------------------------RGB CONTROL--------------------v
91 * ,-----------------------------------------------------------------------------------.
92 * | | Reset|Debug | RGB |RGBMOD| HUE+ | HUE- | SAT+ | SAT- |BRGTH+|BRGTH-| Del |
93 * |------+------+------+------+------+------+------+------+------+------+------+------|
94 * | | |MUSmod|Aud on|Audoff|AGnorm|AGswap| | | | | |
95 * |------+------+------+------+------+------+------+------+------+------+------+------|
96 * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof|TermOn|TermOf| | | |
97 * |------+------+------+------+------+------+------+------+------+------+------+------|
98 * | | | | | | | | | | | |
99 * `-----------------------------------------------------------------------------------'
100 */
101[_ADJ] = LAYOUT_ortho_4x12(
102 _______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
103 _______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, _______, _______, _______, _______, _______,
104 _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF, _______, _______, _______,
105 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
106)
107
108};
109// clang-format on
110
111// let us assume we start with both layers off
112bool toggle_lwr = false;
113bool toggle_rse = false;
114
115bool led_update_user(led_t led_state) {
116 // Disable the default LED update code, so that lock LEDs could be reused to show layer status.
117 return false;
118}
119
120void matrix_scan_user(void) {
121 led_lwr(toggle_lwr);
122 led_rse(toggle_rse);
123 led_t led_state = host_keyboard_led_state();
124 led_caps(led_state.caps_lock);
125 if (layer_state_is(_ADJ)) {
126 led_lwr(true);
127 led_rse(true);
128 }
129}
130
131bool process_record_user(uint16_t keycode, keyrecord_t* record) {
132 switch (keycode) {
133 case (TT(_LWR)):
134 if (!record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
135 // This runs before the TT() handler toggles the layer state, so the current layer state is the opposite of the final one after toggle.
136 toggle_lwr = !layer_state_is(_LWR);
137 }
138 return true;
139 break;
140 case (TT(_RSE)):
141 if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
142 toggle_rse = !layer_state_is(_RSE);
143 }
144 return true;
145 break;
146 default:
147 return true;
148 }
149}
150
151#ifdef ENCODER_ENABLE
152
153bool encoder_update_user(uint8_t index, bool clockwise) {
154 my_encoders(index, clockwise);
155 return true;
156}
157#endif
158
159layer_state_t layer_state_set_user(layer_state_t state) {
160#ifdef RGBLIGHT_ENABLE
161
162 rgblight_set_layer_state(0, layer_state_cmp(state, _QW));
163 rgblight_set_layer_state(1, layer_state_cmp(state, _LWR));
164 rgblight_set_layer_state(2, layer_state_cmp(state, _RSE));
165 rgblight_set_layer_state(3, layer_state_cmp(state, _ADJ));
166
167#endif
168 return update_tri_layer_state(state, _LWR, _RSE, _ADJ);
169}
170
171#ifdef RGBLIGHT_ENABLE
172
173layer_state_t default_layer_state_set_user(layer_state_t state) {
174 rgblight_set_layer_state(0, layer_state_cmp(state, _QW));
175 return state;
176}
177
178void keyboard_post_init_user(void) {
179 // Enable the LED layers
180 rgblight_layers = my_rgb_layers;
181}
182#endif
diff --git a/keyboards/mlego/m48/keymaps/via/config.h b/keyboards/mlego/m48/keymaps/via/config.h
new file mode 100644
index 000000000..637c0a8fa
--- /dev/null
+++ b/keyboards/mlego/m48/keymaps/via/config.h
@@ -0,0 +1,20 @@
1/*
2Copyright 2021-2022 Alin M Elena <alinm.elena@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#define TAPPING_TOGGLE 2
diff --git a/keyboards/mlego/m48/keymaps/via/keymap.c b/keyboards/mlego/m48/keymaps/via/keymap.c
new file mode 100644
index 000000000..54ef03cd5
--- /dev/null
+++ b/keyboards/mlego/m48/keymaps/via/keymap.c
@@ -0,0 +1,137 @@
1/*
2Copyright 2021-2022 Alin M Elena <alinm.elena@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include QMK_KEYBOARD_H
19
20#ifdef RGBLIGHT_ENABLE
21
22const rgblight_segment_t PROGMEM my_qwerty_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_PURPLE});
23const rgblight_segment_t PROGMEM my_lwr_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_CYAN});
24const rgblight_segment_t PROGMEM my_rse_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_RED});
25const rgblight_segment_t PROGMEM my_adj_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, RGBLED_NUM, HSV_GREEN});
26
27const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(my_qwerty_layer, my_lwr_layer, my_rse_layer, my_adj_layer);
28#endif
29
30#define LOWER TT(_LWR)
31#define RAISE TT(_RSE)
32
33// clang-format off
34const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
35[_QW] = LAYOUT_ortho_4x12(
36 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
37 KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL,
38 KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
39 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT
40),
41
42[_LWR] = LAYOUT_ortho_4x12(
43 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL,
44 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
45 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______,
46 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
47),
48
49[_RSE] = LAYOUT_ortho_4x12(
50 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
51 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
52 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______,
53 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
54),
55
56[_ADJ] = LAYOUT_ortho_4x12(
57 _______, RESET, _______, _______, _______, _______, RGB_TOG, RGB_MOD, RGB_RMOD,RGB_M_G, RESET, _______,
58 _______, _______, _______, _______, _______, _______, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, _______,
59 _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______,
60 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
61)
62
63};
64// clang-format on
65
66// let us assume we start with both layers off
67bool toggle_lwr = false;
68bool toggle_rse = false;
69
70bool led_update_user(led_t led_state) {
71 // Disable the default LED update code, so that lock LEDs could be reused to show layer status.
72 return false;
73}
74
75void matrix_scan_user(void) {
76 led_lwr(toggle_lwr);
77 led_rse(toggle_rse);
78 led_t led_state = host_keyboard_led_state();
79 led_caps(led_state.caps_lock);
80 if (layer_state_is(_ADJ)) {
81 led_lwr(true);
82 led_rse(true);
83 }
84}
85
86bool process_record_user(uint16_t keycode, keyrecord_t* record) {
87 switch (keycode) {
88 case (TT(_LWR)):
89 if (!record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
90 // This runs before the TT() handler toggles the layer state, so the current layer state is the opposite of the final one after toggle.
91 toggle_lwr = !layer_state_is(_LWR);
92 }
93 return true;
94 break;
95 case (TT(_RSE)):
96 if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
97 toggle_rse = !layer_state_is(_RSE);
98 }
99 return true;
100 break;
101 default:
102 return true;
103 }
104}
105
106#ifdef ENCODER_ENABLE
107
108bool encoder_update_user(uint8_t index, bool clockwise) {
109 my_encoders(index, clockwise);
110 return true;
111}
112#endif
113
114layer_state_t layer_state_set_user(layer_state_t state) {
115#ifdef RGBLIGHT_ENABLE
116
117 rgblight_set_layer_state(0, layer_state_cmp(state, _QW));
118 rgblight_set_layer_state(1, layer_state_cmp(state, _LWR));
119 rgblight_set_layer_state(2, layer_state_cmp(state, _RSE));
120 rgblight_set_layer_state(3, layer_state_cmp(state, _ADJ));
121
122#endif
123 return update_tri_layer_state(state, _LWR, _RSE, _ADJ);
124}
125
126#ifdef RGBLIGHT_ENABLE
127
128layer_state_t default_layer_state_set_user(layer_state_t state) {
129 rgblight_set_layer_state(0, layer_state_cmp(state, _QW));
130 return state;
131}
132
133void keyboard_post_init_user(void) {
134 // Enable the LED layers
135 rgblight_layers = my_rgb_layers;
136}
137#endif
diff --git a/keyboards/mlego/m48/keymaps/via/rules.mk b/keyboards/mlego/m48/keymaps/via/rules.mk
new file mode 100644
index 000000000..1e5b99807
--- /dev/null
+++ b/keyboards/mlego/m48/keymaps/via/rules.mk
@@ -0,0 +1 @@
VIA_ENABLE = yes
diff --git a/keyboards/mlego/m48/m48.c b/keyboards/mlego/m48/m48.c
new file mode 100644
index 000000000..79ba408cd
--- /dev/null
+++ b/keyboards/mlego/m48/m48.c
@@ -0,0 +1,30 @@
1/* Copyright 2021-2022 alin elena <alin@elena.space>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include "m48.h"
17
18/*
19void keyboard_pre_init_kb(void){
20
21 // Workaround for reversible pcb/mcu
22 palSetLineMode(C13, PAL_MODE_INPUT_PULLUP);
23 palSetLineMode(C15, PAL_MODE_INPUT_PULLUP);
24 palSetLineMode(B7, PAL_MODE_OUTPUT_OPENDRAIN);
25 palSetLineMode(A0, PAL_MODE_OUTPUT_OPENDRAIN);
26 palSetLineMode(A1, PAL_MODE_OUTPUT_OPENDRAIN);
27
28 keyboard_pre_init_user();
29 }
30*/
diff --git a/keyboards/mlego/m48/m48.h b/keyboards/mlego/m48/m48.h
new file mode 100644
index 000000000..766f38124
--- /dev/null
+++ b/keyboards/mlego/m48/m48.h
@@ -0,0 +1,80 @@
1/*
2Copyright 2021-2022 Alin M Elena <alinm.elena@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include "quantum.h"
21
22#define LAYOUT_ortho_4x12( \
23 K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, \
24 K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, \
25 K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, \
26 K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311 \
27) { \
28 { K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011 }, \
29 { K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111 }, \
30 { K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211 }, \
31 { K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311 } \
32}
33
34enum layer_names { _QW = 0, _LWR, _RSE, _ADJ };
35static inline void led_lwr(const bool on) {
36#ifdef LED_NUM_LOCK_PIN
37 writePin(LED_NUM_LOCK_PIN, on);
38#endif
39}
40
41static inline void led_rse(const bool on) {
42#ifdef LED_SCROLL_LOCK_PIN
43 writePin(LED_SCROLL_LOCK_PIN, on);
44#endif
45}
46static inline void led_caps(const bool on) {
47#ifdef LED_CAPS_LOCK_PIN
48 writePin(LED_CAPS_LOCK_PIN, !on);
49#endif
50}
51
52#ifdef ENCODER_ENABLE
53
54# define MEDIA_KEY_DELAY 10
55
56static inline void my_encoders(const uint8_t index, const bool clockwise) {
57 if (index == 0) { /* First encoder */
58 if (IS_LAYER_ON(_LWR)) {
59 if (clockwise) {
60 rgblight_decrease_val_noeeprom();
61 } else {
62 rgblight_increase_val_noeeprom();
63 }
64 } else if (IS_LAYER_ON(_RSE)) {
65 if (clockwise) {
66 rgblight_decrease_hue_noeeprom();
67 } else {
68 rgblight_increase_hue_noeeprom();
69 }
70
71 } else {
72 if (clockwise) {
73 tap_code_delay(KC_VOLD, MEDIA_KEY_DELAY);
74 } else {
75 tap_code_delay(KC_VOLU, MEDIA_KEY_DELAY);
76 }
77 }
78 }
79}
80#endif
diff --git a/keyboards/mlego/m48/readme.md b/keyboards/mlego/m48/readme.md
new file mode 100644
index 000000000..c48cec9c8
--- /dev/null
+++ b/keyboards/mlego/m48/readme.md
@@ -0,0 +1,50 @@
1# M48
2
3![M48](https://i.imgur.com/QLuCAlWh.jpg)
4
5A (12x4) ortholinear keyboard that can be hand wired or using a pcb.
6
7* Keyboard Maintainer: [Alin Elena](https://github.com/alinelena) ([@drFaustroll on GitLab](https://gitlab.com/drFaustroll))
8* Hardware Supported: custom pcb [see](https://gitlab.com/m-lego/m48) STM32F401 from we act (rev1)
9* Hardware Availability: [custom how to](https://gitlab.com/m-lego/m65)
10
11
12Make example for this keyboard (after setting up your build environment):
13
14 make mlego/m48/rev1:default
15
16Flashing example for this keyboard:
17
18 make mlego/m48/rev1:default
19
20To enter flashing mode, press Lower+Raise+1 or Lower+Raise+0 also on microcontroller keep pressed BOOT0 and then NRST, release NRST and then after 0.5s or so release BOOT0.
21
22See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
23
24
25## Pins for rev1 stm32f401
26
27the same for stm32f411
28
29| Rows | C0 | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | C10 | C11 | Pins |
30| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
31| R0 | Tab | q | w | e | r | t | y | u | i | o | p | BSpace| A6 |
32| R1 | Esc | a | s | d | f | g | h | j | k | l | ; | ' | A7 |
33| R2 | Shift | z | x | c | v | b | n | m | , | . | / | Enter | B0 |
34| R3 | Ctrl | Menu | Alt | Fn | Lower | Space | Space | Raise | Left | Down | Up | Right | B10 |
35| Pins | A10 | A15 | B3 | B4 | B5 | B7 | B6 | A1 | A2 | A3 | A4 | A5 | |
36
37### Encoders:
38
39 - Pad_A: A0
40 - Pad_B: B8
41
42### Leds
43
44| Leds | Pin |
45| ----------- | --- |
46| NUM_LOCK | B12 |
47| CAPS_LOCK | C13 |
48| SCROLL_LOCK | B13 |
49| RBG_DI | B15 |
50
diff --git a/keyboards/mlego/m48/rev1/config.h b/keyboards/mlego/m48/rev1/config.h
new file mode 100644
index 000000000..85da34f17
--- /dev/null
+++ b/keyboards/mlego/m48/rev1/config.h
@@ -0,0 +1,58 @@
1/* Copyright 2021-2022 alin m elena <alinm.elena@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include "config_common.h"
19
20/* USB Device descriptor parameter */
21#define PRODUCT_ID 0x0001
22#define DEVICE_VER 0x0001
23
24#define MATRIX_ROW_PINS \
25 { A6, A7, B0, B10 }
26#define MATRIX_COL_PINS \
27 { A10, A15, B3, B4, B5, B7, B6, A1, A2, A3, A4, A5 }
28
29#define ENCODERS_PAD_A \
30 { A0 }
31#define ENCODERS_PAD_B \
32 { B8 }
33
34#define LED_NUM_LOCK_PIN B12
35#define LED_SCROLL_LOCK_PIN B13
36#define LED_CAPS_LOCK_PIN C13
37
38#define RGB_DI_PIN B15
39
40#define UNUSED_PINS
41#define RGBLIGHT_LAYERS
42
43/* COL2ROW, ROW2COL*/
44#define DIODE_DIRECTION COL2ROW
45
46#define MATRIX_IO_DELAY 5
47
48#define RGBLED_NUM 20
49#define RGBLIGHT_EFFECT_BREATHING
50#define RGBLIGHT_EFFECT_RAINBOW_MOOD
51#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
52#define RGBLIGHT_EFFECT_SNAKE
53#define RGBLIGHT_EFFECT_KNIGHT
54#define RGBLIGHT_EFFECT_CHRISTMAS
55#define RGBLIGHT_EFFECT_STATIC_GRADIENT
56#define RGBLIGHT_EFFECT_RGB_TEST
57#define RGBLIGHT_EFFECT_ALTERNATING
58#define RGBLIGHT_EFFECT_TWINKLE
diff --git a/keyboards/mlego/m48/rev1/halconf.h b/keyboards/mlego/m48/rev1/halconf.h
new file mode 100644
index 000000000..89815e23b
--- /dev/null
+++ b/keyboards/mlego/m48/rev1/halconf.h
@@ -0,0 +1,30 @@
1/* Copyright 2020 QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17/*
18 * This file was auto-generated by:
19 * `qmk chibios-confmigrate -i keyboards/zvecr/zv48/f401/halconf.h -r platforms/chibios/common/configs/halconf.h`
20 */
21
22#pragma once
23
24#define HAL_USE_PWM TRUE
25
26#define HAL_USE_SERIAL TRUE
27
28#define SERIAL_USB_BUFFERS_SIZE 256
29
30#include_next <halconf.h>
diff --git a/keyboards/mlego/m48/rev1/mcuconf.h b/keyboards/mlego/m48/rev1/mcuconf.h
new file mode 100644
index 000000000..4d90ec07e
--- /dev/null
+++ b/keyboards/mlego/m48/rev1/mcuconf.h
@@ -0,0 +1,30 @@
1/* Copyright 2020 QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17/*
18 * This file was auto-generated by:
19 * `qmk chibios-confmigrate -i keyboards/zvecr/zv48/f401/mcuconf.h -r platforms/chibios/BLACKPILL_STM32_F401/configs/mcuconf.h`
20 */
21
22#pragma once
23
24#include_next <mcuconf.h>
25
26#undef STM32_PWM_USE_TIM3
27#define STM32_PWM_USE_TIM3 TRUE
28
29#undef STM32_SERIAL_USE_USART1
30#define STM32_SERIAL_USE_USART1 TRUE
diff --git a/keyboards/mlego/m48/rev1/rules.mk b/keyboards/mlego/m48/rev1/rules.mk
new file mode 100644
index 000000000..066cfd4f8
--- /dev/null
+++ b/keyboards/mlego/m48/rev1/rules.mk
@@ -0,0 +1,21 @@
1# MCU name
2MCU = STM32F401
3
4# Bootloader selection
5BOOTLOADER = stm32-dfu
6
7# Build Options
8# change yes to no to disable
9#
10BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
11MOUSEKEY_ENABLE = yes # Mouse keys
12EXTRAKEY_ENABLE = yes # Audio control and System control
13CONSOLE_ENABLE = no # Console for debug
14COMMAND_ENABLE = no # Commands for debug and configuration
15NKRO_ENABLE = yes # Enable N-Key Rollover
16BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
17RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
18AUDIO_ENABLE = no # Audio output
19ENCODER_ENABLE = yes # Enable encoder
20
21LAYOUTS = ortho_4x12