/* ** outputDate() - output the date */ void outputDate(FILE *fo, Image the_image) { float xpos, ypos; char mytime[20]; /* character representation of current time */ char mydate[40]; /* character representation of current date */ get_time_and_date(mytime, mydate); fprintf(fo,"\nmatrix currentmatrix\n"); fprintf(fo,"newpath\n"); if(the_image.orientation == PORTRAIT) { xpos = 0; ypos = the_image.height; fprintf(fo,"%f inch %f inch moveto %% upper left of image\n", xpos, ypos); } else { xpos = 0; ypos = 0; fprintf(fo,"%f inch %f inch moveto %% upper left of image\n", xpos, ypos); fprintf(fo,"90 rotate\n"); } fprintf(fo,"/Times-Roman findfont\n"); fprintf(fo,"10 scalefont\n"); fprintf(fo,"setfont \n"); fprintf(fo,"0 .12 inch rmoveto\n"); fprintf(fo,"(%s) show\n",mydate); fprintf(fo,"stroke\n"); fprintf(fo,"setmatrix\n\n"); }
void outputTime(FILE *fo, Image the_image) { char mytime[20]; /* character representation of current time */ char mydate[40]; /* character representation of current date */ float x, y; get_time_and_date(mytime, mydate); fprintf(fo,"\nmatrix currentmatrix\n"); fprintf(fo,"newpath\n"); if(the_image.orientation == PORTRAIT) { x = the_image.width; y = the_image.height; fprintf(fo,"%f inch %f inch moveto %% upper right of image\n", x, y); } else { x = 0; y = the_image.width; fprintf(fo,"%f inch %f inch moveto %% upper right of image\n", x, y); fprintf(fo,"90 rotate\n"); } fprintf(fo,"/Times-Roman findfont\n"); fprintf(fo,"10 scalefont\n"); fprintf(fo,"setfont \n"); fprintf(fo,"(%s) stringwidth\n",mytime); fprintf(fo,"pop -1 mul .12 inch rmoveto\n"); fprintf(fo,"(%s) show\n",mytime); fprintf(fo,"stroke\n"); fprintf(fo,"setmatrix\n\n"); }
// Initialize Real Time Clock void rtc_init() { int hour, min, sec, day_of_week, day_of_year, day, month, year; CIIR = 0x00000000; AMR = AMRSEC | AMRMIN | AMRHOUR | AMRDOM | AMRDOW | AMRDOY | AMRMON | AMRYEAR; CCR = CLKEN | CLKSRC; get_time_and_date (&hour, &min, &sec, &day_of_week, &day_of_year, &day, &month, &year); if(check_time(&hour, &min, &sec)) set_time(hour, min, sec); if(check_date(&day_of_week, &day_of_year, &day, &month, &year)) set_checked_date(day_of_week, day_of_year, day, month, year); }