Can now adjust image refresh rate

This commit is contained in:
Tyler Cromwell 2015-01-10 18:32:35 -05:00 committed by K Lange
parent 19f7dcac57
commit b81aac9d23
2 changed files with 14 additions and 2 deletions

View File

@ -30,6 +30,9 @@ Do not set the titlebar text.
.B \-e, \-\-no\-clear .B \-e, \-\-no\-clear
Do not clear the display between frames. Do not clear the display between frames.
.TP .TP
.B \-u, \-\-usleep
Set how frequently the image refreshes (1 <= t <= 10).
.TP
.B \-f, \-\-frames .B \-f, \-\-frames
Display the requested number of frames, then quit. Display the requested number of frames, then quit.
.TP .TP

View File

@ -335,6 +335,7 @@ void usage(char * argv[]) {
" -n --no-counter \033[3mDo not display the timer\033[0m\n" " -n --no-counter \033[3mDo not display the timer\033[0m\n"
" -s --no-title \033[3mDo not set the titlebar text\033[0m\n" " -s --no-title \033[3mDo not set the titlebar text\033[0m\n"
" -e --no-clear \033[3mDo not clear the display between frames\033[0m\n" " -e --no-clear \033[3mDo not clear the display between frames\033[0m\n"
" -u --usleep \033[3mSet how frequently the image refreshes (1 <= t <= 10)\033[0m\n"
" -f --frames \033[3mDisplay the requested number of frames, then quit\033[0m\n" " -f --frames \033[3mDisplay the requested number of frames, then quit\033[0m\n"
" -r --min-rows \033[3mCrop the animation from the top\033[0m\n" " -r --min-rows \033[3mCrop the animation from the top\033[0m\n"
" -R --max-rows \033[3mCrop the animation from the bottom\033[0m\n" " -R --max-rows \033[3mCrop the animation from the bottom\033[0m\n"
@ -369,6 +370,7 @@ int main(int argc, char ** argv) {
{"no-counter", no_argument, 0, 'n'}, {"no-counter", no_argument, 0, 'n'},
{"no-title", no_argument, 0, 's'}, {"no-title", no_argument, 0, 's'},
{"no-clear", no_argument, 0, 'e'}, {"no-clear", no_argument, 0, 'e'},
{"usleep", required_argument, 0, 'u'},
{"frames", required_argument, 0, 'f'}, {"frames", required_argument, 0, 'f'},
{"min-rows", required_argument, 0, 'r'}, {"min-rows", required_argument, 0, 'r'},
{"max-rows", required_argument, 0, 'R'}, {"max-rows", required_argument, 0, 'R'},
@ -379,9 +381,12 @@ int main(int argc, char ** argv) {
{0,0,0,0} {0,0,0,0}
}; };
/* Determine the usleep time */
useconds_t speed_divisor = 1;
/* Process arguments */ /* Process arguments */
int index, c; int index, c;
while ((c = getopt_long(argc, argv, "eshiItnf:r:R:c:C:W:H:", long_opts, &index)) != -1) { while ((c = getopt_long(argc, argv, "eshiItnu:f:r:R:c:C:W:H:", long_opts, &index)) != -1) {
if (!c) { if (!c) {
if (long_opts[index].flag == 0) { if (long_opts[index].flag == 0) {
c = long_opts[index].val; c = long_opts[index].val;
@ -410,6 +415,10 @@ int main(int argc, char ** argv) {
case 'n': case 'n':
show_counter = 0; show_counter = 0;
break; break;
case 'u':
if (1 <= atoi(optarg) && atoi(optarg) <= 10)
speed_divisor = atoi(optarg);
break;
case 'f': case 'f':
frame_count = atoi(optarg); frame_count = atoi(optarg);
break; break;
@ -907,7 +916,7 @@ int main(int argc, char ** argv) {
i = 0; i = 0;
} }
/* Wait */ /* Wait */
usleep(90000); usleep(90000 / speed_divisor);
} }
return 0; return 0;
} }