示例#1
0
// Initialize the triac control.
void zcd_init(void)
{
    zcd_time_t zcd_calibration = zcd_calibrate();
    zcd_set(0);
    zcd_run(zcd_calibration);
    printf( strings_get(STR_TRIAC_CALIBRATION), zcd_calibration / (F_CPU / 1000000) );
}
示例#2
0
int main (int argc, char **argv) {

  int count;
  int type;

  if ((fd = open("/dev/dbox/avs0",O_RDWR)) <= 0) {
    perror("open");
    return -1;
  }

	if (ioctl(fd,AVSIOGTYPE,&type)< 0) {
    	perror("can't get avs-type:");
		close(fd);
		return -1;
	}

	switch(type)
	{
		case CXA2092:
			printf("CXA2092 found\n");
			break;
		case CXA2126:
			printf("CXA2126 found\n");
			break;
		case STV6412:
			printf("STV6412 found\n");
			break;
		default:
			printf("unknown avs type\n");
			close(fd);
			return -1;
	}

  for(count=1;count<argc;count++) {

    /* -h or --help */
    if ((strcmp("-h",argv[count]) == 0) || (strcmp("--help",argv[count]) == 0)) {
        help(argv[0]);
    }

    /* -s or --show */
    else if ((strcmp("-s",argv[count]) == 0) || (strcmp("--show",argv[count]) == 0)) {
        routing_show();
        volume_show();
        zcd_show();
        fnc_show();
        ycm_show();
        fblk_show();
    }
    /* -v or --vol */
    else if ((strcmp("-v",argv[count]) == 0) || (strcmp("--vol",argv[count]) == 0)) {
        if (argc == count+1) {
            printf("No volume given\n");
            exit(1);

        } else if ((argv[count+1][0] < 0x30) || (argv[count+1][0] > 0x39)) {
            printf("No volume given\n");
            exit(1);
        } else {
            count++;
            volume_set(atoi(argv[count]));
        }
    }

    /* -ttv or --trash-my-tv */
    else if ((strcmp("-ttv",argv[count]) == 0) || (strcmp("--trash-my-tv",argv[count]) == 0)) {
      printf("\nGet your TV repaired for a low price here at our sponsor: http://www.dvb-shop.de\n\n    greetings -Hunz :-]\n\n");
      while(1) {
	fnc_set(0);
	printf(".");
//	fflush(stdout);
	usleep(500);
	fnc_set(1);
	printf("O");
//	fflush(stdout);
	usleep(500);
      }
    }

    /* -zcd or --zero-cross-detector */
    else if ((strcmp("-zcd",argv[count]) == 0) || (strcmp("--zero-cross-detector",argv[count]) == 0)) {
        if (argc == count+1) {
            printf("No status given\n");
            exit(1);
        } else {
            count++;
            if (strcmp("on",argv[count]) == 0)
                zcd_set(1);
            else
                zcd_set(0);
        }
    }

    /* -ycm */
    else if ((strcmp("-ycm",argv[count]) == 0) || (strcmp("--y-c-mix",argv[count]) == 0)) {
        if (argc == count+1) {
            printf("No status given\n");
            exit(1);
        } else {
            count++;
            if (strcmp("on",argv[count]) == 0)
                ycm_set(1);
            else
                ycm_set(0);
        }
    }

    /* -fnc */
    else if ((strcmp("-fnc",argv[count]) == 0) || (strcmp("--video-function-switch-control",argv[count]) == 0)) {
        if (argc == count+1) {
            printf("No value given\n");
            exit(1);
        } else if ((argv[count+1][0] < 0x30) || (argv[count+1][0] > 0x39)) {
            printf("No value given\n");
            exit(1);
        } else {
            count++;
            fnc_set(atoi(argv[count]));
        }
    }

    /* -fblk */
    else if ((strcmp("-fblk",argv[count]) == 0) || (strcmp("--video-fast-blanking-control",argv[count]) == 0)) {
        if (argc == count+1) {
            printf("No value given\n");
            exit(1);
        } else if ((argv[count+1][0] < 0x30) || (argv[count+1][0] > 0x39)) {
            printf("No value given\n");
            exit(1);
        } else {
            count++;
            fblk_set(atoi(argv[count]));
        }
    }

    /* -m or --mute */
    else if ((strcmp("-m",argv[count]) == 0) || (strcmp("--mute",argv[count]) == 0)) {
        volume_mute();
    }

    /* -u or --unmute */
    else if ((strcmp("-u",argv[count]) == 0) || (strcmp("--unmute",argv[count]) == 0)) {
        volume_unmute();
    }

    /* -rv or --route-video */
    else if ((strcmp("-rv",argv[count]) == 0) || (strcmp("--route-video",argv[count]) == 0)) {
        if (argc < count+3) {
            printf("No source/destination given\n");
            exit(1);
        } else if ((argv[count+1][0] < 0x31) || (argv[count+1][0] > 0x33) || (argv[count+2][0] < 0x30) || (argv[count+2][0] > 0x37)) {
            printf("No source/destination given\n");
            exit(1);
        } else {
            count+=2;
            set_video_source(argv[count-1][0]-0x30,argv[count][0]-0x30);
        }
    }

    /* -ra or --route-audio */
    else if ((strcmp("-ra",argv[count]) == 0) || (strcmp("--route-audio",argv[count]) == 0)) {
        if (argc < count+3) {
            printf("No source/destination given\n");
            exit(1);
        } else if ((argv[count+1][0] < 0x31) || (argv[count+1][0] > 0x33) || (argv[count+2][0] < 0x30) || (argv[count+2][0] > 0x37)) {
            printf("No source/destination given\n");
            exit(1);
        } else {
            count+=2;
            set_audio_source(argv[count-1][0]-0x30,argv[count][0]-0x30);
        }
    } else {
        help(argv[0]);
    }
  }

  close(fd);

  return 0;
}