annotate repper.c @ 0:0e9d15783f1d

Finished program
author VilyaemKenyaz
date Fri, 25 Aug 2023 13:46:12 -0400
parents
children deb42211d649
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
1 // Repper helps the user pace their reps and sets
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
2
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
3 #include <stdio.h>
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
4 #include <stdlib.h>
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
5 #include <unistd.h>
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
6
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
7 int main(int argc, char* argv[]){
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
8
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
9 if (argc == 1){
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
10 puts("Repper by Vilyaem peepsoftgames.github.io thekenyaz@yandex.com\n Usage: \n repper (unsigned int sets) (unsigned int reps) (unsigned int reptime) (unsignd int settime)\n 3 Beeps is a set completion, 1 beep is rep completion, this uses the 'beep' program. \n");
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
11 exit(1);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
12 }
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
13
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
14 unsigned int sets = atoi(argv[1]);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
15 unsigned int reps = atoi(argv[2]);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
16 unsigned int reptime = atoi(argv[3]);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
17 unsigned int settime = atoi(argv[4]);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
18 printf("Starting repper with %d Sets and %d Reps Rep Rest: %d Set Rest: %d \n", sets, reps, reptime, settime);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
19 printf("Waiting 3 Seconds to make sure you are ready\n");
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
20 sleep(3);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
21 for ( sets > 0; sets--;){
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
22
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
23 for (unsigned int newreps = reps; newreps > 0; newreps --){
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
24 sleep(reptime);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
25 system("beep");
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
26 printf("Rep completed, reps left in the set: %d\n", newreps);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
27 }
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
28 system("beep;beep;beep");
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
29 printf("Set completed, sets left in the exercise: %d\n", sets);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
30 sleep(settime);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
31 }
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
32
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
33 printf("Repper is finished\n");
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
34 exit(0);
0e9d15783f1d Finished program
VilyaemKenyaz
parents:
diff changeset
35 }