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

master
QMK Bot 2023-01-01 00:57:59 +00:00
commit 03ec3db651
6 changed files with 69 additions and 78 deletions

View File

@ -84,6 +84,6 @@
#define ENCODERS_PAD_B \ #define ENCODERS_PAD_B \
{ D6, B1 } { D6, B1 }
#define WORK_LOUDER_LED_PIN_1 B7 #define WORK_LOUDER_LED_PIN_1 B6
#define WORK_LOUDER_LED_PIN_2 B6 #define WORK_LOUDER_LED_PIN_2 B7
#define WORK_LOUDER_LED_PIN_3 B5 #define WORK_LOUDER_LED_PIN_3 B5

View File

@ -4,30 +4,29 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
LAYOUT( [0] = LAYOUT(
KC_MPLY, KC_9, KC_0, KC_NO, KC_MPLY, XXXXXXX, XXXXXXX, XXXXXXX,
KC_5, KC_6, KC_7, KC_8, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
KC_1, KC_2, KC_3, KC_4, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
TO(1), KC_DOT, KC_COMM, USER09 RGB_TOG, XXXXXXX, XXXXXXX, 0x5011
), ),
LAYOUT( [1] = LAYOUT(
_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
TO(2), _______, _______, _______ XXXXXXX, XXXXXXX, XXXXXXX, 0x5012
), ),
LAYOUT( [2] = LAYOUT(
_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
TO(3), _______, _______, _______ XXXXXXX, XXXXXXX, XXXXXXX, 0x5013
), ),
LAYOUT( [3] = LAYOUT(
_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
_______, _______, _______, _______, USER00, USER01, USER03, USER05,
_______, _______, _______, _______, XXXXXXX, USER02, USER04, USER06,
TO(0), _______, _______, _______ XXXXXXX, XXXXXXX, XXXXXXX, 0x5010
) )
}; };
@ -51,22 +50,28 @@ typedef union {
work_louder_config_t work_louder_config; work_louder_config_t work_louder_config;
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#ifdef CONSOLE_ENABLE
uprintf("KL: kc: 0x%04X, col: %2u, row: %2u, pressed: %b, time: %5u, int: %b, count: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed, record->event.time, record->tap.interrupted, record->tap.count);
#endif
switch (keycode) { switch (keycode) {
case USER09: case USER09:
if (record->event.pressed) { if (record->event.pressed) {
work_louder_config.led_level++; work_louder_config.led_level++;
if (work_louder_config.led_level > 4) { if (work_louder_config.led_level > 4) {
work_louder_config.led_level = 0; work_louder_config.led_level = 1;
} }
work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4)); work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4));
eeconfig_update_user(work_louder_config.raw); eeconfig_update_user(work_louder_config.raw);
layer_state_set_kb(layer_state); layer_state_set_kb(layer_state);
} }
break; break;
case 0x5000 ... 0x500F:
if (record->event.pressed) {
layer_move(keycode - 0x5000);
}
return false; break;
case 0x5010 ... 0x501F:
if (record->event.pressed) {
layer_move(keycode - 0x5010);
}
return false; break;
} }
return true; return true;
} }
@ -86,7 +91,11 @@ void eeconfig_init_user(void) {
eeconfig_update_user(work_louder_config.raw); eeconfig_update_user(work_louder_config.raw);
} }
void matrix_init_user(void) { void keyboard_post_init_user(void) {
work_louder_config.raw = eeconfig_read_user(); work_louder_config.raw = eeconfig_read_user();
work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4)); work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4));
} }
void suspend_wakeup_init_user(void) {
layer_state_set_user(layer_state);
}

View File

@ -1,2 +1,4 @@
VIA_ENABLE = yes VIA_ENABLE = yes
ENCODER_MAP_ENABLE = yes ENCODER_MAP_ENABLE = yes
MAGIC_ENABLE = no
SPACE_CADET_ENABLE = no

View File

