From 721cc6efeb3e89e28fd3276a1cf27a7c73e7b756 Mon Sep 17 00:00:00 2001 From: Thomaz Moura <5599621+thomazmoura@users.noreply.github.com> Date: Sat, 5 Dec 2020 16:54:44 -0300 Subject: [PATCH] Include logic to send solid colors as foreground to shine and add sample profiles (#14) Include the logic to send a solid color from qmk to shine. That solid color will act as a foreground (will override the current profile) until reset (witch will reactivate the current profile). This functionality depends on changes made for shine as well. Include 3 new profiles: default-full-caps -> same as default, but with the logic of using the red foreground color on caps lock. default-layer-indicators -> same as default, but with the logic of red foreground on caps lock, green foreground on FN1 and blue foreground on FN2. thomazmoura -> my own profile as a sample of an over-engineered advanced case scenario. --- .../keymaps/default-full-caps/keymap.c | 115 +++++ .../keymaps/default-layer-indicators/keymap.c | 132 ++++++ .../annepro2/keymaps/thomazmoura/config.h | 15 + .../annepro2/keymaps/thomazmoura/keymap.c | 419 ++++++++++++++++++ .../annepro2/keymaps/thomazmoura/rules.mk | 47 ++ keyboards/annepro2/qmk_ap2_led.c | 14 + keyboards/annepro2/qmk_ap2_led.h | 3 + 7 files changed, 745 insertions(+) create mode 100644 keyboards/annepro2/keymaps/default-full-caps/keymap.c create mode 100644 keyboards/annepro2/keymaps/default-layer-indicators/keymap.c create mode 100644 keyboards/annepro2/keymaps/thomazmoura/config.h create mode 100644 keyboards/annepro2/keymaps/thomazmoura/keymap.c create mode 100644 keyboards/annepro2/keymaps/thomazmoura/rules.mk diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c new file mode 100644 index 000000000000..329c70dd4abc --- /dev/null +++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c @@ -0,0 +1,115 @@ +#include +#include "annepro2.h" +#include "qmk_ap2_led.h" + +enum anne_pro_layers { + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, +}; + +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* | Caps | a | s | d | f | g | h | j | k | l | ; | ' | Enter | +* |-----------------------------------------------------------------------------------------+ +* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | UP | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | LEFT | DOWN | RIGHT | +* \-----------------------------------------------------------------------------------------/ +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) +), + /* + * Layer _FN1_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift |V-UP |V-DWN|MUTE | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN1_LAYER] = KEYMAP( /* Base */ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS +), + /* + * Layer _FN2_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN2_LAYER] = KEYMAP( /* Base */ + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, + MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS + ), +}; +const uint16_t keymaps_size = sizeof(keymaps); + + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { +} + +layer_state_t layer_state_set_user(layer_state_t layer) { + return layer; +} + +// The function to handle the caps lock logic +bool led_update_user(led_t leds) { + if (leds.caps_lock) { + // Set the leds to red + annepro2LedSetForegroundColor(0xFF, 0x00, 0x00); + } else { + annepro2LedResetForegroundColor(); + } + + return true; +} + diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c new file mode 100644 index 000000000000..b58f916b47c0 --- /dev/null +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -0,0 +1,132 @@ +#include +#include "annepro2.h" +#include "qmk_ap2_led.h" + +enum anne_pro_layers { + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, +}; + +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* | Caps | a | s | d | f | g | h | j | k | l | ; | ' | Enter | +* |-----------------------------------------------------------------------------------------+ +* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | UP | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | LEFT | DOWN | RIGHT | +* \-----------------------------------------------------------------------------------------/ +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) +), + /* + * Layer _FN1_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift |V-UP |V-DWN|MUTE | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN1_LAYER] = KEYMAP( /* Base */ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS +), + /* + * Layer _FN2_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN2_LAYER] = KEYMAP( /* Base */ + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, + MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS + ), +}; +const uint16_t keymaps_size = sizeof(keymaps); + + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { +} + +layer_state_t layer_state_set_user(layer_state_t layer) { + switch(get_highest_layer(layer)) { + case _FN1_LAYER: + // Set the leds to green + annepro2LedSetForegroundColor(0x00, 0xFF, 0x00); + break; + case _FN2_LAYER: + // Set the leds to blue + annepro2LedSetForegroundColor(0x00, 0x00, 0xFF); + break; + default: + // Reset back to the current profile + annepro2LedResetForegroundColor(); + break; + } + return layer; +} + +// The function to handle the caps lock logic +bool led_update_user(led_t leds) { + if (leds.caps_lock) { + // Set the leds to red + annepro2LedSetForegroundColor(0xFF, 0x00, 0x00); + } else { + // Reset back to the current profile if there is no layer active + if(!layer_state_is(_FN1_LAYER) && !layer_state_is(_FN2_LAYER)) { + annepro2LedResetForegroundColor(); + } + } + + return true; +} + diff --git a/keyboards/annepro2/keymaps/thomazmoura/config.h b/keyboards/annepro2/keymaps/thomazmoura/config.h new file mode 100644 index 000000000000..639124e1703f --- /dev/null +++ b/keyboards/annepro2/keymaps/thomazmoura/config.h @@ -0,0 +1,15 @@ +#pragma once + +#undef TAPPING_TERM +#define TAPPING_TERM 200 +#define RETRO_TAPPING + +#undef TAPPING_TOGGLE +#define TAPPING_TOGGLE 2 + +#define MK_3_SPEED +#define MK_MOMENTARY_ACCEL + +#define CAPS_LOCATION (MATRIX_COLS * 0 + 0) + +#define IDLE_PROFILE_INDEX 0 diff --git a/keyboards/annepro2/keymaps/thomazmoura/keymap.c b/keyboards/annepro2/keymaps/thomazmoura/keymap.c new file mode 100644 index 000000000000..6db81c6876bc --- /dev/null +++ b/keyboards/annepro2/keymaps/thomazmoura/keymap.c @@ -0,0 +1,419 @@ +#include +#include "annepro2.h" +#include "qmk_ap2_led.h" +#include "config.h" + +enum anne_pro_layers { + _BASE_LAYER, + _MOUSE_LAYER, + _FUNCTION_LAYER, + _MEDIA_AND_NAVIGATION_LAYER, + _NUMPAD_LAYER, +}; + +typedef struct { + bool is_press_action; + uint8_t state; +} tap; + +// Define a type for as many tap dance states as you need +enum { + SINGLE_TAP = 1, + SINGLE_HOLD, + DOUBLE_TAP, + DOUBLE_HOLD, + TRIPLE_TAP, + TRIPLE_HOLD +}; + +enum profile { + RED, + GREEN, + BLUE, + RAINBOWHORIZONTAL, + RAINBOWVERTICAL, + ANIMATEDRAINBOWVERTICAL, + ANIMATEDRAINBOWFLOW, + ANIMATEDRAINBOWWATERFALL, + ANIMATEDBREATHING, + ANIMATEDSPECTRUM +}; + +uint8_t cyclabe_profiles[] = { + IDLE_PROFILE_INDEX, + ANIMATEDRAINBOWFLOW, + ANIMATEDRAINBOWVERTICAL, + ANIMATEDRAINBOWWATERFALL, + ANIMATEDBREATHING, + ANIMATEDSPECTRUM +}; + +enum custom_codes { + NEXT_PROFILE = AP2_SAFE_RANGE, + ENABLE_OR_DISABLE_LEDS +}; + +enum { + ESC_TAP_DANCE, + GRV_TAP_DANCE, +}; + +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* |-----------------------------------------------------------------------------------------+ | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | FN2 | Alt | FN2 | Win | FN2 | FN1 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | ESC | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | Space | | | | | +* \-----------------------------------------------------------------------------------------/ +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + TD(ESC_TAP_DANCE), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + KC_LCTL, KC_LGUI, KC_LALT, LT(_MEDIA_AND_NAVIGATION_LAYER, KC_SPC), LALT_T(KC_APP), KC_RGUI, MO(_FUNCTION_LAYER), KC_RCTL +), + /* + * Layer _FUNCTION_LAYER + * ,-----------------------------------------------------------------------------------------. + * | Caps| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | | | 7 | 8 | 9 | | | | | | | | | | + * |-----------------------------------------------------------------------------------------+ + * | | 0 | 4 | 5 | 6 | | LFT | DWN | UP | RGT | ; | ' | | + * |-----------------------------------------------------------------------------------------+ + * | | | 1 | 2 | 3 | | | | | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | | | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FUNCTION_LAYER] = KEYMAP( /* Base */ + KC_CAPS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_PSCR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______ +), + /* + * Layer _MEDIA_AND_NAVIGATION_LAYER + * ,-----------------------------------------------------------------------------------------. + * | USB | BT1 | BT2 | BT3 | BT4 | | | |LEDCH|LEDON| | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | MUTE| PREV| PLAY| NEXT| | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | HOME|PGDWN| PGUP| END | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | | |VOLDN|VOLUP| | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | | | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_MEDIA_AND_NAVIGATION_LAYER] = KEYMAP( /* Base */ + KC_AP2_USB, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, _______, _______, NEXT_PROFILE, ENABLE_OR_DISABLE_LEDS, _______, _______, KC_AP2_BT_UNPAIR, + _______, _______, _______, KC_UP, _______, _______, KC_MUTE, KC_MPRV, KC_MPLY, KC_MNXT, _______, KC_BRID, KC_BRIU, _______, + _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_VOLU, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + /* + * Layer _NUMPAD_LAYER + * ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | 7 | 8 | 9 | | + | 7 | 8 | 9 | . | | | | +* |-----------------------------------------------------------------------------------------+ +* | | 0 | 4 | 5 | 6 | | 0 | 4 | 5 | 6 | / | | | +* |-----------------------------------------------------------------------------------------+ +* | | | 1 | 2 | 3 | , | * | 1 | 2 | 3 | - | | +* |-----------------------------------------------------------------------------------------+ +* | | | | 0 | | | | | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_NUMPAD_LAYER] = KEYMAP( /* Base */ + _______, _______, _______, _______, _______, _______, _______, _______, KC_PAST, _______, KC_PSLS, KC_PMNS, KC_PPLS, _______, + _______, _______, _______, _______, _______, _______, _______, KC_7, KC_8, KC_9, KC_COMM, _______, _______, _______, + _______, _______, _______, _______, _______, _______, KC_0, KC_4, KC_5, KC_6, KC_PDOT, _______, _______, + _______, _______, _______, _______, _______, _______, _______, KC_1, KC_2, KC_3, _______, _______, + _______, _______, _______, KC_0, _______, _______, _______, _______ + ), + /* + * Layer _MOUSE_LAYER - Mouse Layer + * ,-----------------------------------------------------------------------------------------. + * | | | | | | | | | | | | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | |ACL2 |WL-U |MS-U |WL-D |ACL1 |ACL0 | | | + * |-----------------------------------------------------------------------------------------+ + * | | | ACL0 | ACL1 | ACL2 | |BTN3 |MS-L |MS-D |MS-R |BTN2 | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | |BTN4 |BTN5 |WL-L |WL-R | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | BTN1 | | | | | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_MOUSE_LAYER] = KEYMAP( /* Base */ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R, _______, _______, _______, _______, + _______, _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_BTN2, _______, _______, + _______, _______, _______, _______, _______, _______, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, _______, + _______, _______, _______, KC_BTN1, _______, _______, _______, _______ + ), +}; +const uint16_t keymaps_size = sizeof(keymaps); + + +// Declare the functions to be used with your tap dance key(s) + +// Function associated with all tap dances +uint8_t cur_dance(qk_tap_dance_state_t *state); + +// Functions associated with individual tap dances +void enableProfileColor(uint8_t * profile); +void resetProfileColor(void); +void esc_layer_finished(qk_tap_dance_state_t *state, void *user_data); +void esc_layer_reset(qk_tap_dance_state_t *state, void *user_data); + +bool is_caps_set = false; +bool is_led_on = true; +uint8_t base_profile = IDLE_PROFILE_INDEX; + +uint8_t idle_profile[] = {0x00,0x00,0x00}; +uint8_t caps_profile[] = {0xFF,0x00,0x00}; +uint8_t function_profile[] = {0x00,0xFF,0x00}; +uint8_t navigation_profile[] = {0x44,0x00,0xFF}; +uint8_t numpad_profile[] = {0xFF,0xDD,0x00}; +uint8_t mouse_profile[] = {0x00,0x88,0xFF}; + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { +} + +void keyboard_post_init_user(void) { + annepro2LedEnable(); + resetProfileColor(); +} + +// The function to handle the caps lock logic +bool led_update_user(led_t leds) { + if (leds.caps_lock) { + is_caps_set = true; + enableProfileColor(caps_profile); + return true; + } else if(is_caps_set) { + is_caps_set = false; + resetProfileColor(); + } + + return true; +} + +layer_state_t layer_state_set_user(layer_state_t state) { + switch(get_highest_layer(state)) { + case _FUNCTION_LAYER: + enableProfileColor(function_profile); + break; + case _NUMPAD_LAYER: + enableProfileColor(numpad_profile); + break; + case _MOUSE_LAYER: + enableProfileColor(mouse_profile); + break; + case _MEDIA_AND_NAVIGATION_LAYER: + enableProfileColor(navigation_profile); + break; + default: + resetProfileColor(); + break; + } + + return state; +} + +// Determine the current tap dance state +uint8_t cur_dance(qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } else if (state->count == 2) { + if (!state->pressed) return DOUBLE_TAP; + else return DOUBLE_HOLD; + } else if (state->count == 3) { + if (!state->pressed) return TRIPLE_TAP; + else return TRIPLE_HOLD; + } else return 8; +} + +// Initialize tap structure associated with example tap dance key +static tap esc_tap_state = { + .is_press_action = true, + .state = 0 +}; + +static tap grav_tap_state = { + .is_press_action = true, + .state = 0 +}; + +void enableProfileColor (uint8_t * profile) { + if(is_caps_set) { + annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); + } else { + annepro2LedSetForegroundColor(profile[0], profile[1], profile[2]); + } +} + +void resetProfileColor(void) { + if(is_caps_set) { + annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); + } else if(base_profile == IDLE_PROFILE_INDEX) { + annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); + } else { + annepro2LedSetProfile(cyclabe_profiles[base_profile]); + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case NEXT_PROFILE: + if (record->event.pressed) { + base_profile++; + if(base_profile >= (sizeof(cyclabe_profiles)/sizeof(cyclabe_profiles[0]))) + base_profile = IDLE_PROFILE_INDEX; + + if(base_profile == IDLE_PROFILE_INDEX) { + annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); + } else { + annepro2LedSetProfile(cyclabe_profiles[base_profile]); + } + } + return true; + case ENABLE_OR_DISABLE_LEDS: + if (record->event.pressed) { + if(is_led_on) { + is_led_on = false; + annepro2LedDisable(); + } else { + annepro2LedEnable(); + is_led_on = true; + } + } + return true; + default: + return true; + } +} + +// Functions that control what our tap dance key does +void esc_layer_finished(qk_tap_dance_state_t *state, void *user_data) { + esc_tap_state.state = cur_dance(state); + + switch (esc_tap_state.state) { + case SINGLE_TAP: + tap_code(KC_ESC); + break; + case SINGLE_HOLD: + layer_on(_FUNCTION_LAYER); + break; + case DOUBLE_TAP: + if (layer_state_is(_MOUSE_LAYER) || layer_state_is(_NUMPAD_LAYER)) { + layer_off(_MOUSE_LAYER); + layer_off(_NUMPAD_LAYER); + } else { + tap_code(KC_ESC); + tap_code(KC_ESC); + } + break; + case DOUBLE_HOLD: + layer_on(_NUMPAD_LAYER); + break; + case TRIPLE_TAP: + if (layer_state_is(_MOUSE_LAYER)) { + layer_off(_MOUSE_LAYER); + } else { + layer_on(_MOUSE_LAYER); + } + break; + case TRIPLE_HOLD: + layer_on(_MOUSE_LAYER); + break; + } +} + +void esc_layer_reset(qk_tap_dance_state_t *state, void *user_data) { + // If the key was held down and now is released then switch off the layer + if (esc_tap_state.state == SINGLE_HOLD) { + layer_off(_FUNCTION_LAYER); + } + if (esc_tap_state.state == DOUBLE_HOLD) { + layer_off(_NUMPAD_LAYER); + } + if (esc_tap_state.state == TRIPLE_HOLD) { + layer_off(_MOUSE_LAYER); + } + esc_tap_state.state = 0; +} + +// Functions that control what our tap dance key does +void grave_layer_finished(qk_tap_dance_state_t *state, void *user_data) { + grav_tap_state.state = cur_dance(state); + + switch (grav_tap_state.state) { + case SINGLE_TAP: + tap_code(KC_GRV); + break; + case SINGLE_HOLD: + tap_code(KC_GRV); + break; + case DOUBLE_TAP: + // Check to see if the layer is already set + if (layer_state_is(_MOUSE_LAYER)) { + // If already set, then switch it off + layer_off(_MOUSE_LAYER); + } else { + // If not already set, then switch the layer on + layer_on(_MOUSE_LAYER); + } + break; + } +} + +void grave_layer_reset(qk_tap_dance_state_t *state, void *user_data) { + // If the key was held down and now is released then switch off the layer + if (grav_tap_state.state == SINGLE_HOLD) { + layer_off(_FUNCTION_LAYER); + } + if (grav_tap_state.state == DOUBLE_HOLD) { + layer_off(_NUMPAD_LAYER); + } + grav_tap_state.state = 0; +} + +// Associate our tap dance key with its functionality +qk_tap_dance_action_t tap_dance_actions[] = { + [ESC_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, esc_layer_finished, esc_layer_reset, 250), + [GRV_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, grave_layer_finished, grave_layer_reset, 300) +}; + diff --git a/keyboards/annepro2/keymaps/thomazmoura/rules.mk b/keyboards/annepro2/keymaps/thomazmoura/rules.mk new file mode 100644 index 000000000000..32697215d61f --- /dev/null +++ b/keyboards/annepro2/keymaps/thomazmoura/rules.mk @@ -0,0 +1,47 @@ +# Anne Pro 2 +SRC = \ + matrix.c \ + hardfault_handler.c \ + annepro2_ble.c \ + qmk_ap2_led.c + +ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) + OPT_DEFS += -DANNEPRO2_EEPROM + SRC += spi_master.c eeprom_w25x20cl.c +endif + +LAYOUTS += + +# MCU +MCU = cortex-m0plus +ARMV = 6 +USE_FPU = no +MCU_FAMILY = HT32 +MCU_SERIES = HT32F523x2 +MCU_LDSCRIPT = HT32F52342_ANNEPRO2 +MCU_STARTUP = ht32f523x2 + +BOARD = ANNEPRO2_C18 + +OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage +#EXTRALDFLAGS = -Wl,--print-memory-usage + +# Options + +# Keys +CUSTOM_MATRIX = yes +NKRO_ENABLE = no +MOUSEKEY_ENABLE = yes +TAP_DANCE_ENABLE = yes +EXTRAKEY_ENABLE = yes +KEY_LOCK_ENABLE = no + +# Other featues +BOOTMAGIC_ENABLE = no +CONSOLE_ENABLE = no +COMMAND_ENABLE = yes +RAW_ENABLE = yes +MIDI_ENABLE = no +VIRTSER_ENABLE = no +COMBO_ENABLE = no + diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index 1a81e73f69a3..d92c13928480 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -80,3 +80,17 @@ void annepro2LedClearMask(uint8_t key) sdPut(&SD0, CMD_LED_CLEAR_MASK); sdPut(&SD0, key); } + +void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue) +{ + sdPut(&SD0, CMD_LED_SET_FOREGROUND_COLOR); + uint8_t colors[3]={red,green,blue}; + sdWrite(&SD0, (uint8_t *)&colors, sizeof(uint8_t)*3); +} + +void annepro2LedResetForegroundColor() +{ + uint8_t currentProfile = annepro2LedGetProfile(); + annepro2LedSetProfile(currentProfile); +} + diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 4a501789dd4d..c626fc14c124 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -13,6 +13,7 @@ #define CMD_LED_CLEAR_MASK 0xB #define CMD_LED_NEXT_INTENSITY 0xC #define CMD_LED_NEXT_ANIMATION_SPEED 0xD +#define CMD_LED_SET_FOREGROUND_COLOR 0xE void annepro2LedDisable(void); void annepro2LedEnable(void); @@ -27,3 +28,5 @@ void annepro2LedSetMask(uint8_t key); void annepro2LedClearMask(uint8_t key); void annepro2LedNextIntensity(void); void annepro2LedNextAnimationSpeed(void); +void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue); +void annepro2LedResetForegroundColor(void);