diff options
| author | tmk <nobody@nowhere> | 2014-11-23 13:08:05 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2014-11-23 13:08:05 +0900 |
| commit | 608ebe2686bdb3fdbd0426731cabdf6082c57b53 (patch) | |
| tree | 15d306082db9d53bb9c890f62aeeaf4cdab49712 /common/keyboard.c | |
| parent | c2d830c07c823c48a17c214b093ec1bab989fb6a (diff) | |
| download | qmk_firmware-608ebe2686bdb3fdbd0426731cabdf6082c57b53.tar.gz qmk_firmware-608ebe2686bdb3fdbd0426731cabdf6082c57b53.zip | |
Matrix power saving
Diffstat (limited to 'common/keyboard.c')
| -rw-r--r-- | common/keyboard.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/common/keyboard.c b/common/keyboard.c index 9a809ff4a..dde91a296 100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -15,6 +15,8 @@ You should have received a copy of the GNU General Public License | |||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | #include <stdint.h> | 17 | #include <stdint.h> |
| 18 | #include <util/delay.h> | ||
| 19 | #include <avr/wdt.h> | ||
| 18 | #include "keyboard.h" | 20 | #include "keyboard.h" |
| 19 | #include "matrix.h" | 21 | #include "matrix.h" |
| 20 | #include "keymap.h" | 22 | #include "keymap.h" |
| @@ -30,12 +32,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #include "bootmagic.h" | 32 | #include "bootmagic.h" |
| 31 | #include "eeconfig.h" | 33 | #include "eeconfig.h" |
| 32 | #include "backlight.h" | 34 | #include "backlight.h" |
| 35 | #include "suspend.h" | ||
| 33 | #ifdef MOUSEKEY_ENABLE | 36 | #ifdef MOUSEKEY_ENABLE |
| 34 | # include "mousekey.h" | 37 | # include "mousekey.h" |
| 35 | #endif | 38 | #endif |
| 36 | #ifdef PS2_MOUSE_ENABLE | 39 | #ifdef PS2_MOUSE_ENABLE |
| 37 | # include "ps2_mouse.h" | 40 | # include "ps2_mouse.h" |
| 38 | #endif | 41 | #endif |
| 42 | #include "lufa.h" | ||
| 39 | 43 | ||
| 40 | 44 | ||
| 41 | #ifdef MATRIX_HAS_GHOST | 45 | #ifdef MATRIX_HAS_GHOST |
| @@ -83,7 +87,25 @@ void keyboard_task(void) | |||
| 83 | static uint8_t led_status = 0; | 87 | static uint8_t led_status = 0; |
| 84 | matrix_row_t matrix_row = 0; | 88 | matrix_row_t matrix_row = 0; |
| 85 | matrix_row_t matrix_change = 0; | 89 | matrix_row_t matrix_change = 0; |
| 90 | static uint32_t last_key_time = 0; | ||
| 86 | 91 | ||
| 92 | /* | ||
| 93 | #define SLEEP_TIME_MS 10000 | ||
| 94 | // (USB_DeviceState == DEVICE_STATE_Suspended) { | ||
| 95 | //if (timer_elapsed32(last_key_time) > SLEEP_TIME_MS) { | ||
| 96 | // TODO: remove LUFA dependent code | ||
| 97 | if (!USB_IsInitialized && timer_elapsed32(last_key_time) > SLEEP_TIME_MS) { | ||
| 98 | matrix_power_down(); | ||
| 99 | // TODO: power down only when no USB connection | ||
| 100 | // Or it makes USB connection lost or suspended | ||
| 101 | suspend_power_down(WDTO_15MS); | ||
| 102 | matrix_power_up(); | ||
| 103 | } | ||
| 104 | else { | ||
| 105 | matrix_power_down(); | ||
| 106 | matrix_power_up(); | ||
| 107 | } | ||
| 108 | */ | ||
| 87 | matrix_scan(); | 109 | matrix_scan(); |
| 88 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { | 110 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { |
| 89 | matrix_row = matrix_get_row(r); | 111 | matrix_row = matrix_get_row(r); |
| @@ -105,6 +127,7 @@ void keyboard_task(void) | |||
| 105 | }); | 127 | }); |
| 106 | // record a processed key | 128 | // record a processed key |
| 107 | matrix_prev[r] ^= ((matrix_row_t)1<<c); | 129 | matrix_prev[r] ^= ((matrix_row_t)1<<c); |
| 130 | last_key_time = timer_read32(); | ||
| 108 | // process a key per task call | 131 | // process a key per task call |
| 109 | goto MATRIX_LOOP_END; | 132 | goto MATRIX_LOOP_END; |
| 110 | } | 133 | } |