@ -49,22 +49,28 @@ bool encoder_update_kb(uint8_t index, bool clockwise) {
#endif #endif
void work_louder_micro_led_1_on(void) { void work_louder_micro_led_1_on(void) {
setPinOutput(WORK_LOUDER_LED_PIN_1);
writePin(WORK_LOUDER_LED_PIN_1, true); writePin(WORK_LOUDER_LED_PIN_1, true);
} }
void work_louder_micro_led_2_on(void) { void work_louder_micro_led_2_on(void) {
setPinOutput(WORK_LOUDER_LED_PIN_2);
writePin(WORK_LOUDER_LED_PIN_2, true); writePin(WORK_LOUDER_LED_PIN_2, true);
} }
void work_louder_micro_led_3_on(void) { void work_louder_micro_led_3_on(void) {
setPinOutput(WORK_LOUDER_LED_PIN_3);
writePin(WORK_LOUDER_LED_PIN_3, true); writePin(WORK_LOUDER_LED_PIN_3, true);
} }
void work_louder_micro_led_1_off(void) { void work_louder_micro_led_1_off(void) {
setPinInput(WORK_LOUDER_LED_PIN_1);
writePin(WORK_LOUDER_LED_PIN_1, false); writePin(WORK_LOUDER_LED_PIN_1, false);
} }
void work_louder_micro_led_2_off(void) { void work_louder_micro_led_2_off(void) {
setPinInput(WORK_LOUDER_LED_PIN_2);
writePin(WORK_LOUDER_LED_PIN_2, false); writePin(WORK_LOUDER_LED_PIN_2, false);
} }
void work_louder_micro_led_3_off(void) { void work_louder_micro_led_3_off(void) {
setPinInput(WORK_LOUDER_LED_PIN_3);
writePin(WORK_LOUDER_LED_PIN_3, false); writePin(WORK_LOUDER_LED_PIN_3, false);
} }
@ -81,15 +87,15 @@ void work_louder_micro_led_all_off(void) {
} }
void work_louder_micro_led_1_set(uint8_t n) { void work_louder_micro_led_1_set(uint8_t n) {
#if WORK_LOUDER_LED_PIN_1 == B7 #if WORK_LOUDER_LED_PIN_1 == B6
OCR1C = n; OCR1B = n;
#else #else
n ? work_louder_micro_led_1_on() : work_louder_micro_led_1_off(); n ? work_louder_micro_led_1_on() : work_louder_micro_led_1_off();
#endif #endif
} }
void work_louder_micro_led_2_set(uint8_t n) { void work_louder_micro_led_2_set(uint8_t n) {
#if WORK_LOUDER_LED_PIN_2 == B6 #if WORK_LOUDER_LED_PIN_2 == B7
OCR1B = n; OCR1C = n;
#else #else
n ? work_louder_micro_led_2_on() : work_louder_micro_led_2_off(); n ? work_louder_micro_led_2_on() : work_louder_micro_led_2_off();
#endif #endif
@ -108,49 +114,16 @@ void work_louder_micro_led_all_set(uint8_t n) {
work_louder_micro_led_3_set(n); work_louder_micro_led_3_set(n);
} }
#ifdef DEFER_EXEC_ENABLE void keyboard_post_init_kb(void) {
uint32_t startup_animation(uint32_t trigger_time, void *cb_arg) { TCCR1A = 0b10101001; // set and configure fast PWM
static uint8_t index = 0; TCCR1B = 0b00001001; // set and configure fast PWM
switch (index) { keyboard_post_init_user();
case 0:
work_louder_micro_led_1_on();
break;
case 1:
work_louder_micro_led_2_on();
break;
case 2:
work_louder_micro_led_3_on();
break;
case 3:
work_louder_micro_led_1_off();
break;
case 4:
work_louder_micro_led_2_off();
break;
case 5:
work_louder_micro_led_3_off();
break;
default:
return 0;
}
index++;
return 100;
} }
#endif
void matrix_init_kb(void) { void work_louder_led_init_animation(void) {
work_louder_micro_led_all_off();
setPinOutput(WORK_LOUDER_LED_PIN_1); // left led
writePin(WORK_LOUDER_LED_PIN_1, false);
setPinOutput(WORK_LOUDER_LED_PIN_2); // middle led
writePin(WORK_LOUDER_LED_PIN_2, false);
setPinOutput(WORK_LOUDER_LED_PIN_3); // right led
writePin(WORK_LOUDER_LED_PIN_3, false);
#ifdef DEFER_EXEC_ENABLE
defer_exec(500, startup_animation, NULL);
#else
wait_ms(500); wait_ms(500);
work_louder_micro_led_1_on(); work_louder_micro_led_1_on();
wait_ms(100); wait_ms(100);
@ -164,7 +137,15 @@ void matrix_init_kb(void) {
wait_ms(100); wait_ms(100);
work_louder_micro_led_3_off(); work_louder_micro_led_3_off();
wait_ms(200); wait_ms(200);
#endif }
matrix_init_user();
void suspend_power_down_kb(void) {
suspend_power_down_user();
work_louder_micro_led_all_off();
}
void suspend_wakeup_init_kb(void) {
work_louder_led_init_animation();
suspend_wakeup_init_user();
} }

View File

@ -20,3 +20,4 @@ extern void work_louder_micro_led_2_set(uint8_t n);
extern void work_louder_micro_led_3_set(uint8_t n); extern void work_louder_micro_led_3_set(uint8_t n);
extern void work_louder_micro_led_all_set(uint8_t n); extern void work_louder_micro_led_all_set(uint8_t n);
void work_louder_led_init_animation(void);

View File

@ -2,5 +2,3 @@ RGB_MATRIX_DRIVER = WS2812
SRC += rgb_functions.c \ SRC += rgb_functions.c \
matrix.c matrix.c
DEFERRED_EXEC_ENABLE = yes