Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
QMK Bot 2021-02-16 18:10:43 +00:00
commit d565586e46
8 changed files with 317 additions and 54 deletions

View File

@ -22,9 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config_common.h"
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x0B91
#define DEVICE_VER 0x0001
#define VENDOR_ID 0x444E // "DN"
#define PRODUCT_ID 0x4450 // "DP"
#define DEVICE_VER 0x0001 // 1.0
#define MANUFACTURER dekuNukem
#define PRODUCT duckyPad
@ -37,10 +37,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLED_NUM 15
#define DRIVER_LED_TOTAL 15
#ifdef RGB_MATRIX_ENABLE
#define RGB_MATRIX_KEYPRESSES
#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_REACTIVE_SIMPLE
#define RGB_MATRIX_STARTUP_HUE 221
#endif
#define I2C1_SCL 8
#define I2C1_SDA 9

View File

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "duckypad.h"
#ifdef RGB_MATRIX_ENABLE
led_config_t g_led_config = { {
{ 2, 1, 0, 3, 4, 5, 8, 7, 6, 9, 10, 11, 14, 13, 12, NO_LED, NO_LED }
}, {
@ -42,6 +44,8 @@ led_config_t g_led_config = { {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
} };
#endif
void keyboard_pre_init_kb(void) {
setPinOutput(A0);
writePinHigh(A0);

View File

@ -24,9 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define LAYOUT( \
k00, k01, k02, \
k10, k11, k12, \
k20, k21, k22, \
k30, k31, k32, \
k40, k41, k42, \
kDown, kUp \
) {{k00, k01, k02, k10, k11, k12, k20, k21, k22, k30, k31, k32, k40, k41, k42, kDown, kUp}}
k03, k04, k05, \
k06, k07, k08, \
k09, k010, k011, \
k012, k013, k014, \
k015, k016 \
) {{k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k010, k011, k012, k013, k014, k015, k016}}

View File

@ -21,25 +21,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include QMK_KEYBOARD_H
#include "stdio.h"
#include <unistd.h>
#include "raw_hid.h"
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define LOGO_SIZE 384
bool rgbToggled = false;
bool altToggled = false;
bool sysToggled = false;
enum layer_codes {
RGB_LAYER = SAFE_RANGE,
ALT_LAYER
};
enum my_keycodes {
Z0 = SAFE_RANGE, Z1, Z2,
Z3, Z4, Z5,
Z6, Z7, Z8,
Z9, Z10, Z11,
Z12, Z13, Z14
ALT_LAYER,
SYS_LAYER,
CLOCK_TOGGLE
};
#define MAC_1 LCTL(LALT(KC_MINS))
@ -65,6 +62,14 @@ enum my_keycodes {
#define _DEFAULT 0
#define _RGB 1
#define _ALT 2
#define _SYS 3
float cpuFreq = 0;
int memPerc = 0;
int gpuLoad = 0;
int temp = 0;
int hour = 0;
int minute = 0;
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@ -78,7 +83,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|=========================================|
| Macro 4 | Macro 5 | Macro 6 |
|=========================================| ,---------------------.
| Macro 7 | Macro 8 | Macro 9 | | RGB Menu | Alt Menu |
| Macro 7 | Macro 8 | Sys. Info | | RGB Menu | Alt Menu |
`=========================================' `--------------------'
*/
[_DEFAULT] = LAYOUT(
@ -86,7 +91,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_AUDIO_MUTE, KC_AUDIO_VOL_DOWN, KC_AUDIO_VOL_UP,
MAC_1, MAC_2, MAC_3,
MAC_4, MAC_5, MAC_6,
MAC_7, MAC_8, MAC_9,
CLOCK_TOGGLE, MAC_8, SYS_LAYER,
RGB_LAYER, ALT_LAYER
),
/*
@ -120,7 +125,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|=========================================|
| Macro 13 | Macro 14 | Macro 15 |
|=========================================| ,----------------------.
| Macro 16 | Macro 17 | Macro 18 | | Norm Menu | Alt Menu |
| Macro 16 | Macro 17 | Sys. Info | | Norm Menu | Alt Menu |
`=========================================' `---------------------'
*/
[_ALT] = LAYOUT(
@ -128,24 +133,32 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_UNDO, KC_CUT, KC_COPY,
KC_PASTE, KC_FIND, KC_PSCR,
MAC_13, MAC_14, MAC_15,
MAC_16, MAC_17, MAC_18,
CLOCK_TOGGLE, MAC_17, SYS_LAYER,
RGB_LAYER, ALT_LAYER
),
[_SYS] = LAYOUT(
KC_NO, KC_NO, KC_NO,
KC_NO, KC_NO, KC_NO,
KC_NO, KC_NO, KC_NO,
KC_NO, KC_NO, KC_NO,
CLOCK_TOGGLE, KC_NO, SYS_LAYER,
RGB_LAYER, ALT_LAYER
)
};
static void render_logo(void) {
static const char PROGMEM ducky_logo[LOGO_SIZE] = {
0, 0, 0, 0,128,128,128,128,128, 0, 0,252,252,252, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0,128,128,128,128,128, 0, 0, 0, 0, 0,252,252,252, 0, 0, 0, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0,128,128,128,128, 0,248,248,248, 56, 56, 56, 56, 56, 56,120,240,224,192, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,128, 0, 0,252,252,252, 0, 0, 0, 0, 0,232, 24, 24,232, 0, 24, 48, 48, 24, 0,232, 24, 24,232, 0, 0,
0,248,254,255,143, 7, 3, 3, 3, 7,142,255,255,255, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0,255,255,255, 0,248,254,255,143, 7, 3, 3, 3, 3,143, 7, 2, 0, 0,255,255,255,240,120,252,254,231,131, 1, 0, 1, 7, 63,254,240,192, 0,224,252,127, 31, 3, 0, 0,255,255,255,112,112,112,112,112,112, 56, 63, 31, 15,193,231,243,115, 51, 51, 51, 55,255,255,252, 0, 0,248,254,255,143, 7, 3, 3, 3, 7,142,255,255,255, 0, 0, 0, 0, 0, 21,127,127,252,252,252,253,253,252,252,252,255,255,255, 0, 0,
0, 0, 3, 7, 15, 15, 14, 14, 14, 7, 3, 15, 15, 15, 0, 0, 0, 3, 7, 15, 15, 14, 14, 6, 3, 15, 15, 15, 0, 0, 3, 7, 7, 15, 14, 14, 14, 14, 7, 7, 2, 0, 0, 15, 15, 15, 0, 0, 0, 1, 3, 15, 15, 12,136,224,224,224,247,127,127, 31, 3, 0, 0, 0, 0, 0, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 15, 14, 14, 14, 6, 3, 15, 15, 15, 0, 0, 0, 3, 7, 15, 15, 14, 14, 14, 7, 3, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 11, 3, 11, 7, 11, 7, 7, 31, 0, 0
static const char PROGMEM raw_logo[] = {
0, 0, 0, 0,128,128,128,128,128, 0, 0,252,252,252, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0,128,128,128,128,128, 0, 0, 0, 0, 0,252,252,252, 0, 0, 0, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0,128,128,128,128, 0,248,248,248, 56, 56, 56, 56, 56, 56,120,240,224,192, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,128, 0, 0,252,252,252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,248,254,255,143, 7, 3, 3, 3, 7,142,255,255,255, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0,255,255,255, 0,248,254,255,143, 7, 3, 3, 3, 3,143, 7, 2, 0, 0,255,255,255,240,120,252,254,231,131, 1, 0, 1, 7, 63,254,240,192, 0,224,252,127, 31, 3, 0, 0,255,255,255,112,112,112,112,112,112, 56, 63, 31, 15,193,231,243,115, 51, 51, 51, 55,255,255,252, 0, 0,248,254,255,143, 7, 3, 3, 3, 7,142,255,255,255, 0, 0, 0, 0,192,240,240, 96, 48, 48, 0, 12, 12,134,198,230,126, 60, 0, 0, 0,
0, 0, 3, 7, 15, 15, 14, 14, 14, 7, 3, 15, 15, 15, 0, 0, 0, 3, 7, 15, 15, 14, 14, 6, 3, 15, 15, 15, 0, 0, 3, 7, 7, 15, 14, 14, 14, 14, 7, 7, 2, 0, 0, 15, 15, 15, 0, 0, 0, 1, 3, 15, 15, 12,136,224,224,224,247,127,127, 31, 3, 0, 0, 0, 0, 0, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 15, 14, 14, 14, 6, 3, 15, 15, 15, 0, 0, 0, 3, 7, 15, 15, 14, 14, 14, 7, 3, 15, 15, 15, 0, 0, 0, 12, 15, 7, 0, 0, 0, 12, 14, 15, 15, 13, 13, 12, 12, 0, 0, 0, 0,
};
oled_write_raw_P(ducky_logo, LOGO_SIZE);
oled_write_raw_P(raw_logo, sizeof(raw_logo));
}
char* make_menu_text(void){
char *s = malloc((30 * 3) * sizeof(*s));
char *s = malloc((30 * 4) * sizeof(*s));
int width = 3;
sprintf(s, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
snprintf(s, 120, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
width, MT_0_0, width, MT_0_1, width, MT_0_2,
width, MT_0_3, width, MT_0_4, width, MT_0_5,
width, MT_0_6, width, MT_0_7, width, MT_0_8,
@ -156,10 +169,10 @@ char* make_menu_text(void){
};
char* make_rgb_text(void){
char *s = malloc((30 * 3) * sizeof(*s));
char *s = malloc((30 * 4) * sizeof(*s));
int width = 3;
sprintf(
s, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
snprintf(
s, 120, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
width, MT_1_0, width, MT_1_1, width, MT_1_2,
width, MT_1_3, width, MT_1_4, width, MT_1_5,
width, MT_1_6, width, MT_1_7, width, MT_1_8,
@ -170,10 +183,10 @@ char* make_rgb_text(void){
};
char* make_alt_text(void){
char *s = malloc((30 * 3) * sizeof(*s));
char *s = malloc((30 * 4) * sizeof(*s));
int width = 3;
sprintf(
s, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
snprintf(
s, 120, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
width, MT_2_0, width, MT_2_1, width, MT_2_2,
width, MT_2_3, width, MT_2_4, width, MT_2_5,
width, MT_2_6, width, MT_2_7, width, MT_2_8,
@ -183,23 +196,87 @@ char* make_alt_text(void){
return s;
};
char* make_sys_info_text(void) {
char *s = malloc((30 * 5) * sizeof(*s));
snprintf(s, 150, " cpu: %.1fGHz\n mem: %d%%\n gpu: %d%%\n temp: %dC\n time: %d:%d", cpuFreq, memPerc, gpuLoad, temp, hour, minute);
return s;
};
void oled_task_user(void) {
if (!sysToggled) {
render_logo();
oled_set_cursor(0,3);
if (rgbToggled) {
char *s = make_rgb_text();
oled_write_ln_P(s, false);
oled_write_ln(s, false);
free(s);
} else if (altToggled) {
char *s = make_alt_text();
oled_write_ln_P(s, false);
oled_write_ln(s, false);
free(s);
} else {
char *s = make_menu_text();
oled_write_ln_P(s, false);
oled_write_ln(s, false);
free(s);
}
}
};
int concat(int a, int b) {
char s1[20];
char s2[20];
sprintf(s1, "%d", a);
sprintf(s2, "%d", b);
strcat(s1, s2);
int c = atoi(s1);
return c;
};
void raw_hid_receive(uint8_t *data, uint8_t length) {
if (sysToggled) {
oled_clear();
render_logo();
int i;
int stepper = 0;
int toWrite;
for (i=0; i < length; i++) {
if (data[i] != 13) {
toWrite = concat(toWrite, data[i]);
} else {
switch (stepper) {
case 0:
cpuFreq = floor(100*toWrite)/10000;
break;
case 1:
memPerc = toWrite / 10;
break;
case 2:
gpuLoad = toWrite;
break;
case 3:
temp = toWrite;
break;
case 4:
hour = toWrite;
break;
case 5:
minute = toWrite;
break;
default:
break;
}
toWrite = 0;
stepper++;
}
}
oled_set_cursor(0,3);
char *s = make_sys_info_text();
oled_write_ln(s, false);
free(s);
}
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
@ -208,10 +285,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (rgbToggled) {
rgbToggled = false;
altToggled = false;
sysToggled = false;
oled_clear();
layer_clear();
} else {
rgbToggled = true;
altToggled = false;
sysToggled = false;
layer_on(_RGB);
}
}
@ -221,16 +301,34 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (altToggled) {
rgbToggled = false;
altToggled = false;
sysToggled = false;
oled_clear();
layer_clear();
} else {
rgbToggled = false;
sysToggled = false;
altToggled = true;
layer_on(_ALT);
}
}
return false;
case SYS_LAYER:
if (record->event.pressed) {
if (sysToggled) {
rgbToggled = false;
altToggled = false;
sysToggled = false;
oled_clear();
layer_clear();
} else {
rgbToggled = false;
sysToggled = true;
altToggled = false;
layer_on(_SYS);
}
}
default:
return true;
}
return false;
}
};

View File

@ -16,6 +16,8 @@ To change the menu, edit the `MT_X_XX` values in `config.h`. The sytax is as fol
The macros currently just map to Ctrl + Alt + (Different Keys) right now. I have them launching certain shortcuts. I recommend you change these and add your shortcuts to match your shortcut manager.
To get sysinfo working, run `pip3 install psutil GPUtil` and then `python sysinfo.py`. Now when pressing the bottom right key, you will get an info screen with your updated system info.
### Need Help?
Contact me on discord: macs#0420

View File

@ -0,0 +1,78 @@
###
# M4cs Keymap for dekuNukem/duckyPad QMK firmware
# Copyright (C) 2020 Max Bridgland
# 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 <http://www.gnu.org/licenses/>.
###
import hid
import time
import string
import psutil
import GPUtil
import datetime
vendor_id = 0x444E
product_id = 0x4450
usage_page = 0xFF60
usage = 0x61
device_interfaces = hid.enumerate(vendor_id, product_id)
raw_hid_interfaces = [i for i in device_interfaces if i['usage_page'] == usage_page and i['usage'] == usage]
if len(raw_hid_interfaces) == 0:
print('Couldnt find any interfaces')
exit()
interface = hid.device()
interface.open_path(raw_hid_interfaces[0]['path'])
print("Manufacturer: %s" % interface.get_manufacturer_string())
print("Product: %s" % interface.get_product_string())
time.sleep(0.05)
while True:
time.sleep(0.75)
cpufreq = psutil.cpu_freq()
currFreq = int(cpufreq.current)
svmem = psutil.virtual_memory()
memPerc = int(svmem.percent * 10)
gpus = GPUtil.getGPUs()
gpu = gpus[0]
load = int(gpu.load*100)
temp = int(gpu.temperature)
data = [0]
for x in str(currFreq):
data.append(int(x))
data.append(13)
for x in str(memPerc):
data.append(int(x))
data.append(13)
for x in str(load):
data.append(int(x))
data.append(13)
for x in str(temp):
data.append(int(x))
data.append(13)
now_hour = datetime.datetime.now().strftime("%I")
now_min = datetime.datetime.now().strftime("%M")
data.append(int(now_hour[0]))
data.append(int(now_hour[1]))
data.append(13)
data.append(int(now_min[0]))
data.append(int(now_min[1]))
data.append(13)
interface.write(data)

View File

@ -0,0 +1,73 @@
/*
Via Keymap for dekuNukem/duckyPad QMK firmware
Copyright (C) 2020 Max Bridgland
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 <http://www.gnu.org/licenses/>.
*/
#include QMK_KEYBOARD_H
#define LOGO_SIZE 384
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LAYOUT(
KC_KP_1, KC_KP_2, KC_KP_3,
KC_KP_4, KC_KP_5, KC_KP_6,
KC_KP_7, KC_KP_8, KC_KP_9,
KC_TRNS, KC_KP_0, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS
),
LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS
),
LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS
),
LAYOUT(
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS
),
};
static void render_logo(void) {
static const char PROGMEM ducky_logo[LOGO_SIZE] = {
0, 0, 0, 0,128,128,128,128,128, 0, 0,252,252,252, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0,128,128,128,128,128, 0, 0, 0, 0, 0,252,252,252, 0, 0, 0, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0,128,128,128,128, 0,248,248,248, 56, 56, 56, 56, 56, 56,120,240,224,192, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,128, 0, 0,252,252,252, 0, 0, 0, 0, 0,232, 24, 24,232, 0, 24, 48, 48, 24, 0,232, 24, 24,232, 0, 0,
0,248,254,255,143, 7, 3, 3, 3, 7,142,255,255,255, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0,255,255,255, 0,248,254,255,143, 7, 3, 3, 3, 3,143, 7, 2, 0, 0,255,255,255,240,120,252,254,231,131, 1, 0, 1, 7, 63,254,240,192, 0,224,252,127, 31, 3, 0, 0,255,255,255,112,112,112,112,112,112, 56, 63, 31, 15,193,231,243,115, 51, 51, 51, 55,255,255,252, 0, 0,248,254,255,143, 7, 3, 3, 3, 7,142,255,255,255, 0, 0, 0, 0, 0, 21,127,127,252,252,252,253,253,252,252,252,255,255,255, 0, 0,
0, 0, 3, 7, 15, 15, 14, 14, 14, 7, 3, 15, 15, 15, 0, 0, 0, 3, 7, 15, 15, 14, 14, 6, 3, 15, 15, 15, 0, 0, 3, 7, 7, 15, 14, 14, 14, 14, 7, 7, 2, 0, 0, 15, 15, 15, 0, 0, 0, 1, 3, 15, 15, 12,136,224,224,224,247,127,127, 31, 3, 0, 0, 0, 0, 0, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 15, 14, 14, 14, 6, 3, 15, 15, 15, 0, 0, 0, 3, 7, 15, 15, 14, 14, 14, 7, 3, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 11, 3, 11, 7, 11, 7, 7, 31, 0, 0
};
oled_write_raw_P(ducky_logo, LOGO_SIZE);
}
void oled_task_user(void) {
render_logo();
}

View File

@ -0,0 +1,3 @@
VIA_ENABLE = yes
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
RGB_MATRIX_ENABLE = no