Compare commits

..
5 Commits
Author SHA1 Message Date
a_p_u_r_o 7874f297b3 Remove CR when computing BOOTLOADER_SIZE. (#7453) 2019-11-24 03:01:03 +11:00
Yan-Fa Li 3541f01a72 Update led_update_kb example (#7451)
* Update led_update_kb example

* Update comment to explain pin behavior

* wordsmith

* wordsmithing 2
2019-11-23 15:37:25 +00:00
Hilary B. Brenum eae21eed74 [Keymap] Adding hbbisenieks keymap for keebio/iris (#7440)
* hbbisenieks keymap

* fixed right encoder

* changes suggested during pr
2019-11-22 14:40:18 -08:00
Yan-Fa Liandfauxpark e62ab7e259 Allow overriding of all functions in wonderland.c (#7198)
* f

* Allow overriding of all functions in wonderland.c

 - needed for custom LED functions in keymap.c

* Example of layer indication via LEDs

optimize

* Use newer led_update_kb and led_update_user hooks

 - these allow overriding without use of __attribute((weak))__

* Update led documentation a bit

 - clarify some of the wording around how  to use led_update_user

* Update led_update_user example

* Update audio example to be complete

* trailing spaces smh

* spaces

* spaces

* smh

* Less code is good

* Update docs/custom_quantum_functions.md

Co-Authored-By: fauxpark <[email protected]>

* Update docs/custom_quantum_functions.md

Co-Authored-By: fauxpark <[email protected]>

* Update docs/custom_quantum_functions.md

Co-Authored-By: fauxpark <[email protected]>

* Update docs/custom_quantum_functions.md

Co-Authored-By: fauxpark <[email protected]>

* Update docs/custom_quantum_functions.md

Co-Authored-By: fauxpark <[email protected]>

* Update docs/custom_quantum_functions.md

Co-Authored-By: fauxpark <[email protected]>
2019-11-22 12:55:45 -08:00
dsanchezseco 0270d4d5a1 [Keymap] changed knight ridder offset to face me on planck (#7445)
* added rgblight controls to planck keymap

* fixed knight ridder offset to face me
2019-11-22 10:26:45 -08:00
11 changed files with 378 additions and 72 deletions

No files matched your search

+35 -52
View File
@@ -114,7 +114,15 @@ Two more deprecated functions exist that provide the LED state as a `uint8_t`:
This function will be called when the state of one of those 5 LEDs changes. It receives the LED state as a struct parameter. This function will be called when the state of one of those 5 LEDs changes. It receives the LED state as a struct parameter.
You must return either `true` or `false` from this function, depending on whether you want to override the keyboard-level implementation. By convention, return `true` from `led_update_user()` to get the `led_update_kb()` hook to run its code, and
return `false` when you would prefer not to run the code in `led_update_kb()`.
Some examples include:
- overriding the LEDs to use them for something else like layer indication
- return `false` because you do not want the `_kb()` function to run, as it would override your layer behavior.
- play a sound when an LED turns on or off.
- return `true` because you want the `_kb` function to run, and this is in addition to the default LED behavior.
?> Because the `led_set_*` functions return `void` instead of `bool`, they do not allow for overriding the keyboard LED control, and thus it's recommended to use `led_update_*` instead. ?> Because the `led_set_*` functions return `void` instead of `bool`, they do not allow for overriding the keyboard LED control, and thus it's recommended to use `led_update_*` instead.
@@ -122,66 +130,41 @@ You must return either `true` or `false` from this function, depending on whethe
```c ```c
bool led_update_kb(led_t led_state) { bool led_update_kb(led_t led_state) {
if(led_update_user(led_state)) { bool res = led_update_user(led_state);
if (led_state.num_lock) { if(res) {
writePinLow(B0); // writePin sets the pin high for 1 and low for 0.
} else { // In this example the pins are inverted, setting
writePinHigh(B0); // it low/0 turns it on, and high/1 turns the LED off.
} // This behavior depends on whether the LED is between the pin
if (led_state.caps_lock) { // and VCC or the pin and GND.
writePinLow(B1); writePin(B0, !led_state.num_lock);
} else { writePin(B1, !led_state.caps_lock);
writePinHigh(B1); writePin(B2, !led_state.scroll_lock);
} writePin(B3, !led_state.compose);
if (led_state.scroll_lock) { writePin(B4, !led_state.kana);
writePinLow(B2);
} else {
writePinHigh(B2);
}
if (led_state.compose) {
writePinLow(B3);
} else {
writePinHigh(B3);
}
if (led_state.kana) {
writePinLow(B4);
} else {
writePinHigh(B4);
}
return true;
} }
return res;
} }
``` ```
### Example `led_update_user()` Implementation ### Example `led_update_user()` Implementation
This incomplete example would play a sound if Caps Lock is turned on or off. It returns `true`, because you also want the LEDs to maintain their state.
```c ```c
#ifdef AUDIO_ENABLE
float caps_on[][2] = SONG(CAPS_LOCK_ON_SOUND);
float caps_off[][2] = SONG(CAPS_LOCK_OFF_SOUND);
#endif
bool led_update_user(led_t led_state) { bool led_update_user(led_t led_state) {
if (led_state.num_lock) { #ifdef AUDIO_ENABLE
writePinLow(B0); static uint8_t caps_state = 0;
} else { if (caps_state != led_state.caps_lock) {
writePinHigh(B0); led_state.caps_lock ? PLAY_SONG(caps_on) : PLAY_SONG(caps_off);
} caps_state = led_state.caps_lock;
if (led_state.caps_lock) {
writePinLow(B1);
} else {
writePinHigh(B1);
}
if (led_state.scroll_lock) {
writePinLow(B2);
} else {
writePinHigh(B2);
}
if (led_state.compose) {
writePinLow(B3);
} else {
writePinHigh(B3);
}
if (led_state.kana) {
writePinLow(B4);
} else {
writePinHigh(B4);
} }
#endif
return true; return true;
} }
``` ```
@@ -0,0 +1,85 @@
/* Copyright 2019 Danny Nguyen <[email protected]>
*
* 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/>.
*/
#include QMK_KEYBOARD_H
#define _AUDACITY 0
#define _LIGHTS 1
enum custom_keycodes {
AUDACITY = SAFE_RANGE,
LIGHTS,
};
#define KC_ KC_TRNS
#define KC_AUD AUDACITY
#define KC_LITE LIGHTS
#define KC_ZNRM LCTL(KC_2) // zoom normal
#define KC_SAVE LCTL(KC_S) // save
#define KC_SYNC LALT(KC_S) // sync-lock tracks
#define KC_SLNC LCTL(KC_L) // silence selection
#define KC_BL_S BL_STEP
#define KC_RGBM RGB_MOD
#define KC_RGBT RGB_TOG
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/*
| Knob 1: Vol Dn/Up | | Knob 2: Page Dn/Up |
| Press: Mute | Home | Press: Play/Pause |
| Hold: Layer 2 | Up | RGB Mode |
| Left | Down | Right |
*/
[_AUDACITY] = LAYOUT(
//,-------+-------+-------.
KC_LITE,KC_SAVE,KC_ZNRM,
//|-------+-------+-------|
KC_SYNC,KC_SLNC,KC_BSPC,
//|-------+-------+-------|
KC_SPC , KC_F1 , KC_F2
//`-------+-------+-------'
),
/*
| RESET | N/A | Media Stop |
| Held: Layer 2 | Home | RGB Mode |
| Media Previous | End | Media Next |
*/
[_LIGHTS] = LAYOUT(
//,-------+-------+-------.
KC_ ,KC_BL_S,KC_STOP,
//|-------+-------+-------|
KC_RGBM,KC_HOME,KC_RGBT,
//|-------+-------+-------|
KC_MPRV,KC_END ,KC_MNXT
//`-------+-------+-------'
),
};
void encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) {
if (clockwise) {
tap_code(KC_RGHT);
} else {
tap_code(KC_LEFT);
}
}
else if (index == 1) {
if (clockwise) {
SEND_STRING(SS_LCTRL("1")); // audacity zoom in
} else {
SEND_STRING(SS_LCTRL("3")); // audacity zoom out
}
}
}
@@ -0,0 +1,41 @@
/*
Copyright 2017 Danny Nguyen <[email protected]>
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
/* Use I2C or Serial, not both */
#define USE_SERIAL
// #define USE_I2C
/* Select hand configuration */
#define MASTER_LEFT
// #define MASTER_RIGHT
// #define EE_HANDS
#define TAPPING_TERM 150
#define TAPPING_TOGGLE 2
#define PERMISSIVE_HOLD
#undef RGBLED_NUM
#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 12
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
@@ -0,0 +1,161 @@
#include QMK_KEYBOARD_H
enum layer_names {
_QWERTY,
_LOWER,
_RAISE,
_ADJUST,
};
enum custom_keycodes {
LOWER = SAFE_RANGE,
RAISE,
ADJUST,
GUSR,
HGRP,
CHUS,
};
#define KC_ KC_TRNS
#define KC_CAPW LGUI(LSFT(KC_3)) // Capture whole screen
#define KC_CPYW LGUI(LSFT(LCTL(KC_3))) // Copy whole screen
#define KC_CAPP LGUI(LSFT(KC_4)) // Capture portion of screen
#define KC_CPYP LGUI(LSFT(LCTL(KC_4))) // Copy portion of screen
#define KC_ESCC MT(MOD_LCTL, KC_ESC)
#define KC_LOWR LOWER
#define KC_RASE RAISE
#define KC_RST RESET
#define KC_BL_S BL_STEP
// Left and right shift as mot-tap square braces
#define KC_LSBR MT(MOD_LSFT, KC_LBRC)
#define KC_RSBR MT(MOD_RSFT, KC_RBRC)
// mod-tap shift/minus
#define KC_SMIN MT(MOD_LSFT, KC_MINS)
// Tap-toggle layers
#define KC_TT_L TT(1)
#define KC_TT_R TT(2)
#define KC_RGBM RGB_MOD
#define KC_RGBT RGB_TOG
#define KC_SLOK LGUI(LCTL(KC_Q)) // mojave lock screen
#define KC_GUSR GUSR // "gam info user" macro
#define KC_HGRP HGRP // "history | grep" macro
#define KC_CHUS CHUS // "thisisunsafe" chrome browser macro
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
GRV , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
TAB , Q , W , E , R , T , Y , U , I , O , P ,BSLS,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
ESC , A , S , D , F , G , H , J , K , L ,SCLN,QUOT,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
LSBR, Z , X , C , V , B ,TT_L, TT_R, N , M ,COMM,DOT ,SLSH,RSBR,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
LCTL,SMIN,LGUI, ENT ,SPC ,LALT
// `----+----+----' `----+----+----'
),
[_LOWER] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
TILD,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,MINS,EQL , ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
,SLOK, , UP , ,RGBT, P7 , P8 , P9 , E , F ,LPRN,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
DEL , ,LEFT,DOWN,RGHT,GUSR, P4 , P5 , P6 , C , D ,RPRN,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
BL_S, , , ,HGRP,CHUS, , , P1 , P2 , P3 , A , B , ,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
, , , DOT , P0 ,COLN
// `----+----+----' `----+----+----'
),
[_RAISE] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
F12 , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 ,F10 ,F11 ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
,RGBT,RGBM, , , , ,AMPR,MUTE, , , ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
,CAPW,CPYW,CAPP,CPYP,PGUP, EQL ,HOME,VOLU,MRWD,MFFD, ,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
, , , , ,PGDN, , ,PLUS,END ,VOLD,MPLY,MSTP, ,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
, , , , ,
// `----+----+----' `----+----+----'
),
[_ADJUST] = LAYOUT(
//,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------.
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
RGB_TOG, RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, _______, _______, _______, _______, _______,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
RESET , DEBUG , RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, _______, _______, _______,
//|--------+--------+--------+--------+--------+--------+--------. ,--------|--------+--------+--------+--------+--------+--------|
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
//`--------+--------+--------+----+---+--------+--------+--------/ \--------+--------+--------+---+----+--------+--------+--------'
_______, _______, _______, _______, _______, _______
// `--------+--------+--------' `--------+--------+--------'
)
};
#ifdef AUDIO_ENABLE
float tone_qwerty[][2] = SONG(QWERTY_SOUND);
#endif
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LOWER:
if (record->event.pressed) {
layer_on(_LOWER);
update_tri_layer(_LOWER, _RAISE, _ADJUST);
} else {
layer_off(_LOWER);
update_tri_layer(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case RAISE:
if (record->event.pressed) {
layer_on(_RAISE);
update_tri_layer(_LOWER, _RAISE, _ADJUST);
} else {
layer_off(_RAISE);
update_tri_layer(_LOWER, _RAISE, _ADJUST);
}
return false;
break;
case ADJUST:
if (record->event.pressed) {
layer_on(_ADJUST);
} else {
layer_off(_ADJUST);
}
return false;
break;
case GUSR:
if (record->event.pressed) {
SEND_STRING("gam info user ");
}
break;
case HGRP:
if (record->event.pressed) {
SEND_STRING("history|grep ");
}
break;
case CHUS:
if (record->event.pressed) {
SEND_STRING("thisisunsafe");
}
break;
}
return true;
}
@@ -0,0 +1,6 @@
# HBBisenieks' Iris Layout
A modified Iris layout with toggle-tap layers and a hexidecimal
numpad. Other features include Space-Cadet-like shift keys that can do
square or curly braces and a home-row escape key.
@@ -0,0 +1,6 @@
RGBLIGHT_ENABLE = yes
BACKLIGHT_ENABLE = yes
# Comment out for pro-micro board
BOOTLOADER = atmel-dfu
@@ -22,3 +22,33 @@ RGB_RMOD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX
_______, KC_LALT, _______, _______, _______, KC_RALT, _______ \ _______, KC_LALT, _______, _______, _______, KC_RALT, _______ \
) )
}; };
#ifdef USE_LEDS_FOR_LAYERS
// example of how to use LEDs as layer indicators
static uint8_t top = 1;
static uint8_t middle = 0;
static uint8_t bottom = 0;
layer_state_t layer_state_set_user(layer_state_t state) {
top = middle = bottom = 0;
switch (get_highest_layer(state)) {
case _BASE:
top = 1;
break;
case _FUNC:
middle = 1;
break;
default: // for any other layers, or the default layer
break;
}
return state;
}
// override kb level function
bool led_update_user(led_t usb_led) {
writePin(B1, !top);
writePin(B2, !middle);
writePin(B3, !bottom);
return false; // we are using LEDs for something else override kb
}
#endif
+10 -18
View File
@@ -1,5 +1,6 @@
#include "wonderland.h" #include "wonderland.h"
__attribute__ ((weak))
void matrix_init_kb(void) { void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
@@ -7,12 +8,14 @@ void matrix_init_kb(void) {
led_init_ports(); led_init_ports();
}; };
__attribute__ ((weak))
void matrix_scan_kb(void) { void matrix_scan_kb(void) {
// put your looping keyboard code here // put your looping keyboard code here
// runs every cycle (a lot) // runs every cycle (a lot)
matrix_scan_user(); matrix_scan_user();
}; };
__attribute__ ((weak))
void led_init_ports(void) { void led_init_ports(void) {
// * Set our LED pins as output // * Set our LED pins as output
setPinOutput(B1); setPinOutput(B1);
@@ -20,23 +23,12 @@ void led_init_ports(void) {
setPinOutput(B3); setPinOutput(B3);
} }
void led_set_kb(uint8_t usb_led) { bool led_update_kb(led_t led_state) {
if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { bool runDefault = led_update_user(led_state);
writePinLow(B1); if (runDefault) {
} else { writePin(B1, !led_state.num_lock);
writePinHigh(B1); writePin(B2, !led_state.caps_lock);
writePin(B3, !led_state.scroll_lock);
} }
return runDefault;
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
writePinLow(B2);
} else {
writePinHigh(B2);
}
if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
writePinLow(B3);
} else {
writePinHigh(B3);
}
led_set_user(usb_led);
} }
@@ -3,3 +3,5 @@
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
#define STARTUP_SONG SONG(DVORAK_SOUND) #define STARTUP_SONG SONG(DVORAK_SOUND)
#endif #endif
#define RGBLIGHT_EFFECT_KNIGHT_OFFSET 5
+1 -1
View File
@@ -321,7 +321,7 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
bootloader: bootloader:
make -C lib/lufa/Bootloaders/DFU/ clean make -C lib/lufa/Bootloaders/DFU/ clean
$(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS) $(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS)
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0))
+1 -1
View File
@@ -397,7 +397,7 @@ ifeq ($(findstring avr-gcc,$(CC)),avr-gcc)
SIZE_MARGIN = 1024 SIZE_MARGIN = 1024
check-size: check-size:
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi))
$(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE)))
$(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE)))