Пример #1
0
static void init(void) {
    char *TERM;

    srandom(time(NULL));
    if ((TERM = getenv("TERM")) == NULL) error("TERM not set");
    li = li < 0 ? 24 : li;
    co = co < 0 ? 80 : co;

    saveterm();
    setterm();
}
Пример #2
0
static void
intro(void)
{
    char *tmpname;

    srandomdev();

    tmpname = getlogin();
    signal(SIGINT,sighandler);
    signal(SIGINT,sighandler);
    signal(SIGIOT,sighandler);		/* for assert(3) */
    if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
		signal(SIGQUIT,sighandler);

    if(tmpname != NULL) {
		strcpy(name,tmpname);
		name[0] = toupper(name[0]);
    } else {
		strcpy(name,dftname);
	}

    initscr();
#ifdef KEY_MIN
    keypad(stdscr, TRUE);
#endif /* KEY_MIN */
    saveterm();
    nonl();
    cbreak();
    noecho();

#ifdef PENGUIN
    clear();
    mvaddstr(4,29,"Welcome to Battleship!");
    move(8,0);
    PR("                                                  \\\n");
    PR("                           \\                     \\ \\\n");
    PR("                          \\ \\                   \\ \\ \\_____________\n");
    PR("                         \\ \\ \\_____________      \\ \\/            |\n");
    PR("                          \\ \\/             \\      \\/             |\n");
    PR("                           \\/               \\_____/              |__\n");
    PR("           ________________/                                       |\n");
    PR("           \\  S.S. Penguin                                         |\n");
    PR("            \\                                                     /\n");
    PR("             \\___________________________________________________/\n");

    mvaddstr(22,27,"Hit any key to continue..."); refresh();
    getch();
#endif /* PENGUIN */

#ifdef A_COLOR
    start_color();

    init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
    init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
    init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
    init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
    init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
    init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
    init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
    init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
#endif /* A_COLOR */

}
Пример #3
0
// main initializes the system and shows the picture. 
// Exit and clean up when you hit [RETURN].
int main(int argc, char **argv) {
	int w, h, n;
	char *usage =
	    "%s [command]\n\tdemo sec\n\tastro\n\ttest ...\n\trand n\n\trotate n ...\n\timage\n\ttext\n\tfontsize\n\traspi\n\tadvert\n\tgradient\n";
	char *progname = argv[0];
	saveterm();
	init(&w, &h);
	rawterm();
	switch (argc) {
	case 2:
		if (strncmp(argv[1], "image", 5) == 0) {
			imagetable(w, h);
		} else if (strncmp(argv[1], "text", 4) == 0) {
			tb(w, h);
		} else if (strncmp(argv[1], "astro", 5) == 0) {
			sunearth(w, h);
		} else if (strncmp(argv[1], "fontsize", 8) == 0) {
			fontrange(w, h);
		} else if (strncmp(argv[1], "advert", 6) == 0) {
			advert(w,h);
		} else if (strncmp(argv[1], "raspi", 5) == 0) {
			raspi(w, h, "The Raspberry Pi");
		} else if (strncmp(argv[1], "gradient", 8) == 0) {
			gradient(w,h);
		} else {
			restoreterm();
			fprintf(stderr, usage, progname);
			return 1;
		}
		break;
	case 3:
		n = atoi(argv[2]);
		if (strncmp(argv[1], "demo", 4) == 0) {
			if (n < 1 || n > 30) {
				n = 5;
			}
			demo(w, h, n);
		} else if (strncmp(argv[1], "rand", 4) == 0) {
			if (n < 1 || n > 1000) {
				n = 100;
			}
			rshapes(w, h, n);
		} else if (strncmp(argv[1], "test", 4) == 0) {
			testpattern(w, h, argv[2]);
		} else {
			restoreterm();
			fprintf(stderr, usage, progname);
			return 1;
		}
		break;

	case 4:
		if (strncmp(argv[1], "rotate", 6) == 0) {
			rotext(w, h, atoi(argv[2]), argv[3]);
		} else {
			restoreterm();
			fprintf(stderr, usage, progname);
			return 1;
		}
		break;

	default:
		refcard(w, h);
	}
	waituntil(0x1b);
	restoreterm();
	finish();
	return 0;
}
Пример #4
0
static void
intro(void)
{
    char *tmpname;

    (void) signal(SIGINT,uninitgame);
    (void) signal(SIGINT,uninitgame);
    if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
	(void)signal(SIGQUIT,uninitgame);

    if ((tmpname = getlogin()) != NULL)
    {
	(void)strlcpy(name, tmpname, sizeof(name));
	name[0] = toupper((unsigned char)name[0]);
    }
    else
	(void)strlcpy(name, dftname, sizeof(name));

    (void)initscr();
    keypad(stdscr, TRUE);
    (void)saveterm();
    (void)nonl();
    (void)cbreak();
    (void)noecho();

    if ((LINES < PROMPTLINE + 3) || (COLS < COLWIDTH)) {
	endwin();
	errx(1, "screen must be at least %dx%d.", PROMPTLINE + 3, COLWIDTH);
    }

#define	PR	(void)addstr
    (void)clear();
    (void)mvaddstr(4,29,"Welcome to Battleship!");
    (void)move(8,0);
    PR("                                                  \\\n");
    PR("                           \\                     \\ \\\n");
    PR("                          \\ \\                   \\ \\ \\_____________\n");
    PR("                         \\ \\ \\_____________      \\ \\/            |\n");
    PR("                          \\ \\/     \\__/    \\      \\/             |\n");
    PR("                           \\/     \\/  \\/    \\_____/              |__\n");
    PR("           ________________/    /\\/  ..\\/                         |\n");
    PR("           \\  S.S. Puffy        \\/\\___o/                          |\n");
    PR("            \\                     / /\\ \\                          /\n");
    PR("             \\___________________________________________________/\n");

    (void) mvaddstr(22,27,"Hit any key to continue..."); (void)refresh();
    (void) getch();

    start_color();

    init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
    init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
    init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
    init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
    init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
    init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
    init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
    init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);

    (void) mousemask(BUTTON1_CLICKED, (mmask_t *)NULL);
}
Пример #5
0
// main initializes the system and shows the picture. 
// Exit and clean up when you hit [RETURN].
int main(int argc, char **argv) {
	int n;
	char *progname = argv[0];
	int NoDeviceEvent=0;
	saveterm();
	init(&wscreen, &hscreen);
	rawterm();

	if(argc>1)
	 {
		NoDeviceEvent=atoi(argv[1]);
		printf("Device Event = %d\n",NoDeviceEvent);
	}
	if (openTouchScreen(NoDeviceEvent) == 1)
		perror("error opening touch screen");
	int screenXmax, screenXmin;
	int screenYmax, screenYmin;
	getTouchScreenDetails(&screenXmin,&screenXmax,&screenYmin,&screenYmax);
	scaleXvalue = ((float)screenXmax-screenXmin) / wscreen;
	//printf ("X Scale Factor = %f\n", scaleXvalue);
	scaleYvalue = ((float)screenYmax-screenYmin) / hscreen;
	//printf ("Y Scale Factor = %f\n", scaleYvalue);

	int wbuttonsize=wscreen/5;	
	int hbuttonsize=hscreen/5;


	int button=AddButton(0*wbuttonsize+20,0+hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9);
	color_t Col;
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"SR125",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"SR125",&Col);

	button=AddButton(1*wbuttonsize+20,hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"SR250",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"SR250",&Col);

	button=AddButton(2*wbuttonsize+20,hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"SR333",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"SR333",&Col);

	button=AddButton(3*wbuttonsize+20,hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"SR500",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"SR500",&Col);

	button=AddButton(4*wbuttonsize+20,hbuttonsize*0+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"SR1000",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"SR1000",&Col);
