forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce the firmware size by 1500 bytes when rgblight_effect_breathing…
…() is enabled.
- Loading branch information
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// this is host program for quantum/rgblight.c:void rgblight_effect_breathing(); | ||
// | ||
#include <stdio.h> | ||
#include <math.h> | ||
#include <stdint.h> | ||
|
||
#define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 | ||
#define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255 | ||
|
||
int main(void) { | ||
int pos; | ||
printf("#ifdef RGBLIGHT_EFFECT_BREATHE_USE_TABLE\n"); | ||
printf("__attribute__ ((weak))\n"); | ||
printf("const uint8_t rgblight_effect_breathe_table[] PROGMEM = {\n"); | ||
for (pos = 0; pos < 256; pos ++ ) { | ||
printf(" 0x%x%s",(uint8_t)( (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E))),pos==255?"":"," ); | ||
if ((pos+1) % 8 == 0) | ||
printf("\n"); | ||
} | ||
printf("};\n"); | ||
printf("#endif\n"); | ||
|
||
return 0; | ||
} |