summaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
authorIBNobody <protospherex@gmail.com>2016-04-18 15:47:10 -0500
committerIBNobody <protospherex@gmail.com>2016-04-18 15:47:10 -0500
commitcbcf0abe62b764a9f3d80848611dca8291d93eb8 (patch)
tree2014b1d839bfaa29acdbf432265d908562304834 /tmk_core/common
parentd5cc31d7d4fc1a36fc3e3e0018369cb52553f50f (diff)
parent4f4b5b8c18d4f1bf4fd4c51ad6f316501dfbd6cc (diff)
Merge remote-tracking branch 'refs/remotes/origin/personal_atomic_planck'
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/action.c8
-rw-r--r--tmk_core/common/action_layer.c12
-rw-r--r--tmk_core/common/action_layer.h1
-rw-r--r--tmk_core/common/action_macro.c8
-rw-r--r--tmk_core/common/action_tapping.c11
-rw-r--r--tmk_core/common/avr/eeconfig.c8
-rw-r--r--tmk_core/common/command.c32
-rw-r--r--tmk_core/common/eeconfig.h6
-rw-r--r--tmk_core/common/keyboard.c8
-rw-r--r--tmk_core/common/keymap.h3
-rw-r--r--tmk_core/common/magic.c36
-rw-r--r--tmk_core/common/magic.h6
-rw-r--r--tmk_core/common/print.h12
13 files changed, 113 insertions, 38 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index f9e6c17dc3..0162fbd632 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -27,11 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_util.h"
#include "action.h"
-#ifdef DEBUG_ACTION
+//#ifdef DEBUG_ACTION
#include "debug.h"
-#else
-#include "nodebug.h"
-#endif
+//#else
+//#include "nodebug.h"
+//#endif
void action_exec(keyevent_t event)
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index e817c0d515..845fbbb210 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -4,14 +4,14 @@
#include "util.h"
#include "action_layer.h"
-#ifdef DEBUG_ACTION
+//#ifdef DEBUG_ACTION
#include "debug.h"
-#else
-#include "nodebug.h"
-#endif
+//#else
+//#include "nodebug.h"
+//#endif
-/*
+/*
* Default Layer State
*/
uint32_t default_layer_state = 0;
@@ -52,7 +52,7 @@ void default_layer_xor(uint32_t state)
#ifndef NO_ACTION_LAYER
-/*
+/*
* Keymap Layer State
*/
uint32_t layer_state = 0;
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index 3a4b1e3349..025cf5420f 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -68,6 +68,7 @@ void layer_xor(uint32_t state);
#define layer_and(state)
#define layer_xor(state)
#define layer_debug()
+
#endif
/* pressed actions cache */
diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c
index 7726b11907..cc78c82327 100644
--- a/tmk_core/common/action_macro.c
+++ b/tmk_core/common/action_macro.c
@@ -19,11 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_macro.h"
#include "wait.h"
-#ifdef DEBUG_ACTION
+//#ifdef DEBUG_ACTION
#include "debug.h"
-#else
-#include "nodebug.h"
-#endif
+//#else
+//#include "nodebug.h"
+//#endif
#ifndef NO_ACTION_MACRO
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c
index 826c233096..6b6fa1dfe2 100644
--- a/tmk_core/common/action_tapping.c
+++ b/tmk_core/common/action_tapping.c
@@ -6,11 +6,11 @@
#include "keycode.h"
#include "timer.h"
-#ifdef DEBUG_ACTION
+//#ifdef DEBUG_ACTION
#include "debug.h"
-#else
-#include "nodebug.h"
-#endif
+//#else
+//#include "nodebug.h"
+//#endif
#ifndef NO_ACTION_TAPPING
@@ -139,7 +139,7 @@ bool process_tapping(keyrecord_t *keyp)
if (event.pressed) {
tapping_key.tap.interrupted = true;
}
- // enqueue
+ // enqueue
return false;
}
}
@@ -324,6 +324,7 @@ bool waiting_buffer_typed(keyevent_t event)
return false;
}
+__attribute__((unused))
bool waiting_buffer_has_anykey_pressed(void)
{
for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
diff --git a/tmk_core/common/avr/eeconfig.c b/tmk_core/common/avr/eeconfig.c
index 5bd47dc6ad..25bb9e849c 100644
--- a/tmk_core/common/avr/eeconfig.c
+++ b/tmk_core/common/avr/eeconfig.c
@@ -13,6 +13,9 @@ void eeconfig_init(void)
#ifdef BACKLIGHT_ENABLE
eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
#endif
+#ifdef AUDIO_ENABLE
+ eeprom_write_byte(EECONFIG_AUDIO, 0xFF); // On by default
+#endif
}
void eeconfig_enable(void)
@@ -43,3 +46,8 @@ void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val
uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); }
#endif
+
+#ifdef AUDIO_ENABLE
+uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); }
+void eeconfig_write_audio(uint8_t val) { eeprom_write_byte(EECONFIG_AUDIO, val); }
+#endif \ No newline at end of file
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c
index b4cd3ca56b..f06abaf7f0 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -49,6 +49,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "usbdrv.h"
#endif
+#ifdef AUDIO_ENABLE
+ #include "audio.h"
+#endif /* AUDIO_ENABLE */
+
static bool command_common(uint8_t code);
static void command_common_help(void);
@@ -122,7 +126,7 @@ static void command_common_help(void)
STR(MAGIC_KEY_VERSION ) ": Version\n"
STR(MAGIC_KEY_STATUS ) ": Status\n"
STR(MAGIC_KEY_CONSOLE ) ": Activate Console Mode\n"
-
+
#if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
STR(MAGIC_KEY_LAYER0 ) ": Switch to Layer 0\n"
STR(MAGIC_KEY_LAYER1 ) ": Switch to Layer 1\n"
@@ -136,11 +140,11 @@ static void command_common_help(void)
STR(MAGIC_KEY_LAYER9 ) ": Switch to Layer 9\n"
#endif
-#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
+#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
"F1-F10: Switch to Layer 0-9 (F10 = L0)\n"
#endif
-#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
+#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
"0-9: Switch to Layer 0-9\n"
#endif
@@ -251,6 +255,7 @@ static void print_status(void)
#ifdef BOOTMAGIC_ENABLE
static void print_eeconfig(void)
{
+#ifndef NO_PRINT
print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n");
debug_config_t dc;
@@ -279,9 +284,12 @@ static void print_eeconfig(void)
print("backlight_config.raw: "); print_hex8(bc.raw); print("\n");
print(".enable: "); print_dec(bc.enable); print("\n");
print(".level: "); print_dec(bc.level); print("\n");
-#endif
+#endif /* BACKLIGHT_ENABLE */
+
+#endif /* !NO_PRINT */
+
}
-#endif
+#endif /* BOOTMAGIC_ENABLE */
static bool command_common(uint8_t code)
{
@@ -305,7 +313,7 @@ static bool command_common(uint8_t code)
#ifdef BOOTMAGIC_ENABLE
// print stored eeprom config
- case MAGIC_KC(MAGIC_KEY_EEPROM):
+ case MAGIC_KC(MAGIC_KEY_EEPROM):
print("eeconfig:\n");
print_eeconfig();
break;
@@ -348,6 +356,9 @@ static bool command_common(uint8_t code)
case MAGIC_KC(MAGIC_KEY_BOOTLOADER):
clear_keyboard(); // clear to prevent stuck keys
print("\n\nJumping to bootloader... ");
+ #ifdef AUDIO_ENABLE
+ play_goodbye_tone();
+ #endif
_delay_ms(1000);
bootloader_jump(); // not return
break;
@@ -369,7 +380,7 @@ static bool command_common(uint8_t code)
break;
// debug matrix toggle
- case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX):
+ case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX):
debug_matrix = !debug_matrix;
if (debug_matrix) {
print("\nmatrix: on\n");
@@ -380,7 +391,7 @@ static bool command_common(uint8_t code)
break;
// debug keyboard toggle
- case MAGIC_KC(MAGIC_KEY_DEBUG_KBD):
+ case MAGIC_KC(MAGIC_KEY_DEBUG_KBD):
debug_keyboard = !debug_keyboard;
if (debug_keyboard) {
print("\nkeyboard: on\n");
@@ -551,6 +562,7 @@ static uint8_t mousekey_param = 0;
static void mousekey_param_print(void)
{
+#ifndef NO_PRINT
print("\n\t- Values -\n");
print("1: delay(*10ms): "); pdec(mk_delay); print("\n");
print("2: interval(ms): "); pdec(mk_interval); print("\n");
@@ -558,6 +570,8 @@ static void mousekey_param_print(void)
print("4: time_to_max: "); pdec(mk_time_to_max); print("\n");
print("5: wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n");
print("6: wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n");
+#endif /* !NO_PRINT */
+
}
//#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n");
@@ -677,7 +691,7 @@ static void mousekey_console_help(void)
"pgdown: -10\n"
"\n"
"speed = delta * max_speed * (repeat / time_to_max)\n");
- xprintf("where delta: cursor=%d, wheel=%d\n"
+ xprintf("where delta: cursor=%d, wheel=%d\n"
"See http://en.wikipedia.org/wiki/Mouse_keys\n", MOUSEKEY_MOVE_DELTA, MOUSEKEY_WHEEL_DELTA);
}
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index 3cd1a174f6..ddefca1347 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_KEYMAP (uint8_t *)4
#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
#define EECONFIG_BACKLIGHT (uint8_t *)6
+#define EECONFIG_AUDIO (uint8_t *)7
/* debug bit */
@@ -72,4 +73,9 @@ uint8_t eeconfig_read_backlight(void);
void eeconfig_write_backlight(uint8_t val);
#endif
+#ifdef AUDIO_ENABLE
+uint8_t eeconfig_read_audio(void);
+void eeconfig_write_audio(uint8_t val);
+#endif
+
#endif
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 302b3ec87c..1d99818481 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -27,7 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "command.h"
#include "util.h"
#include "sendchar.h"
-#include "bootmagic.h"
+#ifdef BOOTMAGIC_ENABLE
+ #include "bootmagic.h"
+#else
+ #include "magic.h"
+#endif
#include "eeconfig.h"
#include "backlight.h"
#ifdef MOUSEKEY_ENABLE
@@ -86,6 +90,8 @@ void keyboard_init(void)
#ifdef BOOTMAGIC_ENABLE
bootmagic();
+#else
+ magic();
#endif
#ifdef BACKLIGHT_ENABLE
diff --git a/tmk_core/common/keymap.h b/tmk_core/common/keymap.h
index e1a6f992e6..abc9bdb32d 100644
--- a/tmk_core/common/keymap.h
+++ b/tmk_core/common/keymap.h
@@ -22,8 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include "action.h"
-
-#ifdef BOOTMAGIC_ENABLE
/* NOTE: Not portable. Bit field order depends on implementation */
typedef union {
uint8_t raw;
@@ -39,7 +37,6 @@ typedef union {
};
} keymap_config_t;
keymap_config_t keymap_config;
-#endif
/* translates key to keycode */
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c
new file mode 100644
index 0000000000..f21d1346c7
--- /dev/null
+++ b/tmk_core/common/magic.c
@@ -0,0 +1,36 @@
+#include <stdint.h>
+#include <stdbool.h>
+#include <util/delay.h>
+#include "matrix.h"
+#include "bootloader.h"
+#include "debug.h"
+#include "keymap.h"
+#include "host.h"
+#include "action_layer.h"
+#include "eeconfig.h"
+#include "magic.h"
+
+keymap_config_t keymap_config;
+
+void magic(void)
+{
+ /* check signature */
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+
+ /* debug enable */
+ debug_config.raw = eeconfig_read_debug();
+
+ /* keymap config */
+ keymap_config.raw = eeconfig_read_keymap();
+
+#ifdef NKRO_ENABLE
+ keyboard_nkro = keymap_config.nkro;
+#endif
+
+ uint8_t default_layer = 0;
+ default_layer = eeconfig_read_default_layer();
+ default_layer_set((uint32_t)default_layer);
+
+} \ No newline at end of file
diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h
new file mode 100644
index 0000000000..3fa2d8b81c
--- /dev/null
+++ b/tmk_core/common/magic.h
@@ -0,0 +1,6 @@
+#ifndef MAGIC_H
+#define MAGIC_H
+
+void magic(void);
+
+#endif
diff --git a/tmk_core/common/print.h b/tmk_core/common/print.h
index c0e9e14309..4f3dde65aa 100644
--- a/tmk_core/common/print.h
+++ b/tmk_core/common/print.h
@@ -2,17 +2,17 @@
/* Very basic print functions, intended to be used with usb_debug_only.c
* http://www.pjrc.com/teensy/
* Copyright (c) 2008 PJRC.COM, LLC
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -91,9 +91,9 @@ void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
#else /* NO_PRINT */
-#define xprintf
-#define print
-#define println
+#define xprintf(fmt, ...)
+#define print(s)
+#define println(s)
#define print_set_sendchar(func)
#define print_dec(data)
#define print_decs(data)