Browse Source

Amptrics 0420 keyboard addition (#24744)

Co-authored-by: jack <jack@pngu.org>
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
vchowl 1 year ago
parent
commit
4e2191ce20

+ 67 - 0
keyboards/amptrics/0422/0422.c

@@ -0,0 +1,67 @@
+/* Copyright 2024 Vinod Chowl (@vchowl)
+ *
+ * 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.0 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/>.
+ */
+
+#include QMK_KEYBOARD_H
+
+#define LED_LAYER_0 B3
+#define LED_LAYER_1 B4
+#define LED_LAYER_2 B5
+#define LED_LAYER_3 B6
+
+#define LED_PINS_COUNT 4
+
+pin_t pins[LED_PINS_COUNT] = {LED_LAYER_0, LED_LAYER_1, LED_LAYER_2, LED_LAYER_3};
+
+
+// Function to turn on all LEDs
+void turn_on_all_leds(void) {
+    for (int i = 0; i < LED_PINS_COUNT; i++) {
+        gpio_write_pin_high(pins[i]); // Turn on LED
+    }
+}
+
+// Function to turn off all LEDs
+void turn_off_all_leds(void) {
+    for (int i = 0; i < LED_PINS_COUNT; i++) {
+        gpio_write_pin_low(pins[i]); // Turn off LED
+    }
+}
+
+void update_leds_for_layer(uint8_t layer) {
+    turn_off_all_leds();
+    gpio_write_pin_high(pins[layer]);
+}
+
+void keyboard_post_init_kb(void) {
+    for (int i = 0; i < LED_PINS_COUNT; i++) {
+        gpio_set_pin_output(pins[i]);
+        gpio_write_pin_low(pins[i]);
+    }
+
+    // Blink all LEDs
+    turn_on_all_leds();
+    wait_ms(500); // Keep LEDs on for 500ms
+    turn_off_all_leds();
+
+    update_leds_for_layer(0); // Update LEDs to indicate the default layer
+    keyboard_post_init_user();
+}
+
+layer_state_t layer_state_set_kb(layer_state_t state) {
+    uint8_t layer = get_highest_layer(state);
+    update_leds_for_layer(layer);
+    return layer_state_set_user(state);
+}

+ 5 - 0
keyboards/amptrics/0422/config.h

@@ -0,0 +1,5 @@
+// Copyright 2025 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#define DYNAMIC_KEYMAP_MACRO_COUNT 36

+ 40 - 0
keyboards/amptrics/0422/keyboard.json

@@ -0,0 +1,40 @@
+{
+    "manufacturer": "Amptrics Technologies",
+    "keyboard_name": "Amptrics 0422",
+    "maintainer": "vchowl",
+    "bootloader": "stm32-dfu",
+    "diode_direction": "ROW2COL",
+    "features": {
+        "bootmagic": true,
+        "extrakey": true,
+        "mousekey": true,
+        "nkro": true
+    },
+    "matrix_pins": {
+        "cols": ["C8", "C7", "C6"],
+        "rows": ["A14", "A13", "A10", "A9"]
+    },
+    "processor": "STM32F072",
+    "url": "",
+    "usb": {
+        "device_version": "1.0.0",
+        "pid": "0x01A6",
+        "vid": "0x616D"
+    },
+    "layouts": {
+        "LAYOUT": {
+            "layout": [
+                {"matrix": [0, 0], "x": 0, "y": 0},
+                {"matrix": [1, 0], "x": 0, "y": 1},
+                {"matrix": [1, 1], "x": 1, "y": 1},
+                {"matrix": [1, 2], "x": 2, "y": 1},
+                {"matrix": [2, 0], "x": 0, "y": 2},
+                {"matrix": [2, 1], "x": 1, "y": 2},
+                {"matrix": [2, 2], "x": 2, "y": 2},
+                {"matrix": [3, 0], "x": 0, "y": 3},
+                {"matrix": [3, 1], "x": 1, "y": 3},
+                {"matrix": [3, 2], "x": 2, "y": 3}
+            ]
+        }
+    }
+}

+ 58 - 0
keyboards/amptrics/0422/keymaps/default/keymap.c

@@ -0,0 +1,58 @@
+/* Copyright 2024 Vinod Chowl (@vchowl)
+ *
+ * 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.0 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/>.
+ */
+
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /*
+     * ┌───┐
+     * │Tog│ 
+     * ├───┼───┬───┐ 
+     * │ 7 │ 8 │ 9 │
+     * ├───┼───┼───┤
+     * │ 4 │ 5 │ 6 │
+     * ├───┼───┼───┤
+     * │ 1 │ 2 │ 3 │ 
+     * └───┴───┴───┘
+     */
+    [0] = LAYOUT(
+        TO(1),
+        KC_7,   KC_8,   KC_9,
+        KC_4,   KC_5,   KC_6,
+        KC_1,   KC_2,   KC_3
+    ),
+
+    [1] = LAYOUT(
+        TO(2),
+        KC_A,   KC_B,   KC_C,
+        KC_D,   KC_E,   KC_F,
+        KC_G,   KC_H,   KC_I
+    ),
+
+    [2] = LAYOUT(
+        TO(3),
+        KC_J,   KC_K,   KC_L,
+        KC_M,   KC_N,   KC_O,
+        KC_P,   KC_Q,   KC_R
+    ),
+
+    [3] = LAYOUT(
+        TO(0),
+        KC_S,   KC_T,   KC_U,
+        KC_V,   KC_W,   KC_X,
+        KC_Y,   KC_Z,   KC_ENT
+    )
+};

+ 25 - 0
keyboards/amptrics/0422/readme.md

@@ -0,0 +1,25 @@
+# Amptrics 0422 Programmable Keypad
+
+![magtray4x3](https://i.imgur.com/G5QMlpn_d.jpeg)
+
+* Keyboard Maintainer: [vchowl](https://github.com/vchowl)
+* Hardware Supported: STM32F072RBT6
+* Hardware Availability: Not yet available.
+
+Make example for this keyboard (after setting up your build environment):
+
+    make amptrics/0422:default
+
+Flashing example for this keyboard:
+
+    make amptrics/0422:default:flash
+
+See 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).
+
+## Bootloader
+
+Enter the bootloader in 3 ways:
+
+* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
+* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
+* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available