mirror of
				https://github.com/mfulz/qmk_firmware.git
				synced 2025-10-31 05:12:33 +01:00 
			
		
		
		
	* Address #1689 by using a formula to define the breathing curve and exposing defines to control the shape of the curve. * Tweak the behavior of breathing for clueboard
This commit is contained in:
		
							parent
							
								
									d3fe6a0588
								
							
						
					
					
						commit
						ad49db8cd2
					
				| @ -49,8 +49,10 @@ If you have `#define RGBLIGHT_ANIMATIONS` in your `config.h` you will have a num | |||||||
| | Option | Default Value | Description | | | Option | Default Value | Description | | ||||||
| |--------|---------------|-------------| | |--------|---------------|-------------| | ||||||
| | `RGBLIGHT_ANIMATIONS` | | `#define` this to enable animation modes. | | | `RGBLIGHT_ANIMATIONS` | | `#define` this to enable animation modes. | | ||||||
| | `RGBLIGHT_EFFECT_SNAKE_LENGTH` | 4 | The number of LEDs to light up for the "snake" mode. | | | `RGBLIGHT_EFFECT_BREATHE_CENTER | 1.85 | Used to calculate the curve for the breathing animation. Valid values 1.0-2.7. | | ||||||
| | `RGBLIGHT_EFFECT_KNIGHT_LENGTH` | 3 | The number of LEDs to light up for the "knight" mode. | | | `RGBLIGHT_EFFECT_BREATHE_MAX | 255 | The maximum brightness for the breathing mode. Valid values 1-255. | | ||||||
|  | | `RGBLIGHT_EFFECT_SNAKE_LENGTH` | 4 | The number of LEDs to light up for the "snake" animation. | | ||||||
|  | | `RGBLIGHT_EFFECT_KNIGHT_LENGTH` | 3 | The number of LEDs to light up for the "knight" animation. | | ||||||
| | `RGBLIGHT_EFFECT_KNIGHT_OFFSET` | 0 | Start the knight animation this many LEDs from the start of the strip. | | | `RGBLIGHT_EFFECT_KNIGHT_OFFSET` | 0 | Start the knight animation this many LEDs from the start of the strip. | | ||||||
| | `RGBLIGHT_EFFECT_KNIGHT_LED_NUM` | RGBLED_NUM | The number of LEDs to have the "knight" animation travel. | | | `RGBLIGHT_EFFECT_KNIGHT_LED_NUM` | RGBLED_NUM | The number of LEDs to have the "knight" animation travel. | | ||||||
| | `RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL` | 1000 | How long to wait between light changes for the "christmas" animation. Specified in ms. | | | `RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL` | 1000 | How long to wait between light changes for the "christmas" animation. Specified in ms. | | ||||||
|  | |||||||
| @ -36,6 +36,8 @@ | |||||||
| #define RGBLIGHT_VAL_STEP 17 | #define RGBLIGHT_VAL_STEP 17 | ||||||
| 
 | 
 | ||||||
| #define RGBLIGHT_ANIMATIONS | #define RGBLIGHT_ANIMATIONS | ||||||
|  | #define RGBLIGHT_EFFECT_BREATHE_CENTER 1 | ||||||
|  | #define RGBLIGHT_EFFECT_BREATHE_MAX 200 | ||||||
| #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 666*2 | #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 666*2 | ||||||
| #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 1 | #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 1 | ||||||
| #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3   // How many LEDs wide to light up
 | #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3   // How many LEDs wide to light up
 | ||||||
|  | |||||||
| @ -36,6 +36,8 @@ | |||||||
| #define RGBLIGHT_VAL_STEP 17 | #define RGBLIGHT_VAL_STEP 17 | ||||||
| 
 | 
 | ||||||
| #define RGBLIGHT_ANIMATIONS | #define RGBLIGHT_ANIMATIONS | ||||||
|  | #define RGBLIGHT_EFFECT_BREATHE_CENTER 1 | ||||||
|  | #define RGBLIGHT_EFFECT_BREATHE_MAX 200 | ||||||
| #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 666*2 | #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 666*2 | ||||||
| #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 1 | #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 1 | ||||||
| #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3   // How many LEDs wide to light up
 | #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3   // How many LEDs wide to light up
 | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ | |||||||
|  * You should have received a copy of the GNU General Public License |  * You should have received a copy of the GNU General Public License | ||||||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 |  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | ||||||
|  */ |  */ | ||||||
|  | #include <math.h> | ||||||
| #include <avr/eeprom.h> | #include <avr/eeprom.h> | ||||||
| #include <avr/interrupt.h> | #include <avr/interrupt.h> | ||||||
| #include <util/delay.h> | #include <util/delay.h> | ||||||
| @ -465,13 +466,17 @@ void rgblight_task(void) { | |||||||
| void rgblight_effect_breathing(uint8_t interval) { | void rgblight_effect_breathing(uint8_t interval) { | ||||||
|   static uint8_t pos = 0; |   static uint8_t pos = 0; | ||||||
|   static uint16_t last_timer = 0; |   static uint16_t last_timer = 0; | ||||||
|  |   float val; | ||||||
| 
 | 
 | ||||||
|   if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) { |   if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) { | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|   last_timer = timer_read(); |   last_timer = timer_read(); | ||||||
| 
 | 
 | ||||||
|   rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, pgm_read_byte(&LED_BREATHING_TABLE[pos])); | 
 | ||||||
|  |   // 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); | ||||||
|   pos = (pos + 1) % 256; |   pos = (pos + 1) % 256; | ||||||
| } | } | ||||||
| void rgblight_effect_rainbow_mood(uint8_t interval) { | void rgblight_effect_rainbow_mood(uint8_t interval) { | ||||||
|  | |||||||
| @ -22,6 +22,14 @@ | |||||||
| 	#define RGBLIGHT_MODES 1 | 	#define RGBLIGHT_MODES 1 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #ifndef RGBLIGHT_EFFECT_BREATHE_CENTER | ||||||
|  | #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85  // 1-2.7
 | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifndef RGBLIGHT_EFFECT_BREATHE_MAX | ||||||
|  | #define RGBLIGHT_EFFECT_BREATHE_MAX 255   // 0-255
 | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH | ||||||
| #define RGBLIGHT_EFFECT_SNAKE_LENGTH 4 | #define RGBLIGHT_EFFECT_SNAKE_LENGTH 4 | ||||||
| #endif | #endif | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 skullydazed
						skullydazed