From 8729be543414649b1964f9ab48de41256531ef2e Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 16 May 2018 13:51:24 -0700 Subject: Fix compile issues for atmega328p --- tmk_core/common/avr/bootloader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tmk_core') diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index d89c8d768..c4b913280 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c @@ -72,7 +72,7 @@ #define BOOTLOADER_RESET_KEY 0xB007B007 uint32_t reset_key __attribute__ ((section (".noinit"))); -/** \brief initialize MCU status by watchdog reset +/** \brief initialize MCU status by watchdog reset * * FIXME: needs doc */ @@ -81,7 +81,7 @@ void bootloader_jump(void) { #if !defined(BOOTLOADER_SIZE) uint8_t high_fuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); - if (high_fuse & BOOT_SIZE_256) { + if (high_fuse & BOOT_SIZE_256) { bootloader_start = (FLASH_SIZE - 512) >> 1; } else if (high_fuse & BOOT_SIZE_512) { bootloader_start = (FLASH_SIZE - 1024) >> 1; @@ -130,7 +130,7 @@ void bootloader_jump(void) { DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; asm volatile("jmp 0x1FC00"); - #endif + #endif #elif defined(BOOTLOADER_CATERINA) // this block may be optional @@ -151,7 +151,7 @@ void bootloader_jump(void) { #else // Assume remaining boards are DFU, even if the flag isn't set - #ifndef __AVR_ATmega32A__ // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? + #if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? UDCON = 1; USBCON = (1<. /* * Keycodes based on HID Usage Keyboard/Keypad Page(0x07) plus special codes - * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf + * https://web.archive.org/web/20060218214400/http://www.usb.org/developers/devclass_docs/Hut1_12.pdf + * or http://www.usb.org/developers/hidpage/Hut1_12v2.pdf (older) */ #ifndef KEYCODE_H #define KEYCODE_H -- cgit v1.2.3 From 751719e6cb547db753b2f33f06ee6fa61607d544 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 29 May 2018 08:05:22 -0700 Subject: Add and fix _noeeprom functions to many of the RGB Underglow functions (#3070) * And and fix _noeeprom functions to many of the RGB Underglow functions * Many functions are unnecessarily calling the eeprom write code. The toggle/enable is command is especially guilty of this, as it writes to EEPROM 3 times. But rgb mode writes twice, every time it's called. And init resets the rgb eeprom range and then writes back to it twice! * Fixed the rgblight_sethsv_noeeprom to work as expected, by moving a lot of the code to a helper function. * Added a noeeprom function for mode, enable, disable, and toggle functions. (didn't bother for increase/decrease stuff, and didn't add new keycodes) * Add to predefined colors list * Add new functions to manual/docs * Update RGB Sleep feature to use _noeeprom Because that's exactly what it should be doing, actually! --- docs/feature_rgblight.md | 35 +++++++++++++--- quantum/rgblight.c | 93 +++++++++++++++++++++++++++++++++---------- quantum/rgblight.h | 9 +++++ quantum/rgblight_list.h | 24 +++++++++++ tmk_core/common/avr/suspend.c | 4 +- 5 files changed, 137 insertions(+), 28 deletions(-) (limited to 'tmk_core') diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index 0f1e649ef..5369d2fb7 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -88,11 +88,36 @@ const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; Look in `rgblights.h` for all available functions, but if you want to control all or some LEDs your goto functions are: ```c -rgblight_disable(); // turn all lights off -rgblight_enable(); // turn lights on, based on their previous state (stored in EEPROM) +// turn all lights off (stored in EEPROM) +rgblight_disable(); +// turn lights on, based on their previous state (stored in EEPROM) +rgblight_enable(); + +// turn all lights off (not stored in EEPROM) +rgblight_disable_noeeprom(); +// turn lights on, based on their previous state (not stored in EEPROM) +rgblight_enable_noeeprom(); + +// where r/g/b is a number from 0..255. Turns all the LEDs to this color (ignores mode, not stored in EEPROM). +rgblight_setrgb(r, g, b); +// HSV color control - h is a value from 0..360 and s/v is a value from 0..255 (stored in EEPROM) +rgblight_sethsv(h, s, v); +// HSV color control - h is a value from 0..360 and s/v is a value from 0..255 (not stored in EEPROM) +rgblight_sethsv_noeeprom(h, s, v); + +// Sets the mode, if rgb animations are enabled (stored in eeprom) +rgblight_mode(x); +// Sets the mode, if rgb animations are enabled (not stored in eeprom) +rgblight_mode_noeeprom(x); +// MODE 1, solid color +// MODE 2-5, breathing +// MODE 6-8, rainbow mood +// MODE 9-14, rainbow swirl +// MODE 15-20, snake +// MODE 21-23, knight +// MODE 24, xmas +// MODE 25-34, static rainbow -rgblight_setrgb(r, g, b); // where r/g/b is a number from 0..255. Turns all the LEDs to this color -rgblight_sethsv(h, s, v); // HSV color control - h is a value from 0..360 and s/v is a value from 0..255 rgblight_setrgb_at(r,g,b, LED); // control a single LED. 0 <= LED < RGBLED_NUM rgblight_sethsv_at(h,s,v, LED); // control a single LED. 0 <= LED < RGBLED_NUM ``` @@ -126,7 +151,7 @@ note: for backwards compatibility, `RGB_SMOD` is an alias for `RGB_MOD`. ## Hardware Modification -![Planck with RGB Underglow](https://raw.githubusercontent.com/qmk/qmk_firmware/master/keyboards/planck/keymaps/yang/planck-with-rgb-underglow.jpg) +![Planck with RGB Underglow](https://raw.githubusercontent.com/qmk/qmk_firmware/3774a7fcdab5544fc787f4c200be05fcd417e31f/keyboards/planck/keymaps/yang/planck-with-rgb-underglow.jpg) Here is a quick demo on Youtube (with NPKC KC60) (https://www.youtube.com/watch?v=VKrpPAHlisY). diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 75512e97a..db66e735b 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -44,7 +44,6 @@ __attribute__ ((weak)) const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; rgblight_config_t rgblight_config; -rgblight_config_t inmem_config; LED_TYPE led[RGBLED_NUM]; uint8_t rgblight_inited = 0; @@ -161,7 +160,7 @@ void rgblight_init(void) { #endif if (rgblight_config.enable) { - rgblight_mode(rgblight_config.mode); + rgblight_mode_noeeprom(rgblight_config.mode); } } @@ -218,7 +217,7 @@ uint32_t rgblight_get_mode(void) { return rgblight_config.mode; } -void rgblight_mode(uint8_t mode) { +void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { if (!rgblight_config.enable) { return; } @@ -229,8 +228,12 @@ void rgblight_mode(uint8_t mode) { } else { rgblight_config.mode = mode; } - eeconfig_update_rgblight(rgblight_config.raw); - xprintf("rgblight mode: %u\n", rgblight_config.mode); + if (write_to_eeprom) { + eeconfig_update_rgblight(rgblight_config.raw); + xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode); + } else { + xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode); + } if (rgblight_config.mode == 1) { #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); @@ -254,11 +257,20 @@ void rgblight_mode(uint8_t mode) { rgblight_timer_disable(); #endif } - rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); + rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); +} + +void rgblight_mode(uint8_t mode) { + rgblight_mode_eeprom_helper(mode, true); +} + +void rgblight_mode_noeeprom(uint8_t mode) { + rgblight_mode_eeprom_helper(mode, false); } + void rgblight_toggle(void) { - xprintf("rgblight toggle: rgblight_config.enable = %u\n", !rgblight_config.enable); + xprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); if (rgblight_config.enable) { rgblight_disable(); } @@ -267,17 +279,34 @@ void rgblight_toggle(void) { } } +void rgblight_toggle_noeeprom(void) { + xprintf("rgblight toggle [NOEEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); + if (rgblight_config.enable) { + rgblight_disable_noeeprom(); + } + else { + rgblight_enable_noeeprom(); + } +} + void rgblight_enable(void) { rgblight_config.enable = 1; - eeconfig_update_rgblight(rgblight_config.raw); - xprintf("rgblight enable: rgblight_config.enable = %u\n", rgblight_config.enable); + // No need to update EEPROM here. rgblight_mode() will do that, actually + //eeconfig_update_rgblight(rgblight_config.raw); + xprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); rgblight_mode(rgblight_config.mode); } +void rgblight_enable_noeeprom(void) { + rgblight_config.enable = 1; + xprintf("rgblight enable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); + rgblight_mode_noeeprom(rgblight_config.mode); +} + void rgblight_disable(void) { rgblight_config.enable = 0; eeconfig_update_rgblight(rgblight_config.raw); - xprintf("rgblight disable: rgblight_config.enable = %u\n", rgblight_config.enable); + xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); #endif @@ -285,6 +314,17 @@ void rgblight_disable(void) { rgblight_set(); } +void rgblight_disable_noeeprom(void) { + rgblight_config.enable = 0; + xprintf("rgblight disable [noEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); + #ifdef RGBLIGHT_ANIMATIONS + rgblight_timer_disable(); + #endif + _delay_ms(50); + rgblight_set(); +} + + // Deals with the messy details of incrementing an integer uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { int16_t new_value = value; @@ -358,23 +398,22 @@ void rgblight_decrease_speed(void) { eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this } -void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { - inmem_config.raw = rgblight_config.raw; +void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) { if (rgblight_config.enable) { LED_TYPE tmp_led; sethsv(hue, sat, val, &tmp_led); - inmem_config.hue = hue; - inmem_config.sat = sat; - inmem_config.val = val; // dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val); rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); } } -void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { + +void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { if (rgblight_config.enable) { if (rgblight_config.mode == 1) { // same static color - rgblight_sethsv_noeeprom(hue, sat, val); + LED_TYPE tmp_led; + sethsv(hue, sat, val, &tmp_led); + rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); } else { // all LEDs in same color if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { @@ -399,11 +438,23 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { rgblight_config.hue = hue; rgblight_config.sat = sat; rgblight_config.val = val; - eeconfig_update_rgblight(rgblight_config.raw); - xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); + if (write_to_eeprom) { + eeconfig_update_rgblight(rgblight_config.raw); + xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); + } else { + xprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); + } } } +void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { + rgblight_sethsv_eeprom_helper(hue, sat, val, true); +} + +void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { + rgblight_sethsv_eeprom_helper(hue, sat, val, false); +} + uint16_t rgblight_get_hue(void) { return rgblight_config.hue; } @@ -546,7 +597,7 @@ void rgblight_effect_breathing(uint8_t interval) { // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ val = (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); - rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, val); + rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); pos = (pos + 1) % 256; } void rgblight_effect_rainbow_mood(uint8_t interval) { @@ -557,7 +608,7 @@ void rgblight_effect_rainbow_mood(uint8_t interval) { return; } last_timer = timer_read(); - rgblight_sethsv_noeeprom(current_hue, rgblight_config.sat, rgblight_config.val); + rgblight_sethsv_noeeprom_old(current_hue, rgblight_config.sat, rgblight_config.val); current_hue = (current_hue + 1) % 360; } void rgblight_effect_rainbow_swirl(uint8_t interval) { diff --git a/quantum/rgblight.h b/quantum/rgblight.h index a6593af98..569424506 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -134,7 +134,16 @@ void rgb_matrix_decrease(void); void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); + void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); +void rgblight_mode_noeeprom(uint8_t mode); +void rgblight_toggle_noeeprom(void); +void rgblight_enable_noeeprom(void); +void rgblight_disable_noeeprom(void); + +void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); +void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); + #define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); diff --git a/quantum/rgblight_list.h b/quantum/rgblight_list.h index 29b280226..407fd8e9d 100644 --- a/quantum/rgblight_list.h +++ b/quantum/rgblight_list.h @@ -76,6 +76,30 @@ #define rgblight_sethsv_magenta() rgblight_sethsv (300, 255, 255) #define rgblight_sethsv_pink() rgblight_sethsv (330, 128, 255) +/* SET HSV List */ +/* If you're doing layer indication, this is best, as it won't */ +/* write to the eeprom, since it's limited (very high value). */ +/* If you want to use modes with this (since you can), then you */ +/* want to use rgblight_mode_noeeprom(x) instead. */ +#define rgblight_sethsv_noeeprom_white() rgblight_sethsv_noeeprom ( 0, 0, 255) +#define rgblight_sethsv_noeeprom_red() rgblight_sethsv_noeeprom ( 0, 255, 255) +#define rgblight_sethsv_noeeprom_coral() rgblight_sethsv_noeeprom ( 16, 176, 255) +#define rgblight_sethsv_noeeprom_orange() rgblight_sethsv_noeeprom ( 39, 255, 255) +#define rgblight_sethsv_noeeprom_goldenrod() rgblight_sethsv_noeeprom ( 43, 218, 218) +#define rgblight_sethsv_noeeprom_gold() rgblight_sethsv_noeeprom ( 51, 255, 255) +#define rgblight_sethsv_noeeprom_yellow() rgblight_sethsv_noeeprom ( 60, 255, 255) +#define rgblight_sethsv_noeeprom_chartreuse() rgblight_sethsv_noeeprom ( 90, 255, 255) +#define rgblight_sethsv_noeeprom_green() rgblight_sethsv_noeeprom (120, 255, 255) +#define rgblight_sethsv_noeeprom_springgreen() rgblight_sethsv_noeeprom (150, 255, 255) +#define rgblight_sethsv_noeeprom_turquoise() rgblight_sethsv_noeeprom (174, 90, 112) +#define rgblight_sethsv_noeeprom_teal() rgblight_sethsv_noeeprom (180, 255, 128) +#define rgblight_sethsv_noeeprom_cyan() rgblight_sethsv_noeeprom (180, 255, 255) +#define rgblight_sethsv_noeeprom_azure() rgblight_sethsv_noeeprom (186, 102, 255) +#define rgblight_sethsv_noeeprom_blue() rgblight_sethsv_noeeprom (240, 255, 255) +#define rgblight_sethsv_noeeprom_purple() rgblight_sethsv_noeeprom (270, 255, 255) +#define rgblight_sethsv_noeeprom_magenta() rgblight_sethsv_noeeprom (300, 255, 255) +#define rgblight_sethsv_noeeprom_pink() rgblight_sethsv_noeeprom (330, 128, 255) + /* SET HSV List */ #define rgblight_sethsv_white_at(at) rgblight_sethsv_at ( 0, 0, 255, at) #define rgblight_sethsv_red_at(at) rgblight_sethsv_at ( 0, 255, 255, at) diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 81e426641..3aa3d1247 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c @@ -101,7 +101,7 @@ static void power_down(uint8_t wdto) #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); #endif - rgblight_disable(); + rgblight_disable_noeeprom(); #endif // TODO: more power saving // See PicoPower application note @@ -157,7 +157,7 @@ void suspend_wakeup_init(void) #endif led_set(host_keyboard_leds()); #ifdef RGBLIGHT_SLEEP - rgblight_enable(); + rgblight_enable_noeeprom(); #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_enable(); #endif -- cgit v1.2.3 From cb91320d6d8836dd13db19bd2434abe2e7cadc20 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sun, 3 Jun 2018 14:57:35 -0700 Subject: Add Suspend functions (#3112) * Add suspend functions * Disable RGB code if it's disabled * Add suspend code to ChibiOS for future compatibility * Add keyboard_init functions * Change where references so it will compile * Wrong command chained in wake up kb function * Fix non-feature file changes * Add documentation * Re-add matrix init docs * add rgblight code to example * Remove keyboard init stuff for separate PR --- docs/custom_quantum_functions.md | 35 +++++++++++++++++++++++++++++++++-- tmk_core/common/avr/suspend.c | 33 +++++++++++++++++++++++++++++++++ tmk_core/common/chibios/suspend.c | 33 +++++++++++++++++++++++++++++++++ tmk_core/common/suspend.h | 5 +++++ 4 files changed, 104 insertions(+), 2 deletions(-) (limited to 'tmk_core') diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md index 6d741b6cb..9a1c486df 100644 --- a/docs/custom_quantum_functions.md +++ b/docs/custom_quantum_functions.md @@ -135,9 +135,11 @@ void led_set_user(uint8_t usb_led) { * Keyboard/Revision: `void led_set_kb(uint8_t usb_led)` * Keymap: `void led_set_user(uint8_t usb_led)` + # Matrix Initialization Code -Before a keyboard can be used the hardware must be initialized. QMK handles initialization of the keyboard matrix itself, but if you have other hardware like LED's or i²c controllers you will need to set up that hardware before it can be used. +Before a keyboard can be used the hardware must be initialized. QMK handles initialization of the keyboard matrix itself, but if you have other hardware like LED's or i²c controllers you will need to set up that hardware before it can be used. + ### Example `matrix_init_user()` Implementation @@ -177,9 +179,38 @@ This function gets called at every matrix scan, which is basically as often as t You should use this function if you need custom matrix scanning code. It can also be used for custom status output (such as LED's or a display) or other functionality that you want to trigger regularly even when the user isn't typing. +# Keyboard Idling/Wake Code + +If the board supports it, it can be "idled", by stopping a number of functions. A good example of this is RGB lights or backlights. This can save on power consumption, or may be better behavior for your keyboard. + +This is controlled by two functions: `suspend_power_down_*` and `suspend_wakeup_init_*`, which are called when the system is board is idled and when it wakes up, respectively. + + +### Example suspend_power_down_user() and suspend_wakeup_init_user() Implementation + +This example, at the keyboard level, sets up B1, B2, and B3 as LED pins. + +``` +void suspend_power_down_user(void) +{ + rgb_matrix_set_suspend_state(true); +} + +void suspend_wakeup_init_user(void) +{ + rgb_matrix_set_suspend_state(false); +} + +``` + +### `keyboard_init_*` Function Documentation + +* Keyboard/Revision: `void suspend_power_down_kb(void)` and `void suspend_wakeup_init_user(void)` +* Keymap: `void suspend_power_down_kb(void)` and `void suspend_wakeup_init_user(void)` + # Layer Change Code -Thir runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling. +This runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling. ### Example `layer_state_set_*` Implementation diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 3aa3d1247..dfa1af273 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c @@ -72,6 +72,21 @@ void suspend_idle(uint8_t time) */ static uint8_t wdt_timeout = 0; +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_user (void) { } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_kb(void) { + suspend_power_down_user(); +} + /** \brief Power down * * FIXME: needs doc @@ -103,6 +118,8 @@ static void power_down(uint8_t wdto) #endif rgblight_disable_noeeprom(); #endif + suspend_power_down_kb(); + // TODO: more power saving // See PicoPower application note // - I/O port input with pullup @@ -144,6 +161,21 @@ bool suspend_wakeup_condition(void) return false; } +/** \brief run user level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_user(void) { } + +/** \brief run keyboard level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_kb(void) { + suspend_wakeup_init_user(); +} /** \brief run immediately after wakeup * * FIXME: needs doc @@ -162,6 +194,7 @@ void suspend_wakeup_init(void) rgblight_timer_enable(); #endif #endif + suspend_wakeup_init_kb(); } #ifndef NO_SUSPEND_POWER_DOWN diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c index 32ef773e2..4a119ccef 100644 --- a/tmk_core/common/chibios/suspend.c +++ b/tmk_core/common/chibios/suspend.c @@ -21,6 +21,21 @@ void suspend_idle(uint8_t time) { wait_ms(time); } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_user (void) { } +/** \brief Run keyboard level Power down + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_power_down_kb(void) { + suspend_power_down_user(); +} + /** \brief suspend power down * * FIXME: needs doc @@ -30,6 +45,7 @@ void suspend_power_down(void) { // shouldn't power down TPM/FTM if we want a breathing LED // also shouldn't power down USB + suspend_power_down_kb(); // on AVR, this enables the watchdog for 15ms (max), and goes to // SLEEP_MODE_PWR_DOWN @@ -53,6 +69,22 @@ bool suspend_wakeup_condition(void) return false; } +/** \brief run user level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_user(void) { } + +/** \brief run keyboard level code immediately after wakeup + * + * FIXME: needs doc + */ +__attribute__ ((weak)) +void suspend_wakeup_init_kb(void) { + suspend_power_down_user(); +} + /** \brief suspend wakeup condition * * run immediately after wakeup @@ -79,4 +111,5 @@ void suspend_wakeup_init(void) #ifdef BACKLIGHT_ENABLE backlight_init(); #endif /* BACKLIGHT_ENABLE */ + suspend_wakeup_init_kb(); } diff --git a/tmk_core/common/suspend.h b/tmk_core/common/suspend.h index 80617a824..c3e444708 100644 --- a/tmk_core/common/suspend.h +++ b/tmk_core/common/suspend.h @@ -10,4 +10,9 @@ void suspend_power_down(void); bool suspend_wakeup_condition(void); void suspend_wakeup_init(void); +void suspend_wakeup_init_user(void); +void suspend_wakeup_init_kb(void); +void suspend_power_down_user (void); +void suspend_power_down_kb(void); + #endif -- cgit v1.2.3 From b5d6c049e6caec89f04707663efd37d46be3e9c5 Mon Sep 17 00:00:00 2001 From: yiancar Date: Wed, 6 Jun 2018 23:24:26 +0100 Subject: Bootloader make issue (#2975) * Added Modular keyboards L,R and NUM Created code modules for the 3 modules of the modular keyboard. Original idea by MechboardsUK. Uses i2c implementation similar to lets split * Remove modular from master This is to fix incorrect branching * fixed bootloader makefile - Echo -e does not behave coorectly on mac - Replaced with equivilant printf statements * quick typo fix --- tmk_core/avr.mk | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tmk_core') diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk index bd58bd285..cf62b0f07 100644 --- a/tmk_core/avr.mk +++ b/tmk_core/avr.mk @@ -252,16 +252,16 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf bootloader: make -C lib/lufa/Bootloaders/DFU/ clean - echo -e "#ifndef QMK_KEYBOARD\n#define QMK_KEYBOARD\n" > lib/lufa/Bootloaders/DFU/Keyboard.h - echo -e `$(GREP) "MANUFACTURER" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h - echo -e `$(GREP) "PRODUCT" $(ALL_CONFIGS) -h | tail -1` Bootloader >> lib/lufa/Bootloaders/DFU/Keyboard.h - echo -e `$(GREP) "QMK_ESC_OUTPUT" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h - echo -e `$(GREP) "QMK_ESC_INPUT" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h - echo -e `$(GREP) "QMK_LED" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h - echo -e `$(GREP) "QMK_SPEAKER" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h - echo -e "\n#endif" >> lib/lufa/Bootloaders/DFU/Keyboard.h + printf "#ifndef QMK_KEYBOARD\n#define QMK_KEYBOARD\n\n" > lib/lufa/Bootloaders/DFU/Keyboard.h + printf "%s\n" "`$(GREP) "MANUFACTURER" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h + printf "%s Bootloader\n" "`$(GREP) "PRODUCT" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h + printf "%s\n" "`$(GREP) "QMK_ESC_OUTPUT" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h + printf "%s\n" "`$(GREP) "QMK_ESC_INPUT" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h + printf "%s\n" "`$(GREP) "QMK_LED" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h + printf "%s\n" "`$(GREP) "QMK_SPEAKER" $(ALL_CONFIGS) -h | tail -1`" >> lib/lufa/Bootloaders/DFU/Keyboard.h + printf "\n#endif" >> lib/lufa/Bootloaders/DFU/Keyboard.h make -C lib/lufa/Bootloaders/DFU/ - echo -e "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex" + printf "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex\n" cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware -- cgit v1.2.3