// FEC	
	button=AddButton(0*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"FEC 1/2",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"FEC 1/2",&Col);
	
	button=AddButton(1*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"FEC 2/3",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"FEC 2/3",&Col);
	
button=AddButton(2*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"FEC 3/4",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"FEC 3/4",&Col);
	
button=AddButton(3*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"FEC 5/6",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"FEC 5/6",&Col);

button=AddButton(4*wbuttonsize+20,hbuttonsize*1+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"FEC 7/8",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"FEC 7/8",&Col);

//SOURCE
button=AddButton(0*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;	
	AddButtonStatus(button,"CAM MPEG2",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"CAM MPEG2",&Col);
	
	button=AddButton(1*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;	
	AddButtonStatus(button,"CAM H264",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"CAM H264",&Col);	

char PictureName[255];
	//strcpy(PictureName,ImageFolder);
	GetNextPicture(PictureName);
button=AddButton(2*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"Patern",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,PictureName,&Col);
	

button=AddButton(3*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"TS File",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"Video Name",&Col);

button=AddButton(4*wbuttonsize+20,hbuttonsize*2+20,wbuttonsize*0.9,hbuttonsize*0.9);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"Carrier",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"Carrier",&Col);

//TRANSMIT

button=AddButton(0*wbuttonsize+20,hbuttonsize*3+20,wbuttonsize*1.2,hbuttonsize*1.2);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"TX   ",&Col);
	Col.r=255;Col.g=0;Col.b=0;
	AddButtonStatus(button,"TX ON",&Col);		

