Exemplo n.º 1
0
int main(int argc, char **argv) {
 Uint8 cram_buffer[128];
 int flags;
 int i;
 gui_screen = (SDL_Surface *)0;
 vdp_init();
 flags = 0;
 load_initial = FALSE;
 for(i=1;i<argc;i++){
  if(strncmp("-f", argv[i], 3)==0) 
   flags = FULLSCREEN;
  else
   if(argv[i][0]!='-'){
    load_initial = TRUE;
    load_initial_name = strdup(argv[i]);
   }
 }

 setup_windows(flags);

 /* now that we have gui_screen->format we can map colors */
 memset(cram_buffer,0,128);
 load_palette(current_vdp, cram_buffer);
 

 arrow = cursor(arrow_data);
 cross = cursor(cross_data);
 horizontal = cursor(horizontal_data);
 vertical = cursor(vertical_data);
 no = cursor(no_data);
 cross_scroll_a = cursor(cross_scroll_a_data);
 cross_scroll_b = cursor(cross_scroll_b_data);
 cross_sprite = cursor(cross_sprite_data);
 hor_a_flip = cursor(hor_a_flip_data);
 ver_a_flip = cursor(ver_a_flip_data);
 hor_b_flip = cursor(hor_b_flip_data);
 ver_b_flip = cursor(ver_b_flip_data);

 working_cursor = cross;
 SDL_SetCursor(arrow);
 undo_A = 
  undo_B = 0;
 hor_ver = HORIZONTAL;
 selection_v1.x = NO_SELECTION;
 save_state();
 load_ovr(NULL);
 render_vdp(0,vdp_h);
 SDL_WM_SetCaption("Mega Happy Sprite!!", NULL);

 group_loop(main_grp);
 SDL_Quit();
#ifndef WINDOWS
 printf("\n        Thank you for using Mega-Happy-Sprite!\n"
        "**Call 24-hours a day, 2 nodes, door-games and more!**\n"
	"              your friendly sysop\n\n");
#endif
 return 0;
}
Exemplo n.º 2
0
void resize_handler(int sig)
{
	/* start over when term gets resized, but first we clean up */
	close_windows();
	endwin();
	refresh();
	clear();
	getmaxyx(stdscr, maxy, maxx);  /* get the new screen size */
	setup_windows();
	/* rate limit */
	sleep(1);
	syslog(LOG_DEBUG, "SIG %d, term resized to %d x %d\n",
		sig, maxy, maxx);
	signal(SIGWINCH, resize_handler);
}
Exemplo n.º 3
0
/**
 @brief main() Initialize user task
 @return void
*/
MEMSPACE 
void setup(void)
{
	int i;
    char time[20];
	int ret;
	uint16_t *ptr;
	double ang;
	extern web_init();
	int w,h;

	ip_msg[0] = 0;

// CPU
// 160MHZ
   REG_SET_BIT(0x3ff00014, BIT(0));
// 80MHZ
//   REG_CLR_BIT(0x3ff00014, BIT(0));

	os_delay_us(200000L);	// Power Up dalay - lets power supplies and devices settle

	// Configure the UART
	//uart_init(BIT_RATE_115200,BIT_RATE_115200);
	uart_init(BIT_RATE_74880,BIT_RATE_74880);

	os_delay_us(200000L);	// Power Up dalay - lets power supplies and devices settle
	os_delay_us(200000L);	// Power Up dalay - lets power supplies and devices settle
	printf("\n\n\n\n");
    sep();
	printf("System init...\n");
    printf("ESP8266 multidevice project\n");
    printf(" (c) 2014-2017 by Mike Gore\n");
    printf(" GNU version 3\n");
    printf("-> https://github.com/magore/esp8266_ili9341\n");
    printf("   GIT last pushed:   %s\n", GIT_VERSION);
    printf("   Last updated file: %s\n", LOCAL_MOD);


    sep();
    PrintRam();

    sep();
	printf("HSPI init...\n");
	hspi_init(1,0);

	printf("Timers init...\n");
	init_timers();

	// 1000HZ timer
	ms_init();

	test_types();

	// Functions manage user defined address pins
	chip_addr_init();

	initialize_clock(300);


#ifdef ADF4351
	#ifdef ADF4351_CS
		chip_select_init(ADF4351_CS);
	#endif
	ADF4351_Init();
	printf("ADF4351 init done\n");
#endif

// Make sure all other GPIO pins are initialized BEFORE SD card
#ifdef FATFS_SUPPORT
    sep();
	// Functions manage chip selects
	#ifdef MMC_CS
		chip_select_init(MMC_CS);
	#endif
	printf("SD Card init...\n");
	mmc_init(1);
#endif

#ifdef DISPLAY
    sep();
	#ifdef ILI9341_CS
		chip_select_init(ILI9341_CS);
	#endif

	#ifdef XPT2046_CS
		XPT2046_spi_init();
	#endif

	// Initialize TFT
	master = tft_init();

 	tft_calX = MatRead("/tft_calX");
 	tft_calY = MatRead("/tft_calY");
	if(tft_calX.data == NULL || tft_calY.data == NULL)
		tft_is_calibrated = 0;
	else
		tft_is_calibrated = 1;
	printf("TFT calibration %s\n", tft_is_calibrated ?  "YES" : "NO");

	// rotateion = 1, debug = 1
	setup_windows(1,1);
#endif

	wdt_reset();
    sep();
	printf("Setup Tasks\n");

    sep();
	setup_networking();

	#ifdef TELNET_SERIAL
		printf("Setup Network Serial Bridge\n");
		bridge_task_init(23);
	#endif

	if ( espconn_tcp_set_max_con(MAX_CONNECTIONS+1) )
		printf("espconn_tcp_set_max_con(%d) != (%d) - failed!\n", 
			MAX_CONNECTIONS+1, espconn_tcp_get_max_con());
	else
		printf("espconn_tcp_set_max_con(%d) = (%d) - success!\n", 
			MAX_CONNECTIONS+1, espconn_tcp_get_max_con());

#ifdef NETWORK_TEST
	printf("Setup Network TFT Display Client\n");
	servertest_setup(TCP_PORT);
#endif

#ifdef WEBSERVER
	printf("Setup Network WEB SERVER\n");
	web_init(80);
#endif

    sep();
    PrintRam();

	system_set_os_print(0);

} //setup()
Exemplo n.º 4
0
/// @param[in] str: User supplied command line 
/// 
/// @return 1 The return code indicates a command matched.
/// @return 0 if no rules matched
MEMSPACE
int user_tests(int argc, char *argv[])
{

    char *ptr;
	time_t t;
	double freq;
	extern int connections;
	int ind;

	if(argc < 2)
		return(0);

	ind = 1;
    ptr = argv[ind++];


    if (MATCHARGS(ptr,"help", (ind+0),argc ))
    {
        user_help();
        return(1);
    }
#ifdef POSIX_TESTS
	if(posix_tests(argc,argv))
		return(1);
#endif
#ifdef FATFS_TESTS
	if(fatfs_tests(argc,argv))
		return(1);
#endif
#ifdef ADF4351
    if (MATCHARGS(ptr,"adf4351", (ind + 1) ,argc))
    {
		adf4351_cmd(argc,argv);
		return(1);
	}
#endif
    if (MATCHARGS(ptr,"setdate", (ind + 1) ,argc))
    {
        setdate_r(argv[ind++]);
        return(1);
    }
    if (MATCHARGS(ptr,"display_clock", (ind + 0) ,argc))
    {
        display_clock();
        return(1);
    }
    if (MATCHARGS(ptr,"time", (ind + 0) ,argc))
    {
		t = time(0);	
		printf("TIME:%s\n", ctime(&t));
        return(1);
	}
    if (MATCHARGS(ptr,"connection", (ind + 0) ,argc))
    {
		printf("connections:%d\n", connections);
        return(1);
	}
    if (MATCHARGS(ptr,"mem", (ind + 0) ,argc))
    {
		PrintRam();
        return(1);
	}
    if (MATCHARGS(ptr,"timetest", (ind + 1) ,argc))
    {
		timetests(argv[ind++],0);
        return(1);
	}
#ifdef DISPLAY
    if (MATCHARGS(ptr,"calibrate", (ind + 1) ,argc))
    {
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		tft_touch_calibrate(master);
		MatWrite("/tft_calX",tft_calX);
		MatWrite("/tft_calY",tft_calY);
		setup_windows(ret & 3,0);
        return(1);
    }
    if (MATCHARGS(ptr,"calibrate_test", (ind + 1) ,argc))
    {
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		tft_touch_calibrate(master);
		MatWrite("/tft_calX",tft_calX);
		MatWrite("/tft_calY",tft_calY);
		tft_map_test(master, 10);
		setup_windows(ret & 3,0);
        return(1);
    }
    if (MATCHARGS(ptr,"rotate", (ind + 1) ,argc))
    {
// FIXME rotate calibration data ???
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		setup_windows(ret & 3,0);
		return(1);
    }
#ifdef VFONTS
    if (MATCHARGS(ptr,"draw", (ind + 1) ,argc))
    {
		char *ptr = argv[ind++];
		int c = *ptr++;
		int n = *ptr++;
		if( n == '1')

			drawSVG(winmsg, 8, 24, c, 0.08, ILI9341_WHITE, 1);
		else
			drawSVG(winmsg, 8, 24, c, 0.08, ILI9341_WHITE, 0);
		return(1);
    }
#endif
    if (MATCHARGS(ptr,"pixel", (ind + 0) ,argc))
    {
		int c;
		int x,y;

		tft_drawPixel(winmsg, 8, 24, ILI9341_WHITE);
		for(y=24;y<26;++y)
		{
			for(x=8;x<10;++x)
			{
				c = tft_readPixel(winmsg, x, y);
				printf("pixel(%d,%d): %04x\n", x,y,c);
			}
		}
		return(1);
    }
#endif	//DISPLAY
	return(0);
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
	int err = 0;
	int id2 = 0, c;
	double yk = 0.0; /* controller output */
	int target_tz_index;

	if (geteuid() != 0) {
		printf("TMON needs to be run as root\n");
		exit(EXIT_FAILURE);
	}

	while ((c = getopt_long(argc, argv, "c:dlht:vgz:", opts, &id2)) != -1) {
		switch (c) {
		case 'c':
			no_control = 0;
			strncpy(ctrl_cdev, optarg, CDEV_NAME_SIZE);
			break;
		case 'd':
			start_daemon_mode();
			printf("Run TMON in daemon mode\n");
			break;
		case 't':
			ticktime = strtod(optarg, NULL);
			if (ticktime < 1)
				ticktime = 1;
			break;
		case 'l':
			printf("Logging data to /var/tmp/tmon.log\n");
			logging = 1;
			break;
		case 'h':
			usage();
			break;
		case 'v':
			version();
			break;
		case 'g':
			debug_on = 1;
			break;
		case 'z':
			target_thermal_zone = strtod(optarg, NULL);
			break;
		default:
			break;
		}
	}
	if (pthread_mutex_init(&input_lock, NULL) != 0) {
		fprintf(stderr, "\n mutex init failed, exit\n");
		return 1;
	}
	start_syslog();
	if (signal(SIGINT, tmon_sig_handler) == SIG_ERR)
		syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
	if (signal(SIGTERM, tmon_sig_handler) == SIG_ERR)
		syslog(LOG_DEBUG, "Cannot handle SIGINT\n");

	if (probe_thermal_sysfs()) {
		pthread_mutex_destroy(&input_lock);
		closelog();
		return -1;
	}
	initialize_curses();
	setup_windows();
	signal(SIGWINCH, resize_handler);
	show_title_bar();
	show_sensors_w();
	show_cooling_device();
	update_thermal_data();
	show_data_w();
	prepare_logging();
	init_thermal_controller();

	nodelay(stdscr, TRUE);
	err = pthread_create(&event_tid, NULL, &handle_tui_events, NULL);
	if (err != 0) {
		printf("\ncan't create thread :[%s]", strerror(err));
		tmon_cleanup();
		exit(EXIT_FAILURE);
	}

	/* validate range of user selected target zone, default to the first
	 * instance if out of range
	 */
	target_tz_index = zone_instance_to_index(target_thermal_zone);
	if (target_tz_index < 0) {
		target_thermal_zone = ptdata.tzi[0].instance;
		syslog(LOG_ERR, "target zone is not found, default to %d\n",
			target_thermal_zone);
	}
	while (1) {
		sleep(ticktime);
		show_title_bar();
		show_sensors_w();
		update_thermal_data();
		if (!dialogue_on) {
			show_data_w();
			show_cooling_device();
		}
		cur_thermal_record++;
		time_elapsed += ticktime;
		controller_handler(trec[0].temp[target_tz_index] / 1000,
				&yk);
		trec[0].pid_out_pct = yk;
		if (!dialogue_on)
			show_control_w();
		if (tmon_exit)
			break;
	}
	tmon_cleanup();
	return 0;
}