From 3755ef5ddbdad9f25a53fee951c3eb78035b52c3 Mon Sep 17 00:00:00 2001 From: IBNobody Date: Wed, 13 Apr 2016 20:57:51 -0500 Subject: [PATCH] Compiler Warnings / Atomic TLC Corrected compiler warnings for a number of issues. Gave Atomic some TLC. --- keyboard/atomic/Makefile | 4 +- keyboard/atomic/atomic.h | 3 + keyboard/atomic/backlight.c | 2 + keyboard/atomic/config.h | 93 +++++++++++++++++++++++++---- keyboard/atomic/keymaps/default.c | 26 ++++---- keyboard/atomic/keymaps/pc_atomic.c | 3 +- quantum/keymap_common.c | 6 +- quantum/keymap_common.h | 2 - quantum/keymap_midi.h | 2 +- tmk_core/common/action_code.h | 2 +- tmk_core/common/keymap.c | 3 +- 11 files changed, 112 insertions(+), 34 deletions(-) diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile index 17baeaf536..2b017446dc 100644 --- a/keyboard/atomic/Makefile +++ b/keyboard/atomic/Makefile @@ -120,13 +120,13 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA -#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality #MIDI_ENABLE = yes # MIDI controls #UNICODE_ENABLE = yes # Unicode #BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keyboard/atomic/atomic.h b/keyboard/atomic/atomic.h index d8574efa93..d5461e424d 100644 --- a/keyboard/atomic/atomic.h +++ b/keyboard/atomic/atomic.h @@ -26,5 +26,8 @@ void matrix_init_user(void); void matrix_scan_user(void); +void process_action_user(keyrecord_t *record); +void led_set_user(uint8_t usb_led); +void backlight_init_ports(void); #endif \ No newline at end of file diff --git a/keyboard/atomic/backlight.c b/keyboard/atomic/backlight.c index f69364b2af..647b57e718 100644 --- a/keyboard/atomic/backlight.c +++ b/keyboard/atomic/backlight.c @@ -1,6 +1,8 @@ #include #include "backlight.h" +#include "atomic.h" + #define CHANNEL OCR1C diff --git a/keyboard/atomic/config.h b/keyboard/atomic/config.h index 11c0e848e1..f30a9e6cc4 100644 --- a/keyboard/atomic/config.h +++ b/keyboard/atomic/config.h @@ -32,36 +32,109 @@ along with this program. If not, see . #define MATRIX_ROWS 5 #define MATRIX_COLS 15 -// Planck PCB default pin-out -// Change this to how you wired your keyboard -// COLS: Left to right, ROWS: Top to bottom +/* + * Keyboard Matrix Assignments + * + * Change this to how you wired your keyboard + * COLS: AVR pins used for columns, left to right + * ROWS: AVR pins used for rows, top to bottom + * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) + * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) + * +*/ #define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 } #define ROWS (int []){ D0, D5, B5, B6, C6 } /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW -/* define if matrix has ghost */ +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* define if matrix has ghost (lacks anti-ghosting diodes) */ //#define MATRIX_HAS_GHOST /* number of backlight levels */ -/* NOTE: this is the max value of 0..BACKLIGHT_LEVELS so really 16 levels. */ #define BACKLIGHT_LEVELS 3 -/* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 - /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE -/* key combination for command */ +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +//#define FORCE_NKRO + +/* + * Magic Key Options + * + * Magic keys are hotkey commands that allow control over firmware functions of + * the keyboard. They are best used in combination with the HID Listen program, + * found here: https://www.pjrc.com/teensy/hid_listen.html + * + * The options below allow the magic key functionality to be changed. This is + * useful if your keyboard/keypad is missing keys and you want magic key support. + * + */ + +/* key combination for magic key command */ #define IS_COMMAND() ( \ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ ) +/* control how magic key switches layers */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false +/* override magic key keymap */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM +//#define MAGIC_KEY_HELP1 H +//#define MAGIC_KEY_HELP2 SLASH +//#define MAGIC_KEY_DEBUG D +//#define MAGIC_KEY_DEBUG_MATRIX X +//#define MAGIC_KEY_DEBUG_KBD K +//#define MAGIC_KEY_DEBUG_MOUSE M +//#define MAGIC_KEY_VERSION V +//#define MAGIC_KEY_STATUS S +//#define MAGIC_KEY_CONSOLE C +//#define MAGIC_KEY_LAYER0_ALT1 ESC +//#define MAGIC_KEY_LAYER0_ALT2 GRAVE +//#define MAGIC_KEY_LAYER0 0 +//#define MAGIC_KEY_LAYER1 1 +//#define MAGIC_KEY_LAYER2 2 +//#define MAGIC_KEY_LAYER3 3 +//#define MAGIC_KEY_LAYER4 4 +//#define MAGIC_KEY_LAYER5 5 +//#define MAGIC_KEY_LAYER6 6 +//#define MAGIC_KEY_LAYER7 7 +//#define MAGIC_KEY_LAYER8 8 +//#define MAGIC_KEY_LAYER9 9 +//#define MAGIC_KEY_BOOTLOADER PAUSE +//#define MAGIC_KEY_LOCK CAPS +//#define MAGIC_KEY_EEPROM E +//#define MAGIC_KEY_NKRO N +//#define MAGIC_KEY_SLEEP_LED Z /* * Feature disable options @@ -81,6 +154,4 @@ along with this program. If not, see . //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION -#define MAGIC_KEY_BOOTLOADER B - #endif diff --git a/keyboard/atomic/keymaps/default.c b/keyboard/atomic/keymaps/default.c index 4ed8a71f15..0ede363a1f 100644 --- a/keyboard/atomic/keymaps/default.c +++ b/keyboard/atomic/keymaps/default.c @@ -11,7 +11,7 @@ #define _DV 2 #define _LW 3 #define _RS 4 -#define _FN 4 +#define _FN 5 /* ROW 1 OPTIONS * .--------------------------------------------------------------------------------------------------------------------------------------. @@ -148,11 +148,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * .---------------------------------------------------------------------------------------------------------------------- 2u ------------. * | | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | XXXXXX . | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| - * | | | | | | | | | | | | | | | INS | + * | | ! | @ | # | $ | % | ^ | & | * | ( | ) | | | | INS | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------| - * | | | | | | | | | | | | | XXXXXX . | | + * | | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | XXXXXX . | | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------| - * | | | | | | | | | | | | XXXXXX . | | | + * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | | XXXXXX . | | | * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------| * | | | | | | XXXXXX . | | | | | | | | | * '--------------------------------------------------------------------------------------------------------------------------------------' @@ -160,9 +160,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_LW] = { /* LOWERED */ { _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ }, + { _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, _______, _______, KC_INS }, + { _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, ___T___, ___T___, _______ }, + { _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, ___T___, ___T___, _______, _______ }, { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, }, @@ -170,11 +170,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * .---------------------------------------------------------------------------------------------------------------------- 2u ------------. * | | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | XXXXXX . | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| - * | | | | | | | | | | | | | | | INS | + * | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | | | | INS | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------| - * | | | | | | | | | | | | | XXXXXX . | | + * | | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | XXXXXX . | | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------| - * | | | | | | | | | | | | XXXXXX . | | | + * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | | XXXXXX . | | | * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------| * | | | | | | XXXXXX . | | | | | | | | | * '--------------------------------------------------------------------------------------------------------------------------------------' @@ -182,9 +182,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_RS] = { /* RAISED */ { _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______ }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, _______, _______ }, + { _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, _______, _______, KC_INS }, + { _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, ___T___, ___T___, _______ }, + { _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, ___T___, ___T___, _______, _______ }, { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, }, diff --git a/keyboard/atomic/keymaps/pc_atomic.c b/keyboard/atomic/keymaps/pc_atomic.c index 1c0425a76d..bdf575046b 100644 --- a/keyboard/atomic/keymaps/pc_atomic.c +++ b/keyboard/atomic/keymaps/pc_atomic.c @@ -6,6 +6,7 @@ #define _FN 3 #define _______ KC_TRNS +#define ___T___ KC_TRNS #define XXXXXXX KC_NO /* @@ -48,7 +49,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ___T___, ___T___ }, { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, KC_PAUS, KC_PSCR }, { KC_CAPS, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_ACL0, KC_ACL2, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, ___T___, ___T___, KC_WH_U }, - { _______, _______, _______, DF(_CM), DF(_DV), _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ___T___, ___T___, KC_MS_U, KC_WH_D }, { _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R }, }, }; diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 2eef4f15a7..ae6cddb343 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -87,6 +87,7 @@ action_t action_for_key(uint8_t layer, keypos_t key) return action; #endif } else if (keycode == RESET) { // RESET is 0x5000, which is why this is here + action_t action; clear_keyboard(); #ifdef AUDIO_ENABLE play_notes(&goodbye, 5, false); @@ -96,12 +97,13 @@ action_t action_for_key(uint8_t layer, keypos_t key) *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific #endif bootloader_jump(); - return; + return action; } else if (keycode == DEBUG) { // DEBUG is 0x5001 // TODO: Does this actually work? + action_t action; print("\nDEBUG: enabled.\n"); debug_enable = true; - return; + return action; } else if (keycode >= 0x5000 && keycode < 0x6000) { // Layer movement shortcuts // See .h to see constraints/usage diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h index 3db40772e0..4a877d2a70 100644 --- a/quantum/keymap_common.h +++ b/quantum/keymap_common.h @@ -184,8 +184,6 @@ extern const uint16_t fn_actions[]; // Toggle to layer - 256 layer max #define TG(layer) (layer | 0x5400) -#define MIDI(n) (n | 0x6000) - // M-od, T-ap - 256 keycode max #define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8)) #define CTL_T(kc) MT(0x1, kc) diff --git a/quantum/keymap_midi.h b/quantum/keymap_midi.h index a89420ce2a..436fb2eb50 100644 --- a/quantum/keymap_midi.h +++ b/quantum/keymap_midi.h @@ -20,7 +20,7 @@ along with this program. If not, see . #include -#define MIDI 0x6000 +#define MIDI(n) (n | 0x6000) #define MIDI12 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000 #define CHNL(note, channel) (note + (channel << 8)) diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index 4fe9c1d581..2b0b0b077e 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h @@ -301,7 +301,7 @@ enum backlight_opt { #define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8) #define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8) #define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8) -#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level) +#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | (level)) /* Command */ #define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) /* Function */ diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index 11f4aa8aaa..8955fc710d 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -22,7 +22,7 @@ along with this program. If not, see . #include "action_macro.h" #include "wait.h" #include "debug.h" - +#include "bootloader.h" static action_t keycode_to_action(uint8_t keycode); @@ -143,6 +143,7 @@ static action_t keycode_to_action(uint8_t keycode) action.code = ACTION_TRANSPARENT; break; case KC_BOOTLOADER: + action.code = ACTION_NO; clear_keyboard(); wait_ms(50); bootloader_jump(); // not return