diff options
author | Drashna Jaelre <drashna@live.com> | 2022-07-26 12:50:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-26 20:50:45 +0100 |
commit | 5f36285fc5905913aea0671e037bb343fd84391f (patch) | |
tree | fe678b41ae43d5ff42546a828f0028325eb55c05 /keyboards/work_louder/micro/micro.c | |
parent | 9dbc0473efd64ae246e171fe0201708725c9eeda (diff) |
[Keyboard] Add work louder micro (#17586)
* [Keyboard] Add work louder micro
* Update keyboards/work_louder/micro/readme.md
* Update readme
* Update kb config files
* Update to use encoder map
Co-authored-by: Tom Barnes <barnestom@me.com>
Diffstat (limited to 'keyboards/work_louder/micro/micro.c')
-rw-r--r-- | keyboards/work_louder/micro/micro.c | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/keyboards/work_louder/micro/micro.c b/keyboards/work_louder/micro/micro.c new file mode 100644 index 0000000000..aae8048c59 --- /dev/null +++ b/keyboards/work_louder/micro/micro.c @@ -0,0 +1,170 @@ +// Copyright 2022 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +#if defined(RGB_MATRIX_ENABLE) +// clang-format off +led_config_t g_led_config = { { + { NO_LED, 10, 11, NO_LED }, + { 9 , 8, 7, 6 }, + { 2, 3, 4, 5 }, + { NO_LED, 1, 0, NO_LED } + }, { + { 122, 64 }, { 103, 64 }, + { 84, 45 }, { 103, 45 }, { 133, 45 }, { 152, 45 }, + { 152, 26 }, { 122, 26 }, { 103, 26 }, { 84, 26 }, + { 103, 7 }, { 122, 7 } + }, + { + 4, 4, + 4, 4, 4, 4, + 4, 4, 4, 4, + 4, 4 + } +}; +// clang-format on +#endif + +#if defined(ENCODER_ENABLE) && !defined(ENCODERS) && !defined(ENCODER_MAP_ENABLE) +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) { + return false; + } + if (index == 0) { + if (clockwise) { + tap_code_delay(KC_VOLU, 10); + } else { + tap_code_delay(KC_VOLD, 10); + } + } else if (index == 1) { + if (clockwise) { + tap_code_delay(KC_WH_U, 10); + } else { + tap_code_delay(KC_WH_D, 10); + } + } + return true; +} +#endif + +void work_louder_micro_led_1_on(void) { + writePin(WORK_LOUDER_LED_PIN_1, true); +} +void work_louder_micro_led_2_on(void) { + writePin(WORK_LOUDER_LED_PIN_2, true); +} +void work_louder_micro_led_3_on(void) { + writePin(WORK_LOUDER_LED_PIN_3, true); +} + +void work_louder_micro_led_1_off(void) { + writePin(WORK_LOUDER_LED_PIN_1, false); +} +void work_louder_micro_led_2_off(void) { + writePin(WORK_LOUDER_LED_PIN_2, false); +} +void work_louder_micro_led_3_off(void) { + writePin(WORK_LOUDER_LED_PIN_3, false); +} + +void work_louder_micro_led_all_on(void) { + work_louder_micro_led_1_on(); + work_louder_micro_led_2_on(); + work_louder_micro_led_3_on(); +} + +void work_louder_micro_led_all_off(void) { + work_louder_micro_led_1_off(); + work_louder_micro_led_2_off(); + work_louder_micro_led_3_off(); +} + +void work_louder_micro_led_1_set(uint8_t n) { +#if WORK_LOUDER_LED_PIN_1 == B7 + OCR1C = n; +#else + n ? work_louder_micro_led_1_on() : work_louder_micro_led_1_off(); +#endif +} +void work_louder_micro_led_2_set(uint8_t n) { +#if WORK_LOUDER_LED_PIN_2 == B6 + OCR1B = n; +#else + n ? work_louder_micro_led_2_on() : work_louder_micro_led_2_off(); +#endif +} +void work_louder_micro_led_3_set(uint8_t n) { +#if WORK_LOUDER_LED_PIN_3 == B5 + OCR1A = n; +#else + n ? work_louder_micro_led_3_on() : work_louder_micro_led_3_off(); +#endif +} + +void work_louder_micro_led_all_set(uint8_t n) { + work_louder_micro_led_1_set(n); + work_louder_micro_led_2_set(n); + work_louder_micro_led_3_set(n); +} + +#ifdef DEFER_EXEC_ENABLE +uint32_t startup_animation(uint32_t trigger_time, void *cb_arg) { + static uint8_t index = 0; + + switch (index) { + 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) { + + 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); + work_louder_micro_led_1_on(); + wait_ms(100); + work_louder_micro_led_2_on(); + wait_ms(100); + work_louder_micro_led_3_on(); + wait_ms(100); + work_louder_micro_led_1_off(); + wait_ms(100); + work_louder_micro_led_2_off(); + wait_ms(100); + work_louder_micro_led_3_off(); + wait_ms(200); +#endif + matrix_init_user(); + +} |