[Keyboard] Add Pica40 (#19220)

Co-authored-by: Drashna Jaelre <drashna@live.com>
This commit is contained in:
Evgenii Vilkov
2022-12-30 01:53:31 +01:00
committed by GitHub
parent a7ff2b8d54
commit ced8142847
18 changed files with 775 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
// Copyright 2022 zzeneg (@zzeneg)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#ifdef RGBLIGHT_ENABLE
# define RGBLIGHT_DISABLE_KEYCODES // disable keycodes for RGB Light controls, only status LED is supported
# define PICA40_RGBLIGHT_TIMEOUT 5 // turn RGB off after N minutes
#endif

View File

@@ -0,0 +1,39 @@
{
"processor": "atmega32u4",
"bootloader": "caterina",
"diode_direction": "COL2ROW",
"matrix_pins": {
"cols": ["D2", "B5", "B4", "E6", "D7"],
"rows": ["B1", "B3", "B2", "B6", "F4", "F5", "F6", "F7"]
},
"features": {
"bootmagic": true,
"command": false,
"console": false,
"mousekey": true,
"extrakey": true,
"encoder": true,
"oled": true,
"rgblight": true,
"nkro": true
},
"rgblight": {
"led_count": 1,
"pin": "D3",
"layers": {
"enabled": true,
"max": 3
}
},
"encoder": {
"rotary": [{ "pin_a": "C6", "pin_b": "D4" }]
},
"usb": {
"device_version": "1.0.0",
"pid": "0x0841",
"vid": "0xFEED"
},
"build": {
"lto": true
}
}

View File

@@ -0,0 +1,91 @@
// Copyright 2022 zzeneg (@zzeneg)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "rev1.h"
#ifdef PICA40_RGBLIGHT_TIMEOUT
uint16_t check_rgblight_timer = 0;
uint16_t idle_timer = 0;
uint8_t counter = 0;
void housekeeping_task_kb(void) {
if (timer_elapsed(check_rgblight_timer) > 1000) {
check_rgblight_timer = timer_read();
if (rgblight_is_enabled() && timer_elapsed(idle_timer) > 10000) {
idle_timer = timer_read();
counter++;
}
if (rgblight_is_enabled() && counter > PICA40_RGBLIGHT_TIMEOUT * 6) {
counter = 0;
rgblight_disable_noeeprom();
}
}
housekeeping_task_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed && timer_elapsed(idle_timer) > 1000) {
idle_timer = timer_read();
counter = 0;
if (!rgblight_is_enabled()) {
rgblight_enable_noeeprom();
}
}
return process_record_user(keycode, record);
}
void keyboard_post_init_kb(void) {
check_rgblight_timer = timer_read();
idle_timer = timer_read();
rgblight_enable_noeeprom();
keyboard_post_init_user();
}
#endif // PICA40_RGBLIGHT_TIMEOUT
#ifdef OLED_ENABLE
oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
return OLED_ROTATION_270;
}
void render_mods(uint8_t modifiers) {
oled_write_ln_P((modifiers & MOD_MASK_CTRL) ? PSTR("Ctrl") : PSTR(" "), false);
oled_write_ln_P((modifiers & MOD_MASK_ALT) ? PSTR("Alt") : PSTR(" "), false);
oled_write_ln_P((modifiers & MOD_MASK_SHIFT) ? PSTR("Shft") : PSTR(" "), false);
oled_write_ln_P((modifiers & MOD_MASK_GUI) ? PSTR("GUI") : PSTR(" "), false);
}
bool oled_task_kb(void) {
// display's top is hidden by cover
oled_write_ln_P(PSTR(" "), false);
oled_write_ln_P(PSTR(" "), false);
oled_write_ln_P(PSTR(" "), false);
if (!oled_task_user()) return false;
render_mods(get_mods());
return true;
}
#endif // OLED_ENABLE
#ifdef ENCODER_ENABLE
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) return false;
tap_code(clockwise ? KC_VOLU : KC_VOLD);
return false;
}
#endif // ENCODER_ENABLE

View File

@@ -0,0 +1,6 @@
// Copyright 2022 zzeneg (@zzeneg)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "quantum.h"

View File

@@ -0,0 +1 @@
OLED_DRIVER = SSD1306