1 ///////////////////////////////////////////////////////////////////////////
2 // Workfile: tvout.c (Implementation)
3 // Author: Daniel Giritzer
5 // Description: Simple Program to move the picture of the composite video
9 // Copyright (C) 2017, Daniel Giritzer (giri@nwrk.biz)
10 ///////////////////////////////////////////////////////////////////////////
18 /////////////////////////////////////////////////
19 /// \brief This function gets called by the program
20 /// to print the usage message.
22 /// \param FILE* output file descriptor
23 /////////////////////////////////////////////////
24 void PrintUsageMessage(FILE* output)
26 fprintf(output, "++++++++++++++++++++++++++++++++++++++++\n");
27 fprintf(output, "Usage: tvout [-m [-r][-x val] [-y val]] \n\n");
28 fprintf(output, "-m \t move the picture\n");
29 fprintf(output, " -x \t vertical offset in px \n");
30 fprintf(output, " -y \t horizontal offset in px \n");
31 fprintf(output, " -r \t reset position \n");
32 fprintf(output, "\nThis program was created for the \nArmbian Project.\n");
33 fprintf(output, "(c) 2017, Daniel G. (giri@nwrk.biz)\n");
34 fprintf(output, "++++++++++++++++++++++++++++++++++++++++\n");
37 /////////////////////////////////////////////////
38 /// \brief Main Program. Parses Commandline
39 /// Parameters and writes user Input
40 /// to the matching TV-Encoder registers.
41 /////////////////////////////////////////////////
42 int main(int argc, char **argv)
44 bool mFlag = false; //move
45 bool xFlag = false; //y Offset
47 bool yFlag = false; //x Offset
49 bool rFlag = false; //reset Offset
52 //let us do the errorhandling
55 //check if there are any arguments
58 PrintUsageMessage(stdout);
61 // Use getopt to parse the cmd parameters
62 while ((c = getopt (argc, argv, "mx:y:r")) != -1)
81 PrintUsageMessage(stdout);
88 //check if m flag was set
91 unsigned long to_write = 0;
96 writemem(TV_ENCODER_RESYNC, to_write, 'w');
100 // read current position
101 readmem(TV_ENCODER_RESYNC, 'w', &to_write);
105 to_write += strtoul(xVal, 0, 0) << X_REG_OFFSET;
111 to_write += strtoul(yVal, 0, 0) << Y_REG_OFFSET;
113 //write new position to register
114 writemem(TV_ENCODER_RESYNC, to_write, 'w');
118 unsigned int index = 0;
119 for (index = optind; index < argc; index++)
121 printf ("Invalid argument %s\n", argv[index]);