Example #1
0
static DWORD WINAPI playlistProc(LPVOID lpParam){
	MSG msg;

	SetThreadPriority(hPlaylistThread, THREAD_PRIORITY_LOWEST);

	if(!init_playlist())
		return 0;

	while (1) {
		int ret = GetMessage(&msg,NULL,0,0);
		if (!ret) break;
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	hPlaylistWnd = NULL;
	hPlaylistThread = NULL;

	return 0;
}
Example #2
0
int init(int bpp) {
	char wm_caption[20];

	fprintf(stdout, "Epiar %s\n", epiar_version);
	fprintf(stdout, "http://www.epiar.net/\n");
	fprintf(stdout, "\nPlease report all bugs at http://bugs.epiar.net/\n\n");

	setup_video(screen_width, screen_height, bpp, fullscreen);

	init_colors(); /* basically sets up common Uint32s to avoid calls to SDL_MapRGB() */

	/* load the main archive file (used throughout epiar) */
	if ((epiar_eaf = eaf_open_file(apply_game_path("epiar.eaf"))) == NULL)
		printf("Couldn't open epiar.eaf file.\n");
	if ((main_eaf = eaf_open_file(apply_game_path("main.eaf"))) == NULL)
		printf("Couldn't open epiar.eaf file.\n");

	init_audio();
	init_music();

	SDL_ShowCursor(0);

	sprintf(wm_caption, "Epiar [%s]", epiar_version);

	SDL_WM_SetCaption(wm_caption, wm_caption);

	load_input_cfg();

	init_trig();
	init_playlist();

	gui_init();

	init_plugins();

	srand(time(NULL));

	return (0);
}
Example #3
0
//TODO add set/get and destructor
loook_opt* loook_init(void){

	loook_opt *opt;
	GF_SAFEALLOC(opt, loook_opt);

	opt->width = 640;
	opt->height = 480;
	opt->frame_per_segment = 30;
	opt->frame_duration = 1;
	opt->gop_size = 30;
	opt->bitrate = 5000000;
	opt->seg_dur_in_ms = 1000;
//	opt->timescale = 1000000;
	opt->data_size = opt->width * opt->height * 3;

	opt->now = 0;
	opt->timeref = 0;
	opt->timeScreenshot = 0;

	init_playlist();

	return opt;
}
Example #4
0
int main() {
    cli();

    wdt_disable(); // To make sure nothing weird happens
    init_tlc5940();
    init_spi();
    init_ps();

    init_blank_timer();
    init_effect_timer();

    init_playlist();

    initUSART();
    sei();

    hcsr04_start_continuous_meas();
    adc_start();

    serial_boot_report();

    // Select correct startup mode
    pick_startup_mode();

    while(1) {
        /* Serial processing is implementation specific and defined in
         * serial_common.c */
        process_serial();

        switch (mode) {
        case MODE_SLEEP:
        // Fall through to MODE_IDLE
        case MODE_IDLE:
            // No operation
            sleep_if_no_traffic();
            break;
        case MODE_PLAYLIST:
            ticks = centisecs();
            if (ticks > effect_length) {
                next_effect();
                init_current_effect();
            }

        // no need to break!
        // fall to MODE_EFFECT on purpose
        case MODE_EFFECT:
            // If a buffer is not yet flipped, wait interrupts
            if (flags.may_flip) {
                sleep_if_no_traffic();
                break;
            }

            // Update clock
            ticks = centisecs();

            /* Go back to serial handler if drawing time
             * is reached. By doing this we avoid serial
             * port slowdown when FPS is low */
            if (ticks < next_draw_at ) {
                sleep_if_no_traffic();
                break;
            }

            /* Restart effect if maximum ticks is
             * reached. This may result a glitch but is
             * better than the effect to stop. */
            if (ticks == ~0) {
                init_current_effect();
                ticks = 0;
            }

            // Update sensor values
            sensors.distance1 = hcsr04_get_distance_in_cm();
            sensors.distance2 = hcsr04_get_distance_in_cm(); //TODO: use separate sensor
            sensors.ambient_light = adc_get(0) >> 2;
            sensors.sound_pressure_level = adc_get(1) >> 2;

            // Do the actual drawing
            draw_t draw = (draw_t)pgm_get(effect->draw,word);
            if (draw != NULL) {
                draw();
                allow_flipping(true);
            }

            // Update time when next drawing is allowed
            next_draw_at = ticks + pgm_get(effect->minimum_ticks,byte);

            break;
        }
    }

    return 0;
}
Example #5
0
int main() {
	cli();

	wdt_disable(); // To make sure nothing weird happens
	init_tlc5940();
	init_spi();
	init_ps();

	init_blank_timer();
	init_effect_timer();
	
	init_playlist();
	
	initUSART();
	sei();

	hcsr04_start_continuous_meas();
	adc_start();

	serial_elo_init();
	
	// Select correct startup mode
	pick_startup_mode();

	while(1) {
		if(serial_available()) {
			uint8_t cmd = serial_read();
#if defined AVR_ZCL
			serial_zcl_process(cmd);
#elif defined AVR_ELO
			serial_elo_process(cmd);
#elif defined SIMU
			// Do nothing
#else
#error Unsupported serial communication type
#endif
		}

		switch (mode) {
		case MODE_SLEEP:
			// Fall through to MODE_IDLE
		case MODE_IDLE:
			// No operation
			sleep_mode();
			break;
		case MODE_PLAYLIST:
			ticks = centisecs();
			if (ticks > effect_length) {
				next_effect();
				init_current_effect();
			}

			// no need to break!
			// fall to MODE_EFFECT on purpose
		case MODE_EFFECT:
			// If a buffer is not yet flipped
			if (flags.may_flip) break;

			// Update clock and sensor values
			ticks = centisecs();
			sensors.distance1 = hcsr04_get_distance_in_cm();
			sensors.distance2 = hcsr04_get_distance_in_cm(); //TODO: use separate sensor
			sensors.ambient_light = adc_get(0) >> 2;
			sensors.sound_pressure_level = adc_get(1) >> 2;

			// Do the actual drawing
			draw_t draw = (draw_t)pgm_get(effect->draw,word);
			if (draw != NULL) {
				draw();
				allow_flipping(true);
			}

			// Slow down drawing if FPS is going to be too high
			uint16_t target_ticks =
				ticks + pgm_get(effect->minimum_ticks,byte);
			while (centisecs() < target_ticks ) {
				sleep_mode();
			}

			break;
		}
	}

	return 0;
}