diff options
author | Aaron Ball <nullspoon@oper.io> | 2019-09-07 13:04:14 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2019-09-07 13:04:14 -0600 |
commit | 5503c140dac2f22eee2a620703aff57f28b4512b (patch) | |
tree | 0e29f7f169b0acf6119bafc35faafb97567c4512 | |
parent | f9415b4976b31ce6c6f68ee6776194af90bcf05b (diff) | |
download | kbd-fade-5503c140dac2f22eee2a620703aff57f28b4512b.tar.gz kbd-fade-5503c140dac2f22eee2a620703aff57f28b4512b.tar.xz |
Previously, bad wait values default to 0 (like `sdf`) because atoi
returns 0 when it doesn't understand the input. This caused very rapid
color changing.
Now we check if wait is set to less than 1, assuming an error, and
defaults to 1000. This accounts for when users pass negative values and
strings.
Also removed unused `highest` variable.
-rw-r--r-- | src/main.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -107,7 +107,6 @@ void channel_fade(int* a, int* b) { */ void rgb_fade(int r, int g, int b, int wait) { int i = 0; - int highest = 0; int colors[3] = {r, g, b}; int size = 3; @@ -133,6 +132,11 @@ int main(int argc, char* argv[]) { if(argc == 2) wait = atoi(argv[1]); + if(wait < 1) { + printf("Error setting wait. Defaulting to 1000\n"); + wait=1000; + } + load_current_state(&r, &g, &b); rgb_fade(r, g, b, wait); } |