button=AddButton(1*wbuttonsize*3+20,hbuttonsize*3+20,wbuttonsize*1.2,hbuttonsize*1.2);
	Col.r=0;Col.g=0;Col.b=128;
	AddButtonStatus(button,"RX   ",&Col);
	Col.r=0;Col.g=128;Col.b=0;
	AddButtonStatus(button,"RX ON",&Col);		
	
	Start(wscreen,hscreen);
	IsDisplayOn=1;

	
	char Param[]="symbolrate";
	char Value[255];
	GetConfigParam(PATH_CONFIG,Param,Value);
	
	SR=atoi(Value);
	switch(SR)
	{
		case 125:SelectSR(0);break;
		case 250:SelectSR(1);break;
		case 333:SelectSR(2);break;
		case 500:SelectSR(3);break;
		case 1000:SelectSR(4);break;
	}

	strcpy(Param,"fec");
	strcpy(Value,"");
	GetConfigParam(PATH_CONFIG,Param,Value);
	printf("Value=%s %s\n",Value,"Fec");
	fec=atoi(Value);
	switch(fec)
	{
		case 1:SelectFec(5);break;
		case 2:SelectFec(6);break;
		case 3:SelectFec(7);break;
		case 5:SelectFec(8);break;
		case 7:SelectFec(9);break;
	}
	
	strcpy(Param,"modeinput");
	GetConfigParam(PATH_CONFIG,Param,Value);
	strcpy(ModeInput,Value);
	if(strcmp(Value,"CAMH264")==0)
	{
	     SelectSource(11,1);
	     
	}
	if(strcmp(Value,"CAMMPEG-2")==0)
	{
	 	SelectSource(10,1);

	}
	if(strcmp(Value,"PATERNAUDIO")==0)
	{
	 	SelectSource(12,1);

	}
	if(strcmp(Value,"CARRIER")==0)
	{
		SelectSource(13,1);
	}
	UpdateWindow();
	
	// RESIZE JPEG TO BE DONE
	/*char PictureName[255];
	strcpy(PictureName,ImageFolder);
	GetNextPicture(PictureName);
	
	Image(0,0,300,200,PictureName);

	End();
	*/
	waituntil(wscreen,hscreen,0x1b);
	restoreterm();
	finish();
	return 0;
}